:root {
  color-scheme: dark;
  --bg: #0e1316;
  --bg2: #12191c;
  --card: #161f22;
  --card2: #202c30;
  --border: #2b3a3e;
  --border-soft: #253337;
  --text: #edf5f2;
  --muted: #a3b7b2;
  --accent: #85e7bf;
  --accent2: #a5f4d5;
  --accent-soft: #20362e;
  --accent-border: #426659;
  --on-accent: #102a21;
  --gold: #efc783;
  --gold-soft: #3a3021;
  --green: #84e2b1;
  --green-soft: #203b33;
  --red: #ffa9b7;
  --red-soft: #402a36;
  --blue: #a7c7ff;
  --blue-soft: #243650;
  --orange: #ffba86;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 26px -22px #000;
  --header-h: 62px;
  --page-width: 1540px;
  --side-width: 192px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eaf0ed;
  --bg2: #f0f4f1;
  --card: #f8faf8;
  --card2: #e2ebe5;
  --border: #cddbd2;
  --border-soft: #e5eeeb;
  --text: #192e30;
  --muted: #526963;
  --accent: #077568;
  --accent2: #075d52;
  --accent-soft: #e1f3ed;
  --accent-border: #8acbbb;
  --on-accent: #fff;
  --gold: #815709;
  --gold-soft: #fff1d2;
  --green: #18764e;
  --green-soft: #e5f5eb;
  --red: #a2344a;
  --red-soft: #fbe8ed;
  --blue: #285d9f;
  --blue-soft: #e8f0fa;
  --orange: #91490e;
  --shadow: 0 8px 26px -22px #233c38;
}

html { -webkit-text-size-adjust: 100%; }
body {
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: .005em;
}
button, input, select, textarea { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }
.icon {
  display: block;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  z-index: 60;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--on-accent);
  background: var(--accent);
}
.skip-link:focus { transform: none; }

/* App shell */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: calc(var(--header-h) - 1px);
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 8px 22px;
}
.brand, .header-actions, .header-button { display: flex; align-items: center; }
.brand { gap: 10px; font-size: 15px; font-weight: 800; line-height: 1.15; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 11px;
}
.brand-mark .icon { width: 21px; height: 21px; }
.header-actions { gap: 8px; }
.header-button {
  gap: 8px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
}
.header-button:hover, .header-button[aria-expanded=true] { border-color: var(--accent-border); background: var(--accent-soft); }
#nav-toggle { display: none; }
.header-button .icon { color: var(--accent); }
.theme-icon-light, [data-theme=light] .theme-icon-dark { display: none; }
[data-theme=light] .theme-icon-light { display: block; }

.app-shell {
  display: grid;
  grid-template-columns: var(--side-width) minmax(0, 1fr);
  max-width: var(--page-width);
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
}
.app-sidebar { min-width: 0; border-right: 1px solid var(--border); background: var(--bg2); }
#nav {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  padding: 19px 13px;
  scrollbar-width: thin;
}
.nav-group + .nav-group { margin-top: 15px; }
.nav-heading {
  margin: 0 9px 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.nav-group button, .nav-group a {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  position: relative;
  min-height: 33px;
  padding: 5px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.nav-group button:hover, .nav-group a:hover { background: var(--card2); color: var(--text); text-decoration: none; }
.nav-group button.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent2);
  font-weight: 750;
}
.nav-group button.active::before {
  content: "";
  position: absolute;
  inset: 7px auto 7px -1px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-links .external-icon { width: 13px; height: 13px; margin-left: auto; }

.workspace { min-width: 0; padding: 23px clamp(18px, 3vw, 36px) 48px; }
.workspace-heading { margin-bottom: 17px; }
.workspace-heading h1 {
  font-size: clamp(29px, 3vw, 44px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.045em;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.workspace-heading:not([data-section=route]) .route-only { display: none; }
.workspace-heading[data-section=route] {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(20px, 3vw, 29px);
  border: 1px solid #38594e;
  border-radius: var(--radius);
  background: radial-gradient(ellipse at 95% 0%, #274a3e, transparent 78%), #172a2b;
  color: #eef7f1;
}
.heading-content { position: relative; z-index: 1; }
.heading-location {
  margin-bottom: 7px;
  color: #a4e7ca;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .115em;
  text-transform: uppercase;
}
.heading-description { max-width: 44ch; margin-top: 8px; color: #c4d9d4; }
.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 5px 10px;
  border: 1px solid #4e7365;
  border-radius: var(--radius-sm);
  background: #254036;
  color: #c0f1da;
  font-size: 13px;
  font-weight: 700;
}
.hero-link:hover { background: #345a4a; text-decoration: none; }
.heading-map {
  position: absolute;
  inset: 0 0 0 38%;
  background:
    linear-gradient(#85e7bf18 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, #85e7bf18 1px, transparent 1px) 0 0 / 24px 24px,
    url("../map/out/regions/johto-gray.png") 61% 48% / cover;
  mix-blend-mode: screen;
  opacity: .46;
  mask-image: linear-gradient(to right, transparent, #000 60%);
  pointer-events: none;
}

/* Character and route progress */
.charbar {
  display: flex;
  align-items: center;
  gap: 12px 25px;
  flex-wrap: wrap;
  margin-bottom: 13px;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.charbar-inner { display: grid; flex: 2 1 360px; grid-template-columns: minmax(56px, .7fr) repeat(3, minmax(76px, 1fr)); gap: 9px; }
.charbar label { display: grid; align-content: end; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 650; }
.charbar input[type=number], .charbar select, .account-control {
  min-height: 33px;
  width: 100%;
  padding: 4px 8px;
  background: var(--bg2);
}
.account-setting { cursor: pointer; }
.account-control { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.badge-free, .badge-vip { padding: 3px 7px; border-radius: 6px; font-size: 11px; font-weight: 800; }
.badge-free { color: var(--muted); background: var(--card2); }
.badge-vip { color: var(--gold); background: var(--gold-soft); }
.xpbar-wrap { flex: 1 1 200px; min-width: 0; }
.xpbar-heading { display: flex; justify-content: space-between; gap: 8px; color: var(--text); font-size: 12px; font-weight: 650; }
.xpbar-heading strong { color: var(--accent2); font-variant-numeric: tabular-nums; }
.xpbar-label { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.xpbar { height: 5px; margin-top: 5px; border-radius: 99px; overflow: hidden; background: var(--card2); }
.xpbar-fill { height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .25s; }
#route-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat { min-width: 0; padding: 12px 14px; border-radius: var(--radius); text-align: left; }
.stat .l { font-size: 12px; font-weight: 650; letter-spacing: 0; text-transform: none; }
.stat .v { margin-top: 4px; color: var(--text); font-size: 23px; line-height: 1.1; font-variant-numeric: tabular-nums; }
#route-stats .stat:first-child { border-color: var(--accent-border); }
#route-stats .stat:last-child .v { color: var(--accent2); }
.stat .v small { color: var(--muted); font-size: .64em; font-weight: 600; }
.stat-detail { margin-top: 4px; color: var(--muted); font-size: 11px; }

.route-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 9px 13px; margin-bottom: 11px; }
.route-filters h2 { flex: 1 1 115px; font-size: 17px; }
.route-filters .chk { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; cursor: pointer; }
.route-filters .ghost { padding: 6px 10px; font-size: 12px; }
.phase { margin-bottom: 12px; padding: 0 12px 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg2); }
.phase:has(.phase-head[aria-expanded=true]) { border-color: var(--accent-border); }
.phase-head {
  width: 100%;
  margin-bottom: 0;
  padding: 12px 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
}
.phase-head::after {
  content: "";
  width: 7px;
  height: 7px;
  margin: 0 3px 4px 0;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
}
.phase-head[aria-expanded=false]::after { transform: rotate(-45deg); }
.phase-body { padding-top: 7px; }
.phase-notes { margin: 0 0 10px; padding: 7px 10px; border-left: 2px solid var(--accent-border); white-space: pre-line; }
.phase-proj { background: var(--green-soft); color: var(--green); }
.phase-prog { margin: 0 0 4px; background: var(--card2); }
#tab-route .qrow:last-child { margin-bottom: 0; }
.qrow.locked { opacity: 1; }
.qrow.locked .qname { color: var(--muted); }
.qrow.locked .lock-reason { margin-left: 6px; }
.tag.faction-police { background: var(--blue-soft); color: var(--blue); }
.tag.faction-rocket { background: var(--red-soft); color: var(--red); }
.entry-title { border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.entry-title:hover { color: var(--accent2); text-decoration: underline; text-underline-offset: 3px; }
button.quest-reopen { flex: 0 0 auto; align-self: center; padding: 5px 10px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.quest-notice {
  position: fixed;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 60;
  width: min(390px, calc(100% - 24px));
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.quest-notice:not([hidden]) { display: flex; }
.quest-notice p { flex: 1; min-width: 0; padding-left: 3px; overflow-wrap: anywhere; }
#quest-undo { padding: 6px 10px; border-color: var(--accent-border); background: var(--accent-soft); color: var(--accent2); }
#quest-undo:hover { border-color: var(--accent); }
.quest-notice-close {
  display: grid;
  place-items: center;
  min-width: 30px;
  min-height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.quest-notice-close:hover { background: var(--card2); color: var(--text); }

/* Shared components */
.section-title { color: var(--text); font-size: 1.05rem; padding-bottom: 8px; }
.filters { align-items: center; gap: 8px; border-radius: var(--radius); }
input[type=text], input[type=number], select, textarea {
  max-width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
}
.filters input::placeholder { color: var(--muted); }
.filters input[type=text] { min-width: min(220px, 100%); }
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.planner-filters label { display: flex; align-items: center; gap: 9px; color: var(--muted); font-weight: 650; }
.planner-quest { padding: 8px 10px; }
.planner-note { margin-top: 6px; color: var(--muted); font-size: .79rem; }
.planner-line { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 7px 0; }
.planner-line + .planner-line { border-top: 1px solid var(--border-soft); }
.planner-line small { display: block; color: var(--muted); }
.planner-line > .tag { flex-shrink: 0; }
#kanto-container .card { align-self: start; }
#kanto-container .section-title .tag { margin-left: 5px; }
#type-quest { width: min(100%, 24rem); }
.grid, .hunt-grid, .passive-xp { grid-template-columns: repeat(auto-fill, minmax(min(100%, 275px), 1fr)); gap: 12px; }
.wide-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 375px), 1fr)); }
.card, .hunt-card, .passive-xp .px-card { min-width: 0; border-radius: var(--radius); }
.tag, .pkm, .tchip { border-radius: 999px; }
.modal .sub { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.modal-close { display: grid; place-items: center; }
.modal .meta-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
table { border-collapse: separate; border-spacing: 0; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--border-soft); }
th { background: var(--bg2); color: var(--muted); font-size: .73rem; text-align: left; }
tbody tr:hover td { background: var(--accent-soft); }
.dex-layout { grid-template-columns: minmax(230px, 34%) minmax(0, 1fr); }
.dex-detail { top: calc(var(--header-h) + 12px); max-height: calc(100vh - var(--header-h) - 24px); }
.dc-tier { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; }
.dc-tier summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.dc-rewards { margin-left: auto; color: var(--green); font-size: .8rem; }
.dc-tier[open] summary { margin-bottom: 4px; }
@media (max-width: 600px) { .dc-rewards { margin-left: 0; width: 100%; } }
.task-advisor { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 9px; }
.task-advisor > summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: .88rem; }
.task-advisor > summary::marker { color: var(--gold); }
.task-advisor-results { margin-top: 10px; }
.task-advisor-targets { margin: 0 0 9px; }
.task-advisor-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.task-advisor-columns section { min-width: 0; }
.task-advisor-pick { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.task-advisor-icon { width: 36px; height: 36px; object-fit: contain; border-radius: 50%; background: var(--card2); }
.task-advisor-pick > div { min-width: 0; }
.task-advisor-name { font-weight: 700; }
.task-advisor-meta { color: var(--muted); font-size: .78rem; line-height: 1.5; }
.task-advisor-moves { display: block; margin-top: 3px; }
.task-advisor-locations { margin: 10px 0; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg2); }
.task-advisor-location { padding: 8px 0; border-top: 1px solid var(--border-soft); }
.task-advisor-spawn-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.task-advisor-spawn-links a { color: var(--accent); font-size: .78rem; }
.task-advisor-note { margin: 9px 0 0; font-size: .75rem; }
.mission-card .desc { margin-top: 8px; }
.mission-facts { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border-soft); font-size: .79rem; }
.mission-facts > div + div { margin-top: 6px; }
.mission-facts dt { color: var(--text); font-weight: 650; }
.mission-facts dd { color: var(--muted); }
.task-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.task-map-link { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 700; }
.task-map-link .icon { color: var(--accent); }

@media (max-width: 940px) {
  #nav-toggle { display: flex; }
  .app-shell { display: block; }
  .app-sidebar { display: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .app-sidebar.is-open { display: block; }
  #nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    position: static;
    max-height: none;
    padding: 14px 18px;
  }
  .nav-group + .nav-group { margin-top: 0; }
}

@media (max-width: 700px) {
  :root { --header-h: 60px; }
  .header-row { padding-inline: 12px; }
  #nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { padding: 15px 12px 36px; }
  .heading-map { inset-inline-start: 22%; opacity: .29; }
  .charbar { gap: 11px; }
  .stat { padding: 9px 10px; }
  .stat .l { line-height: 1.3; }
  .stat .v { font-size: 20px; }
  .route-filters h2 { flex-basis: 100%; }
  .phase-stats { width: 100%; margin-left: 0; }
  .phase-head::after { position: absolute; right: 6px; bottom: 17px; }
  .phase-head { position: relative; }
  .filters select { min-width: 0; }
  .dex-list { max-height: 240px; }
  .gym-block, .tablewrap, .scroll-x { overflow-x: auto; }
  .card table, .walk table, .dex-detail table, #tab-johto .wt-tbl {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 440px) {
  .share-view-button { width: 36px; justify-content: center; padding-inline: 8px; }
  .share-view-button span { display: none; }
  .charbar-inner { grid-template-columns: 1fr 1fr; }
  .header-button { padding-inline: 9px; }
  .filters input[type=text] { flex-basis: 100%; }
  .dc-rewards { width: 100%; margin-left: 0; }
}

@media (max-width: 365px) {
  #nav-toggle { justify-content: center; width: 36px; }
  #nav-toggle span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
.plan-action-card h4 { margin: 8px 0 4px; }
.plan-action-meta, .plan-action-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.plan-action-buttons { justify-content: space-between; margin-top: 12px; }
.plan-action-buttons button, .activity-check { margin: 0; }
.plan-prereq { padding-top: 5px; }
.plan-repeatable-card, .cycle-overview { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plan-repeatable-card button { flex: 0 0 auto; }
.cycle-overview { margin: 0 0 14px; }
.activity-card.done { border-color: rgba(57,211,131,.45); }
.activity-check { margin-top: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card2); color: var(--text); cursor: pointer; }
.activity-check.on { border-color: rgba(57,211,131,.5); color: #8ce2b1; }
.activity-check:disabled { opacity: .5; cursor: not-allowed; }
.data-audit-summary { display: grid; gap: 4px; margin-bottom: 10px; }
.data-audit-list { display: grid; gap: 8px; }
.data-audit-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border-soft); }
.data-audit-row h4 { margin: 6px 0 2px; }
.data-audit-filters { margin: 10px 0; }
@media(max-width:600px) {
  .cycle-overview, .plan-repeatable-card, .data-audit-row { align-items: flex-start; flex-direction: column; }
  .plan-repeatable-card button { width: 100%; }
}
