:root {
  color-scheme: dark;
  --bg: #070b12;
  --surface: #0d1420;
  --panel: #121b29;
  --panel-2: #192638;
  --panel-3: #223247;
  --line: #2b3b50;
  --line-soft: rgba(148, 163, 184, .16);
  --text: #f7f9fc;
  --muted: #a8b4c5;
  --subtle: #77869a;
  --accent: #f7b718;
  --accent-strong: #ffd45c;
  --blue: #69beff;
  --purple: #c89cff;
  --ok: #5ee795;
  --danger: #ff8095;
  --warning: #ffd166;
  --shadow: 0 18px 46px rgba(0, 0, 0, .28);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, .18);
  --radius-lg: 22px;
  --radius: 16px;
  --radius-sm: 12px;
  --topbar-height: 92px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Sans", sans-serif;
  background:
    radial-gradient(circle at 92% -5%, rgba(247, 183, 24, .13), transparent 31rem),
    radial-gradient(circle at -15% 35%, rgba(105, 190, 255, .07), transparent 25rem),
    linear-gradient(180deg, #0a1019 0%, var(--bg) 46%, #070b12 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.menu-open { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .42; cursor: not-allowed; filter: saturate(.55); }
a { color: inherit; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-height);
  padding: calc(10px + env(safe-area-inset-top)) 15px 10px;
  border-bottom: 1px solid rgba(43, 59, 80, .82);
  background: rgba(7, 11, 18, .9);
  backdrop-filter: blur(18px) saturate(1.2);
}
.brand-block { min-width: 0; flex: 1; }
.brand-row { display: flex; align-items: center; gap: 8px; }
.eyebrow {
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.network-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}
.network-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--subtle);
  box-shadow: 0 0 0 3px rgba(119, 134, 154, .12);
}
.network-status.online::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(94, 231, 149, .12); }
.network-status.offline::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 128, 149, .12); }
.topbar h1 {
  margin: 4px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(17px, 4.8vw, 22px);
  line-height: 1.15;
  letter-spacing: .01em;
}
.screen-title { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 800; }
.save-status { margin-top: 2px; color: var(--subtle); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(25, 38, 56, .9);
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
}
.icon-button:active { transform: scale(.97); }

.race-context {
  position: sticky;
  top: calc(var(--topbar-height) + env(safe-area-inset-top));
  z-index: 24;
  width: min(760px, calc(100% - 20px));
  min-height: 52px;
  margin: 8px auto 0;
  padding: 8px 11px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(247, 183, 24, .32);
  border-radius: 15px;
  background: rgba(18, 27, 41, .93);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(15px);
  text-align: left;
}
.race-context-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(247, 183, 24, .14);
  color: var(--accent);
  font-weight: 1000;
}
.race-context-main { min-width: 0; }
.race-context-main b, .race-context-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-context-main b { font-size: 12px; }
.race-context-main small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.race-context-arrow { color: var(--muted); font-size: 22px; }

/* Layout */
.app-shell { width: min(760px, 100%); margin: 0 auto; padding: 14px 12px calc(94px + env(safe-area-inset-bottom)); }
.screen { display: none; animation: screen-in .18s ease-out; }
.screen.active { display: block; }
@keyframes screen-in { from { opacity: .55; transform: translateY(3px); } }
.screen-intro { margin: 2px 3px 12px; }
.screen-intro h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.screen-intro p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 15px;
  align-items: center;
  padding: 18px;
  margin-bottom: 12px;
  border: 1px solid rgba(247, 183, 24, .32);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(247, 183, 24, .16), rgba(18, 27, 41, .95) 56%),
    var(--panel);
  box-shadow: var(--shadow);
}
.hero-card h2 { margin: 5px 0 7px; font-size: 20px; line-height: 1.32; }
.hero-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.68; }
.hero-mark, .modal-mark {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 20px;
  background: linear-gradient(150deg, var(--accent-strong), var(--accent));
  color: #1a1305;
  font-size: 30px;
  line-height: .86;
  font-weight: 1000;
  text-align: center;
  box-shadow: inset 0 -10px 22px rgba(0, 0, 0, .14), 0 12px 25px rgba(247, 183, 24, .12);
}
.hero-mark small { display: block; font-size: 10px; letter-spacing: .08em; }

.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 12px; }
.mode-grid.three-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mode-card {
  position: relative;
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr) 14px;
  grid-template-rows: auto auto;
  column-gap: 9px;
  align-items: center;
  min-height: 82px;
  padding: 12px 9px 12px 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(18, 27, 41, .94);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-soft);
}
.mode-card:active { transform: scale(.985); }
.mode-card > span:first-child {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 13px;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 19px;
  font-weight: 1000;
}
.mode-card > b { font-size: 12px; line-height: 1.25; }
.mode-card > small { color: var(--muted); font-size: 9px; line-height: 1.42; }
.mode-arrow { grid-column: 3; grid-row: 1 / 3; color: var(--subtle); font-style: normal; font-size: 20px; }
.mode-card.live { border-color: rgba(105, 190, 255, .36); }
.mode-card.live > span:first-child { background: rgba(105, 190, 255, .13); color: var(--blue); }
.mode-card.simulation { border-color: rgba(247, 183, 24, .36); }
.mode-card.simulation > span:first-child { background: rgba(247, 183, 24, .13); color: var(--accent); }
.mode-card.result { border-color: rgba(94, 231, 149, .29); }
.mode-card.result > span:first-child { background: rgba(94, 231, 149, .11); color: var(--ok); }
.mode-card.calculator { border-color: rgba(200, 156, 255, .33); }
.mode-card.calculator > span:first-child { background: rgba(200, 156, 255, .12); color: var(--purple); }

.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat-card { padding: 11px 9px; border: 1px solid var(--line-soft); border-radius: 14px; background: rgba(18, 27, 41, .8); text-align: center; }
.stat-card .label { color: var(--muted); font-size: 9px; }
.stat-card .value { margin-top: 4px; font-size: 20px; line-height: 1; font-weight: 1000; }

.panel {
  padding: 15px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 27, 41, .94);
  box-shadow: var(--shadow-soft);
}
.panel h2, .panel h3 { margin: 0; }
.internet-panel { border-color: rgba(247, 183, 24, .32); background: linear-gradient(145deg, rgba(247, 183, 24, .07), rgba(18, 27, 41, .97)); }
.workflow-panel { border-color: rgba(105, 190, 255, .3); background: linear-gradient(145deg, rgba(105, 190, 255, .055), rgba(18, 27, 41, .97)); }
.calculator-head { border-color: rgba(200, 156, 255, .3); background: linear-gradient(145deg, rgba(200, 156, 255, .055), rgba(18, 27, 41, .97)); }
.updater-panel { border-color: rgba(56, 189, 248, .3); background: linear-gradient(145deg, rgba(56, 189, 248, .055), rgba(18, 27, 41, .97)); }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.section-heading > div { display: flex; align-items: center; gap: 9px; min-width: 0; }
.section-heading h2 { font-size: 16px; line-height: 1.3; }
.section-heading.compact { margin-bottom: 9px; }
.step {
  display: inline-grid;
  place-items: center;
  min-width: 31px;
  height: 31px;
  border: 1px solid rgba(247, 183, 24, .23);
  border-radius: 10px;
  background: rgba(247, 183, 24, .12);
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
}

/* Disclosures */
.disclosure-panel { padding: 0; overflow: clip; }
.disclosure-panel > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 13px 15px;
  cursor: pointer;
  user-select: none;
}
.disclosure-panel > summary::-webkit-details-marker { display: none; }
.disclosure-title b, .disclosure-title small { display: block; }
.disclosure-title b { font-size: 14px; }
.disclosure-title small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.disclosure-chevron { color: var(--muted); font-size: 20px; transition: transform .18s ease; }
.disclosure-panel[open] .disclosure-chevron { transform: rotate(180deg); }
.disclosure-body { padding: 0 15px 15px; border-top: 1px solid var(--line-soft); }

/* Forms and actions */
label { display: block; margin: 10px 0; color: var(--muted); font-size: 11px; font-weight: 800; }
input, select, textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #090f18;
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: #64748a; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #0b121d; box-shadow: 0 0 0 3px rgba(247, 183, 24, .1); }
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; gap: 9px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

button, .file-button {
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 900;
  text-align: center;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
button:active:not(:disabled), .file-button:active { transform: translateY(1px); }
button.primary { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-strong), var(--accent)); color: #181204; }
button.primary.action-main { min-height: 52px; box-shadow: 0 10px 25px rgba(247, 183, 24, .12); }
button.ghost, .file-button { background: rgba(9, 15, 24, .45); }
button.ghost:hover { border-color: #40536e; }
button.danger { border-color: rgba(255, 128, 149, .35); background: rgba(255, 128, 149, .1); color: #ffdce2; }
button.small { min-height: 38px; padding: 7px 10px; font-size: 11px; }
.full { width: 100%; }
.button-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.button-stack { display: grid; gap: 8px; }
.file-row { display: grid; grid-template-columns: 1.25fr .75fr; gap: 8px; margin-top: 8px; }
.file-button { position: relative; display: grid; place-items: center; margin: 0; color: var(--text); font-size: 13px; }
.file-button input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.quick-date-row { display: flex; gap: 7px; margin: -2px 0 10px; }
.chip-button { min-height: 34px; padding: 6px 13px; border-radius: 99px; background: rgba(9, 15, 24, .55); color: var(--muted); font-size: 11px; }
.hint { margin: -2px 0 10px; color: var(--muted); font-size: 11px; line-height: 1.65; }

/* Lists and cards */
.race-list, .horse-list, .history-list, .progress-list { display: grid; gap: 8px; }
.race-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 75px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  background: rgba(9, 15, 24, .62);
  color: var(--text);
  text-align: left;
}
.race-card.active { border-color: rgba(247, 183, 24, .62); box-shadow: inset 3px 0 0 var(--accent); }
.race-no { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 13px; background: var(--panel-2); color: var(--accent); font-size: 17px; font-weight: 1000; }
.race-main { min-width: 0; }
.race-main b, .race-main span { display: block; overflow: hidden; text-overflow: ellipsis; }
.race-main b { font-size: 13px; white-space: nowrap; }
.race-main span { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.chevron { color: var(--subtle); font-size: 22px; }
.race-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-color: rgba(247, 183, 24, .3); }
.race-banner > div:first-child { min-width: 0; }
.race-banner h2 { margin: 4px 0 7px; overflow-wrap: anywhere; font-size: 20px; line-height: 1.28; }
.status-pill, .count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  line-height: 1.2;
}
.status-pill.ok { border-color: rgba(94, 231, 149, .38); color: var(--ok); }
.status-pill.warn { border-color: rgba(255, 209, 102, .34); color: var(--warning); }
.progress-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 11px 1px; border-bottom: 1px solid var(--line-soft); }
.progress-item:last-child { border-bottom: 0; }
.progress-item span { color: var(--muted); font-size: 11px; }
.progress-item b { font-size: 12px; }
.progress-item b.ok { color: var(--ok); }
.progress-item b.warn { color: var(--warning); }

.horse-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  background: rgba(9, 15, 24, .65);
}
.horse-rank { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px; background: var(--panel-2); color: var(--accent); font-size: 18px; font-weight: 1000; }
.horse-name { font-size: 13px; font-weight: 900; line-height: 1.45; }
.horse-name .status-pill { margin-left: 3px; vertical-align: middle; }
.horse-meta { margin-top: 4px; color: var(--muted); font-size: 9.5px; line-height: 1.55; }
.auto-score { color: var(--blue); }
.score-box { min-width: 54px; text-align: right; }
.score-box b { display: block; font-size: 20px; line-height: 1; }
.score-box span { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }
.horse-actions { grid-column: 2 / 4; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* Workflow */
.workflow-timeline { display: grid; gap: 7px; margin-bottom: 12px; }
.workflow-step { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(9, 15, 24, .62); }
.workflow-step > span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); color: var(--muted); font-size: 10px; font-weight: 900; }
.workflow-step.done { border-color: rgba(94, 231, 149, .27); }
.workflow-step.done > span { background: rgba(94, 231, 149, .12); color: var(--ok); }
.workflow-step b { display: block; font-size: 11px; }
.workflow-step small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.workflow-actions { margin-bottom: 4px; }
.result-gate-box { display: grid; gap: 4px; margin: 10px 0; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: rgba(9, 15, 24, .62); }
.result-gate-box b { font-size: 11px; }
.result-gate-box span { color: var(--muted); font-size: 10px; line-height: 1.55; }
.result-gate-box.ready { border-color: rgba(94, 231, 149, .34); background: rgba(94, 231, 149, .055); }
.result-gate-box.waiting { border-color: rgba(247, 183, 24, .29); background: rgba(247, 183, 24, .045); }
.workflow-history { margin-top: 14px; }
.workflow-history h3 { margin: 0 0 7px; color: var(--accent); font-size: 11px; }
.workflow-history-item { padding: 10px; border: 1px solid var(--line-soft); border-radius: 11px; background: rgba(9, 15, 24, .6); }
.workflow-history-item + .workflow-history-item { margin-top: 7px; }
.workflow-history-item b { display: block; font-size: 10px; }
.workflow-history-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.55; }

/* Tickets */
.ticket-tabs { position: sticky; top: 158px; z-index: 5; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 11px; padding: 4px; border-radius: 14px; background: rgba(9, 15, 24, .94); backdrop-filter: blur(12px); }
.tab { background: transparent; }
.tab.active { border-color: var(--accent); color: var(--accent); background: rgba(247, 183, 24, .08); }
.ticket-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; max-height: 58vh; overflow: auto; overscroll-behavior: contain; }
.ticket { padding: 10px 5px; border: 1px solid var(--line-soft); border-radius: 11px; background: rgba(9, 15, 24, .65); text-align: center; font-size: 13px; font-weight: 1000; }
.ticket small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 8px; font-weight: 600; }
.lock-box { margin-top: 12px; padding: 11px; border-radius: 11px; background: #080e17; color: var(--muted); font-size: 9px; overflow-wrap: anywhere; line-height: 1.65; }
.lock-box:empty { display: none; }
.history-item { padding: 11px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(9, 15, 24, .6); }
.history-item b { font-size: 11px; line-height: 1.5; }
.history-item p { margin: 5px 0 8px; color: var(--muted); font-size: 9px; overflow-wrap: anywhere; line-height: 1.5; }

/* Result and analysis */
.result-search-list { margin-top: 12px; }
.result-search-card.registered { border-color: rgba(94, 231, 149, .28); }
.result-search-card.unregistered { border-color: rgba(247, 183, 24, .25); }
.evaluation { display: grid; gap: 9px; }
.eval-card { padding: 13px; border: 1px solid var(--line-soft); border-radius: 14px; background: rgba(9, 15, 24, .62); }
.eval-card.hit { border-color: rgba(94, 231, 149, .38); }
.eval-card.miss { border-color: rgba(255, 128, 149, .3); }
.eval-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.eval-top h3 { font-size: 13px; }
.eval-top strong { font-size: 12px; }
.eval-top strong.hit { color: var(--ok); }
.eval-top strong.miss { color: var(--danger); }
.eval-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.eval-numbers div { padding: 8px 5px; border-radius: 10px; background: var(--panel-2); text-align: center; }
.eval-numbers span { display: block; color: var(--muted); font-size: 8px; }
.eval-numbers b { display: block; margin-top: 3px; font-size: 14px; }
.result-analysis { display: grid; gap: 10px; }
.analysis-hero { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 11px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(9, 15, 24, .62); }
.analysis-grade { display: grid; place-items: center; min-height: 64px; border-radius: 13px; background: var(--panel-2); text-align: center; }
.analysis-grade span, .analysis-kicker { color: var(--muted); font-size: 8px; font-weight: 800; }
.analysis-grade b { display: block; margin-top: -3px; color: var(--accent); font-size: 29px; line-height: 1; }
.analysis-hero h3 { margin: 3px 0 4px; font-size: 15px; }
.analysis-hero p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.analysis-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.analysis-metrics > div, .coverage-grid > div { padding: 10px; border: 1px solid var(--line-soft); border-radius: 11px; background: rgba(9, 15, 24, .62); }
.analysis-metrics span, .coverage-grid span { display: block; color: var(--muted); font-size: 8px; }
.analysis-metrics b, .coverage-grid b { display: block; margin-top: 4px; font-size: 17px; }
.analysis-metrics small, .coverage-grid small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.analysis-subtitle { margin: 4px 0 -2px; color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .04em; }
.finish-analysis-grid { display: grid; gap: 7px; }
.finish-analysis-card { padding: 10px; border: 1px solid var(--line-soft); border-radius: 11px; background: rgba(9, 15, 24, .62); }
.finish-analysis-card > span { display: inline-block; min-width: 34px; color: var(--accent); font-size: 9px; font-weight: 900; }
.finish-analysis-card > b { font-size: 12px; }
.finish-analysis-card > small { display: block; margin: 5px 0 0 38px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.coverage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.coverage-grid > div { padding: 8px 5px; text-align: center; }
.coverage-grid b { font-size: 14px; }
.analysis-insights { margin: 0; padding: 0 0 0 19px; color: var(--muted); font-size: 10px; line-height: 1.68; }
.analysis-insights li + li { margin-top: 4px; }
.score-gap-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.score-gap-row span { padding: 9px; border-radius: 9px; background: #080e17; color: var(--muted); font-size: 9px; text-align: center; }
.score-gap-row b { color: var(--text); }
.revision-comparison { margin-top: 13px; }
.revision-table { display: grid; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.revision-row { display: grid; grid-template-columns: 1.15fr .7fr .7fr 1fr; align-items: center; gap: 6px; padding: 9px; border-bottom: 1px solid var(--line-soft); background: rgba(9, 15, 24, .62); font-size: 9px; }
.revision-row:last-child { border-bottom: 0; }
.revision-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.revision-head { background: var(--panel-2); color: var(--muted); font-weight: 900; }
.hit-text { color: var(--ok); }
.miss-text { color: var(--danger); }
.analysis-editor { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line-soft); }

/* Calculator */
.calculator-fields { display: grid; gap: 9px; margin-top: 9px; }
.calculator-field-card { padding: 10px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(9, 15, 24, .62); }
.calculator-field-card label { margin: 0; }
.calculator-field-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 7px; }
.calculator-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.calculator-summary > .compact-empty, .calculator-summary > .calculator-error { grid-column: 1 / -1; }
.calculator-stat { padding: 11px 7px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(9, 15, 24, .62); text-align: center; }
.calculator-stat span { display: block; color: var(--muted); font-size: 8px; }
.calculator-stat b { display: block; margin-top: 4px; font-size: 16px; }
.calculator-error { padding: 11px; border: 1px solid rgba(255, 128, 149, .32); border-radius: 11px; background: rgba(255, 128, 149, .07); color: #ffdce2; font-size: 10px; line-height: 1.65; }
.calculator-warnings { display: grid; gap: 6px; margin-top: 9px; }
.calculator-warning { padding: 8px 10px; border: 1px solid rgba(247, 183, 24, .25); border-radius: 9px; background: rgba(247, 183, 24, .05); color: var(--muted); font-size: 9px; line-height: 1.5; }
.calculator-result-actions { margin-bottom: 10px; }
.calculator-ticket-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; max-height: 52vh; overflow: auto; overscroll-behavior: contain; }
.calculator-ticket { padding: 8px 4px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgba(9, 15, 24, .62); text-align: center; font-size: 11px; font-weight: 1000; }
.calculator-ticket small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 7px; font-weight: 600; }
.calculator-more { grid-column: 1 / -1; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; font-size: 9px; }
.coverage-card { text-align: left !important; }
.coverage-card b { font-size: 11px !important; }
.coverage-card span { margin-top: 5px; line-height: 1.5; }
.calculator-note { margin-top: 12px; }

/* Utility boxes */
.privacy-box, .source-box, .storage-box {
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: rgba(9, 15, 24, .55);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.privacy-box { margin: 0 0 11px; border-color: rgba(247, 183, 24, .23); background: rgba(247, 183, 24, .045); }
.privacy-box.ok { border-color: rgba(94, 231, 149, .3); background: rgba(94, 231, 149, .05); }
.source-box, .storage-box { margin-top: 11px; }
.source-box:empty, .lock-box:empty { display: none; }
.index-progress { min-height: 1.35rem; margin-top: .7rem; color: var(--muted); font-size: 10px; line-height: 1.55; }
.index-progress.busy::before { content: ""; display: inline-block; width: .72rem; height: .72rem; margin-right: .45rem; border: 2px solid rgba(255, 255, 255, .2); border-top-color: var(--accent); border-radius: 50%; animation: index-spin .8s linear infinite; vertical-align: -1px; }
@keyframes index-spin { to { transform: rotate(360deg); } }
.empty-state { padding: 34px 16px; border: 1px dashed var(--line); border-radius: 15px; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.7; }
.compact-empty { padding: 14px 11px; border-radius: 10px; font-size: 9px; }
.version { margin: 12px 0 0; color: var(--muted); text-align: center; font-size: 9px; }

/* Updater */
.updater-panel code { padding: 1px 4px; border-radius: 5px; background: #07101a; color: #8fdcff; font-size: .9em; }
.update-candidate-box { margin-top: 10px; }
.update-candidate { display: grid; grid-template-columns: 1.2fr .55fr .8fr; gap: 8px; padding: 11px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(9, 15, 24, .62); }
.update-candidate.ready { border-color: rgba(94, 231, 149, .35); background: rgba(94, 231, 149, .045); }
.update-candidate.blocked { border-color: rgba(255, 128, 149, .34); background: rgba(255, 128, 149, .045); }
.update-candidate > div { min-width: 0; }
.update-candidate span { display: block; color: var(--muted); font-size: 8px; }
.update-candidate b { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: 10px; }
.update-candidate > small { grid-column: 1 / -1; color: var(--muted); font-size: 8px; line-height: 1.55; }
.update-candidate .update-alert { padding: 7px 8px; border-radius: 8px; background: rgba(255, 128, 149, .07); color: #ffdce2; }

/* Bottom navigation and more sheet */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 35;
  width: min(760px, 100%);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 6px 7px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(43, 59, 80, .85);
  background: rgba(7, 11, 18, .95);
  backdrop-filter: blur(18px) saturate(1.2);
}
.nav-item { min-height: 56px; padding: 4px 2px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 9px; line-height: 1.1; }
.nav-item span { display: block; margin-bottom: 4px; color: inherit; font-size: 16px; font-weight: 1000; }
.nav-item.active { color: var(--accent); background: rgba(247, 183, 24, .09); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(8px);
}
.modal { width: min(430px, 100%); padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.modal .modal-mark { width: 74px; margin: 0 auto 14px; font-size: 17px; }
.modal h2 { margin: 0 0 10px; text-align: center; }
.modal h3 { margin: 16px 0 5px; color: var(--accent); font-size: 13px; }
.modal p { color: var(--muted); font-size: 11px; line-height: 1.6; }
.error-text { min-height: 20px; margin-top: 8px; color: var(--danger); text-align: center; font-size: 10px; }
.lock-modal { z-index: 130; }
.bottom-sheet-backdrop { place-items: end center; padding: 0; }
.bottom-sheet {
  width: min(760px, 100%);
  padding: 9px 13px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: #101925;
  box-shadow: 0 -20px 55px rgba(0, 0, 0, .42);
  animation: sheet-up .2s ease-out;
}
@keyframes sheet-up { from { transform: translateY(18px); opacity: .7; } }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 9px; border-radius: 99px; background: #40506a; }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-heading h2 { margin: 0; font-size: 17px; }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.more-card { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 76px; padding: 10px; background: rgba(9, 15, 24, .62); text-align: left; }
.more-card > span:first-child { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--panel-2); color: var(--accent); font-size: 17px; font-weight: 1000; }
.more-card b, .more-card small { display: block; }
.more-card b { font-size: 12px; }
.more-card small { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }

.notice {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 80;
  width: min(430px, calc(100% - 24px));
  transform: translate(-50%, 18px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #1b283b;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
  font-size: 11px;
  line-height: 1.5;
}
.notice.show { opacity: 1; transform: translate(-50%, 0); }
.notice.bad { border-color: var(--danger); }
.scroll-top {
  position: fixed;
  right: max(14px, calc((100vw - 760px) / 2 + 14px));
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 28;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 14px;
  background: rgba(25, 38, 56, .94);
  box-shadow: var(--shadow-soft);
}

/* Responsive */
@media (max-width: 560px) {
  :root { --topbar-height: 88px; }
  .topbar { padding-inline: 12px; }
  .topbar h1 { font-size: 17px; }
  .screen-title { font-size: 10px; }
  .save-status { max-width: 235px; }
  .app-shell { padding-inline: 10px; }
  .hero-card { grid-template-columns: minmax(0, 1fr) 72px; padding: 15px; }
  .hero-card h2 { font-size: 18px; }
  .hero-card p { font-size: 11px; }
  .hero-mark { border-radius: 17px; font-size: 26px; }
  .mode-card { min-height: 79px; }
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .form-grid.three label:nth-child(3) { grid-column: 1 / -1; }
  .ticket-grid, .calculator-ticket-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .race-banner { align-items: flex-start; }
  .race-banner .top-actions { flex-direction: column; }
}

@media (max-width: 410px) {
  .top-actions { gap: 5px; }
  .icon-button { width: 39px; height: 39px; min-height: 39px; border-radius: 12px; }
  .mode-grid, .mode-grid.three-modes { gap: 7px; }
  .mode-card { grid-template-columns: 38px minmax(0, 1fr) 10px; min-height: 76px; padding: 10px 7px 10px 9px; column-gap: 7px; }
  .mode-card > span:first-child { width: 38px; height: 38px; border-radius: 11px; font-size: 17px; }
  .mode-card > b { font-size: 11px; }
  .mode-card > small { font-size: 8px; }
  .stats-grid { gap: 6px; }
  .stat-card { padding: 10px 5px; }
  .stat-card .label { font-size: 8px; }
  .stat-card .value { font-size: 18px; }
  .form-grid.two { grid-template-columns: 1fr; gap: 0; }
  .button-row { grid-template-columns: 1fr; }
  .file-row { grid-template-columns: 1fr; }
  .calculator-summary { grid-template-columns: 1fr 1fr; }
  .calculator-stat:last-child { grid-column: 1 / -1; }
  .revision-row { grid-template-columns: 1.05fr .65fr .65fr 1fr; padding: 8px 6px; font-size: 8px; }
  .analysis-hero { grid-template-columns: 62px minmax(0, 1fr); }
  .analysis-grade { min-height: 58px; }
  .analysis-grade b { font-size: 26px; }
  .update-candidate { grid-template-columns: 1fr 1fr; }
  .update-candidate > div:first-child { grid-column: 1 / -1; }
  .more-grid { grid-template-columns: 1fr 1fr; }
  .more-card { grid-template-columns: 36px minmax(0, 1fr); min-height: 68px; gap: 8px; padding: 8px; }
  .more-card > span:first-child { width: 36px; height: 36px; }
}

@media (min-width: 761px) {
  .bottom-nav { border-inline: 1px solid var(--line); border-radius: 18px 18px 0 0; }
  .race-context { top: calc(var(--topbar-height) + env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
