/* Journey — styles. Light + dark from the system setting. */
:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #f1f1ed;
  --surface-3: #e7e7e2;
  --border: #e3e3dd;
  --border-strong: #d0d0c9;
  --text: #17181a;
  --text-2: #4c5057;
  --muted: #84888f;
  --accent: #3a68ea;
  --accent-ink: #ffffff;
  --accent-soft: rgba(58, 104, 234, 0.14);
  --gain: #0d8650;
  --loss: #cf3443;
  --gain-bg: #1baf7a;
  --loss-bg: #e34948;
  --warm: #e09a00;
  --shadow: 0 1px 2px rgba(16, 18, 20, 0.04), 0 4px 14px rgba(16, 18, 20, 0.05);
  --shadow-lg: 0 24px 64px rgba(16, 18, 20, 0.2);
  --t-trade: #2a78d6;
  --t-idea: #e09a00;
  --t-diary: #8a63e6;
  --t-strategy: #13a27e;
  --t-system: #e8662f;
  --t-tool: #6c7f96;
  --t-trick: #dd5a95;
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c0d10;
    --surface: #141619;
    --surface-2: #1b1d22;
    --surface-3: #24272d;
    --border: #23262c;
    --border-strong: #353940;
    --text: #eceef1;
    --text-2: #a8adb5;
    --muted: #737983;
    --accent: #7096ff;
    --accent-ink: #0a0c12;
    --accent-soft: rgba(112, 150, 255, 0.16);
    --gain: #35c88b;
    --loss: #f2636f;
    --gain-bg: #199e70;
    --loss-bg: #e66767;
    --warm: #f0b429;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 80px rgba(0, 0, 0, 0.6);
    --t-trade: #4d94ec;
    --t-idea: #f0b429;
    --t-diary: #a58bf5;
    --t-strategy: #2cc29a;
    --t-system: #f07a45;
    --t-tool: #8d9db0;
    --t-trick: #ec7cad;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.spacer { flex: 1; }
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  color: var(--muted);
  background: var(--surface);
}
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ---------------------------------------------------------------- buttons & fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--loss); border-color: var(--loss); color: #fff; }
.btn.ghost.danger { background: transparent; border-color: transparent; color: var(--loss); }
.btn.ghost.danger:hover { background: color-mix(in srgb, var(--loss) 10%, transparent); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0;
  border-radius: 9px; border: 0; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn:disabled { opacity: 0.3; cursor: default; background: transparent; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 500; }
.link:hover { text-decoration: underline; }
.field {
  height: 40px; min-width: 0; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus, .field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder, .field input::placeholder, textarea::placeholder { color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 30px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.on {
  color: var(--text);
  background: color-mix(in srgb, var(--c, var(--text)) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--c, var(--text)) 50%, transparent);
}
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.seg button {
  height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button.on.long { color: var(--gain); }
.seg button.on.short { color: var(--loss); }

/* ---------------------------------------------------------------- layout */
.shell { min-height: 100dvh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand img { border-radius: 8px; }
.view { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(100px + env(safe-area-inset-bottom, 0px)); }
.view[data-view="stats"], .view[data-view="gallery"], .view[data-view="playbook"] { max-width: 1080px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0; font-size: 10.5px; font-weight: 500; color: var(--muted); text-decoration: none; }
.tabbar a.on { color: var(--text); }
.tab-new {
  justify-self: center; display: grid; place-items: center;
  width: 54px; height: 46px; border: 0; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.tab-new:active { transform: scale(0.96); }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 18px;
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: 22px 16px 18px;
    background: var(--surface); border-right: 1px solid var(--border);
  }
  .sidebar .brand { padding: 0 6px; }
  .new-btn kbd { margin-left: auto; background: transparent; border-color: color-mix(in srgb, var(--accent-ink) 40%, transparent); color: color-mix(in srgb, var(--accent-ink) 75%, transparent); }
  .new-btn { justify-content: flex-start; }
  .view { padding: 36px 36px 80px; }
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  height: 38px; padding: 0 10px; border-radius: 9px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav a kbd { margin-left: auto; opacity: 0; transition: opacity 0.15s; }
.nav a:hover kbd { opacity: 1; }
.streak { margin-top: auto; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.streak p { margin: 8px 0 0; }
.streak-top { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.streak-top b { font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
.streak-top.lit .i, .streak-pill.lit .i { color: var(--warm); fill: color-mix(in srgb, var(--warm) 35%, transparent); }
.streak-dots { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; margin-top: 10px; }
.streak-dots span { aspect-ratio: 1; border-radius: 3px; background: var(--surface-3); }
.streak-dots span.on { background: var(--accent); }
.streak-dots span.today { box-shadow: 0 0 0 1.5px var(--text-2); }
.side-foot { display: flex; flex-direction: column; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 13px; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.streak-pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
  font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums;
}

.page-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 26px; font-weight: 700; }

/* ---------------------------------------------------------------- journal */
.quick { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.quick-input {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 48px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--surface-2); color: var(--muted);
  font-size: 15.5px; text-align: left;
  transition: border-color 0.15s, color 0.15s;
}
.quick-input:hover { border-color: var(--border-strong); color: var(--text-2); }
.quick-types { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.quick-types::-webkit-scrollbar, .chips::-webkit-scrollbar, .c-types::-webkit-scrollbar { display: none; }

.filters { margin-top: 18px; }
.search {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.chips { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }

.day { margin-top: 24px; }
.day-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 4px 8px; font-size: 13.5px; font-weight: 650; color: var(--text);
}
.day-head .muted { font-weight: 500; }
.day-sum { font-size: 12.5px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-sum .gain, .day-sum .loss { font-weight: 650; }

.entry {
  position: relative; margin-bottom: 8px; padding: 12px 14px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.entry:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.entry-meta { display: flex; align-items: center; gap: 6px; min-height: 28px; font-size: 12.5px; color: var(--text-2); }
.type-name { font-weight: 650; color: var(--text); }
.mood { font-size: 14px; }
.pinned { display: inline-flex; color: var(--muted); }
.entry-actions { margin-left: auto; display: flex; gap: 2px; transition: opacity 0.15s; }
@media (hover: hover) {
  .entry-actions { opacity: 0; }
  .entry:hover .entry-actions, .entry:focus-within .entry-actions { opacity: 1; }
}
.entry-title { margin: 4px 0 2px; font-size: 16px; font-weight: 650; }
.entry-body { margin-top: 2px; }
.entry > .link { margin-top: 4px; }
.trade-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.trade-line .sym { font-weight: 750; font-size: 15px; letter-spacing: 0.01em; }
.trade-line .pnl { font-weight: 700; font-size: 15px; }
.side, .badge {
  font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 7px; border-radius: 6px;
}
.side.long { color: var(--gain); background: color-mix(in srgb, var(--gain) 13%, transparent); }
.side.short { color: var(--loss); background: color-mix(in srgb, var(--loss) 13%, transparent); }
.badge.open { color: var(--warm); background: color-mix(in srgb, var(--warm) 15%, transparent); }
.trade-line .r { font-size: 13px; font-weight: 650; color: var(--text-2); }
.trade-line .setup { font-size: 12.5px; color: var(--text-2); border: 1px solid var(--border); padding: 1px 9px; border-radius: 999px; }

.md { font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.md p { margin: 0; }
.md p.gap { height: 0.55em; }
.md p.h { font-weight: 650; margin-top: 0.3em; }
.md ul, .md ol { margin: 0.15em 0; padding-left: 1.3em; }
.md li { margin: 0.1em 0; }
.md li.check { list-style: none; position: relative; }
.md li.check::before {
  content: ''; position: absolute; left: -1.25em; top: 0.3em;
  width: 0.85em; height: 0.85em; border: 1.5px solid var(--border-strong); border-radius: 4px;
}
.md li.check.done::before {
  content: '✓'; background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-size: 0.7em; font-weight: 800; line-height: 1.05; text-align: center;
  width: 1.2em; height: 1.2em; top: 0.42em;
}
.md a { word-break: break-all; }
.md .tag { border: 0; background: none; padding: 0; font-size: inherit; color: var(--accent); font-weight: 500; }
.md .tag:hover { text-decoration: underline; }
.md .ticker { font-weight: 650; }
.clamp { max-height: 19em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }

.thumbs { display: grid; gap: 6px; margin-top: 10px; }
.thumbs.n1 { grid-template-columns: minmax(0, 440px); }
.thumbs.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.thumbs.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.thumbs.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.thumb {
  position: relative; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  aspect-ratio: 16 / 10; background: var(--surface-2); cursor: zoom-in;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.more-n { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.5); color: #fff; font-weight: 700; font-size: 18px; }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 30% { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); } }

.empty { text-align: center; padding: 36px 22px; }
.empty.slim { padding: 32px 0; color: var(--muted); }
.empty h2 { font-size: 18px; margin-bottom: 6px; }
.empty p { margin: 0 auto 16px; max-width: 460px; color: var(--text-2); }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--surface-2); color: var(--text-2); }
.tips { display: inline-flex; flex-direction: column; gap: 6px; margin: 2px auto 20px; padding: 0; list-style: none; text-align: left; font-size: 14px; color: var(--text-2); }
.tips li::before { content: '→ '; color: var(--muted); }

/* ---------------------------------------------------------------- cards (shared) */
.card { margin-top: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card.pad { padding: 22px; text-align: center; }
.card-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; font-weight: 650; }
.card-head .muted { font-size: 12.5px; }

/* ---------------------------------------------------------------- playbook */
.pb-sec { margin-top: 28px; }
.pb-sec:first-of-type { margin-top: 8px; }
.pb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pb-head h2 { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 700; }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.pb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.pb-card {
  display: flex; flex-direction: column; gap: 8px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.pb-card:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--border)); box-shadow: var(--shadow); }
.pb-card h3 { font-size: 15.5px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.pb-img { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.pb-excerpt { font-size: 13.5px; color: var(--text-2); max-height: 8.2em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 65%, transparent); mask-image: linear-gradient(#000 65%, transparent); }
.pb-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; padding-top: 8px; border-top: 1px solid var(--border); }
.pb-stats.muted { font-weight: 500; }
.pb-foot { margin-top: auto; }
.pb-empty {
  padding: 18px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: transparent; color: var(--muted); text-align: left; font-size: 13.5px; line-height: 1.5;
}
.pb-empty:hover { border-color: var(--c); color: var(--text-2); }
.unwritten { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }

/* ---------------------------------------------------------------- gallery & lightbox */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.g-item { position: relative; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--surface-2); cursor: zoom-in; }
.g-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.g-item:hover img { transform: scale(1.03); }
.g-cap {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 6px;
  padding: 18px 9px 7px; font-size: 11.5px; font-weight: 600; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}
#lightbox { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; padding: 0; border: 0; background: rgba(6, 7, 9, 0.94); color: #e9ebee; }
#lightbox::backdrop { background: transparent; }
.lb { display: flex; flex-direction: column; height: 100%; }
.lb img { flex: 1; min-height: 0; width: 100%; object-fit: contain; padding: max(16px, env(safe-area-inset-top, 0px)) 16px 8px; }
.lb-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)); font-size: 13.5px; }
.lb-cap { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .icon-btn, .lb .btn.ghost { color: #d6d9de; }
.lb .icon-btn:hover, .lb .btn.ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.lb .muted { color: #9aa0a8; }

/* ---------------------------------------------------------------- composer */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(8, 10, 14, 0.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#composer {
  width: min(680px, calc(100vw - 32px)); max-width: none; max-height: none;
  margin: 8vh auto auto; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
#composer[open] { animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.99); } }
.composer { display: flex; flex-direction: column; max-height: 84vh; }
.c-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 12px 14px; border-bottom: 1px solid var(--border); }
.c-types { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.save-top { display: none; }
.c-note { padding: 10px 16px 0; font-size: 13px; color: var(--text-2); }
.c-body { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px 10px; overflow-y: auto; }
.c-body textarea {
  width: 100%; min-height: 120px; padding: 0;
  border: 0; outline: 0; resize: none; background: transparent;
  font-size: 16px; line-height: 1.55; color: var(--text);
}
.c-trade {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.25fr) 84px;
  grid-template-areas: "sym side pnl r" "setup setup more more" "extra extra extra extra";
}
.c-trade .sym { grid-area: sym; font-weight: 700; text-transform: uppercase; }
.c-trade .sym::placeholder { text-transform: none; font-weight: 400; }
.c-trade .seg { grid-area: side; }
.c-trade .pnl { grid-area: pnl; }
.c-trade .r { grid-area: r; padding: 0; }
.c-trade .r input { width: 100%; height: 100%; padding: 0 12px; border: 0; outline: 0; background: transparent; }
.c-trade .setup { grid-area: setup; }
.c-trade .more-toggle { grid-area: more; justify-self: start; white-space: nowrap; }
.c-more { grid-area: extra; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.c-more .hint { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.field.pnl { display: flex; align-items: center; gap: 2px; padding: 0 8px 0 4px; }
.field.pnl input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-weight: 650; font-variant-numeric: tabular-nums; }
.field.pnl .cur { color: var(--muted); font-weight: 600; }
.field.pnl.neg input, .field.pnl.neg .cur { color: var(--loss); }
.field.pnl .sign {
  width: 30px; height: 30px; margin-right: 2px; border: 0; border-radius: 7px;
  background: var(--surface-3); color: var(--text-2); font-weight: 700; font-size: 15px;
}
.field.pnl .sign:hover { color: var(--text); }
.c-images { display: flex; flex-wrap: wrap; gap: 8px; }
.c-images:empty { display: none; }
.c-img { position: relative; width: 104px; height: 72px; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.c-img img { width: 100%; height: 100%; object-fit: cover; }
.c-img.busy img { opacity: 0.45; }
.c-img.busy::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.c-img .rm { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; }
.c-mood { display: flex; align-items: center; gap: 2px; }
.c-mood .label { margin-right: 8px; font-size: 13px; color: var(--muted); }
.mood-btn {
  width: 40px; height: 40px; padding: 0; border: 1px solid transparent; border-radius: 10px; background: transparent;
  font-size: 21px; line-height: 1; filter: grayscale(1); opacity: 0.5; transition: opacity 0.15s, filter 0.15s, transform 0.15s;
}
.mood-btn:hover { opacity: 1; filter: none; }
.mood-btn.on { opacity: 1; filter: none; background: var(--surface-2); border-color: var(--border-strong); transform: scale(1.06); }
.c-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.c-foot label.icon-btn { cursor: pointer; }
.c-when { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; border-radius: 9px; color: var(--text-2); }
.c-when:hover { background: var(--surface-2); }
.c-when input { border: 0; outline: 0; background: transparent; color: inherit; font-size: 13px; font-variant-numeric: tabular-nums; }
.c-foot .hint { display: flex; align-items: center; gap: 3px; margin-left: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.c-confirm { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 18px 18px; font-size: 14px; font-weight: 500; }
.c-confirm span { flex: 1; }
#composer.drag .composer { outline: 2px dashed var(--accent); outline-offset: -8px; border-radius: 18px; }
@media (max-width: 760px) { .c-foot .hint.keys { display: none; } }
@media (max-width: 640px) {
  #composer { width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  #composer[open] { animation: slide 0.2s ease-out; }
  @keyframes slide { from { transform: translateY(24px); opacity: 0; } }
  .composer { height: 100%; max-height: none; }
  .c-head { padding-top: calc(env(safe-area-inset-top, 0px) + 10px); }
  .c-body { flex: 1; }
  .save-top { display: inline-flex; }
  .save-bottom { display: none; }
  .c-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .c-trade {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "sym side" "pnl r" "setup setup" "more more" "extra extra";
  }
  .c-trade .r { width: auto; }
  .c-more { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .c-confirm { border-radius: 0; flex-wrap: wrap; }
}

/* ---------------------------------------------------------------- performance */
.stats-head { justify-content: space-between; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 1380px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpi { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.kpi-label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.kpi-value { margin-top: 4px; font-size: 23px; font-weight: 700; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-value .slash { color: var(--muted); font-weight: 400; }
.kpi-sub { margin-top: 2px; font-size: 12px; color: var(--muted); }
.equity { width: 100%; min-height: 200px; }
.eq-svg { display: block; overflow: visible; }
.eq-svg .grid { stroke: var(--border); stroke-width: 1; }
.eq-svg .grid.zero { stroke: var(--border-strong); stroke-dasharray: 3 3; }
.eq-svg .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.eq-svg .eq-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.eq-svg .eq-stop-a { stop-color: var(--accent); stop-opacity: 0.22; }
.eq-svg .eq-stop-b { stop-color: var(--accent); stop-opacity: 0; }
.eq-svg .eq-end { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.eq-svg .xh { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 2 3; }
.eq-svg .xh-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.eq-svg .hit { cursor: crosshair; touch-action: pan-y; }

.cal-head { align-items: center; }
.cal-nav { display: flex; align-items: center; gap: 2px; }
.cal-title { min-width: 120px; text-align: center; font-size: 13.5px; font-weight: 600; }
.cal-sum { margin-left: auto; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-sum .muted { font-weight: 500; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { padding-bottom: 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; }
.cal-cell {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  min-width: 0; height: 64px; padding: 5px 7px;
  border-radius: 8px; background: var(--surface-2); overflow: hidden;
}
.cal-cell::before { content: ''; position: absolute; inset: 0; background: var(--fill, transparent); opacity: var(--a, 0); }
.cal-cell.gain { --fill: var(--gain-bg); }
.cal-cell.loss { --fill: var(--loss-bg); }
.cal-cell > * { position: relative; }
.cal-cell.blank { background: transparent; }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-d { font-size: 11px; font-weight: 600; color: var(--text-2); }
.cal-v { align-self: flex-end; font-size: 12.5px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-jot { align-self: flex-end; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 12px; }
@media (min-width: 780px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bk-row {
  display: grid; grid-template-columns: minmax(0, 1.3fr) 62px minmax(48px, 1.4fr) 68px; align-items: center; gap: 10px;
  padding: 7px 0; border-top: 1px solid var(--border); font-size: 13.5px;
}
.bk-row:first-child { border-top: 0; padding-top: 0; }
.bk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.bk-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bk-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bk-bar span { display: block; height: 100%; border-radius: 4px; background: var(--muted); }
.bk-bar span.gain { background: var(--gain-bg); }
.bk-bar span.loss { background: var(--loss-bg); }
.bk-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.trades-table summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; }
.trades-table summary::-webkit-details-marker { display: none; }
.trades-table summary h2 { font-size: 15px; font-weight: 650; }
.trades-table summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.trades-table[open] summary::after { content: '▴'; }
.table-wrap { margin-top: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th { padding: 6px 10px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; }
td.num.gain, td.num.loss { font-weight: 650; }

@media (max-width: 560px) {
  .page-head h1 { font-size: 23px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px 13px; }
  .kpi-value { font-size: 19px; }
  .card { padding: 14px 12px; }
  .cal { gap: 3px; }
  .cal-cell { padding: 3px 4px; border-radius: 6px; height: 46px; }
  .cal-v { font-size: 10px; }
  .cal-d { font-size: 10px; }
  .cal-sum { margin-left: 0; width: 100%; }
  .bk-row { grid-template-columns: minmax(0, 1fr) 56px minmax(36px, 0.8fr) 62px; gap: 8px; font-size: 13px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .thumbs.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- toasts, tooltip, login */
#toasts {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transform: translateX(-50%); pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
@media (min-width: 960px) { #toasts { bottom: 28px; } }
.toast {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 16px;
  border-radius: 12px; background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: auto;
}
.toast.in { opacity: 1; transform: none; }
.toast.error { background: var(--loss); color: #fff; }
.toast button { border: 0; background: none; padding: 0; color: inherit; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
#tip {
  position: fixed; left: 0; top: 0; z-index: 300; max-width: 260px; padding: 8px 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.45; font-variant-numeric: tabular-nums;
  pointer-events: none; opacity: 0; transition: opacity 0.1s;
}
#tip.on { opacity: 1; }
.login { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px; }
.login-card { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); padding: 32px 26px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); text-align: center; }
.login-logo { margin: 0 auto 4px; border-radius: 14px; }
.login-card h1 { font-size: 24px; }
.login-card p { margin: -6px 0 6px; }
.login-card .field { height: 44px; font-size: 16px; }
.login-err { min-height: 1.2em; margin: 0 !important; color: var(--loss); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
