/* Valmy app: chat-first shell. Every page = nav rail + Valmy chat (primary) + desk (page context). */

body.app { height: 100vh; height: 100dvh; overflow: hidden; }
.app-shell { --deck-w: minmax(380px, 540px); display: grid; grid-template-columns: 76px minmax(0, 1fr) var(--deck-w); height: 100%; }
body.deck-wide .app-shell { --deck-w: minmax(420px, 46%); }
body.deck-hidden .app-shell { grid-template-columns: 76px minmax(0, 1fr) 0; }
body.deck-hidden .deck { display: none; }

/* ---------- Rail ---------- */
.rail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 0 12px; border-right: 1px solid var(--line); background: var(--bg); }
.rail-logo { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-bottom: 14px; }
.rail-logo .logo-caret { width: 9px; height: 17px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 0 8px; }
.rail a.rail-item { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 0 8px; border-radius: 9px; color: var(--muted-2); font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em; position: relative; }
.rail a.rail-item svg { width: 20px; height: 20px; }
.rail a.rail-item:hover { color: var(--text); background: #131519; }
.rail a.rail-item[aria-current="page"] { color: var(--text); background: var(--surface-3); }
.rail a.rail-item[aria-current="page"]::before { content: ""; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; padding: 0 10px; }
.rail-credits { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0; border-radius: 9px; color: var(--muted-2); }
.rail-credits:hover { background: #131519; color: var(--text); }
.rail-credits b { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text-2); }
.rail-credits small { font-size: 10px; }
.meter { width: 100%; height: 4px; border-radius: 2px; background: #22262C; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }

/* ---------- Chat column ---------- */
.chat-col { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-col::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(rgba(237,238,240,0.07) 1px, transparent 1.4px); background-size: 24px 24px; -webkit-mask-image: radial-gradient(ellipse 70% 50% at 50% 0%, #000 10%, transparent 75%); mask-image: radial-gradient(ellipse 70% 50% at 50% 0%, #000 10%, transparent 75%); }
.chat-head { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 20px 0 24px; border-bottom: 1px solid var(--line); flex: none; }
.chat-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-title .px { width: 28px; height: 28px; }
.chat-title-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.chat-title-text b { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.chat-title-text button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title-text button:hover { color: var(--text); }
.chat-title-text button svg { width: 12px; height: 12px; flex: none; }
.chat-head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.view-toggle { display: none; }

.chat-stream { position: relative; z-index: 1; flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; padding: 8px 24px 24px; }
.chat-inner { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-3); }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }

.msg { display: grid; grid-template-columns: 62px minmax(0, 1fr); column-gap: 14px; padding: 12px 0; }
.msg-who { padding-top: 3px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-3); white-space: nowrap; }
.msg-valmy .msg-who { color: var(--accent); }
.msg-body { min-width: 0; font-size: 15px; line-height: 1.62; color: var(--text-3); }
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { color: var(--text); font-weight: 600; }
.msg-body ul, .msg-body ol { margin: 4px 0 10px; padding-left: 20px; }
.msg-body li { margin: 3px 0; }
.msg-body code { font-family: var(--mono); font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); }
.msg-user .msg-body { color: var(--text); }
.msg-user .msg-text { display: inline-block; max-width: 100%; padding: 10px 14px; background: #121418; border: 1px solid #22262C; border-radius: 4px 12px 12px 12px; }
.msg-meta { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-family: var(--mono); font-size: 11px; color: var(--muted-3); }
.msg-meta a { color: var(--muted-2); text-decoration: underline; text-decoration-color: #3A3F48; text-underline-offset: 3px; }
.msg-meta a:hover { color: var(--text); }

/* event tape line inside the stream (fills, agent reports, system) */
.msg-event { padding: 6px 0; }
.msg-event .msg-who { color: var(--muted-3); font-size: 10.5px; padding-top: 6px; }
.event { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 12px; border: 1px dashed #2A2E35; border-radius: 8px; font-family: var(--mono); font-size: 12px; color: var(--text-3); background: rgba(17,19,23,.6); }
.event b { font-weight: 500; color: var(--text); }
.event .ev-kind { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.event a { margin-left: auto; color: var(--muted-2); }
.event a:hover { color: var(--text); }

/* streaming / thinking */
@keyframes px-blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.thinking { display: inline-flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: 14px; }
.px-loader { display: grid; grid-template-columns: repeat(3, 4px); gap: 2px; }
.px-loader i { width: 4px; height: 4px; background: var(--accent); animation: px-blink 1s infinite; }
.px-loader i:nth-child(2), .px-loader i:nth-child(4) { animation-delay: .15s; }
.px-loader i:nth-child(3), .px-loader i:nth-child(5), .px-loader i:nth-child(7) { animation-delay: .3s; }
.px-loader i:nth-child(6), .px-loader i:nth-child(8) { animation-delay: .45s; }
.px-loader i:nth-child(9) { animation-delay: .6s; }
.stream-caret { display: inline-block; width: 8px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--accent); animation: v-caret 1.1s steps(1) infinite; }

/* message cards */
.mcard { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.mcard-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-3); }
.mcard-head .t { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); }
.mcard-body { padding: 14px; }
.mcard-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line-2); background: #101216; }
.mcard-foot .note { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted-3); }
.expiry { height: 2px; background: #22262C; }
.expiry > i { display: block; height: 100%; background: var(--accent); width: 100%; transition: width 1s linear; }
.cites { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.cite { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px 7px; min-height: 26px; padding: 4px 10px; line-height: 1.35; border: 1px solid #2A2E35; border-radius: 6px; background: var(--inset); font-size: 12.5px; color: var(--text-3); }
.cite svg { width: 13px; height: 13px; color: var(--accent); flex: none; }
.cite:hover { border-color: var(--accent-line); color: var(--text); }
.cite .anchor { font-family: var(--mono); font-size: 11px; color: var(--muted-3); }
.opts { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.opt { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 7px 13px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--surface); font-size: 14px; color: var(--text-2); text-align: left; }
.opt:hover { border-color: #4A505A; color: #FFFFFF; background: #15181C; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); color: var(--text); }
.opt[aria-pressed="true"]::before { content: ""; width: 7px; height: 7px; background: var(--accent); border-radius: 1px; }
.opt small { color: var(--muted-3); font-size: 12.5px; }
.opt-quiet { border-style: dashed; color: var(--muted-2); background: transparent; }
.suggest { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--accent-line); border-radius: 10px; background: linear-gradient(0deg, rgba(200,245,96,.04), rgba(200,245,96,.04)), var(--surface); }
.suggest-top { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.suggest p { margin: 8px 0 12px; font-size: 14px; color: var(--text-2); }
.suggest .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Composer ---------- */
.composer-wrap { position: relative; z-index: 2; flex: none; padding: 0 24px 18px; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.chips { max-width: 800px; margin: 0 auto 10px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-top: 6px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; color: var(--text-3); white-space: nowrap; }
.chip::before { content: "›"; color: var(--accent); font-family: var(--mono); font-size: 14px; }
.chip:hover { border-color: #4A505A; color: #FFFFFF; }
.composer { max-width: 800px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 18px 40px -24px rgba(0,0,0,.9); }
.composer:focus-within { border-color: #4A505A; }
.composer-ctx { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px 0; }
.ctx { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 6px 0 8px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--border); font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.ctx svg { width: 12px; height: 12px; color: var(--muted-2); }
.ctx button { all: unset; cursor: pointer; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 3px; color: var(--muted-3); }
.ctx button:hover { color: var(--text); background: #2A2E35; }
.ctx-add svg { width: 12px; height: 12px; }
.ctx-add { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 5px; font-family: var(--mono); font-size: 11px; color: var(--muted-3); border: 1px dashed #2E333B; }
.ctx-add:hover { color: var(--text); border-color: #4A505A; }
.composer-row { display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 14px; }
.composer-row .prompt { font-family: var(--mono); font-size: 18px; line-height: 26px; color: var(--accent); flex: none; }
.composer textarea { flex: 1; min-height: 26px; max-height: 200px; padding: 0; margin: 0; border: 0; outline: none; resize: none; background: transparent; color: var(--text); font-size: 15px; line-height: 26px; }
.composer .send { height: 36px; padding: 0 10px 0 14px; }
.composer-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; max-width: 800px; margin: 8px auto 0; padding: 0 4px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.02em; color: var(--muted-3); }
.composer-foot .sp { margin-left: auto; }

/* ---------- Desk (page context column) ---------- */
.deck { min-width: 0; min-height: 0; overflow-y: auto; border-left: 1px solid var(--line); background: var(--bg-alt); }
.deck-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(14,16,19,.92); backdrop-filter: blur(10px); }
.deck-head h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.deck-head .r { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.deck-sec { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.deck-sec:last-child { border-bottom: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sec-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; color: var(--text); }
.sec-head h2 small { margin-left: 6px; font-weight: 400; color: var(--muted-3); font-size: 12.5px; }
.sec-head a, .sec-head .link { font-size: 12.5px; color: var(--muted-2); }
.sec-head a:hover { color: var(--text); }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.hero-fig { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
.hero-fig .v { font-size: 44px; line-height: 1; font-weight: 600; letter-spacing: -0.035em; color: var(--text); }
.hero-fig .u { font-family: var(--mono); font-size: 13px; color: var(--muted-2); }
.delta { font-family: var(--mono); font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stat { display: flex; flex-direction: column; gap: 5px; padding: 12px 14px; background: var(--bg-alt); min-width: 0; }
.stat .k { font-size: 12px; color: var(--muted-2); }
.stat .v { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); white-space: nowrap; }
.stat .v small { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted-3); margin-left: 4px; letter-spacing: 0; }
.stat .d { font-family: var(--mono); font-size: 11.5px; color: var(--muted-3); }
.chart { position: relative; width: 100%; }

.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-2); min-width: 0; }
.row-item:first-child { border-top: 0; padding-top: 2px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-main b { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main span { font-family: var(--mono); font-size: 11px; color: var(--muted-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.row-side small { font-size: 11px; color: var(--muted-3); }

.next-card { display: flex; gap: 14px; align-items: flex-start; padding: 14px; border: 1px solid var(--accent-line); border-radius: 10px; background: linear-gradient(0deg, rgba(200,245,96,.035), rgba(200,245,96,.035)), var(--surface); }
.next-card p { margin: 4px 0 12px; font-size: 14px; color: var(--text-2); }
.next-card .row { display: flex; gap: 8px; flex-wrap: wrap; }

.seg-bar { display: flex; gap: 2px; width: 100%; }
.seg-bar .seg-part { height: 8px; border-radius: 4px; }
.seg-bar-tall .seg-part { height: 28px; border-radius: 4px; display: flex; align-items: center; padding: 0 8px; font-family: var(--mono); font-size: 11px; font-weight: 600; color: #0C0D0F; min-width: 0; overflow: hidden; }
.seg-bar .seg-part:focus-visible { outline-offset: 2px; }

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px; border: 1px dashed #2A2E35; border-radius: 10px; color: var(--muted); font-size: 14px; }
.empty b { color: var(--text-2); font-weight: 500; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 22px; position: sticky; top: 58px; z-index: 4; background: rgba(14,16,19,.92); backdrop-filter: blur(10px); overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs a { all: unset; cursor: pointer; padding: 12px 10px 11px; font-size: 13.5px; color: var(--muted-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover, .tabs a:hover { color: var(--text); }
.tabs [aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.progress { height: 6px; border-radius: 3px; background: #22262C; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.util { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; font-size: 13px; color: var(--text-3); }
.util .meter { grid-column: 1 / -1; height: 6px; border-radius: 3px; }
.util .meter > i { border-radius: 3px; }
.util .num { font-family: var(--mono); font-size: 12px; color: var(--muted-2); }


/* portfolio */
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.acct { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.acct:hover { border-color: #4A505A; color: var(--text); }
.acct-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acct-v { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.acct-v small { font-family: var(--mono); font-size: 11.5px; font-weight: 400; letter-spacing: 0; color: var(--muted-3); }
.asset { display: inline-flex; align-items: center; gap: 9px; font-weight: 500; color: var(--text); }
.coin { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border-2); font-size: 11px; color: var(--text-3); }
.limits { display: flex; flex-direction: column; gap: 16px; }
.conn { display: flex; align-items: center; gap: 12px; }
.conn-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border); color: var(--muted-2); flex: none; }
.conn-ic svg { width: 17px; height: 17px; }


/* strategy builder */
.strat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.strat-name { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
.strat-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.versions { display: flex; align-items: center; gap: 0; margin-top: 18px; overflow-x: auto; scrollbar-width: none; }
.ver { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 12.5px; color: var(--muted); min-width: 92px; }
.ver b { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text-2); }
.ver-cur { border-color: var(--accent-line); }
.ver-cur b { color: var(--accent); }
.ver-prop { border-style: dashed; border-color: #4A505A; }
.ver-link { flex: none; width: 18px; height: 1px; background: var(--border-3); }
.otherwise { margin-top: 8px; padding: 9px 14px; border: 1px dashed #2E333B; border-radius: 10px; font-family: var(--mono); font-size: 12px; color: var(--muted-2); }
.param { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line-2); }
.param:first-child { border-top: 0; padding-top: 0; }
.param label { font-size: 14px; color: var(--text-2); }
.param output { font-family: var(--mono); font-size: 13px; color: var(--text); }
.param input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.param .hint { grid-column: 1 / -1; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.choice { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: linear-gradient(0deg, rgba(200,245,96,.04), rgba(200,245,96,.04)), var(--surface); }
.choice input { position: absolute; opacity: 0; }
.choice b { font-size: 14px; font-weight: 600; color: var(--text); }
.choice span { font-size: 13px; color: var(--muted); line-height: 1.5; }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 16px; }
.checks li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); }
.checks li svg { width: 14px; height: 14px; color: var(--accent); flex: none; }
.checks li.warn svg { color: var(--warn); }
.code { margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--inset); font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--text-3); overflow-x: auto; white-space: pre; }
.code .k { color: #9DA3AD; } .code .s { color: var(--accent); } .code .n { color: var(--stocks); }
details.more > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted-2); }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary:hover { color: var(--text); }
details.more[open] > summary { margin-bottom: 12px; }
.ladder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.step { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.step .label { display: flex; align-items: center; gap: 6px; }
.step b { font-size: 13.5px; font-weight: 500; color: var(--text); }
.step span { font-size: 12.5px; color: var(--muted-2); }
.step-done .label { color: var(--accent); }
.step-locked { border-style: dashed; }
.tpl { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line-2); }
.tpl:first-child { border-top: 0; padding-top: 0; }
@media (max-width: 520px) { .ladder { grid-template-columns: 1fr; } }

/* backtests */
.run-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.run-form .full { grid-column: 1 / -1; }
.run-form .input, .run-form .select { height: 40px; font-size: 14px; }
.coverage { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--muted-2); }
.coverage .bar { flex: 1; height: 6px; border-radius: 3px; background: #22262C; position: relative; overflow: hidden; }
.coverage .bar i { position: absolute; top: 0; bottom: 0; background: var(--accent-line); }
.coverage .bar b { position: absolute; top: 0; bottom: 0; background: var(--accent); }
.runs .row-item { cursor: pointer; }
.runs .row-item[aria-current="true"] .row-main b { color: var(--accent); }
.manifest { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 13px; }
.manifest dt { color: var(--muted-2); }
.manifest dd { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
@media (max-width: 520px) { .run-form { grid-template-columns: 1fr; } .manifest { grid-template-columns: 1fr; gap: 2px; } .manifest dd { margin-bottom: 8px; } }

/* learn */
.path { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.path li { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 14px; color: var(--muted); }
.path li .n { width: 22px; height: 22px; flex: none; border-radius: 6px; display: grid; place-items: center; font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--border-2); color: var(--muted-3); }
.path li.done { color: var(--muted-2); }
.path li.done .n { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent); }
.path li.cur { color: var(--text); }
.path li.cur .n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.path li a { color: inherit; }
.path li a:hover { color: #FFFFFF; }
.path li .lv { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--muted-3); }
.reader h3 { margin: 0 0 10px; font-size: 20px; line-height: 1.3; letter-spacing: -0.02em; font-weight: 600; }
.reader p { margin: 0 0 14px; font-size: 15px; line-height: 1.65; color: var(--text-3); max-width: 68ch; }
.callout { margin: 0 0 16px; padding: 12px 14px; border-left: 2px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; font-size: 14px; color: var(--text-3); line-height: 1.6; }
.callout b { display: block; margin-bottom: 2px; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.reader figure { margin: 0 0 14px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: #1a1a19; }
.reader figure img { margin: 0 auto; width: 100%; max-width: 380px; height: auto; }
.reader figcaption { margin-top: 10px; font-size: 12.5px; line-height: 1.5; color: var(--muted-2); }
.reader-foot { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.lib-item .lv { font-family: var(--mono); font-size: 10.5px; color: var(--muted-3); }

/* settings */
.prefs { display: flex; flex-direction: column; }
.pref { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 16px; padding: 14px 0; border-top: 1px solid var(--line-2); align-items: start; }
.pref:first-child { border-top: 0; padding-top: 0; }
.pref .pk { font-size: 13.5px; color: var(--muted); padding-top: 8px; }
.pref .opts { margin-top: 0; }
.pref .hint { grid-column: 2; }
.exp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.exp-grid .select { height: 38px; font-size: 14px; }
@media (max-width: 520px) { .pref { grid-template-columns: 1fr; } .pref .pk { padding-top: 0; } .pref .hint { grid-column: 1; } }

/* welcome (first sign-in) */
body.welcome .wl-shell { display: grid; grid-template-rows: 58px minmax(0, 1fr); height: 100%; }
.wl-head { display: flex; align-items: center; gap: 16px; padding: 0 24px; border-bottom: 1px solid var(--line); }
.wl-steps { margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.wl-dots { display: flex; gap: 4px; }
.wl-dots i { width: 18px; height: 4px; border-radius: 2px; background: #2A2E35; }
.wl-dots i.on { background: var(--accent); }
.wl-body { display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-height: 0; }
.wl-chat { position: relative; display: flex; flex-direction: column; min-height: 0; }
.wl-chat::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(rgba(237,238,240,0.09) 1px, transparent 1.4px); background-size: 24px 24px; -webkit-mask-image: radial-gradient(ellipse 60% 45% at 50% 20%, #000 10%, transparent 75%); mask-image: radial-gradient(ellipse 60% 45% at 50% 20%, #000 10%, transparent 75%); }
.wl-stream { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 24px 24px 24px; scroll-behavior: smooth; }
.wl-inner { max-width: 720px; }
.wl-hello { display: flex; justify-content: flex-start; padding: 28px 0 8px 76px; }
.wl-mark { display: grid; grid-template-columns: repeat(5, 12px); gap: 3px; }
.wl-mark i { width: 12px; height: 12px; background: #1F2328; border-radius: 1px; }
.wl-mark i.on { background: var(--accent); animation: wl-px .5s ease-out both; }
@keyframes wl-px { from { background: #1F2328; transform: scale(.4); } to { background: var(--accent); transform: scale(1); } }
.wl-greet { margin: 0 0 6px; font-size: clamp(28px, 3vw, 40px); line-height: 1.1; letter-spacing: -0.035em; font-weight: 600; color: var(--text); }
.wl-greet span { color: var(--muted-2); }
.wl-memory { border-left: 1px solid var(--line); background: var(--bg-alt); padding: 40px 28px; overflow-y: auto; }
.wl-card { padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.wl-mem { margin: 0; display: flex; flex-direction: column; }
.wl-mem > div { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.wl-mem dt { font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-3); }
.wl-mem dd { margin: 0; font-size: 14px; color: var(--muted-3); }
.wl-mem dd.set { color: var(--text); }
.wl-mem > div.flash dd { animation: wl-flash 1.2s ease-out; }
@keyframes wl-flash { 0% { color: var(--accent); } 100% { color: var(--text); } }
.welcome .composer, .welcome .composer-foot { max-width: 720px; }
.wl-continue { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.wl-note { margin-top: 10px; font-size: 13px; color: var(--muted-2); }
@media (max-width: 960px) {
  .wl-body { grid-template-columns: minmax(0, 1fr); }
  .wl-memory { display: none; }
  .wl-head { padding: 0 14px; }
  .wl-steps .label { display: none; }
  .wl-stream { padding: 16px 14px; }
  .wl-hello { padding: 12px 0 4px; }
}

/* menus */
.menu { position: absolute; z-index: 30; min-width: 260px; padding: 6px; background: var(--surface-3); border: 1px solid #343941; border-radius: 10px; box-shadow: var(--shadow-pop); }
.menu a, .menu button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; color: var(--text-3); }
.menu a:hover, .menu button:hover { background: #23272E; color: #FFFFFF; }
.menu .sep { height: 1px; margin: 6px 4px; background: #2A2E35; }
.menu small { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--muted-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .app-shell { --deck-w: minmax(340px, 420px); }
  body.deck-wide .app-shell { --deck-w: minmax(360px, 44%); }
}
@media (max-width: 960px) {
  body.app { overflow: hidden; }
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 60px; }
  body.deck-wide .app-shell, body.deck-hidden .app-shell { grid-template-columns: minmax(0, 1fr); }
  .rail { grid-row: 2; flex-direction: row; padding: 0 6px; border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .rail-logo, .rail-foot { display: none; }
  .rail-nav { flex-direction: row; padding: 0; justify-content: space-around; }
  .rail a.rail-item { flex: 1; padding: 8px 0 6px; }
  .rail a.rail-item[aria-current="page"]::before { left: 30%; right: 30%; top: -1px; bottom: auto; width: auto; height: 2px; border-radius: 0 0 2px 2px; }
  .chat-col, .deck { grid-row: 1; grid-column: 1; }
  .deck { display: none; border-left: 0; }
  body[data-view="deck"] .deck { display: block; }
  body[data-view="deck"] .chat-col { display: none; }
  body.deck-hidden .deck { display: none; }
  .view-toggle { display: inline-flex; }
  .chat-head, .deck-head { padding: 0 14px; }
  .chat-stream { padding: 8px 14px 18px; }
  .composer-wrap { padding: 0 12px 12px; }
  .msg { grid-template-columns: minmax(0, 1fr); row-gap: 4px; }
  .msg-who { padding-top: 0; }
  .deck-sec { padding: 18px 16px; }
  .tabs { padding: 0 14px; }
  .hide-sm { display: none !important; }
  .composer-foot .sp { margin-left: 0; }
}
@media (min-width: 961px) { .show-sm { display: none !important; } }

/* ---------- Wired states (live data) ---------- */
.toasts { position: fixed; z-index: 60; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 10px 14px; border: 1px solid #343941; border-radius: 10px; background: var(--surface-3); box-shadow: var(--shadow-pop); font-size: 13.5px; color: var(--text-2); }
.toast-err { border-color: rgba(255,123,114,.45); color: #FFB3AD; }
.toast-ok { border-color: var(--accent-line); }
@media (max-width: 960px) { .toasts { bottom: 76px; right: 12px; left: 12px; max-width: none; } }
.skel { display: flex; flex-direction: column; gap: 10px; }
.skel i { display: block; height: 14px; border-radius: 4px; background: linear-gradient(90deg, #15181C, #1C1F24, #15181C); background-size: 200% 100%; animation: skel 1.2s linear infinite; }
.skel i:nth-child(2n) { width: 70%; }
@keyframes skel { from { background-position: 200% 0; } to { background-position: 0 0; } }
.linkish { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; color: inherit; }
.empty .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ctx-toggle[aria-pressed="true"] { border-style: solid; border-color: var(--accent-line); color: var(--accent); }
.composer-foot.out .sp { color: var(--warn); }
.mcard-foot .note.neg { color: var(--neg); margin-left: 0; }
.chart.stale { opacity: .55; }

/* Markdown inside Valmy answers (rendered from text, never HTML) */
.answer > *:last-child { margin-bottom: 0; }
.answer pre.code { margin: 0 0 10px; white-space: pre-wrap; }
.answer blockquote { margin: 0 0 10px; padding: 2px 0 2px 12px; border-left: 2px solid var(--border-3); color: var(--muted); }
.answer hr { border: 0; border-top: 1px solid var(--line-2); margin: 12px 0; }
.answer a, .reader a { color: var(--text); text-decoration: underline; text-decoration-color: #4A505A; text-underline-offset: 3px; }
.answer .link-host { font-family: var(--mono); font-size: 11.5px; color: var(--muted-3); overflow-wrap: anywhere; }
.answer .table-wrap, .reader .table-wrap { overflow-x: auto; margin: 0 0 12px; }
.answer .table th, .answer .table td { padding: 6px 10px; font-size: 13px; }
.answer p.note, .reader p.note { margin: 0 0 14px; padding: 12px 14px; border-left: 2px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; font-size: 14px; color: var(--text-3); }
.answer p.note .k, .reader p.note .k { display: block; margin-bottom: 2px; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }

/* Full lesson in the app reader */
.reader h2 { margin: 26px 0 10px; font-size: 17px; line-height: 1.35; letter-spacing: -0.015em; font-weight: 600; color: var(--text); scroll-margin-top: 120px; }
.reader h3 { scroll-margin-top: 120px; }
.reader h4, .reader h5 { margin: 18px 0 8px; font-size: 15px; color: var(--text-2); scroll-margin-top: 120px; }
.reader ul, .reader ol { margin: 0 0 14px; padding-left: 20px; color: var(--text-3); font-size: 15px; line-height: 1.6; }
.reader li { margin: 4px 0; }
.reader code { font-family: var(--mono); font-size: 13px; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); }
.reader pre.code { margin: 0 0 14px; }
.reader blockquote { margin: 0 0 14px; padding-left: 12px; border-left: 2px solid var(--border-3); color: var(--muted); }
.reader :target, .reader .flash-target { animation: reader-flash 1.8s ease-out; }
@keyframes reader-flash { 0% { background: var(--accent-wash); } 100% { background: transparent; } }
.reader-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.reader-rights { margin-top: 18px; font-size: 12.5px; color: var(--muted-3); line-height: 1.55; }

/* Trade ticket */
.ticket .mcard { margin-top: 4px; }
.ticket .run-form { margin: 0; }
.pos-actions { display: inline-flex; gap: 6px; }
