/* ==========================================================================
   EDGEMARK — css/edgemark.css
   The original Edgemark look (dark, candle glyphs, violet/teal), plus what
   the Zyentora conversion adds: the shared frame's colours, a bottom bar and
   slide-in menu on phones, Pro markers and locked cards, the Ai Smart
   Insights spotlight, Refer & Earn, and the first-run screen.
   Phone fixes (Phase A found a 431px-wide page on a 375px screen): the
   topbar's "Saved locally" pill and button label, and the 10-button rating
   rows, no longer push the page wider than the screen.
   ========================================================================== */
/* Release B (2026-10-21): light by default with a Dark mode switch (shared/zy-theme.js),
   on the calm --c-* tokens (shared/zy-theme.css). Violet and teal stay Edgemark's
   accents; green / red / amber still mean profit / loss / warning. Each has a fill
   colour (charts, candles, bars) and a "-t" text colour that passes WCAG AA on the
   theme's surfaces. The accent setting (Settings > Look) writes --accent, --accent-soft,
   --accent-fill, --accent-deep and --accent-on on <html> (pages.js applySettings). */
:root {
  --accent: #7C6CF0; --accent-soft: rgba(124, 108, 240, 0.14);
  --accent-fill: #6A5AE0; --accent-deep: #5240CC; --accent-on: #FFFFFF; /* buttons and chips filled with the accent */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --radius-s: 8px; --radius-m: 12px; --radius-l: 18px;
  --sidebar-w: 236px; --topbar-h: 60px; --bottom-h: 64px;
}
html[data-theme="light"] {
  --bg: var(--c-bg); --side: var(--c-side); --surface: var(--c-surface); --surface-2: var(--c-surface2); --surface-3: var(--c-surface3); --hover: var(--c-hover);
  --border: var(--c-border2); --border-soft: var(--c-border); --field: var(--c-field);
  --text: var(--c-t1); --text-dim: var(--c-t2); --text-faint: var(--c-t3);
  --accent-t: #5440B8;
  --accent-2: #1AAE9E; --accent-2-soft: rgba(42, 201, 184, 0.14); --accent-2-t: #0A6B61;
  --green: #12A06A; --green-soft: rgba(18, 160, 106, 0.12); --green-t: #0A6E45;
  --red: #DC3A55; --red-soft: rgba(220, 58, 85, 0.10); --red-t: #B4233C;
  --amber: #E2A336; --amber-soft: rgba(226, 163, 54, 0.16); --amber-t: #845500;
  --grey: #8A849A; --on-green: #04140A;
  --overlay: var(--c-overlay); --scrim: rgba(24, 18, 40, 0.35);
  --shadow-card: var(--c-shadow-1); --shadow-pop: var(--c-shadow-2);
  --glow-primary: 0 6px 16px -8px rgba(82, 64, 204, 0.45); --glow-fab: var(--c-shadow-2);
  --topbar-bg: rgba(246, 245, 249, 0.88); --bar-bg: rgba(251, 250, 253, 0.97);
  --page-wash: radial-gradient(1200px 600px at 85% -10%, rgba(124, 108, 240, 0.06), transparent 60%), radial-gradient(900px 500px at -10% 20%, rgba(42, 201, 184, 0.05), transparent 55%);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: var(--c-bg); --side: var(--c-side); --surface: var(--c-surface); --surface-2: var(--c-surface2); --surface-3: var(--c-surface3); --hover: var(--c-hover);
  --border: var(--c-border2); --border-soft: var(--c-border); --field: var(--c-field);
  --text: var(--c-t1); --text-dim: var(--c-t2); --text-faint: var(--c-t3);
  --accent-t: #B9A8FF;
  --accent-2: #2AC9B8; --accent-2-soft: rgba(42, 201, 184, 0.14); --accent-2-t: #2AC9B8;
  --green: #2ECC71; --green-soft: rgba(46, 204, 113, 0.12); --green-t: #2ECC71;
  --red: #F0495A; --red-soft: rgba(240, 73, 90, 0.12); --red-t: #FF8A9C;
  --amber: #E6A23C; --amber-soft: rgba(230, 162, 60, 0.12); --amber-t: #E6A23C;
  --grey: #6F6A82; --on-green: #04140A;
  --overlay: var(--c-overlay); --scrim: rgba(6, 4, 12, 0.6);
  --shadow-card: var(--c-shadow-1); --shadow-pop: var(--c-shadow-2);
  --glow-primary: 0 8px 20px -8px rgba(124, 108, 240, 0.55); --glow-fab: 0 10px 30px -8px rgba(124, 108, 240, 0.6);
  --topbar-bg: rgba(21, 19, 28, 0.88); --bar-bg: rgba(24, 22, 31, 0.97);
  --page-wash: radial-gradient(1200px 600px at 85% -10%, rgba(124, 108, 240, 0.08), transparent 60%), radial-gradient(900px 500px at -10% 20%, rgba(42, 201, 184, 0.05), transparent 55%);
  color-scheme: dark;
}
/* the shared frame (zy-panel, zy-ask, the Dark mode switch) in Edgemark's colours, following the theme */
html {
  --zy-bg: var(--surface); --zy-surface: var(--surface-2); --zy-border: var(--border);
  --zy-text: var(--text); --zy-muted: var(--text-dim); --zy-accent: var(--accent-2); --zy-accent-ink: var(--accent-2-t); --zy-accent-text: #04140F;
  --zy-ok: var(--green); --zy-warn: var(--amber); --zy-danger: var(--red); --zy-font: var(--font-body);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); font-family: var(--font-body); min-height: 100vh; overflow-x: hidden;
  background: var(--page-wash), var(--bg);
}
body.modal-open { overflow: hidden; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-fill); color: var(--accent-on); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--text-faint); font-size: 12.8px; }
.pos { color: var(--green-t) !important; }
.neg { color: var(--red-t) !important; }
.mono { font-family: var(--font-mono); }
.link { background: none; border: 0; padding: 0; color: var(--accent-2-t); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: inherit; }
.hint { font-size: 12px; color: var(--text-faint); margin: -4px 0 12px; line-height: 1.5; }
.spacer { flex: 1; }
body.no-anim *, body.no-anim *::before, body.no-anim *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; } }

/* ---------- candle glyph ---------- */
.candle { display: inline-block; width: 10px; height: 22px; position: relative; flex: none; }
.candle::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: currentColor; opacity: 0.55; transform: translateX(-50%); }
.candle::after { content: ''; position: absolute; left: 1px; right: 1px; top: 6px; bottom: 6px; background: currentColor; border-radius: 1px; }
.candle.up { color: var(--green); } .candle.down { color: var(--red); } .candle.flat { color: var(--grey); }
.section-mark { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; min-width: 0; }
.section-mark .candle { width: 8px; height: 18px; }
.section-mark h2 { font-size: 20px; font-weight: 600; }
.section-mark .sub { color: var(--text-faint); font-size: 12.5px; font-family: var(--font-mono); margin-left: auto; text-align: right; }
.page-lede { color: var(--text-dim); font-size: 13px; line-height: 1.6; margin: -6px 0 16px; max-width: 70ch; }

/* ---------- loader ---------- */
.loader { position: fixed; inset: 0; background: var(--bg); z-index: 500; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; transition: opacity 0.4s, visibility 0.4s; }
.loader.hide { opacity: 0; visibility: hidden; }
.loader-marks { display: flex; gap: 5px; align-items: flex-end; height: 44px; }
.loader-marks .candle { animation: loaderbar 1s ease-in-out infinite; }
.loader-marks .candle:nth-child(2) { animation-delay: 0.1s; } .loader-marks .candle:nth-child(3) { animation-delay: 0.2s; }
.loader-marks .candle:nth-child(4) { animation-delay: 0.3s; } .loader-marks .candle:nth-child(5) { animation-delay: 0.4s; }
@keyframes loaderbar { 0%, 100% { transform: scaleY(0.6); } 50% { transform: scaleY(1.3); } }
.loader .brand { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.02em; font-size: 15px; color: var(--text-dim); }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: none; background: var(--side); border-right: 1px solid var(--border-soft); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; transition: transform 0.25s ease; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 16px; border-bottom: 1px solid var(--border-soft); }
.brand-mark { width: 32px; height: 32px; flex: none; border-radius: 9px; background: linear-gradient(135deg, #7C6CF0, #2AC9B8); color: #0A0D12; display: flex; align-items: center; justify-content: center; } /* the logo: the same in both themes */
.brand-mark.big { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16.5px; }
.brand-sub { font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.sidebar-close { display: none; margin-left: auto; background: none; border: 0; color: var(--text-dim); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; align-items: center; justify-content: center; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-item { display: flex; width: 100%; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-s); color: var(--text-dim); font-size: 13.5px; font-weight: 500; cursor: pointer; margin-bottom: 2px; transition: background 0.15s, color 0.15s; border: 1px solid transparent; background: none; text-align: left; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.nav-item.active svg { color: var(--accent-t); }
.nav-item svg { flex: none; opacity: 0.9; }
.nav-item .badge { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); }
.nav-spark svg, .bn-spark svg { color: var(--accent-2-t); opacity: 1; }
.nav-pro, .pro-badge { margin-left: auto; padding: 2px 6px; border-radius: 100px; background: var(--amber-soft); color: var(--amber-t); font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; font-family: var(--font-body); white-space: nowrap; }
.pro-badge { margin-left: 6px; display: inline-block; vertical-align: middle; }
.nav-divider { height: 1px; background: var(--border-soft); margin: 10px 8px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); padding: 8px 12px 6px; }
.sidebar-footer { padding: 14px 18px 18px; border-top: 1px solid var(--border-soft); font-size: 11.5px; color: var(--text-faint); display: grid; gap: 6px; }
.sidebar-footer a { text-decoration: underline; text-underline-offset: 2px; }
.scrim { display: none; }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; background: var(--topbar-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 30; }
.topbar h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; flex: none; border-radius: 9px; align-items: center; justify-content: center; cursor: pointer; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.topbar-actions .zy-chip { min-height: 36px; }

.page { padding: 26px 28px 80px; max-width: 1360px; width: 100%; margin: 0 auto; display: none; }
.page.active { display: block; animation: pagein 0.3s ease; }
@keyframes pagein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bottom-nav { display: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: transform 0.12s, background 0.15s, border-color 0.15s; min-height: 40px; text-decoration: none; }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent-fill), var(--accent-deep)); border-color: transparent; color: var(--accent-on); box-shadow: var(--glow-primary); }
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent-fill), var(--accent-deep)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-danger { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 35%, transparent); color: var(--red-t); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; min-height: 36px; }
.btn-icon { width: 38px; height: 38px; padding: 0; min-height: 0; }
.btn-group { display: flex; gap: 8px; }
.fab { position: fixed; right: 26px; bottom: 26px; z-index: 50; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #0A0D12; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--glow-fab); transition: transform 0.18s; }
.fab:hover { transform: scale(1.06); }
.fab svg { width: 24px; height: 24px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 14px; }
.grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-l); padding: 16px 18px; box-shadow: var(--shadow-card); min-width: 0; }
.stat-card { position: relative; overflow: hidden; }
.stat-card .label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 8px; }
.stat-card .value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stat-card .value.small { font-family: var(--font-body); font-size: 14px; line-height: 1.35; }
.stat-card .value.pos { color: var(--green-t); } .stat-card .value.neg { color: var(--red-t); }
.stat-card .sub { font-size: 11px; color: var(--text-faint); margin-top: 6px; font-family: var(--font-mono); }
.card-title { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.card-title.spaced { margin-top: 18px; margin-bottom: 8px; }
.card-title svg { color: var(--accent-2-t); }
.card-title .tag { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); font-weight: 400; }
.card-title .tag-link { font-size: 12px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1080px) { .two-col { grid-template-columns: minmax(0, 1fr); } .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
canvas { display: block; max-width: 100%; }

table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border-soft); color: var(--text-dim); white-space: nowrap; }
tr[data-em] { cursor: pointer; }
tr[data-em]:hover td, tr[data-em]:focus td { background: var(--hover); }
.row-actions { text-align: right; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tag-chip { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 100px; font-size: 11px; font-weight: 600; font-family: var(--font-mono); }
.tag-win { background: var(--green-soft); color: var(--green-t); } .tag-loss { background: var(--red-soft); color: var(--red-t); }
.tag-be { background: var(--hover); color: var(--text-dim); }
.tag-long { background: var(--accent-2-soft); color: var(--accent-2-t); } .tag-short { background: var(--red-soft); color: var(--red-t); }

.empty-state { text-align: center; padding: 40px 16px; color: var(--text-faint); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state .candle { width: 14px; height: 34px; margin-bottom: 6px; }
.empty-state h3 { color: var(--text-dim); font-size: 15px; }
.empty-state p { font-size: 12.8px; max-width: 340px; line-height: 1.5; }
.empty-state .btn { margin-top: 8px; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select, .field textarea, .list-bar select, .list-bar input, .setting-row select, .setting-row input[type="number"], .inline-add input {
  width: 100%; background: var(--surface); border: 1px solid var(--field); border-radius: 9px; padding: 10px 12px; color: var(--text); font-size: 14px; min-height: 42px; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .list-bar input:focus, .list-bar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-faint); opacity: 1; }
.field input[type="file"] { padding: 8px; font-size: 13px; }
.field-row { display: grid; gap: 12px; }
.field-row.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-row.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .field-row.c2, .field-row.c3 { grid-template-columns: minmax(0, 1fr); } }
.net-preview { display: flex; align-items: center; min-height: 42px; padding: 0 12px; border-radius: 9px; background: var(--surface-3); color: var(--text-dim); font-family: var(--font-mono); }
.more-details { margin-top: 4px; }
.more-details summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent-2-t); padding: 10px 0; list-style-position: inside; }
.more-body { padding-top: 10px; }
.shot-preview { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 8px; }
.shot-preview:empty { display: none; }
.shot-item { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; width: min(180px, calc(50% - 5px)); }
.shot-preview img { width: 100%; height: auto; max-height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.shot-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.field label.shot-add, .shot-add { display: inline-flex; align-items: center; position: relative; overflow: hidden; cursor: pointer; margin: 0; text-transform: none; letter-spacing: normal; font-size: 12.5px; color: var(--text); }
.shot-add input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.shot-count { font-size: 12px; color: var(--text-faint); }
/* 10 buttons that always fit the width they're given */
.rating-input { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; max-width: 380px; }
.rating-input button { height: 34px; min-width: 0; padding: 0; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text-faint); cursor: pointer; font-family: var(--font-mono); font-size: 12px; }
.rating-input button.active { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-on); }
.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { padding: 7px 13px; border-radius: 100px; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); font-size: 12.5px; cursor: pointer; transition: 0.15s; min-height: 34px; }
.chip-opt.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip-opt.swatch span { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--sw); margin-right: 6px; }
.chip-opt.swatch.active { border-color: var(--sw); }
.toggle { position: relative; width: 44px; height: 26px; flex: none; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .track { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--field); border-radius: 100px; transition: 0.2s; cursor: pointer; }
.toggle .track::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--text-faint); border-radius: 50%; transition: 0.2s; }
.toggle input:checked + .track { background: var(--accent-fill); border-color: var(--accent-fill); }
.toggle input:checked + .track::before { transform: translateX(18px); background: var(--accent-on); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border-soft); }
.setting-row:last-child { border-bottom: none; }
.setting-row .meta { min-width: 0; }
.setting-row .meta .t { font-size: 13.5px; font-weight: 600; }
.setting-row .meta .d { font-size: 12px; color: var(--text-faint); margin-top: 3px; max-width: 440px; line-height: 1.45; }
.setting-row select, .setting-row input[type="number"] { width: auto; min-width: 96px; }
.setting-row > .btn, .setting-row > .mono { flex: none; }
.setting-row > .chip-select { flex: 0 1 auto; min-width: 0; justify-content: flex-end; }
.setting-row input[type="number"] { max-width: 140px; }
.inline-add { display: flex; gap: 8px; margin-top: 14px; }
.inline-add input { flex: 1; min-width: 0; }

/* ---------- modal / confirm / toast ---------- */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); width: 100%; max-width: 640px; box-shadow: var(--shadow-pop); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { font-size: 16.5px; min-width: 0; }
.modal-head .close { margin-left: auto; background: none; border: none; color: var(--text-faint); cursor: pointer; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.modal-head .close:hover { background: var(--hover); color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.confirm-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 150; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; pointer-events: none; transition: 0.2s; }
.confirm-overlay.open { opacity: 1; pointer-events: auto; }
.confirm-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-pop); padding: 22px; max-width: 380px; width: 100%; text-align: center; }
.confirm-box h4 { margin-bottom: 8px; font-size: 15px; }
.confirm-box p { font-size: 13px; color: var(--text-dim); margin-bottom: 18px; line-height: 1.5; }
.confirm-box .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.toast-stack { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 11px 16px; border-radius: 10px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 9px; box-shadow: var(--shadow-pop); animation: toastin 0.25s ease; transition: opacity 0.25s, transform 0.25s; }
.toast.leaving { opacity: 0; transform: translateY(8px); }
.toast .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); flex: none; }
.toast.err .dot { background: var(--red); }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- pages ---------- */
.kpi-strip { display: flex; gap: 22px; flex-wrap: wrap; }
.kpi-spread { justify-content: space-between; margin-top: 12px; }
.kpi .n { font-family: var(--font-mono); font-size: 19px; font-weight: 600; }
.kpi .l { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.progress { display: block; height: 8px; background: var(--surface-3); border-radius: 100px; overflow: hidden; }
.progress > span, .progress > div { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 100px; }
.list-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.list-bar > select, .list-bar > input[type="date"] { width: auto; }
.search-box { position: relative; flex: 1 1 220px; min-width: 0; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-faint); pointer-events: none; }
.search-box input { padding-left: 34px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-bar select { width: auto; min-height: 40px; padding: 8px 10px; font-size: 13px; }
.quota-note { margin-bottom: 14px; padding: 9px 12px; border-radius: 9px; background: var(--amber-soft); color: var(--text-dim); font-size: 12.8px; line-height: 1.5; }
.quota-note b { color: var(--text); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-grid.weekdays { margin-bottom: 6px; }
.calendar-day { aspect-ratio: 1.05; border-radius: 9px; border: 1px solid var(--border-soft); padding: 6px; cursor: pointer; position: relative; background: var(--surface); color: var(--text); text-align: left; min-width: 0; overflow: hidden; }
.calendar-day:hover { border-color: var(--accent); }
.calendar-day .dnum { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); position: absolute; top: 6px; left: 7px; }
.calendar-day.profit { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.calendar-day.loss { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.calendar-day.flat { background: var(--surface-2); }
.calendar-day.empty { background: transparent; border-color: transparent; cursor: default; }
.calendar-day .r { position: absolute; bottom: 6px; right: 6px; font-family: var(--font-mono); font-size: 10px; font-weight: 600; }
.calendar-day.today { outline: 2px solid var(--accent-2); outline-offset: -1px; }
.weekday-lbl { font-size: 10px; text-align: center; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.day-summary { font-size: 14px; margin-bottom: 14px; color: var(--text-dim); }
.day-text { font-size: 13px; color: var(--text-dim); line-height: 1.55; margin-bottom: 6px; }
.entry-card { border: 1px solid var(--border-soft); border-radius: var(--radius-m); padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2); }
.entry-card .eh { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.entry-card .eh .d { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }
.entry-card .eh .actions { margin-left: auto; display: flex; gap: 6px; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 10px; }
.entry-grid .ef { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.entry-grid .ef .l { font-size: 10px; text-transform: uppercase; color: var(--text-faint); letter-spacing: 0.04em; }
.entry-grid .ef .v { font-size: 12.8px; margin-top: 2px; overflow-wrap: anywhere; line-height: 1.45; }
.rule-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.rule-row:last-of-type { border-bottom: none; }
.checkbox { width: 26px; height: 26px; border-radius: 7px; border: 1.5px solid var(--field); cursor: pointer; flex: none; display: flex; align-items: center; justify-content: center; background: none; padding: 0; }
.checkbox.checked { background: var(--accent-fill); border-color: var(--accent-fill); }
.checkbox svg { width: 13px; height: 13px; color: var(--accent-on); opacity: 0; }
.checkbox.checked svg { opacity: 1; }
.rule-row .rn { font-size: 13.5px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.mistake-tag { display: inline-flex; align-items: center; padding: 7px 13px; border-radius: 100px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; cursor: pointer; min-height: 34px; color: var(--text-dim); }
.mistake-tag.active { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 40%, transparent); color: var(--red-t); }
.heatmap { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 3px; }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: color-mix(in srgb, var(--red) calc(var(--a) * 100%), transparent); }
.goals-grid { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.goal-card { display: grid; gap: 8px; text-align: left; border: 1px solid var(--border-soft); border-radius: var(--radius-m); padding: 16px; background: var(--surface-2); color: var(--text); cursor: pointer; position: relative; overflow: hidden; }
.goal-card.done::before { content: '✓ DONE'; position: absolute; top: 12px; right: -28px; background: var(--green); color: var(--on-green); font-size: 9px; font-weight: 700; padding: 3px 32px; transform: rotate(35deg); letter-spacing: 0.05em; }
.goal-name { font-weight: 600; font-size: 14.5px; padding-right: 40px; }
.goal-meta { font-size: 11.5px; color: var(--text-faint); }
.goal-foot { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); }
.about-block { margin-bottom: 22px; }
.card.about-block { margin-bottom: 16px; }
.about-block h3 { font-size: 15px; margin-bottom: 8px; color: var(--accent-2-t); }
.about-block p, .about-block li { font-size: 13px; color: var(--text-dim); line-height: 1.7; }
.about-block ul { margin: 0; padding-left: 18px; }
.about-links { margin-top: 6px; }
.about-links a { color: var(--accent-2-t); }
.disclaimer-box { margin-top: 16px; background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); border-radius: var(--radius-m); padding: 16px 18px; font-size: 12.8px; color: var(--amber-t); line-height: 1.7; }
.danger-card .card-title { color: var(--red-t); }
.kbd { font-family: var(--font-mono); background: var(--surface-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 7px; font-size: 11px; }

/* ---------- Ai Smart Insights ---------- */
.insight-item { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border-soft); }
.insight-item:last-child { border-bottom: none; }
.insight-item .ic { width: 32px; height: 32px; border-radius: 9px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent-2-soft); color: var(--accent-2-t); }
.insight-good .ic { background: var(--green-soft); color: var(--green-t); }
.insight-warn .ic { background: var(--amber-soft); color: var(--amber-t); }
.insight-item .tx { min-width: 0; }
.insight-item .h { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; line-height: 1.4; }
.insight-item .d { font-size: 12.8px; color: var(--text-dim); line-height: 1.55; }
.insight-item .tip { font-size: 12.5px; color: var(--accent-2-t); line-height: 1.5; margin-top: 5px; }
.spotlight-card { border-color: color-mix(in srgb, var(--accent-2) 40%, transparent); background: radial-gradient(120% 140% at 100% 0%, var(--accent-2-soft), transparent 55%), var(--surface); display: grid; gap: 6px; }
.spot-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.spot-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.spot-title svg { color: var(--accent-2-t); }
.spot-note { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }
.spotlight-card .insight-item { border-bottom: 0; padding: 8px 0 4px; }
.spot-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spot-pro { font-size: 12px; color: var(--text-faint); }

/* ---------- Ask Edgemark (the shared Ask screen, zy-ask.js) ---------- */
/* A fixed-height card the conversation fills, so the question box is always
   on screen (no scrolling down to reach it), and no floating + over Send. */
.ask-card { padding: 14px; display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 150px); height: calc(100dvh - var(--topbar-h) - 150px); min-height: 440px; }
body[data-page="ask"] .fab { display: none; }
@media (max-width: 900px) {
  .ask-card { height: calc(100dvh - var(--topbar-h) - var(--bottom-h) - 128px - env(safe-area-inset-bottom)); min-height: 380px; }
}
.ask-note { margin-top: 10px; font-size: 12px; color: var(--text-faint); }
.ask-teaser { display: grid; gap: 10px; }
.ask-samples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ask-samples .zy-ask-q { background: var(--surface-2); }
.more-locked { margin-top: 10px; }

/* ---------- Pro: locked page / teaser ---------- */
.lock-card { max-width: 560px; margin: 8px auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 20px; }
.lock-icon { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--amber-soft); color: var(--amber-t); }
.lock-card .pro-badge { margin: 0; }
.lock-title { font-size: 20px; }
.lock-text { font-size: 13.5px; color: var(--text-dim); line-height: 1.6; max-width: 46ch; }
.lock-list { text-align: left; display: grid; gap: 8px; margin: 4px 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-dim); }
.lock-list li { position: relative; padding-left: 22px; line-height: 1.45; }
.lock-list li::before { content: '✓'; position: absolute; left: 0; color: var(--green-t); font-weight: 700; }
.lock-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.lock-kept { font-size: 12px; color: var(--text-faint); }
.lock-teaser { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer; color: var(--text); }
.lock-teaser:hover { border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.lock-teaser-icon { width: 38px; height: 38px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--amber-soft); color: var(--amber-t); }
.lock-teaser-icon svg { width: 17px; height: 17px; }
.lock-teaser-text { min-width: 0; font-size: 13.5px; line-height: 1.45; }
.lock-teaser-sub { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
/* A Pro number in a row of Free numbers (dashboard, insights). */
.lock-stat { display: block; width: 100%; text-align: left; cursor: pointer; color: var(--text); font: inherit; }
.lock-stat .label, .lock-stat .value, .lock-stat .sub { display: block; }
.lock-stat .value { color: var(--amber-t); line-height: 1; }
.lock-stat .value svg { width: 20px; height: 20px; }
.lock-stat .pro-badge { margin-left: 0; }
.lock-stat:hover { border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
/* "N older trades are kept safe" (Free's 30-day window). */
.history-note { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 10px 12px; border-radius: 9px; border: 1px dashed color-mix(in srgb, var(--amber) 50%, transparent); color: var(--text-dim); font-size: 12.8px; line-height: 1.5; }
.history-note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--amber-t); }
.history-note b { color: var(--text); }
.card .history-note { margin: 12px 0 0; }
.card-title.dash-sub { margin: 20px 0 10px; }

/* ---------- Refer & Earn banner ---------- */
.refer-banner { display: flex; align-items: stretch; margin-top: 14px; border: 1px solid var(--border-soft); border-radius: var(--radius-l); background: var(--surface); overflow: hidden; }
.refer-banner-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: none; color: var(--text); font-size: 13px; text-align: left; cursor: pointer; }
.refer-icon { width: 30px; height: 30px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--green-soft); color: var(--green-t); }
.refer-banner-text { flex: 1; min-width: 0; line-height: 1.4; }
.refer-banner-main > svg { color: var(--text-faint); flex: none; }
.refer-banner-x { width: 46px; flex: none; border: 0; border-left: 1px solid var(--border-soft); background: none; color: var(--text-faint); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.refer-banner-main:hover, .refer-banner-x:hover { background: var(--hover); }

/* ---------- first run ---------- */
.onboarding { position: fixed; inset: 0; z-index: 400; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px 16px; overflow-y: auto; transition: opacity 0.24s; }
.onboarding.leaving { opacity: 0; }
.onboarding-card { width: 100%; max-width: 460px; text-align: center; }
.onboarding-card h1 { font-size: 26px; margin-bottom: 10px; }
.ob-sub { color: var(--text-dim); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.ob-currencies { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ob-currency { display: grid; gap: 2px; padding: 14px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; }
.ob-currency.recommended { border-color: var(--accent-2); grid-column: 1 / -1; background: linear-gradient(135deg, var(--accent-soft), var(--accent-2-soft)); }
.ob-currency:hover { border-color: var(--accent); }
.ob-code { font-family: var(--font-mono); font-weight: 600; font-size: 16px; }
.ob-name { font-size: 12px; color: var(--text-dim); }
.ob-demo { display: flex; gap: 10px; align-items: flex-start; text-align: left; margin-top: 16px; font-size: 13px; color: var(--text-dim); line-height: 1.5; cursor: pointer; }
.ob-demo input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent-fill); flex: none; }
.ob-signin { margin-top: 16px; font-size: 13px; color: var(--text-dim); }
.ob-brand { margin-top: 14px; font-size: 12px; color: var(--text-faint); }
.ob-brand a { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- phones and small tablets ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: min(300px, 86vw); box-shadow: var(--shadow-pop); }
  .sidebar.open { transform: none; }
  .sidebar-close { display: inline-flex; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 10px; padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .topbar h1 { font-size: 16.5px; }
  .page { padding: 18px 14px calc(var(--bottom-h) + 96px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--bar-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border-soft); }
  .bn-item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; color: var(--text-faint); font-size: 10.5px; font-weight: 500; cursor: pointer; padding: 6px 2px; }
  .bn-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .bn-item.active { color: var(--text); }
  .bn-item.active svg { color: var(--accent-t); }
  .bn-item.bn-spark.active svg { color: var(--accent-2-t); }
  .fab { right: 16px; bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom)); width: 52px; height: 52px; }
  .toast-stack { bottom: calc(var(--bottom-h) + 84px + env(safe-area-inset-bottom)); }
  .desktop-only { display: none; }
}
@media (max-width: 560px) {
  .topbar-add span { display: none; }
  .topbar-add { width: 38px; padding: 0; }
  .topbar-actions .zy-chip { padding: 0 10px; }
  .grid-stats { gap: 10px; }
  .card { padding: 14px; }
  .stat-card .value { font-size: 18px; }
  .section-mark h2 { font-size: 18px; }
  .lock-actions .btn { width: 100%; }
  .list-bar > .btn-primary { width: 100%; }
  /* full-screen sheet; block layout so a long form grows the sheet instead of spilling out of it */
  .modal-overlay { padding: 0; display: block; }
  .modal { border-radius: 0; min-height: 100%; border: 0; }
  .modal-body { padding: 16px; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .setting-row { flex-wrap: wrap; }
  .calendar-day { aspect-ratio: auto; height: 54px; padding: 4px; }
  .calendar-day .dnum { top: 4px; left: 5px; }
  .calendar-day .r { font-size: 9px; right: 3px; bottom: 4px; letter-spacing: -0.03em; }
  .heatmap { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .setting-row > .chip-select { justify-content: flex-start; }
  table.compact .col-dir { display: none; }
  /* phones: R and the result stay in view; setup and net P/L are in the trade itself */
  .col-setup, .col-net, .row-actions { display: none; } /* delete is inside the trade too */
  td, th { padding-left: 8px; padding-right: 8px; }
}
@media (max-width: 400px) { .col-dir { display: none; } td, th { padding-left: 6px; padding-right: 6px; } .tag-chip { padding: 3px 7px; } }
@media (max-width: 360px) {
  .grid-stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stat-card .value { font-size: 16px; }
  .topbar h1 { font-size: 15px; }
}
.import-facts { margin: 8px 0 14px; padding-left: 18px; font-size: 13.5px; line-height: 1.6; color: var(--text-dim); }
.import-facts b { color: var(--text); }
