:root {
  --bg: #f6f6f8; --panel: #ffffff; --panel-2: #f0f0f4; --text: #18181b; --muted: #6b6b76; --line: #e3e3ea;
  --accent: #5b5bd6; --accent-text: #ffffff; --danger: #d23f3f; --ok: #1f9d55; --warn: #b7791f;
  --radius: 10px; --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114; --panel: #1a1a1f; --panel-2: #23232a; --text: #ececf1; --muted: #9a9aa6; --line: #2e2e37;
    --accent: #7b7bf0; --danger: #ef6b6b; --ok: #4cc38a; --warn: #e0a84a; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

.layout { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
nav { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; padding: 0 8px 18px; }
nav .brand .logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #fff; }
nav a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
nav a:hover { background: var(--panel-2); }
nav a.active { background: var(--accent); color: var(--accent-text); }
nav .foot { position: absolute; bottom: 16px; left: 12px; right: 12px; }
main { padding: 24px 28px 60px; max-width: 1180px; width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat .n { font-size: 24px; font-weight: 650; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 8px; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 7px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
button.danger { color: var(--danger); }
button.icon { padding: 4px 8px; min-width: 30px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
label.field { display: grid; gap: 4px; }
label.field > span { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 550; }
tr:last-child td { border-bottom: 0; }

.chip { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); margin: 2px 4px 2px 0; }
.chip.on { color: var(--ok); }
.chip.off { color: var(--muted); }
.addon { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; }
.addon img, .addon .ph { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: var(--panel-2); }
.addon.disabled { opacity: .55; }

.posters { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.poster { position: relative; }
.poster img, .poster .ph { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 7px; background: var(--panel-2); display: block; }
.poster .t { font-size: 12px; margin-top: 4px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.poster .acts { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; opacity: 0; transition: opacity .15s; }
.poster:hover .acts, .poster:focus-within .acts { opacity: 1; }
.poster .acts button { padding: 1px 7px; font-size: 12px; background: rgb(0 0 0 / 70%); color: #fff; border: 0; }

.split { display: grid; grid-template-columns: 260px 1fr; gap: 14px; align-items: start; }
.listnav a { display: flex; justify-content: space-between; padding: 7px 10px; border-radius: 7px; text-decoration: none; color: var(--text); }
.listnav a.active { background: var(--panel-2); font-weight: 600; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: background .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 420px; z-index: 10; }
.toast.err { background: var(--danger); color: #fff; }
.login { max-width: 360px; margin: 12vh auto; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.feed li { padding: 5px 0; border-bottom: 1px solid var(--line); list-style: none; }
.feed { padding: 0; margin: 0; }
.connect { font-size: 16px; padding: 8px 12px; background: var(--panel-2); border-radius: 8px; display: inline-block; user-select: all; }
.source-row td { font-size: 12.5px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  nav { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  nav .brand { width: 100%; padding-bottom: 8px; }
  nav .foot { position: static; width: 100%; }
  main { padding: 16px; }
  .split { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
