:root {
  --bg: #f4efe6;
  --bg-2: #fffdf8;
  --ink: #1b2430;
  --muted: #5c6570;
  --line: #d8cfc0;
  --accent: #9a4a16;
  --accent-2: #c46a2b;
  --good: #1f6b4a;
  --bad: #9b2c2c;
  --chip: #ece4d4;
  --shadow: 0 18px 40px rgba(27, 36, 48, 0.08);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #12161c;
  --bg-2: #1b212b;
  --ink: #f3eadc;
  --muted: #b7b0a3;
  --line: #343c48;
  --accent: #e08a45;
  --accent-2: #f0b27a;
  --good: #7dcea0;
  --bad: #f1948a;
  --chip: #262d38;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html {
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { overflow-x: clip; }
body {
  margin: 0;
  padding: 0;
  font-family: Outfit, system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(154, 74, 22, 0.12), transparent 50%),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

img, svg, video { max-width: 100%; height: auto; }
canvas { max-width: 100%; }
.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: max(64px, calc(28px + env(safe-area-inset-bottom)));
}
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 36px;
}
.brand {
  display: flex; gap: 12px; align-items: center;
  text-decoration: none; color: inherit;
  min-width: 0;
}
.brand-logo {
  display: block;
  height: 52px;
  width: auto;
  max-width: min(340px, 72vw);
  object-fit: contain;
  background: #0b1c3a;
  border-radius: 8px;
}
.name { font-family: "Source Serif 4", Georgia, serif; font-weight: 600; font-size: 1.25rem; letter-spacing: 0.01em; }
.tag { color: var(--muted); font-size: 0.82rem; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip, .ghost, .primary, .secondary {
  border-radius: 999px; border: 1px solid var(--line); padding: 8px 14px;
  background: var(--chip); color: var(--ink); font: inherit; cursor: pointer;
}
.chip { font-family: "IBM Plex Mono", monospace; font-size: 0.75rem; }
.ghost { background: transparent; }
.primary {
  background: var(--accent); color: #fffdf8; border-color: transparent; font-weight: 600;
}
.secondary { background: var(--bg-2); font-weight: 600; }
.primary:disabled, .secondary:disabled { opacity: 0.45; cursor: not-allowed; }

.ad-banner {
  margin: 0 0 28px;
  border: 1px solid var(--line);
  background: #f4efe6;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ad-banner-stage { position: relative; background: #f4efe6; }
.ad-banner img {
  display: block;
  width: 100%;
  height: auto;
}
.banner-play {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fffdf8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(27, 36, 48, 0.28);
  z-index: 2;
}
.banner-play svg { margin-left: 3px; }
.banner-play:hover { filter: brightness(1.08); }
.banner-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ad-banner .hint {
  margin: 0;
  padding: 8px 14px 10px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
}

.dip-explain { margin-top: 0; }
.dip-explain h2 { margin-bottom: 10px; }
.dip-explain > p { margin: 0 0 12px; max-width: none; }
.dip-explain-params { margin: 0 0 16px; }
.dip-explain-body {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
  gap: 18px 22px;
  align-items: start;
  margin-bottom: 12px;
}
.dip-chart {
  margin: 0;
  background: #f4efe6;
  border: 1px solid var(--line);
  overflow: hidden;
}
.dip-chart svg { display: block; width: 100%; height: auto; }
.dip-chart .dip-bg { fill: #f4efe6; }
.dip-chart .dip-panel { fill: #fffdf8; stroke: #d8cfc0; stroke-width: 1; }
.dip-chart .dip-grid line { stroke: #d8cfc0; stroke-dasharray: 4 5; }
.dip-chart .dip-axis text,
.dip-chart .dip-lane-lbl text,
.dip-chart .dip-legend text {
  fill: #5c6570;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.dip-chart .dip-price {
  fill: none;
  stroke: #1b2430;
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.dip-chart .dip-lane-guide { stroke: #d8cfc0; stroke-width: 1; }
.dip-chart .dip-lot { stroke-width: 7; stroke-linecap: round; }
.dip-chart .dip-lot.open { stroke: #3d8f68; }
.dip-chart .dip-lot.closed { stroke: #c4b49a; }
.dip-chart .dip-marks .buy { fill: #1c7a52; }
.dip-chart .dip-marks .sell { fill: #b42318; }
.dip-chart .dip-legend .buy { fill: #1c7a52; }
.dip-chart .dip-legend .sell { fill: #b42318; }
.dip-chart .dot-n {
  fill: #fffdf8;
  font-family: Outfit, system-ui, sans-serif;
  font-weight: 700;
}
.dip-chart figcaption {
  margin: 0;
  padding: 8px 12px 10px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}
.dip-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: dip;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dip-steps li {
  position: relative;
  padding: 10px 12px 10px 40px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.92rem;
  line-height: 1.45;
}
.dip-steps li::before {
  counter-increment: dip;
  content: counter(dip);
  position: absolute;
  left: 10px;
  top: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1c7a52;
  color: #fffdf8;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dip-steps li:nth-child(4)::before,
.dip-steps li:nth-child(5)::before { background: #b42318; }
.dip-steps strong { color: var(--ink); }
.dip-steps .cash {
  display: block;
  margin-top: 6px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.hero h1 {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600; font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  line-height: 1.2; margin: 8px 0 14px; max-width: none;
}
.kicker { letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.72rem; color: var(--accent); font-weight: 600; }
.lede { max-width: none; color: var(--muted); font-size: 1.05rem; }
.disclaimer {
  border: 1px solid var(--line); background: var(--bg-2); padding: 12px 14px;
  font-size: 0.88rem; color: var(--muted); margin: 22px 0;
}
.panel {
  background: var(--bg-2); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 22px; margin: 18px 0;
}
.panel h2 { margin: 0 0 16px; font-family: "Source Serif 4", Georgia, serif; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
input, select, textarea, button {
  font: inherit;
  max-width: 100%;
}
input {
  color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  padding: 10px 12px; font-family: "IBM Plex Mono", monospace; font-size: 16px;
}
input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}
input:placeholder-shown {
  color: var(--muted);
}
.signed-input {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  min-height: 42px;
}
.signed-prefix {
  flex: 0 0 auto;
  padding: 10px 0 10px 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.4;
  user-select: none;
  pointer-events: none;
}
.signed-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding-left: 4px;
  outline: none;
}
.signed-input:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.period-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 16px; }
.span-2 { grid-column: 1 / -1; }
.wallet-box { margin-top: 16px; padding: 12px; border: 1px solid var(--line); background: var(--bg); }
#express-checkout-element { min-height: 48px; margin-top: 8px; }
.legal h1 { font-family: "Source Serif 4", Georgia, serif; }
.legal a { color: var(--accent); }
.brand-legal a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.05rem;
  letter-spacing: 0;
  text-transform: none;
}
.brand-legal img {
  display: block;
  height: 40px;
  width: auto;
  max-width: min(280px, 80vw);
  object-fit: contain;
  background: #0b1c3a;
  border-radius: 6px;
}
.advanced { margin: 18px 0; }
.advanced summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hint { color: var(--muted); font-size: 0.82rem; }
.code-box {
  margin-top: 16px; padding: 14px; border: 1px dashed var(--accent);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.code-box strong { font-family: "IBM Plex Mono", monospace; font-size: 1.15rem; letter-spacing: 0.08em; }
.error { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bg-2)); padding: 10px 12px; margin-top: 12px; }
.loading { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.card { position: relative; z-index: 0; border: 1px solid var(--line); background: var(--bg); padding: 12px 14px; overflow: visible; }
.card:hover,
.card.info-open { z-index: 9; }
.card .lbl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card .lbl > span:first-child { min-width: 0; }
.card .val { font-family: "IBM Plex Mono", monospace; font-size: 1.15rem; margin-top: 4px; }
.card .formula {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.info-i {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  font: 600 10px/1 "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0;
  text-transform: none;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.info-i:hover,
.info-i:focus-visible,
.card.info-open .info-i {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}
.info-tip {
  display: none;
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(100% + 4px);
  z-index: 8;
  padding: 9px 11px;
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 8px;
}
.info-i:focus-visible + .info-tip,
.card.info-open .info-tip { display: block; }
@media (hover: hover) {
  .info-i:hover + .info-tip { display: block; }
}
.pos { color: var(--good); }
.neg { color: var(--bad); }

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 8px;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; font-family: "IBM Plex Mono", monospace; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; }
.chart-tools { display: flex; gap: 8px; align-items: center; }
.chart-zoom {
  min-width: 44px;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  padding: 8px 12px;
}
.chart-wrap { height: 320px; margin: 8px 0 10px; cursor: crosshair; }
.book-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 10px;
  margin: 8px 0 18px;
  background: #f4efe6;
  border: 1px solid var(--line);
  padding: 8px;
}
.book-plot {
  position: relative;
  min-width: 0;
  cursor: crosshair;
  overscroll-behavior: contain;
}
.book-plot canvas { display: block; width: 100%; height: 460px; touch-action: none; }
.book-rect {
  position: absolute;
  border: 1.5px solid #9a4a16;
  background: rgba(154, 74, 22, 0.16);
  pointer-events: none;
  z-index: 2;
}
.book-tip {
  position: absolute;
  z-index: 5;
  min-width: 140px;
  max-width: min(240px, calc(100% - 16px));
  padding: 8px 10px;
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
  pointer-events: none;
}
.book-tip .tip-side { font-weight: 600; margin-bottom: 4px; }
.book-tip .tip-side.buy { color: #1c7a52; }
.book-tip .tip-side.sell { color: #b42318; }
.book-side { padding: 4px 4px 0 2px; }
.book-pnl {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 12px 12px;
  text-align: center;
}
.book-pnl .lbl {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}
.book-pnl .val {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 8px;
}
.book-pnl .pct {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 2px;
}
.book-pnl .sub { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
.chart-bands {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 20px;
}
.chart-bands .swatch {
  display: inline-block;
  width: 14px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(27, 36, 48, 0.12);
}
.swatch-capital { background: rgba(196, 106, 43, 0.5); }
.swatch-lotcap { background: rgba(74, 93, 122, 0.45); }
.method { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
footer { margin-top: 28px; color: var(--muted); font-size: 0.8rem; }
footer a { color: var(--accent); }
.foot-note { overflow-wrap: anywhere; }
details.trades { margin-top: 12px; }
details.trades summary { cursor: pointer; font-weight: 600; }

.legal-disclaimer {
  margin-top: 48px;
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
}
.legal-disclaimer h2 {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 12px;
}
.legal-disclaimer p {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 12px;
  max-width: none;
}
.legal-disclaimer a { color: var(--accent); }
.form-disclaimer a { color: var(--accent); margin-left: 0.35em; }

@media (max-width: 720px) {
  .shell {
    padding: 16px 14px 40px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: max(40px, calc(20px + env(safe-area-inset-bottom)));
  }
  .top {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
  }
  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
  .chip {
    max-width: calc(100% - 88px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .brand-logo { height: 42px; max-width: min(260px, 70vw); }
  .hero h1 { max-width: none; font-size: 1.55rem; }
  .lede { font-size: 0.98rem; }
  .panel { padding: 16px 14px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-pnl {
    grid-column: 1 / -1;
    padding: 16px;
  }
  .card-pnl .val {
    font-size: clamp(1.5rem, 7vw, 2.05rem);
    font-weight: 600;
    line-height: 1.2;
    overflow-wrap: anywhere;
    margin-top: 8px;
  }
  .card-pnl .formula { font-size: 0.88rem; }
  .book-view { grid-template-columns: 1fr; margin-left: -6px; margin-right: -6px; }
  .book-side { order: -1; }
  .book-side .hint { margin: 8px 0 10px; font-size: 0.8rem; }
  .book-pnl {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "lbl sub"
      "val pct";
    align-items: baseline;
    gap: 2px 14px;
    text-align: left;
    padding: 16px 16px 14px;
  }
  .book-pnl .lbl { grid-area: lbl; font-size: 0.8rem; }
  .book-pnl .val {
    grid-area: val;
    font-size: clamp(1.7rem, 8vw, 2.25rem);
    margin-top: 6px;
    line-height: 1.15;
  }
  .book-pnl .pct {
    grid-area: pct;
    font-size: clamp(1.2rem, 5vw, 1.55rem);
    margin-top: 6px;
  }
  .book-pnl .sub { grid-area: sub; margin-top: 0; text-align: right; }
  table.month-pnl { font-size: 1.05rem; }
  table.month-pnl td.num {
    font-size: 1.22rem;
    font-weight: 600;
  }
  .book-plot canvas { height: min(70vh, 560px); min-height: 440px; }
  .dip-explain-body { grid-template-columns: 1fr; }
  .dip-steps li { font-size: 0.95rem; padding: 12px 12px 12px 42px; }
  .dip-steps .cash { font-size: 1.05rem; }
  .banner-play { width: 52px; height: 52px; }
  .actions .primary,
  .actions .secondary {
    min-height: 44px;
    flex: 1 1 100%;
  }
  .ghost { min-height: 40px; }
  .legal-disclaimer { margin-top: 32px; }
  .legal-disclaimer p { font-size: 0.78rem; }
  .chart-head { align-items: flex-start; }
  th, td { padding: 8px 8px; white-space: nowrap; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
  .name { font-size: 1.1rem; }
  .brand-logo { height: 40px; }
  .book-plot canvas { height: min(72vh, 540px); min-height: 420px; }
  .hero h1 { font-size: 1.4rem; }
}
