:root {
  --bg: #0f172a;
  --panel: #111827;
  --surface: #0c1324;
  --input-bg: #0b1220;
  --muted: #94a3b8;
  --text: #e2e8f0;
  --accent: #22d3ee;
  --border: #1f2937;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.5);
  --danger-text: #fecdd3;
}
.theme-light {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --surface: #ffffff;
  --input-bg: #ffffff;
  --muted: #475569;
  --text: #0f172a;
  --accent: #0ea5e9;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-bg: rgba(248, 113, 113, 0.16);
  --danger-border: rgba(220, 38, 38, 0.6);
  --danger-text: #b91c1c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.08), transparent 25%), var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1080px; margin: 0 auto; padding: 24px 16px 48px; }
.header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { display: inline-flex; }
.brand canvas { width: 62px; height: 62px; filter: drop-shadow(0 8px 22px rgba(34, 211, 238, 0.25)); }
.brand-text { display: flex; flex-direction: column; gap: 4px; }
.logo { margin: 0; font-size: 24px; letter-spacing: 0.02em; }
.brand-text .logo { opacity: 0; transform: translateY(4px); transition: opacity 0.55s ease 0.45s, transform 0.55s ease 0.45s; }
.brand-text .logo.visible { opacity: 1; transform: translateY(0); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle { white-space: nowrap; }
.breadcrumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.breadcrumbs a { color: var(--text); font-weight: 500; }
.crumb-current { color: var(--muted); }
.crumb-sep { color: var(--muted); }
.subtitle { margin: 4px 0 0; color: var(--muted); }
.nav-link { color: var(--text); margin-left: 12px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.35); position: relative; }
.panel h2, .panel h3 { margin-top: 0; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; align-items: end; }
.filters-mobile-toggle { display: none; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; }
.field input, .field select, .inline-form input, .form-grid input, .form-grid select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
}
.field-tags { grid-column: 1 / -1; }
.tags-select { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.tag-option { font-size: 14px; color: var(--text); }
.muted { color: var(--muted); }
.actions { display: flex; gap: 10px; align-items: center; }
button, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(34, 211, 238, 0.05));
  color: var(--text); cursor: pointer; font-weight: 600;
}
.secondary { background: transparent; text-decoration: none; }
button.danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
button:hover { filter: brightness(1.1); }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1200px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }
.card { position: relative; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: visible; display: flex; flex-direction: column; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; height: 100%; z-index: 1; }
.card.menu-open { z-index: 5; }
.card:hover { transform: translateY(-2px); box-shadow: 0 14px 40px rgba(0,0,0,0.35); border-color: rgba(34, 211, 238, 0.35); }
.card-thumb-link { display: block; }
.card-thumb { position: relative; padding-top: 160%; background-size: cover; background-position: center; background-repeat: no-repeat; border-radius: 12px 12px 0 0; overflow: hidden; }
.card-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb.placeholder { background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(255, 255, 255, 0)); display: flex; align-items: center; justify-content: center; }
.thumb-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.card-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.4; flex: 1; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { display: flex; flex-direction: column; gap: 2px; }
.badge-mobile { display: none; }
.badge-desktop { display: inline-flex; }
.badge { background: rgba(34, 211, 238, 0.1); border: 1px solid rgba(34, 211, 238, 0.4); padding: 5px 9px; border-radius: 8px; text-transform: uppercase; font-size: 11px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag button { background: rgba(34, 211, 238, 0.12); border: 1px solid rgba(34, 211, 238, 0.35); color: var(--text); padding: 6px 10px; border-radius: 8px; }
.more-tags { color: var(--accent); font-size: 12px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.inline-form input { flex: 1; }
.card-actions { display: flex; gap: 8px; align-items: center; margin-top: auto; justify-content: space-between; }
.actions-right { position: relative; display: flex; align-items: center; }
.gear-btn { width: 34px; height: 34px; border-radius: 10px; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: rgba(34, 211, 238, 0.12); border: 1px solid rgba(34, 211, 238, 0.35); color: var(--text); cursor: pointer; font-size: 25px; }
.card-actions .secondary { white-space: nowrap; }
.card-menu { position: absolute; top: calc(100% + 6px); right: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; min-width: 140px; box-shadow: 0 12px 30px rgba(0,0,0,0.4); z-index: 999; }
.card-menu[hidden] { display: none; }
.card-menu .menu-item { width: 100%; text-align: left; padding: 10px 12px; background: transparent; border: none; color: var(--text); cursor: pointer; }
.card-menu .menu-item:hover { background: rgba(34, 211, 238, 0.08); }
.card-menu .menu-item.danger { color: var(--danger-text); }
.pagination { display: flex; justify-content: center; gap: 12px; align-items: center; margin-top: 12px; }
.list-header { display: flex; justify-content: space-between; align-items: baseline; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.record-header { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.record-panel { padding-top: 22px; }
.delete-inline { position: absolute; top: 10px; right: 10px; }
.delete-inline .icon { width: 32px; height: 32px; border-radius: 50%; padding: 0; font-size: 18px; }
.record-layout { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 16px; align-items: start; margin-top: 8px; }
.poster-column { width: 100%; max-width: 220px; }
.poster-large { width: 100%; aspect-ratio: 2 / 3; border-radius: 12px; border: 1px solid var(--border); background-size: cover; background-position: center; margin: 4px 0; position: relative; }
.poster-large.placeholder { background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(255, 255, 255, 0)); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.record-info { display: flex; flex-direction: column; gap: 12px; min-height: 100%; }
.record-actions { margin-top: auto; display: flex; justify-content: flex-end; }
.tags-block { display: flex; flex-direction: column; gap: 8px; }
.tag-add { max-width: 360px; width: fit-content; align-self: flex-start; }
.tag-add input { min-width: 160px; }
.tag-add button { white-space: nowrap; }
.compact-text { margin: 2px 0; line-height: 1.3; font-size: 12px; }
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(15, 23, 42, 0.72); backdrop-filter: blur(4px); z-index: 99; }
.modal[hidden] { display: none; }
.modal-content { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; width: min(360px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,0.45); }
.modal-actions { justify-content: flex-end; gap: 8px; }
@media (max-width: 720px) {
  .record-layout { grid-template-columns: 1fr; }
  .poster-column { max-width: 200px; }
}
@media (max-width: 540px) {
  .container { padding: 16px 12px 32px; }
  .header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .brand { align-items: flex-start; }
  .brand canvas { width: 52px; height: 52px; }
  .brand-text { gap: 2px; }
  .logo { font-size: 20px; }
  .filters { gap: 10px 12px; }
  .filters-mobile-toggle { display: flex; justify-content: space-between; margin-bottom: 8px; }
  .filters-mobile-toggle button { width: 100%; }
  .filters.mobile-closed { display: none; }
  .filters.mobile-open { display: grid; }
  .field label { font-size: 13px; }
  .field input, .field select { padding: 9px 11px; }
  .cards { gap: 6px; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); align-items: stretch; }
  .card-thumb { padding-top: 120%; }
  .card-body { padding: 5px; gap: 3px; font-size: 11px; display: grid; grid-template-rows: auto auto auto 1fr auto; }
  .card h3 { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .card-title .compact-text { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
  .card-header { gap: 6px; }
  .badge { padding: 3px 6px; font-size: 9px; border-radius: 7px; letter-spacing: 0.5px; }
  .badge-desktop { display: none; }
  .badge-mobile { display: inline-flex; margin-top: 2px; align-self: flex-start; }
  .meta { gap: 3px; font-size: 10px; }
  .tags { gap: 3px; }
  .tags .muted { margin: 0; font-size: 10px; }
  .card-actions { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: nowrap; margin-top: 4px; }
  .card-actions .secondary, .actions-right { flex-shrink: 0; white-space: nowrap; }
  .actions-right { align-self: center; }
  .gear-btn { width: 30px; height: 30px; font-size: 18px; }
  .card-actions .secondary { padding: 6px 9px; font-size: 11px; }
  .record-panel { padding: 12px; }
  .record-layout { gap: 12px; }
  .poster-column { max-width: 180px; }
  .poster-large { margin: 0; }
  .record-actions { justify-content: stretch; }
  .record-actions button { width: 100%; }
  .inline-form { flex-wrap: wrap; }
  .tag-add { width: 100%; max-width: none; }
}
