:root {
  --bg: #0e0f11; --surface: #16181b; --line: #25282d; --text: #e7e8ea;
  --muted: #8b9097; --accent: #8fb8ff; --danger: #e5786d; --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); line-height: 1.5;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; transition: border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: #0b1220; border-color: var(--accent); font-weight: 600; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.field {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px;
}

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 320px; display: grid; gap: 12px; }
.login h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; letter-spacing: .2px; }
.login p { margin: 0; color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }

/* App shell */
.wrap { max-width: 760px; margin: 0 auto; padding: 28px 16px 80px; }

/* Header */
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.top h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: .2px; }
.top-r { display: flex; align-items: center; gap: 8px; }
.role { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; }

/* Tabs + tools */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 0 10px; color: var(--muted); }
.tab.on { color: var(--text); border-color: var(--accent); }
.tab .n { margin-left: 7px; font-size: 12px; color: var(--muted); }
.tools { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 8px; }
.tools select.field { width: auto; }

/* List */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.thumb { width: 44px; height: 62px; flex: none; border-radius: 6px; object-fit: cover; background: var(--surface); }
.thumb.ph { display: grid; place-items: center; color: var(--muted); font-size: 18px; border: 1px solid var(--line); }
.info { flex: 1; min-width: 0; }
.title { font-weight: 500; overflow-wrap: anywhere; }
.title a { text-decoration: none; }
.title a:hover { color: var(--accent); }
.meta { color: var(--muted); font-size: 13px; text-transform: capitalize; }
.note { color: var(--muted); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.rating { font-variant-numeric: tabular-nums; font-size: 18px; color: var(--accent); }
.empty { padding: 48px 0; text-align: center; color: var(--muted); }

@media (max-width: 480px) {
  .tools { grid-template-columns: 1fr 1fr; }
  .tools input { grid-column: 1 / -1; }
  .tools select.field { width: 100%; }
}

/* Add/Edit panel */
.row .edit { flex: none; padding: 6px 10px; font-size: 13px; }
.panel { margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(420px, 100%); border: 0; border-left: 1px solid var(--line);
  background: var(--bg); color: var(--text); padding: 24px 20px; overflow-y: auto; }
.panel::backdrop { background: rgba(0,0,0,.55); }
.panel form { display: grid; gap: 14px; }
.panel h2 { margin: 0; font-size: 17px; font-weight: 600; }
.lbl { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
textarea.field { resize: vertical; }

/* Row actions + small modal */
.acts { display: flex; flex: none; gap: 2px; }
.acts .btn { padding: 6px 10px; font-size: 13px; }
.actions .del { margin-right: auto; }
.modal { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); padding: 22px 20px; width: min(360px, calc(100% - 32px)); }
.modal::backdrop { background: rgba(0,0,0,.55); }
.modal form { display: grid; gap: 12px; }
.modal h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal .meta { margin: 0; }
@media (max-width: 480px) { .row { flex-wrap: wrap; } .acts { width: 100%; justify-content: flex-end; } }

/* Type-ahead suggestions */
.sw { position: relative; }
.sugg { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.sg { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 6px; cursor: pointer; }
.sg:hover, .sg.on { background: var(--line); }
.sgt { width: 30px; height: 42px; flex: none; border-radius: 4px; object-fit: cover; background: var(--bg); }
.sgt.ph { display: grid; place-items: center; color: var(--muted); font-size: 13px; border: 1px solid var(--line); }
.sgi { min-width: 0; }
.sgn { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
