/* App shell: rail + top bar + content; the sign-in modal; page patterns (tools, studio editor, pickers). */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--rail) calc(var(--rail-w) - 1px), var(--line) calc(var(--rail-w) - 1px) var(--rail-w), transparent var(--rail-w)) }
#page:focus { outline: none }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: var(--s4) var(--s3); background: var(--rail); border-right: 1px solid var(--line); overflow-y: auto }
.brand { display: flex; align-items: center; gap: 10px; padding: var(--s2) var(--s2) var(--s4); text-decoration: none; color: var(--text) }
.brand .mark { width: 24px; height: 24px; color: var(--text) } .brand b { font-weight: 600; letter-spacing: -.01em } .brand small { display: block; color: var(--muted); font-size: var(--t-xs); margin-top: -2px }
.rail .seg { display: grid; grid-template-columns: 1fr 1fr; margin: 0 var(--s1) var(--s4) }
.nav-label { padding: var(--s4) var(--s3) var(--s1); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
.nv { display: flex; align-items: center; gap: var(--s3); height: 36px; padding: 0 var(--s3); border-radius: var(--r-sm); font-size: var(--t-sm); font-weight: 500; color: var(--text-2); text-decoration: none; position: relative }
.nv svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .85 }
.nv:hover { background: var(--raise); color: var(--text) }
.nv[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line) }
.nv[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent) }
.nv .badge { margin-left: auto; height: 18px; font-size: 10px }
.rail-foot { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--line); display: grid; gap: var(--s2) }
.credit { display: grid; gap: 2px; padding: var(--s3); border-radius: var(--r-md); background: var(--surface); box-shadow: 0 0 0 1px var(--line); text-decoration: none }
.credit .k { font-size: var(--t-xs); color: var(--muted) } .credit b { font-size: var(--t-lg); font-weight: 500; font-variant-numeric: tabular-nums } .credit .meter { margin-top: 6px }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); height: 60px; padding: 0 var(--s6); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px) }
.crumbs { font-size: var(--t-sm); color: var(--muted) } .crumbs b { color: var(--text); font-weight: 500 }
.topbar .sp { flex: 1 }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); font-size: var(--t-xs); font-weight: 600; border: 0; cursor: pointer }
.main { padding: var(--s6) var(--s6) var(--s8); max-width: calc(var(--content-w) + 2 * var(--s6)) }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s6) }
.preview-tag { margin-left: var(--s2) }

/* studio home: tools as a ruled row, not a card grid */
.tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line) }
.tool { display: grid; gap: var(--s2); align-content: start; padding: var(--s5) var(--s5) var(--s5) 0; text-decoration: none; color: var(--text) }
.tool + .tool { padding-left: var(--s5); border-left: 1px solid var(--line) }
.tool .ic { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--rail); box-shadow: inset 0 0 0 1px var(--line); margin-bottom: var(--s2) }
.tool .ic svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round }
.tool b { font-weight: 600 } .tool p { margin: 0; font-size: var(--t-sm); color: var(--muted) } .tool .go { font-size: var(--t-sm); color: var(--text-2); margin-top: var(--s2) }
.tool:hover b { text-decoration: underline; text-underline-offset: 4px }

/* studio editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s6); align-items: start }
.editor .textarea { min-height: 280px; font-size: var(--t-lg); padding: var(--s4) var(--s5) }
.side { display: grid; gap: var(--s4); position: sticky; top: 84px }
.voice-pick { display: grid; gap: 2px } .vrow { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s2); border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer; text-align: left; background: none }
.vrow:hover { background: var(--raise) } .vrow[aria-pressed="true"] { border-color: var(--line-strong); background: var(--surface) }
.vrow img, .vrow .ph { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--raise) } .vrow b { font-weight: 500; font-size: var(--t-sm) } .vrow span { display: block; font-size: var(--t-xs); color: var(--muted) }
.wave { height: 56px; display: flex; align-items: center; gap: 2px } .wave i { flex: 1; background: var(--line-strong); border-radius: 2px }
.player { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); margin-top: var(--s4) }

/* sign-in modal: product visual left, form right */
.auth { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 560px }
.auth-visual { position: relative; overflow: hidden; padding: var(--s6); background: #1A1C1E; color: #F6F3EF; display: flex; flex-direction: column; justify-content: space-between; border-radius: var(--r-lg) 0 0 var(--r-lg) }
.auth-visual .mark { width: 28px; height: 28px; color: #F6F3EF }
.auth-visual h2 { font-family: var(--serif); font-weight: 400; font-size: 2rem; line-height: 1.2; letter-spacing: -.01em; max-width: 14ch }
.auth-visual p { color: #B9B5AE; font-size: var(--t-sm); margin: var(--s3) 0 0; max-width: 34ch }
.auth-visual canvas { position: absolute; inset: auto 0 0 0; width: 100%; height: 55%; opacity: .95 }
.auth-visual .caps { position: relative; display: flex; gap: var(--s2); flex-wrap: wrap }
.auth-visual .caps span { height: 26px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: var(--r-pill); border: 1px solid #3A3D42; font-size: var(--t-xs); color: #D7D3CC; background: rgba(26, 28, 30, .6) }
.auth-form { padding: var(--s7) var(--s6); display: flex; flex-direction: column; justify-content: center; gap: var(--s4) }
.auth-form h1 { font-size: var(--t-xl) } .auth-form .lede { margin-top: 2px }
.or { display: flex; align-items: center; gap: var(--s3); color: var(--muted); font-size: var(--t-xs) } .or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line) }
.social { display: grid; gap: var(--s2) } .social .btn { justify-content: center; gap: 10px }
.otp { display: flex; gap: var(--s2) } .otp input { width: 48px; height: 56px; text-align: center; font-size: var(--t-xl); font-variant-numeric: tabular-nums; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface) }
.otp input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent) }
.legal { font-size: var(--t-xs); color: var(--muted) }
.x { position: absolute; top: var(--s3); right: var(--s3) }
.landing { min-height: 100vh; display: grid; place-items: center; padding: var(--s4) }

@media (max-width: 960px) {
  .tools { grid-template-columns: 1fr 1fr } .tool:nth-child(3) { border-left: 0; padding-left: 0 } .tool:nth-child(n+3) { border-top: 1px solid var(--line) }
  .editor { grid-template-columns: 1fr } .side { position: static }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 45; transform: translateX(-102%); transition: transform var(--slow) var(--ease); box-shadow: var(--shadow) }
  body.nav-open .rail { transform: none } body.nav-open::after { content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 44 }
  .topbar { padding: 0 var(--s4) } .main { padding: var(--s5) var(--s4) var(--s7) }
  .stats { grid-template-columns: 1fr 1fr } .stat:nth-child(3) { border-left: 0; padding-left: 0 } .stat:nth-child(n+3) { border-top: 1px solid var(--line) }
  .shell { background: none } .scrim { padding: 0; place-items: stretch } .dialog { border-radius: 0; max-height: 100vh; min-height: 100vh }
  .auth { grid-template-columns: 1fr; min-height: 0 } .auth-visual { min-height: 0; padding: var(--s5) var(--s4); border-radius: 0 } .auth-visual h2 { font-size: 1.375rem; margin-top: 16px !important; max-width: none }
  .auth-visual canvas, .auth-visual .caps, .auth-visual p { display: none }
  .auth-form { padding: var(--s5) var(--s4) var(--s6) } .hide-sm { display: none }
}
@media (min-width: 761px) { .menu-btn { display: none } }

/* stage 2 patterns: tables that scroll instead of wrapping, forms, pickers, studio tools */
.row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap }
.ctl { margin: var(--s5) 0 var(--s3) }
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: var(--s3) }
.tw .table { min-width: 520px } .nw { white-space: nowrap } .clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.table tr.cur td { background: color-mix(in srgb, var(--accent) 5%, transparent) }
svg.chart { width: 100%; height: 210px; display: block }
.badge.accent { color: var(--accent) }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); border-top: 1px solid var(--line); margin-top: var(--s3) }
.lv { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4) var(--s3) 0; border-bottom: 1px solid var(--line) }
.lv img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover } .lv b { font-weight: 500; display: block } .lv code { font-size: 11px }
.keyform { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr) auto auto; gap: var(--s4); align-items: end; padding: var(--s4) 0; border-block: 1px solid var(--line) }
.scopes { border: 0; padding: 0; margin: 0 } .scopes > div { display: flex; gap: var(--s3); height: 44px; align-items: center; flex-wrap: wrap; font-size: var(--t-sm) }
.scopes input, .check input { accent-color: var(--text) }
.check { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--t-sm); color: var(--text-2) }
.packs { display: grid; max-width: 860px; border-top: 1px solid var(--line); margin-top: var(--s3) }
.packs label { display: grid; grid-template-columns: 20px 96px minmax(0, 1fr) auto; gap: var(--s4); align-items: center; padding: var(--s4) var(--s1); border-bottom: 1px solid var(--line); cursor: pointer }
.packs label:has(input:checked) { box-shadow: inset 2px 0 0 var(--accent); background: color-mix(in srgb, var(--accent) 3%, transparent) }
.packs label.off { opacity: .5; cursor: not-allowed } .packs b { font-size: 1.375rem; font-weight: 500 } .packs input { accent-color: var(--text) }
.eff { font-variant-numeric: tabular-nums; white-space: nowrap }
.limits-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5); padding: var(--s4) 0; border-block: 1px solid var(--line); max-width: 960px }
.limits-form > div:last-child { grid-column: 1 / -1 }
.kv { display: grid; grid-template-columns: 200px minmax(0, 1fr); max-width: 760px; border-top: 1px solid var(--line); margin: 0 }
.kv dt { padding: var(--s4) 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: var(--t-sm) } .kv dd { margin: 0; padding: var(--s4) 0; border-bottom: 1px solid var(--line) }
.steps { list-style: none; padding: 0; margin: 0 0 var(--s5); display: grid; max-width: 760px; border-top: 1px solid var(--line); counter-reset: st }
.steps li { counter-increment: st; display: grid; gap: var(--s2); padding: var(--s5) 0 var(--s5) 44px; border-bottom: 1px solid var(--line); position: relative }
.steps li::before { content: counter(st); position: absolute; left: 0; top: var(--s5); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600 }
blockquote { margin: 0; padding: var(--s3) var(--s4); border-left: 2px solid var(--accent); background: var(--rail); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: var(--t-md); line-height: 1.6 }
.soonwrap { opacity: .55; pointer-events: none; max-width: 860px }
.drop { display: grid; justify-items: center; gap: 6px; padding: var(--s7) var(--s4); border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); text-align: center }
.drop .ic { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--rail) } .drop svg { width: 22px; height: 22px }
.chatbox { display: grid; gap: var(--s3); padding: var(--s5); border: 1px solid var(--line); border-radius: var(--r-lg); min-height: 220px; align-content: start }
.msg { max-width: 70%; padding: var(--s3) var(--s4); border-radius: var(--r-lg); font-size: var(--t-sm) } .msg.them { background: var(--rail) } .msg.me { justify-self: end; background: var(--text); color: var(--bg) }
@media (max-width: 760px) {
  .hm { display: none } .tw .table { min-width: 0 } .clip { max-width: 140px }
  .keyform, .limits-form { grid-template-columns: 1fr } .kv { grid-template-columns: 1fr } .kv dt { border-bottom: 0; padding-bottom: 0 }
  .packs label { grid-template-columns: 20px 72px minmax(0, 1fr) } .packs .eff { grid-column: 3 } .page-head .row { width: 100% }
}

/* editorial headings (serif) over a crisp sans UI */
.h-page { font-family: var(--serif); font-weight: 400; font-size: 2.25rem; letter-spacing: -.01em }
.h-sec { font-family: var(--sans); font-weight: 600; font-size: var(--t-md); letter-spacing: 0 }
.section { margin-top: 40px } .section > header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3) }
.section > header p { margin: 2px 0 0; color: var(--muted); font-size: var(--t-sm) }
.panel { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: var(--s5) }
.panel.flush { padding: 0; overflow: hidden } .panel.flush .table th:first-child, .panel.flush .table td:first-child { padding-left: var(--s5) } .panel.flush .table th:last-child, .panel.flush .table td:last-child { padding-right: var(--s5) }
.panel.flush .table tr:last-child td { border-bottom: 0 } .panel.flush .tw { margin: 0 }
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface) }
.hero > div { padding: var(--s5) var(--s6) } .hero > div + div { border-left: 1px solid var(--line) }
.hero .k { font-size: var(--t-sm); color: var(--muted) } .hero .big { font-family: var(--serif); font-size: 2.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: 6px }
.hero .v { font-size: 1.5rem; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 6px } .hero .s { font-size: var(--t-sm); color: var(--muted); margin-top: 4px }
.num { font-variant-numeric: tabular-nums }
/* charts */
.chart-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3) }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; height: 220px; font: 11px var(--mono); color: var(--muted); text-align: right; transform: translateY(-6px) }
.chart-plot { position: relative; outline: none } .chart-plot svg { display: block; width: 100%; height: 220px }
.chart-plot:focus-visible { box-shadow: 0 0 0 2px var(--focus); border-radius: var(--r-sm) }
.chart-plot .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke } .chart-plot .grid.base { stroke: var(--line-strong) }
.chart-plot .hit.on { fill: color-mix(in srgb, var(--text) 5%, transparent) }
.chart-x { display: flex; justify-content: space-between; font: 11px var(--mono); color: var(--muted); margin-top: 6px }
.chart-tip { position: absolute; top: -8px; min-width: 160px; padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: var(--t-xs); display: grid; gap: 3px; pointer-events: none; z-index: 5 }
.chart-tip b { font-weight: 600 } .chart-tip .t { font-size: var(--t-md); font-variant-numeric: tabular-nums }
.chart-tip .r { display: grid; grid-template-columns: 8px 1fr auto; gap: 6px; align-items: center; color: var(--text-2) } .chart-tip .r em { font-style: normal; font-variant-numeric: tabular-nums }
.chart-tip i, .chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px }
.chart-legend { display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s3); font-size: var(--t-xs); color: var(--text-2) } .chart-legend span { display: inline-flex; gap: 6px; align-items: center }
.chart-empty { height: 220px; display: grid; place-items: center; color: var(--muted); font-size: var(--t-sm); border: 1px dashed var(--line-strong); border-radius: var(--r-md) }
/* modal */
.modal { width: min(560px, 100%) } .modal-body { padding: var(--s6) } .modal-body h2 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem } .modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s6); border-top: 1px solid var(--line) }
.secret { display: flex; gap: var(--s2); align-items: center; padding: var(--s3); border-radius: var(--r-md); background: var(--raise); font: 13px var(--mono); word-break: break-all }
/* filters */
.filters { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line) }
.filters .select { height: 34px; width: auto; font-size: var(--t-sm) }
/* model / voice cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s4) }
.mcard { display: grid; gap: var(--s2); padding: var(--s5); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); align-content: start }
.mcard .top { display: flex; justify-content: space-between; align-items: center; gap: var(--s2) } .mcard h3 { font-family: var(--serif); font-weight: 400; font-size: 1.375rem }
.mcard .price { font-size: 1.25rem; font-weight: 500; font-variant-numeric: tabular-nums } .mcard dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: var(--s2) 0 0; font-size: var(--t-sm) } .mcard dt { color: var(--muted) } .mcard dd { margin: 0 }
.vcard { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface) }
.vcard img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover } .vcard b { display: block; font-weight: 500 } .vcard .play { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text) }
.vcard .play[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text) }
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s6) } .calc .out { display: grid; gap: var(--s2); align-content: start }
.calc .out .big { font-family: var(--serif); font-size: 2.5rem; font-variant-numeric: tabular-nums }
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr } .hero > div + div { border-left: 0; border-top: 1px solid var(--line) } .hero > div { padding: var(--s4) }
  .h-page { font-size: 1.75rem } .calc { grid-template-columns: 1fr } .chart-y { display: none } .chart-wrap { grid-template-columns: 1fr }
  .panel { padding: var(--s4) } .filters { padding: var(--s3) var(--s4) }
}
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 10px; vertical-align: -1px }
.money { display: flex; align-items: center; gap: var(--s2) } .money > span { color: var(--muted); font-size: var(--t-sm) } .money .input { max-width: 180px }
.money.sm { justify-content: flex-end } .money.sm .input { height: 34px; max-width: 120px; text-align: right }
.limits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5) }
.switch { position: relative; display: inline-block; width: 40px; height: 22px } .switch input { opacity: 0; width: 0; height: 0 }
.switch span { position: absolute; inset: 0; border-radius: 22px; background: var(--line-strong); transition: background var(--fast) var(--ease) }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform var(--fast) var(--ease) }
.switch input:checked + span { background: var(--accent) } .switch input:checked + span::after { transform: translateX(18px) } .switch input:disabled + span { opacity: .5 }
.packs-panel { padding: 0 } .packs-panel .packs { margin: 0; border-top: 0; max-width: none } .packs-panel .packs label { padding: var(--s4) var(--s5) }
.buyrow { padding: var(--s4) var(--s5); border-top: 1px solid var(--line) } .packs-panel .error { padding: 0 var(--s5) }
.field-stack { display: grid; gap: var(--s4); align-content: start }
.vcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s3) }
@media (max-width: 760px) { .limits { grid-template-columns: 1fr } .packs-panel .packs label { padding: var(--s4) } .buyrow { padding: var(--s4) } }

.packs-panel .error:empty { display: none } .packs-panel .buyrow { border-bottom: 0 }
