:root {
  --bg: #ffffff;
  --surface: #f4f4f6;
  --surface2: #e9e9ee;
  --text: #1c1c22;
  --muted: #6d6d78;
  --border: #d8d8e0;
  --accent: #3a6df0;
  --accent-text: #ffffff;
  /* Movie/OVA identity colors: gold frame + violet wash, deliberately
     outside the red->green heat scale so films never read as episodes. */
  --movie-frame: #b8860b;
  --movie-tint: rgba(124, 58, 237, .16);
  /* Empty (no votes yet) bucket color of the score map strip. */
  --strip-empty: #dcdce4;
}
/* Dark theme is opt-in via the header toggle (persisted in localStorage);
   light is the default regardless of the OS setting. */
:root[data-theme="dark"] {
  --bg: #141419;
  --surface: #1e1e26;
  --surface2: #2a2a35;
  --text: #f0f0f4;
  --muted: #a2a2b0;
  --border: #3a3a48;
  --accent: #5b84ff;
  --accent-text: #ffffff;
  --movie-frame: #e3b341;
  --movie-tint: rgba(124, 58, 237, .28);
  --strip-empty: #34343f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; cursor: pointer; }

/* header */
.site-header {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
  max-width: 960px; margin: 0 auto;
}
.logo {
  background: none; border: none; padding: 0;
  font-size: 24px; font-weight: 800; color: var(--text);
}
.tagline { margin: 4px 0 12px; font-size: 13px; color: var(--muted); }
.header-tools { display: flex; gap: 8px; }
#search {
  flex: 1; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
#add-toggle {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); font-weight: 700; white-space: nowrap;
}
#theme-toggle {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); white-space: nowrap;
}

/* my-status panel (stamp-rally record + X share, under the header) */
.status-panel {
  max-width: 960px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.status-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.status-text { font-size: 13.5px; font-weight: 600; }
.status-share-btn {
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--text); background: var(--text); color: var(--bg);
  font-size: 13px; font-weight: 700;
}

/* per-work / per-season X share rows on the work page */
.share-row { margin: 10px 0 2px; }
.share-btn {
  display: inline-block; padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--text); background: var(--text); color: var(--bg);
  font-size: 13px; font-weight: 700; text-decoration: none;
}

/* intro / about (static hero text under the header) */
.intro {
  max-width: 960px; margin: 0 auto; padding: 16px 16px 2px;
}
.intro h1 { font-size: 17px; margin: 0 0 6px; line-height: 1.4; }
.intro p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.8; color: var(--muted); }
.intro p b { color: var(--text); }

/* add panel */
#add-panel {
  margin-top: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
#add-panel h3 { margin: 0 0 6px; font-size: 16px; }
.add-desc { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.add-row { display: flex; gap: 8px; margin-bottom: 8px; }
.add-input {
  flex: 1; padding: 9px 10px; font-size: 16px; min-width: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
.add-btn {
  padding: 9px 14px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-weight: 600;
}
.add-status { font-size: 13px; color: var(--muted); min-height: 1.2em; margin: 6px 0; }
.add-results { display: flex; flex-direction: column; gap: 6px; }
.add-result {
  text-align: left; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px;
}

/* main */
main { max-width: 960px; margin: 0 auto; padding: 8px 16px 24px; }
.sec-title { font-size: 18px; margin: 22px 0 10px; }
/* Home accordion sections: tappable header row + collapsible body. */
.sec-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin: 18px 0 0; padding: 10px 2px; background: none; border: none;
  border-bottom: 1px solid var(--border); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.sec-head-title { font-size: 18px; font-weight: 700; }
.sec-head-count { font-size: 12px; opacity: .65; }
.sec-head-chev { margin-left: auto; opacity: .6; transition: transform .15s; }
.sec-head.open .sec-head-chev { transform: rotate(90deg); }
.sec-body { margin-top: 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  padding: 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
a.card { text-decoration: none; cursor: pointer; }
/* Per-work identity accent: --accent-hue is set inline per work (hashed
   from the work id in app.js) — a colored left border + title underline
   distinguish cards without any cover art. */
.card { border-left: 5px solid hsl(var(--accent-hue, 220), 62%, 52%); }
.card-title {
  font-size: 16px; font-weight: 700; line-height: 1.35;
  text-decoration: underline;
  text-decoration-color: hsl(var(--accent-hue, 220), 62%, 55%);
  text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.card-meta { font-size: 12px; color: var(--muted); }
.card-note { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; }

/* score map strip: a one-element miniature of the whole episode map.
   The background is a single linear-gradient with hard stops (one stop
   pair per bucket) built in app.js; buckets without votes use
   --strip-empty, which is also the no-gradient fallback fill. */
.map-strip {
  height: 10px; border-radius: 5px; margin-top: 6px;
  background: var(--strip-empty);
}
.map-strip-lg { height: 14px; border-radius: 7px; margin: 6px 0 12px; }

/* work view */
.back-btn {
  margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.work-title { font-size: 22px; margin: 12px 0 4px; line-height: 1.35; }
.work-note, .season-info { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
/* watch links row (streaming-service search buttons) */
.watch-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0 12px; }
.watch-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.watch-btn {
  font-size: 12.5px; font-weight: 600; text-decoration: none;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.watch-btn:hover { border-color: var(--accent); color: var(--accent); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tab {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 13px; font-size: 13px;
}
.tab.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.order-tabs { margin-bottom: 14px; }

/* release-date order view */
.rel-section { margin-top: 18px; }
.rel-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.rel-title { font-size: 16px; font-weight: 700; line-height: 1.35; }
.kind-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.kind-badge.movie { background: #e9bc45; color: #2a1e00; border-color: var(--movie-frame); }
.rel-date { font-size: 12px; color: var(--muted); }
.movie-cell {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  border-radius: 10px; padding: 12px 14px; border: 2px solid var(--movie-frame);
  background: linear-gradient(var(--movie-tint), var(--movie-tint)), var(--surface2);
  color: #141414;
}
.movie-cell .m-label { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; line-height: 1.35; }
.movie-cell .m-meta { display: block; font-size: 11px; font-weight: 400; opacity: .75; margin-top: 2px; }
.movie-cell .m-sc { font-size: 26px; font-weight: 800; line-height: 1; }
.movie-cell.novote { color: var(--muted); }
.movie-cell.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--movie-frame); }
.movie-cell.mine { box-shadow: inset 0 0 0 2px rgba(255,255,255,.85), 0 0 0 1px var(--text); }

/* episode grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; }
.grid.dense { grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.cell {
  border-radius: 8px; padding: 5px 2px 4px; text-align: center;
  border: 2px solid transparent; color: #141414; background: var(--surface2);
  display: flex; flex-direction: column; align-items: center; line-height: 1.2;
}
.cell .ep { font-size: 9px; opacity: .75; }
.cell .sc { font-size: 16px; font-weight: 800; }
.grid.dense .cell .sc { font-size: 13px; }
.grid.dense .cell .ep { font-size: 8px; }
.cell.novote { background: var(--surface2); color: var(--muted); }
.cell.unaired {
  background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 6px, var(--surface2) 6px, var(--surface2) 12px);
  color: var(--muted); cursor: default;
}
.cell.sel { border-color: var(--text); }
.cell.mine { box-shadow: inset 0 0 0 2px rgba(255,255,255,.85), 0 0 0 1px var(--text); }

/* legend */
.legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 12px; }
.legend .grad { flex: 1; min-width: 80px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, hsl(0,70%,48%), hsl(45,85%,52%), hsl(120,55%,42%)); }
.legend-item { white-space: nowrap; }
.legend-movie {
  border: 1px solid var(--movie-frame); border-radius: 4px; padding: 1px 6px;
  background: linear-gradient(var(--movie-tint), var(--movie-tint)), var(--surface2);
  color: var(--text);
}

/* detail panel */
.detail {
  margin-top: 14px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: 14px;
}
.detail-hint { margin: 0; color: var(--muted); font-size: 14px; }
.detail-head { margin: 0 0 6px; font-size: 16px; }
.detail-ep-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; line-height: 1.4; }
.detail-synopsis {
  margin: 0 0 12px; font-size: 13.5px; line-height: 1.75; color: var(--text);
  background: var(--surface2); border-radius: 8px; padding: 10px 12px;
}
.detail-score { margin: 0 0 8px; font-size: 14px; }
.detail-score b { font-size: 22px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; margin-bottom: 12px; }
.bar i { display: block; height: 100%; }
.vote-label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 6px; }
.vote-row { display: flex; gap: 8px; align-items: center; }
.vote-slider { flex: 1; min-width: 0; accent-color: var(--accent); height: 32px; }
.vote-num {
  width: 64px; padding: 8px; font-size: 16px; text-align: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
.vote-btn {
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); font-weight: 700; white-space: nowrap;
}
.vote-del {
  margin-top: 8px; background: none; border: none; color: var(--muted);
  font-size: 13px; text-decoration: underline; padding: 4px 0;
}

/* static per-work SEO section (/works/<id>.html, generated) */
.seo-work {
  max-width: 960px; margin: 0 auto; padding: 4px 16px 8px;
}
.seo-work h1 { font-size: 19px; margin: 10px 0 6px; line-height: 1.45; }
.seo-work h2 { font-size: 16px; margin: 18px 0 6px; }
.seo-work h3 { font-size: 14.5px; margin: 14px 0 4px; }
.seo-work p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.8; color: var(--muted); }
.seo-work .ep-list { margin: 0 0 6px; padding-left: 1.6em; font-size: 13px; line-height: 1.7; color: var(--muted); }
.seo-work .ep-list b { color: var(--text); font-weight: 600; }
.seo-work a { color: var(--accent); }

.site-footer {
  max-width: 960px; margin: 0 auto; padding: 14px 16px 28px;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 12px;
}
.site-footer a { color: var(--accent); }
