:root {
  --bg: #0d0d0d;
  --panel: #1a1a1a;
  --panel2: #222;
  --border: #333;
  --text: #f0ede8;
  --muted: #9a948a;
  --orange: #ff7a1a;
  --orange-dark: #cc5f0f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #2a1a0a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 13, 13, 0.7);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--orange), #ffb25e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-actions { display: flex; gap: 10px; align-items: center; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.card:hover { transform: translateY(-3px); border-color: var(--orange-dark); }

.card-body { cursor: pointer; }

.card-icon {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--panel2);
  display: block;
  border-bottom: 1px solid var(--border);
}

.card-icon.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--orange);
  background: linear-gradient(180deg, #2a1a0a, var(--panel2));
}

.card-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.card-body h3 { margin: 0; font-size: 17px; }

.desc {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  flex: 1;
  word-break: break-word;
  white-space: pre-wrap;
}

.desc a { color: var(--orange); text-decoration: underline; }
.desc a:hover { color: #ffb25e; }

.card-actions { display: flex; gap: 8px; margin-top: 10px; }

.btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn:hover { background: #2c2c2c; }

.btn-download {
  background: var(--orange);
  border-color: var(--orange);
  color: #1a0d00;
  font-weight: 700;
  flex: 1;
  text-align: center;
  text-decoration: none;
}
.btn-download:hover { background: #ff8c3a; }

.btn-add { background: var(--orange); border-color: var(--orange); color: #1a0d00; font-weight: 700; }
.btn-add:hover { background: #ff8c3a; }

.btn-sync { color: var(--orange); border-color: var(--orange-dark); }
.btn-sync:hover { background: #2a1a0a; }
.btn-sync:disabled { opacity: 0.6; cursor: default; }

.badge {
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #1a0d00;
  background: var(--orange);
  border-radius: 6px;
  padding: 2px 7px;
}

.btn-danger { color: #ff6b5e; border-color: #5a2a24; }
.btn-danger:hover { background: #3a1a15; }

.btn-edit { color: var(--orange); border-color: var(--orange-dark); }
.btn-edit:hover { background: #2a1a0a; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.hidden { display: none !important; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box h2 { margin: 0 0 16px; color: var(--orange); }

label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }

input[type="text"], textarea {
  width: 100%;
  margin-top: 6px;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
}
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--orange-dark); }

input[type="file"] { margin-top: 6px; color: var(--muted); font-size: 13px; }

.row { display: flex; gap: 10px; margin-top: 6px; }
.row .btn-primary { background: var(--orange); border-color: var(--orange); color: #1a0d00; font-weight: 700; flex: 1; }
.row .btn-primary:hover { background: #ff8c3a; }

.error { color: #ff6b5e; font-size: 13px; margin: 10px 0 0; }

/* Detail modal */
.detail-box { position: relative; max-width: 560px; padding-top: 14px; }
.btn-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  padding: 0;
  line-height: 1;
  font-size: 22px;
  color: var(--muted);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.btn-close:hover { color: var(--text); background: #2c2c2c; }
.detail-icon {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.detail-box h2 { margin: 0 0 12px; }
.detail-box .desc { margin-bottom: 16px; }