:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #13171c;
  --surface-2: #1a2027;
  --border: #2a333d;
  --text: #eef2f6;
  --muted: #9ca8b5;
  --accent: #ff7a33;
  --accent-soft: rgba(255, 122, 51, .14);
  --shadow: 0 14px 34px rgba(0, 0, 0, .24);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #dce2e8;
  --text: #19212a;
  --muted: #677483;
  --accent: #e85f18;
  --accent-soft: rgba(232, 95, 24, .11);
  --shadow: 0 12px 30px rgba(31, 43, 56, .09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", Meiryo, sans-serif;
  line-height: 1.65;
}

button, input { font: inherit; }
a { color: inherit; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.header-inner {
  max-width: 1180px;
  min-height: 64px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  margin-right: auto;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}

.brand-mark { color: var(--accent); margin-right: .45em; }

.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a {
  padding: 7px 10px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  font-size: .9rem;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.theme-toggle {
  min-width: 44px;
  min-height: 40px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.page-shell { max-width: 1180px; margin: 0 auto; padding: 46px 20px 72px; }

.hero { max-width: 820px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: .78rem; font-weight: 800; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.25; letter-spacing: -.025em; }
.lead { margin: 14px 0 0; color: var(--muted); font-size: clamp(.95rem, 2.5vw, 1.08rem); }
.update-label { display: inline-block; margin-top: 13px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .82rem; font-weight: 700; }

.toolbar {
  position: sticky;
  top: 76px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: 0 0 22px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.filter-wrap { position: relative; }
.filter-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.character-filter {
  width: 100%;
  min-height: 48px;
  padding: 10px 42px;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
}
.character-filter:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.clear-filter { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 8px; }
.clear-filter[hidden] { display: none; }

.result-count { min-width: 8.5em; text-align: right; color: var(--muted); font-size: .9rem; }
.result-count strong { color: var(--text); font-size: 1.08rem; }

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.character-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.character-card:hover { border-color: color-mix(in srgb, var(--accent) 58%, var(--border)); background: var(--surface-2); }
.character-card mark { padding: 0 1px; border-radius: 2px; background: #ffcb43; color: #17120a; }
.film-badge, .milestone { color: var(--accent); font-weight: 800; }
.sequence { display: block; margin-bottom: 3px; color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }

.notes-panel { margin-top: 28px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); color: var(--muted); font-size: .9rem; }
.notes-panel p { margin: 0; }
.notes-panel p + p { margin-top: 8px; }
.notes-panel:empty { display: none; }
.empty-state { padding: 50px 20px; border: 1px dashed var(--border); border-radius: 14px; color: var(--muted); text-align: center; }
.empty-state[hidden] { display: none; }

.page-footer { margin-top: 46px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; text-align: center; }

@media (max-width: 720px) {
  .header-inner { min-height: 58px; padding: 8px 14px; gap: 8px; flex-wrap: wrap; }
  .brand { width: calc(100% - 52px); }
  .theme-toggle { order: 2; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links a { flex: 0 0 auto; padding: 6px 9px; }
  .page-shell { padding: 30px 14px 56px; }
  .hero { margin-bottom: 20px; }
  .toolbar { top: 105px; grid-template-columns: 1fr; gap: 7px; padding: 10px; border-radius: 13px; }
  .result-count { min-width: 0; text-align: left; padding: 0 3px; }
  .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .character-card { padding: 10px 11px; font-size: .9rem; }
  .notes-panel { padding: 15px; }
}

@media (max-width: 390px) {
  .character-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
