:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #8b92a3;
  --accent: #ffe94d;
  --planned: #9aa3b5;
  --active: #4cd38a;
  --done: #6fb2ff;
  --dropped: #e5686b;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, select, input, textarea { font: inherit; color: inherit; }

button, .button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 6px 12px;
}
button:hover, .button:hover { border-color: #3a4150; }
.ghost { background: transparent; }
.danger { color: var(--dropped); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px;
  background: rgba(15, 17, 21, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.sticker {
  display: grid; place-items: center; width: 32px; height: 32px;
  background: var(--accent); color: #111; border-radius: 8px;
  font-weight: 900; font-size: 20px; transform: rotate(-8deg);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, .5);
}
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  border: 0; background: transparent; color: var(--muted); text-decoration: none;
  padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab[aria-selected="true"] { color: #111; background: var(--accent); }
.tab .count { opacity: .6; font-weight: 600; margin-left: 6px; font-size: 13px; }
.menu { display: flex; align-items: center; gap: 6px; }
.subtle { color: var(--muted); border-color: transparent; }
.save-status { color: var(--muted); font-size: 13px; margin-right: 6px; white-space: nowrap; }

main { max-width: 1240px; margin: 0 auto; padding: 24px 28px 64px; }

/* Search */
.search { position: relative; }
.search input {
  width: 100%;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  font-size: 16px;
}
.search input:focus { border-color: var(--accent); }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 4;
  max-height: 60vh; overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  padding: 6px;
}
.result {
  display: flex; gap: 12px; align-items: center; width: 100%;
  text-align: left; border: 0; background: transparent;
  padding: 8px; border-radius: 8px;
}
.result:hover, .result:focus-visible { background: var(--panel-2); outline: none; }
.result img, .result .thumb {
  width: 40px; height: 60px; object-fit: cover; border-radius: 4px;
  background: var(--panel-2); flex: none;
}
.result .meta { flex: 1; min-width: 0; }
.result .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .sub { color: var(--muted); font-size: 13px; }
.result .tag { color: var(--muted); font-size: 13px; flex: none; }
.result.added .tag { color: var(--active); }
.results .note { padding: 12px; color: var(--muted); }

/* Toolbar */
.toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 22px 0 18px; flex-wrap: wrap;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border-radius: 999px; padding: 5px 12px; font-size: 14px;
  background: transparent; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
.chip .n { margin-left: 4px; opacity: .7; }
select {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px;
}

/* Grid */
.grid {
  display: grid; gap: 22px 18px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  border: 0; padding: 0; background: transparent; text-align: left;
  display: flex; flex-direction: column; gap: 8px;
}
.poster {
  position: relative; aspect-ratio: 2 / 3; width: 100%;
  border-radius: 10px; overflow: hidden;
  background: var(--panel-2);
  box-shadow: 0 0 0 1px var(--line);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover .poster { transform: translateY(-3px); box-shadow: 0 0 0 1px #3a4150, 0 10px 24px rgba(0, 0, 0, .4); }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder {
  width: 100%; height: 100%;
  display: grid; place-items: center; padding: 12px; text-align: center;
  color: var(--muted); font-weight: 600;
}
.badge {
  position: absolute; left: 8px; top: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 7px; border-radius: 6px;
  background: rgba(15, 17, 21, .85); color: var(--text);
}
.badge::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 5px; vertical-align: 1px; background: var(--c);
}
.score {
  position: absolute; right: 8px; top: 8px;
  font-size: 12px; font-weight: 700;
  padding: 3px 7px; border-radius: 6px;
  background: rgba(15, 17, 21, .85);
}
.poster .where {
  position: absolute; left: 8px; bottom: 8px;
  display: flex; gap: 4px;
}
.poster .where img {
  width: 24px; height: 24px; border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .45);
}
.poster .where .more {
  display: grid; place-items: center; height: 24px; padding: 0 6px; border-radius: 6px;
  font-size: 11px; font-weight: 700; background: rgba(15, 17, 21, .85);
}
.card .title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: -4px; }

.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted);
  padding: 72px 0;
}
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* Detail dialog */
dialog {
  width: min(680px, calc(100vw - 32px));
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); color: var(--text);
  padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.detail { display: grid; grid-template-columns: 180px 1fr; gap: 22px; padding: 22px; }
.detail .poster { box-shadow: none; }
.detail h2 { margin: 0 0 2px; font-size: 21px; line-height: 1.25; }
.detail .alt { color: var(--muted); font-size: 14px; }
.detail .info { color: var(--muted); font-size: 14px; margin: 6px 0 16px; }
.detail .info a { color: var(--accent); text-decoration: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.field { margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { padding: 5px 10px; font-size: 14px; }
.seg button[aria-pressed="true"] { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); }
.rating button { width: 34px; padding: 5px 0; }
.rating button[aria-pressed="true"] { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
.progress { display: flex; align-items: center; gap: 8px; }
.progress input { width: 80px; }
.progress .of { color: var(--muted); }
.field input[type="number"], .field input[type="text"], textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; outline: none;
}
.field input:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
.where-box .muted { color: var(--muted); }
.offer-group + .offer-group { margin-top: 10px; }
.offer-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.offer-row { display: flex; flex-wrap: wrap; gap: 6px; }
.offer {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); color: var(--text); text-decoration: none;
}
a.offer:hover { border-color: var(--accent); }
.offer img { width: 30px; height: 30px; border-radius: 7px; flex: none; }
.offer b { display: block; font-size: 14px; font-weight: 600; line-height: 1.25; }
.offer small { display: block; font-size: 12px; color: var(--muted); line-height: 1.25; }
.where-box .jw { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--accent); text-decoration: none; }
.where-box .jw:hover { text-decoration: underline; }
.actions { display: flex; justify-content: space-between; padding: 14px 22px; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .tabs { order: 3; flex-basis: 100%; }
  .menu { margin-left: auto; }
  main { padding: 16px 16px 48px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 16px 12px; }
  .detail { grid-template-columns: 1fr; }
  .detail .poster { width: 140px; }
}
