:root {
  --bg: #faf9f5; --card: #ffffff; --card-2: #f3f2ee; --text: #1f1e1d; --muted: #6b6a65;
  --border: rgba(31,30,29,0.12); --border-strong: rgba(31,30,29,0.28); --accent: #185FA5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1e1d; --card: #2a2927; --card-2: #33322f; --text: #ecebe6; --muted: #a3a29c;
    --border: rgba(236,235,230,0.12); --border-strong: rgba(236,235,230,0.3); --accent: #85B7EB;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.6;
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
main { max-width: 1280px; margin: 0 auto; padding: 28px 20px 40px; }
a { color: var(--accent); }
h1 { font-size: 24px; font-weight: 500; margin: 0; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.status { margin-left: auto; color: var(--muted); font-size: 12px; align-self: center; }

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; width: min(420px, 100%); }
input[type=search], select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--card);
  border: 0.5px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; height: 36px;
}
.search input { width: 100%; }
.qres { position: absolute; top: 40px; left: 0; right: 0; z-index: 10; background: var(--card);
  border: 0.5px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.qres button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px;
  background: none; border: 0; border-top: 0.5px solid var(--border); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.qres button:first-child { border-top: 0; }
.qres button:hover, .qres button.on { background: var(--card-2); }
.qres small { color: var(--muted); margin-left: auto; font-size: 12px; white-space: nowrap; }

.tabs { display: flex; gap: 4px; border-bottom: 0.5px solid var(--border); margin-bottom: 12px; }
.tabs button { font: inherit; font-size: 14px; background: none; border: 0; color: var(--muted); padding: 8px 14px;
  border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--card); border: 0.5px solid var(--border); border-radius: 12px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar #epQ { flex: 1; min-width: 200px; }
.tools { display: flex; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend label { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.line { display: inline-block; width: 16px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; }
button.ghost, .btn { font: inherit; font-size: 13px; color: var(--text); background: transparent; cursor: pointer;
  border: 0.5px solid var(--border-strong); border-radius: 8px; padding: 6px 12px; }
button.ghost:hover, .btn:hover { background: var(--card-2); }

svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; cursor: grab; }
svg text { font-size: 12px; fill: var(--muted); pointer-events: none; }
svg g[data-id] { cursor: pointer; }

.panel { padding: 18px; font-size: 14px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.panel .hero { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.panel .hero img, .panel .ph { width: 96px; height: 128px; object-fit: cover; border-radius: 8px; flex: none; background: var(--card-2); }
.panel .ph { display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--muted); }
.panel h2 { font-size: 18px; font-weight: 500; margin: 0; }
.panel .meta { color: var(--muted); font-size: 13px; }
.panel h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 16px 0 6px; }
.panel ul { list-style: none; padding: 0; margin: 0; }
.panel li { padding: 6px 0; border-top: 0.5px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel .summary { font-size: 13px; line-height: 1.7; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 12px; border: 0.5px solid currentColor; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.seasons { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.seasons button { font: inherit; font-size: 13px; border: 0.5px solid var(--border-strong); background: transparent; color: var(--text);
  border-radius: 8px; padding: 4px 10px; cursor: pointer; }
.seasons button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.eps { display: grid; gap: 10px; }
.ep { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; padding: 12px; }
@media (max-width: 600px) { .ep { grid-template-columns: minmax(0, 1fr); } }
.ep img, .ep .ph { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--card-2); }
.ep h4 { margin: 0 0 2px; font-size: 15px; font-weight: 500; }
.ep .meta { color: var(--muted); font-size: 12px; }
.ep p { margin: 6px 0 0; font-size: 13px; line-height: 1.7; }

footer { margin-top: 24px; font-size: 12px; color: var(--muted); }
