:root {
  --bg: #080B12;
  --panel: #111827;
  --panel-2: #172033;
  --text: #E6EDF7;
  --muted: #A7B4C8;
  --cyan: #22D3EE;
  --magenta: #E879F9;
  --positive: #34D399;
  --negative: #FB7185;
  --up: #e25b5b;
  --down: #3dbe7a;
  --warn: #f0d0a0;
  --line: rgba(167, 180, 200, 0.34);
  --focus: #22D3EE;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --radius: 2px;
  --chamfer: 14px;
  --shadow: 0 0 0 1px rgba(34, 211, 238, 0.22);
  --motion: 120ms;
  --font: "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  --hit: 44px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  font: 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
}
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
}
main {
  position: relative;
  z-index: 1;
  max-width: 52rem;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) 3rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--hit);
  margin: 0 0 var(--space-3);
  pointer-events: none;
}
.brand-mark { display: block; width: 48px; height: 48px; flex: 0 0 auto; }
.brand-word { display: block; height: 28px; width: auto; max-width: calc(100% - 60px); }
h1 { font-size: 1.35rem; font-weight: 700; margin: 0 0 var(--space-2); }
h2 { font-size: 1.05rem; font-weight: 700; margin: var(--space-5) 0 0; }
p, li, td, th, button, a, label, input { overflow-wrap: anywhere; }
.card p { margin: 0.35rem 0; white-space: pre-wrap; word-break: break-word; }
.lead { margin: 0 0 var(--space-2); }
.notice, .sub {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-3) var(--space-3) 0.85rem;
  border-left: 3px solid var(--cyan);
  color: var(--text);
  background: var(--panel);
}
label { display: block; margin: 0.85rem 0 0.35rem; }
input[type="text"], input[type="password"] {
  width: 100%;
  min-height: var(--hit);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--cyan);
  outline: 1px solid var(--muted);
  outline-offset: 2px;
  flex: 0 0 auto;
}
input::placeholder {
  color: var(--muted);
  opacity: 1;
}
input[aria-invalid="true"] {
  border: 2px solid var(--negative);
}
.row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-height: var(--hit);
  margin: 0.65rem 0;
}
button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  min-height: var(--hit);
  padding: 0.55rem 0.85rem;
  font: inherit;
  font-variant-numeric: tabular-nums;
  background: var(--panel-2);
  color: var(--text);
  width: auto;
  margin: 0;
  cursor: pointer;
}
button:hover { border-color: var(--cyan); }
button:active { border-color: var(--magenta); }
#run-btn {
  width: 100%;
  background: var(--cyan);
  color: #080B12;
  font-weight: 700;
  border-color: var(--cyan);
}
#run-btn:hover { background: #67E8F9; }
#run-btn:active { background: #06B6D4; }
#run-btn:disabled,
#run-btn:disabled:hover,
#run-btn:disabled:active {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px dashed var(--muted);
}
button:disabled,
button[aria-disabled="true"] {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px dashed var(--muted);
  cursor: not-allowed;
}
.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.actions-secondary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.actions-secondary button { width: 100%; }
.hidden { display: none; }
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  margin-top: var(--space-4);
}
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: var(--chamfer);
  height: var(--chamfer);
  pointer-events: none;
}
.card::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
}
.card::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid var(--magenta);
  border-bottom: 2px solid var(--magenta);
}
.meta { color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.err {
  color: var(--negative);
  margin-top: 0.75rem;
  padding: var(--space-3);
  border: 1px solid var(--negative);
  border-left-width: 4px;
  background: var(--panel);
}
.hit { padding: 0.75rem 0; border-top: 1px solid var(--line); }
.hit:first-child { border-top: 0; }
.pct { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-fold, .price-fold { margin-top: 0.8rem; }
.detail-fold > summary,
.price-fold > summary {
  cursor: pointer;
  font-weight: 700;
  min-height: var(--hit);
  display: flex;
  align-items: center;
}
summary:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
label:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
#run-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
  box-shadow: 0 0 0 2px #080B12;
}
.warn { color: var(--warn); }
.research-view { max-width: 100%; overflow-x: hidden; }
.research-status { font-weight: 700; }
.research-warn {
  margin: 0.7rem 0;
  padding: 0.75rem 0.8rem;
  border-radius: var(--radius);
  color: var(--text);
  background: #2A2416;
  border: 1px solid #C4A15A;
  border-left-width: 4px;
}
.research-title { font-weight: 700; }
.research-note { color: var(--muted); font-size: 0.92rem; }
.plan-compare { width: 100%; border-collapse: collapse; table-layout: fixed; }
.plan-compare th, .plan-compare td {
  text-align: left;
  padding: 0.4rem 0.3rem;
  border-bottom: 1px solid var(--line);
  font-weight: 450;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.plan-cards { display: none; }
.plan-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  margin-top: 0.55rem;
  background: var(--panel-2);
}
.plan-card p { display: flex; justify-content: space-between; gap: 0.75rem; }
@media (max-width: 520px) {
  .plan-compare { display: none; }
  .plan-cards { display: block; }
}
.curve-title { font-size: 1.2rem; font-weight: 700; }
.equity-slot { margin: 0.6rem 0; }
.equity-line { width: 100%; height: auto; display: block; color: var(--text); }
.equity-line polyline { stroke: var(--cyan); }
.equity-line circle { fill: var(--cyan); stroke: none; }
.equity-missing { color: var(--text); border-left: 3px solid var(--muted); padding-left: 0.6rem; }
.kchart {
  height: 460px;
  width: 100%;
  margin: 0.35rem 0 0.75rem;
  background: var(--bg);
}
@media (max-width: 520px) {
  .kchart { height: 320px; }
}
#price-history-status,
#price-history-retry { overflow-wrap: anywhere; max-width: 100%; }
#price-history-retry { width: 100%; margin-top: var(--space-2); }
.price-chart { max-width: 100%; }
.price-tools, .level-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin: var(--space-2) 0;
}
.price-tools button, .level-toggles label {
  width: auto;
  margin: 0;
  min-height: var(--hit);
  padding: 0.4rem 0.7rem;
  font-size: 0.95rem;
  background: var(--panel-2);
  color: var(--text);
}
.level-toggles label { display: inline-flex; gap: 0.3rem; align-items: center; }
.price-legend { font-variant-numeric: tabular-nums; min-height: 1.4rem; }
.level-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin: 0.2rem 0 0.4rem;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.level-list li { margin: 0; }
.tv-note a { color: var(--cyan); }
.price-chart.is-max {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: auto;
  background: var(--bg);
  padding:
    calc(0.75rem + env(safe-area-inset-top))
    calc(0.75rem + env(safe-area-inset-right))
    calc(0.75rem + env(safe-area-inset-bottom))
    calc(0.75rem + env(safe-area-inset-left));
}
.price-chart.is-max .kchart { height: calc(100dvh - 13rem); }
body.price-max { overflow: hidden; }
.frames { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0.45rem 0 0.2rem; }
.frames button.frame {
  width: auto;
  margin: 0;
  min-height: var(--hit);
  min-width: var(--hit);
  padding: 0.4rem 0.7rem;
  font-size: 0.95rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.frames button.frame.on {
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  border: 2px solid var(--cyan);
  box-shadow: inset 0 -3px 0 var(--cyan);
}
.frames button.chart-enter { background: var(--panel-2); }
body.chart-open { overflow: hidden; }
.chart-window {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding:
    calc(0.75rem + env(safe-area-inset-top))
    calc(1rem + env(safe-area-inset-right))
    calc(1rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  background: var(--bg);
}
.chart-window.hidden { display: none; }
.chart-window-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.chart-window-bar p { margin: 0; font-weight: 700; }
.chart-tools { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chart-tools button {
  width: auto;
  margin: 0;
  min-height: var(--hit);
  padding: 0.4rem 0.7rem;
  font-size: 0.95rem;
  background: var(--panel-2);
}
.chart-window-stage { flex: 1; min-height: 0; }
.chart-window .kchart { height: 100%; }
.chart-window svg {
  width: 100%;
  height: calc(100dvh - 9.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
ul { padding-left: 1.1rem; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
