/* impliedMoves · "Glass" design system, light (market open) and dark (market closed). */

:root,
:root[data-theme="light"] {
  --bg: #eceef2;
  --ink: #1d1d1f;
  --ink2: #424245;
  --mute: #86868b;
  --faint: #a1a1a6;
  --hair: rgba(0, 0, 0, 0.08);
  --gridline: rgba(0, 0, 0, 0.05);
  --accent: #059669;
  --accent-rgb: 5, 150, 105;
  --accent2: #34d399;
  --up: #248a3d;
  --down: #d70015;

  --glass: rgba(255, 255, 255, 0.58);
  --stroke: rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 16px 40px -24px rgba(30, 40, 80, 0.2), 0 1px 3px rgba(30, 40, 80, 0.05);
  --fill: rgba(118, 118, 128, 0.12);
  --raised: #ffffff;
  --raised-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --track: rgba(0, 0, 0, 0.1);
  --knob: #ffffff;

  --blob1: #b9ecd6;
  --blob2: #cbe8ef;
  --blob3: #e6f2c8;
  --blob-opacity: 0.55;

  --tip-bg: rgba(255, 255, 255, 0.72);
  --menu-bg: rgba(255, 255, 255, 0.96);
  --tip-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --marker-bg: #1d1d1f;
  --marker-text: #ffffff;
  --chart-glow: 0;

  --error-bg: rgba(255, 59, 48, 0.1);
  --error-text: #c4170c;
  --notice-bg: rgba(255, 159, 10, 0.13);
  --notice-text: #8a4b00;

  --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  /* Neutral near-black, flat cards, green accent; faint green glow behind the cards. */
  --bg: #0b0c10;
  --ink: #e8e9ee;
  --ink2: #c4c6cf;
  --mute: #8b8e99;
  --faint: #5c5f6b;
  --hair: rgba(255, 255, 255, 0.07);
  --gridline: rgba(255, 255, 255, 0.05);
  --accent: #34d399;
  --accent-rgb: 52, 211, 153;
  --accent2: #6ee7b7;
  --up: #34d399;
  --down: #f87171;

  --glass: #14161c;
  --stroke: rgba(255, 255, 255, 0.07);
  --glass-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --fill: rgba(255, 255, 255, 0.06);
  --raised: rgba(255, 255, 255, 0.1);
  --raised-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --track: rgba(255, 255, 255, 0.1);
  --knob: #e8e9ee;

  --blob1: #10b981;
  --blob2: #0d9488;
  --blob3: transparent;
  --blob-opacity: 0.05;

  --tip-bg: rgba(20, 22, 28, 0.94);
  --menu-bg: #181a21;
  --tip-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.1);
  --marker-bg: #e8e9ee;
  --marker-text: #0b0c10;
  --chart-glow: 0;

  --error-bg: rgba(248, 113, 113, 0.12);
  --error-text: #fca5a5;
  --notice-bg: rgba(251, 191, 36, 0.1);
  --notice-text: #fcd34d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }

body {
  min-height: 100vh;
  font: 15px/1.5 var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.5s, color 0.3s;
}

input, select, button { font: inherit; color: inherit; }

/* ---------- backdrop ---------- */

.blob { position: fixed; border-radius: 50%; filter: blur(80px); z-index: 0; pointer-events: none; opacity: var(--blob-opacity); transition: background-color 0.6s, opacity 0.6s; }
.b1 { width: 620px; height: 620px; left: -160px; top: -180px; background: var(--blob1); }
.b2 { width: 520px; height: 520px; right: -140px; top: 120px; background: var(--blob2); }
.b3 { width: 560px; height: 460px; left: 30%; bottom: -220px; background: var(--blob3); opacity: calc(var(--blob-opacity) * 0.8); }

.wrap { position: relative; z-index: 1; max-width: 1160px; margin: 0 auto; padding: 20px 28px 40px; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--stroke);
  border-radius: 28px;
  box-shadow: var(--glass-shadow);
  min-width: 0;
  transition: background-color 0.4s, border-color 0.4s;
}

/* ---------- header ---------- */

/* Brand sits on the page; the controls get the glass bar. */
.topbar { position: relative; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav { display: flex; align-items: center; min-width: 0; }

.brand {
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.035em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.controls { display: flex; gap: 8px; min-width: 0; }

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  background: var(--fill);
  border-radius: 999px;
  padding: 0 14px;
  font-size: 14px;
  border: 1px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
/* Header pills match the cards below. */
.nav .pill {
  background: var(--glass);
  border-color: var(--stroke);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  backdrop-filter: blur(28px) saturate(170%);
}
.pill:focus-within { border-color: rgba(var(--accent-rgb), 0.6); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18); }
.pill > span { color: var(--mute); font-size: 12px; white-space: nowrap; }
.pill input, .pill select {
  border: 0; background: transparent; outline: none; color: var(--ink);
  font: 600 14px var(--font); -webkit-appearance: none; appearance: none;
}

.ticker-pill { position: relative; padding-right: 3px; }
.suggest-menu { left: 0; right: auto; width: min(360px, calc(100vw - 40px)); }
.picker-opt.suggest-opt { justify-content: flex-start; align-items: baseline; gap: 12px; }
.suggest-opt b { flex: 0 0 58px; font-weight: 600; color: var(--ink); }
.suggest-opt span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; color: var(--mute); }
#ticker { width: 64px; text-transform: uppercase; letter-spacing: 0.02em; }
#go {
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: var(--accent); display: grid; place-items: center; cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}
#go:hover { filter: brightness(1.08); }
#go:disabled { opacity: 0.55; cursor: default; }
#go svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.select-pill { position: relative; padding-right: 32px; }
.select-pill::after {
  content: ""; position: absolute; right: 15px; top: 50%; width: 6px; height: 6px;
  border-right: 1.6px solid var(--mute); border-bottom: 1.6px solid var(--mute);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
#expiry { cursor: pointer; font-variant-numeric: tabular-nums; min-width: 0; text-overflow: ellipsis; }
#expiry:disabled { color: var(--faint); cursor: default; }
/* Chrome on macOS draws the open menu natively and only understands installed font names
   (not -apple-system / system-ui aliases), so name a real font for the select itself. */
#expiry { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }
#expiry option { color: initial; }

/* custom expiry menu (picker.js), mouse/trackpad only */
.select-pill.enhanced select { display: none; }
.picker-btn {
  border: 0; background: transparent; color: var(--ink); cursor: pointer; padding: 0;
  font: 600 14px var(--font); font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0; text-align: left;
}
.picker-btn::before { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.picker-btn:disabled { color: var(--faint); cursor: default; }
.picker-btn:focus-visible { outline: none; }
.picker-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  width: 260px; max-height: min(420px, 70vh); overflow-y: auto; padding: 6px;
  background: var(--menu-bg); -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--stroke); border-radius: 16px; box-shadow: var(--tip-shadow);
  overscroll-behavior: contain;
}
.picker-menu[hidden] { display: none; }
.picker-opt {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 15px; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.picker-opt small { font-size: 13px; color: var(--mute); }
.picker-opt.active { background: var(--fill); }
.picker-opt[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.picker-opt[aria-selected="true"] small { color: var(--accent); }

/* ---------- layout ---------- */

main { padding-top: 18px; }

.content { position: relative; transition: opacity 0.25s; }
.content.busy { opacity: 0.55; }
.content.empty > :not(.loading) { visibility: hidden; }
.content > section { margin-bottom: 16px; }

.banner {
  margin-bottom: 16px;
  border-radius: 18px;
  padding: 12px 18px;
  font-size: 14px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.banner.error { background: var(--error-bg); color: var(--error-text); }
.banner.notice { background: var(--notice-bg); color: var(--notice-text); }
.banner ul { margin: 0; padding-left: 18px; }

.card { padding: 22px 24px; }
.lab { font-size: 13px; color: var(--mute); font-weight: 500; margin: 0; }
h2.lab { font-size: 15px; color: var(--ink); font-weight: 600; margin-bottom: 14px; }

/* ---------- implied move ---------- */

.move {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 14px 22px; font-variant-numeric: tabular-nums; line-height: 1.2;
}
.move .lab { font-size: 15px; }
.move strong { color: var(--accent); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.move-range { margin-left: auto; color: var(--mute); font-size: 15px; white-space: nowrap; }

/* ---------- chart ---------- */

.c-chart { position: relative; padding: 18px 16px 12px; }
.chart-unit { position: absolute; top: 16px; right: 18px; z-index: 2; display: flex; gap: 8px; align-items: center; }
.flash {
  position: absolute; bottom: calc(100% + 8px); right: 0; white-space: nowrap; pointer-events: none;
  background: var(--marker-bg); color: var(--marker-text); font: 600 12px var(--font);
  padding: 5px 10px; border-radius: 999px; opacity: 0;
}
.flash.show { animation: flash 1.6s ease forwards; }
@keyframes flash { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.chart-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 6px 6px 0; }
.chart-foot .asof { margin: 0; text-align: left; }
.chart-actions { display: flex; gap: 6px; flex-shrink: 0; }
.chart-actions .link-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 999px; background: var(--fill); color: var(--ink2); font-size: 13px; white-space: nowrap;
}
.chart-actions .link-btn:hover { color: var(--accent); }
.share-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer; color: var(--mute); text-decoration: none;
  font: 500 12px var(--font);
}
.link-btn:hover { color: var(--accent); }

.embed-dialog {
  position: fixed; width: min(560px, calc(100vw - 32px)); padding: 24px; color: var(--ink); border-radius: 24px;
  background: var(--menu-bg);
}
.embed-dialog::backdrop { background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(2px); }
.embed-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 999px;
  background: var(--fill); color: var(--mute); display: grid; place-items: center; cursor: pointer;
}
.embed-close:hover { color: var(--ink); }
.embed-close svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.embed-dialog h2 { padding-right: 40px; }
.embed-hint { font-size: 14px; color: var(--mute); margin: 0 0 14px; }
.embed-dialog textarea {
  width: 100%; resize: none; border: 0; border-radius: 12px; background: var(--fill); color: var(--ink);
  padding: 12px 14px; font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, monospace; outline: none;
}
.embed-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.embed-actions .spacer { flex: 1; }
.btn {
  position: relative; height: 36px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer;
  font: 600 13px var(--font);
}
.btn { background: var(--accent); color: #fff; }
/* Sideways drags scrub the tooltip without scrolling the page; vertical swipes still scroll. */
.chart { width: 100%; touch-action: pan-y; }
.chart-lg { height: 420px; }
.chart-sm { height: 270px; margin-top: 8px; }
.asof { margin: 6px 6px 0; font-size: 12px; color: var(--mute); text-align: right; }

/* ---------- calculator ---------- */

.seg-ctl { display: flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--fill); }
.seg-ctl button {
  border: 0; border-radius: 999px; background: transparent; color: var(--mute); cursor: pointer;
  font: 600 13px var(--font); min-width: 34px; padding: 5px 10px; transition: background-color 0.2s, color 0.2s;
}
.seg-ctl button:hover { color: var(--ink); }
.seg-ctl button[aria-checked="true"] { background: var(--raised); color: var(--ink); box-shadow: var(--raised-shadow); }
.calc { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: 18px; align-items: center; }
.field-input {
  height: 44px; border-radius: 12px; border: 1px solid transparent; background: var(--fill);
  padding: 0 14px; color: var(--ink); font: 500 16px var(--font); outline: none; min-width: 0; width: 100%;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus { border-color: rgba(var(--accent-rgb), 0.6); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18); }
.field-input::placeholder { color: var(--faint); }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.calc-out { margin-top: 18px; font-variant-numeric: tabular-nums; }
.split { display: flex; justify-content: space-between; gap: 12px; }
.split small { display: block; font-size: 13px; color: var(--mute); }
.split b { display: block; font-size: 30px; font-weight: 600; letter-spacing: -0.03em; margin-top: 2px; }
.split .r { text-align: right; }
.splitbar { margin-top: 14px; height: 8px; border-radius: 8px; background: rgba(var(--accent-rgb), 0.35); overflow: hidden; }
.splitbar i { display: block; height: 100%; background: var(--accent); border-radius: 8px 0 0 8px; transition: width 0.3s; }
.range-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.range-to { color: var(--mute); font-size: 14px; }
.range-out { margin-top: 18px; font-variant-numeric: tabular-nums; }
.split3 { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; }
.split3 small { white-space: nowrap; }
.split3 .mid { text-align: center; }
.split3 .mid b { color: var(--accent); }
.rangebar { position: relative; margin-top: 14px; height: 8px; border-radius: 8px; background: rgba(var(--accent-rgb), 0.25); overflow: hidden; }
.rangebar i { position: absolute; top: 0; bottom: 0; background: var(--accent); transition: left 0.3s, width 0.3s; }

.slider {
  --t: 50%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; outline: none;
  margin: 0; cursor: pointer; background: linear-gradient(90deg, var(--accent) var(--t), var(--track) var(--t));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--knob); cursor: grab;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.1);
}
.slider::-moz-range-thumb {
  width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--knob); cursor: grab;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.3), 0 1px 6px rgba(0, 0, 0, 0.3); }
.calc-empty { color: var(--mute); font-size: 14px; }

.hint { font-variant-numeric: tabular-nums; }

/* ---------- loading ---------- */

.loading { position: absolute; inset: 0; display: flex; justify-content: center; padding-top: 220px; z-index: 5; pointer-events: none; }
.loading[hidden] { display: none; }
.spinner {
  width: 28px; height: 28px; border: 2.5px solid var(--track); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.foot { padding: 10px 6px 0; font-size: 12px; color: var(--mute); }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  /* Phones/tablets: brand on its own line, controls full width below it. */
  .topbar { display: block; }  /* stays position: relative; z-index: 20 so menus overlay the cards */
  .brand { display: block; font-size: 24px; padding: 6px 4px 12px; }
  .controls { flex: 1; }
  .select-pill { flex: 1; }
  #expiry { width: 100%; }
}

@media (max-width: 640px) {
  .wrap { padding: 12px 14px 32px; }
  .controls { width: 100%; }
  .ticker-pill { flex: 0 0 auto; }
  .pill { padding-left: 12px; }
  main { padding-top: 14px; }
  .glass { border-radius: 22px; }
  .content > section { margin-bottom: 14px; }
  .card { padding: 18px; }
  .c-chart { padding: 12px 4px 10px; }
  .chart-lg { height: clamp(300px, 44svh, 400px); }
  .chart-sm { height: 240px; }
    .split b { font-size: 26px; }
  /* One line on phones: the dollar range would wrap, and the chart's band already shows it. */
  .move-range { display: none; }
  .move { flex-wrap: nowrap; }
  .move strong { margin-left: auto; white-space: nowrap; }
}

@media (max-width: 400px) {
  .pill > span { display: none; }
  .move { padding: 12px 14px; gap: 4px 6px; }
  .move .lab { font-size: 13px; }
  .move strong { font-size: 15px; letter-spacing: -0.02em; }
  .calc { gap: 14px; grid-template-columns: 100px 1fr; }
}

/* ---------- embed (/embed) ---------- */

body.embed { background: transparent; padding: 0; }
body.embed .blob { display: none; }
.embed-card { margin: 0; padding: 14px 14px 10px; border-radius: 16px; height: 100vh; display: flex; flex-direction: column; }
.embed-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 0 4px 4px; }
.embed-top strong { color: var(--accent); font-size: 15px; font-weight: 600; margin-left: 6px; font-variant-numeric: tabular-nums; }
.embed-brand { font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap; }
.embed-brand:hover { color: var(--accent); }
.embed-card .chart { flex: 1; min-height: 0; }
