:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --ink: #121722;
  --muted: #687284;
  --line: #dfe4ea;
  --dark: #101722;
  --red: #e5484d;
  --red-soft: #fff0f1;
  --blue: #3478f6;
  --blue-soft: #edf4ff;
  --gray: #8a94a6;
  --green: #218c63;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--dark); }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.app-shell { width: 100%; max-width: 768px; min-height: 100vh; margin: auto; padding-bottom: 116px; background: var(--bg); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; color: #fff; background: var(--dark); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; color: #fff; background: var(--red); font-size: 20px; font-weight: 800; }
.brand p, .brand h1 { margin: 0; letter-spacing: 0; }
.brand p { color: #aeb8c8; font-size: 10px; }
.brand h1 { margin-top: 2px; font-size: 19px; }
.text-button { min-width: 48px; min-height: 40px; border: 1px solid #536071; color: #fff; background: transparent; }
.main-tabs { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: repeat(3,1fr); height: 48px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.main-tabs button { border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-size: 14px; font-weight: 700; }
.main-tabs button.active { color: var(--ink); border-bottom-color: var(--red); }
.view { display: none; }
.view.active { display: block; }
.session-strip { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.session-strip div { display: grid; gap: 3px; }
.session-strip span { font-size: 13px; font-weight: 700; }
.session-strip small { color: var(--muted); font-size: 10px; }
.sync-status { display: flex; align-items: center; gap: 6px; color: var(--green); font-size: 10px !important; }
.sync-status i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-panel { display: flex; align-items: stretch; min-height: 132px; color: #fff; background: var(--dark); }
.status-copy { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 22px 18px; }
.status-copy > span { color: #aeb8c8; font-size: 11px; }
.status-copy strong { margin: 7px 0 5px; font-size: clamp(30px, 10vw, 48px); line-height: 1; }
.status-copy small { color: #c5ccd7; font-size: 11px; }
.mt-value { display: grid; place-content: center; min-width: 96px; border-left: 1px solid #334052; text-align: center; }
.mt-value span { color: #aeb8c8; font-size: 11px; }
.mt-value strong { margin-top: 5px; font-size: 28px; }
.status-panel.up .status-copy strong, .status-panel.up .mt-value strong { color: #ff6b70; }
.status-panel.down .status-copy strong, .status-panel.down .mt-value strong { color: #6ba0ff; }
.metrics-grid { display: grid; grid-template-columns: repeat(4,1fr); border-bottom: 1px solid var(--line); background: var(--surface); }
.metrics-grid > div { min-width: 0; padding: 12px 8px; border-right: 1px solid var(--line); text-align: center; }
.metrics-grid > div:last-child { border-right: 0; }
.metrics-grid span, .metrics-grid small { display: block; color: var(--muted); font-size: 9px; }
.metrics-grid strong { display: block; margin: 5px 0 3px; font-size: 20px; }
.chart-section, .sequence-section, .stats-section { margin-top: 10px; padding: 16px; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-heading, .page-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading span, .page-heading span { color: var(--muted); font-size: 10px; }
.section-heading h2, .page-heading h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: 0; }
.section-heading > strong { color: var(--muted); font-size: 11px; }
.compact-select { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.compact-select select { height: 34px; border: 1px solid var(--line); color: var(--ink); background: #fff; }
.chart-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); background: #fbfcfd; }
.chart-scroll canvas { display: block; height: 270px; }
.chart-legend { display: flex; align-items: center; gap: 12px; min-height: 40px; color: var(--muted); font-size: 10px; }
.chart-legend span { display: flex; align-items: center; gap: 4px; }
.chart-legend i { width: 8px; height: 8px; }
.chart-legend .red { background: var(--red); }.chart-legend .blue { background: var(--blue); }.chart-legend .gray { background: var(--gray); }
.chart-legend button { margin-left: auto; min-height: 32px; padding: 0 10px; border: 1px solid var(--line); color: var(--ink); background: #fff; }
.m-chart-wrap { border: 1px solid var(--line); overflow: hidden; }
.m-chart-wrap canvas { display: block; width: 100%; height: 150px; }
.sequence-grid { display: grid; grid-template-columns: repeat(10, 28px); gap: 8px; min-height: 42px; overflow-x: auto; align-items: start; }
.sequence-dot { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 800; }
.sequence-dot.win { background: var(--red); }.sequence-dot.loss { background: var(--blue); }
.empty-state { grid-column: 1/-1; margin: 5px 0; color: var(--muted); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.stats-grid div { min-height: 64px; padding: 11px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats-grid span { display: block; color: var(--muted); font-size: 10px; }
.stats-grid strong { display: block; margin-top: 7px; font-size: 17px; }
.disclaimer { margin: 14px 16px 0; color: #747f8e; font-size: 11px; line-height: 1.6; }
.record-bar { position: fixed; left: 50%; bottom: 0; z-index: 30; display: grid; grid-template-columns: 54px 1fr 1fr; gap: 9px; width: min(768px,100%); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(16,23,34,.97); transform: translateX(-50%); backdrop-filter: blur(16px); }
.record-bar button { min-height: 60px; border: 0; }
.undo-button { color: #c8d0dc; background: #293443; font-size: 12px; }.undo-button:disabled { opacity: .4; }
.result-button { display: flex; align-items: center; justify-content: center; gap: 10px; color: #fff; }
.result-button span { font-size: 12px; opacity: .85; }.result-button strong { font-size: 24px; }
.result-button.win { background: var(--red); }.result-button.loss { background: var(--blue); }
.result-button:active { transform: scale(.98); }
.page-heading { padding: 22px 16px 12px; margin: 0; }
.primary-action { min-height: 40px; padding: 0 14px; border: 0; color: #fff; background: var(--red); }
.history-list { display: grid; gap: 1px; background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.history-item { padding: 16px; background: #fff; }
.history-item header { display: flex; justify-content: space-between; gap: 12px; }
.history-item h3 { margin: 0; font-size: 16px; }.history-item time { color: var(--muted); font-size: 10px; }
.history-item p { margin: 7px 0 12px; color: var(--muted); font-size: 11px; }
.history-metrics { display: grid; grid-template-columns: repeat(4,1fr); margin-bottom: 12px; }
.history-metrics span { display: grid; gap: 3px; color: var(--muted); font-size: 9px; }.history-metrics strong { color: var(--ink); font-size: 14px; }
.history-actions { display: flex; gap: 8px; }.history-actions button { min-height: 36px; border: 1px solid var(--line); background: #fff; font-size: 11px; }
.settings-list { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.settings-list label { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 74px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.settings-list label:last-child { border-bottom: 0; }.settings-list label > span { display: grid; gap: 4px; }
.settings-list strong { font-size: 14px; }.settings-list small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.settings-list select { height: 38px; border: 1px solid var(--line); background: #fff; }
input[role="switch"] { width: 46px; height: 26px; accent-color: var(--red); }
.data-actions { display: grid; gap: 9px; padding: 16px; }.data-actions button { min-height: 48px; border: 1px solid var(--line); background: #fff; }
.data-actions .danger-outline { color: var(--red); border-color: #f0b7ba; }
.algorithm-note { margin: 0 16px; padding: 16px 0; border-top: 1px solid var(--line); }.algorithm-note h3 { margin: 0 0 8px; font-size: 15px; }.algorithm-note p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.menu-panel { position: fixed; inset: 0 0 0 auto; z-index: 50; display: grid; align-content: start; gap: 1px; width: min(320px,88vw); padding: max(72px,env(safe-area-inset-top)) 12px 12px; background: var(--dark); box-shadow: -20px 0 50px rgba(0,0,0,.25); }
.menu-panel button { min-height: 50px; border: 0; color: #fff; text-align: left; background: #202a38; padding: 0 16px; }
dialog { padding: 0; border: 0; }.sheet-dialog { width: min(520px,100%); max-width: none; margin: auto 0 0; background: #fff; }.sheet-dialog::backdrop,.confirm-dialog::backdrop { background: rgba(10,16,24,.62); }
.sheet-dialog form { position: relative; padding: 24px 18px calc(22px + env(safe-area-inset-bottom)); }.dialog-close { position: absolute; right: 12px; top: 12px; width: 40px; height: 40px; border: 0; border-radius: 50%; font-size: 24px; }
.dialog-eyebrow { color: var(--red); font-size: 10px; font-weight: 700; }.sheet-dialog h2 { margin: 6px 0; font-size: 22px; }.sheet-dialog p { color: var(--muted); font-size: 12px; }.warning-text { padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); line-height: 1.6; }
.edit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }.edit-actions button { min-height: 50px; border: 0; color: #fff; }.win-choice { background: var(--red); }.loss-choice { background: var(--blue); }.edit-actions .delete-choice { grid-column: 1/-1; color: var(--red); background: var(--red-soft); }
.confirm-dialog { width: min(360px,calc(100% - 32px)); margin: auto; }.confirm-dialog form { padding: 22px; }.confirm-dialog h2 { margin: 0 0 8px; font-size: 19px; }.confirm-dialog p { color: var(--muted); font-size: 13px; line-height: 1.6; }.confirm-dialog form > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }.confirm-dialog button { min-height: 44px; border: 1px solid var(--line); background: #fff; }.confirm-dialog #confirmAccept { color: #fff; border-color: var(--red); background: var(--red); }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 45; display: flex; align-items: center; justify-content: space-between; gap: 18px; width: min(360px,calc(100% - 24px)); padding: 12px 14px; color: #fff; background: #25303e; transform: translateX(-50%); box-shadow: 0 12px 30px rgba(0,0,0,.25); font-size: 12px; }.toast button { border: 0; color: #ff8589; background: transparent; font-weight: 700; }
@media (min-width: 769px) { body { background: #dfe3e8; }.app-shell { box-shadow: 0 0 45px rgba(16,23,34,.18); }.record-bar { border-left: 1px solid #3b4655; border-right: 1px solid #3b4655; }.sheet-dialog { margin: auto; } }
@media (max-width: 370px) { .metrics-grid strong { font-size: 17px; }.sequence-grid { grid-template-columns: repeat(8,28px); }.status-copy strong { font-size: 29px; }.stats-grid { grid-template-columns: repeat(2,1fr); } }

