/* Playground: a two-pane workbench. Input left, tools right. */
.wrap.wide { max-width: none; }
body.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.app .topbar .wrap { height: 56px; }
.brand-sub { font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.app .nav { margin-left: 18px; }

.pg { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, var(--in-w, 38%)) 6px minmax(0, 1fr); }
.pg.resizing { cursor: col-resize; user-select: none; }
.pane-in, .pane-tool { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.pane-in { background: var(--surface); }
.resizer { background: var(--line); cursor: col-resize; position: relative; outline-offset: -2px; }
.resizer::after { content: ""; position: absolute; top: 50%; left: 1px; width: 4px; height: 36px; margin-top: -18px; border-radius: 2px; background: var(--line-2); }
.resizer:hover, .resizer:focus-visible, .pg.resizing .resizer { background: var(--mark); }
.pane-tool { background: var(--paper); }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 56px; }
.bar h1 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; margin-right: auto; }
.bar-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.bar .hint { color: var(--ink-3); font-size: 14.5px; margin-right: auto; }
.bar .run { margin-left: auto; }
.run kbd { font: 500 11.5px var(--sans); opacity: .65; margin-left: 2px; }
.grow { flex: 1; min-width: 180px; }

.field { height: 36px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 14.5px var(--sans); padding: 0 10px; min-width: 0; }
.field.mono, .mono { font-family: var(--mono); font-size: 13.5px; }
.field.num { width: 130px; font-variant-numeric: tabular-nums; }
select.field { padding-right: 28px; max-width: 280px; }
.btn-q { height: 36px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: var(--r-sm); padding: 0 12px; font: 500 14px var(--sans); cursor: pointer; }
.btn-q:hover { border-color: var(--ink-3); }
.btn-q:disabled, .btn:disabled { opacity: .5; cursor: progress; transform: none; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; background: var(--surface); }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 999px; font: 500 14px var(--sans); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.tok-seg button { padding: 4px 10px; font-size: 13.5px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }

/* editor: a transparent textarea over a highlighted copy, with a line-number gutter */
.editor { flex: 1; min-height: 0; display: flex; position: relative; overflow: hidden; background: var(--surface); }
.gutter { flex: none; width: 46px; overflow: hidden; border-right: 1px solid var(--line); background: var(--sunk); }
.gutter > div { padding: 14px 8px 14px 0; text-align: right; font: 12px/21px var(--mono); color: var(--ink-3); white-space: pre; user-select: none; will-change: transform; }
.ed-body { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.ed-hl, .editor textarea { margin: 0; padding: 14px 16px; font: 13px/21px var(--mono); tab-size: 2; white-space: pre; letter-spacing: 0; border: 0; }
.ed-hl { position: absolute; inset: 0 auto auto 0; min-width: 100%; color: var(--ink); pointer-events: none; will-change: transform; }
.ed-hl code { font: inherit; background: none; padding: 0; }
.editor textarea { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; outline: none; background: transparent; color: transparent; caret-color: var(--ink); overflow: auto; }
.editor textarea::selection { background: color-mix(in srgb, var(--cobalt) 30%, transparent); color: transparent; }
.editor textarea::placeholder { color: var(--ink-3); }
.editor.plain textarea { color: var(--ink); }
.editor.plain .ed-hl { display: none; }
.editor:focus-within { box-shadow: inset 0 0 0 2px var(--cobalt); }
.editor.drag { box-shadow: inset 0 0 0 3px var(--mark); }
.ed-loading { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 80%, transparent); z-index: 2; }
.ed-loading[hidden] { display: none; }
.ed-loading span { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 14.5px; }
.ed-loading span::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--paper) 35%, transparent); border-top-color: var(--mark); animation: spin .8s linear infinite; }
.code-in { flex: 1; width: 100%; resize: none; border: 0; outline: none; background: transparent; color: var(--ink); font: 13px/1.6 var(--mono); padding: 14px 16px; tab-size: 2; white-space: pre; overflow: auto; }
.status { border-top: 1px solid var(--line); padding: 8px 16px; font-size: 13.5px; color: var(--ink-3); display: flex; gap: 10px; align-items: center; min-height: 37px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; }
.status.ok .dot { background: var(--ok); }
.status.err { color: var(--waste); }
.status.err .dot { background: var(--waste); }

/* loading: a thin bar under the tabs, the old result dimmed, the run button counting */
.pane-tool { position: relative; }
.progress { position: absolute; left: 0; right: 0; top: 0; height: 2px; overflow: hidden; z-index: 3; opacity: 0; transition: opacity .15s; }
.progress.on { opacity: 1; }
.progress i { position: absolute; top: 0; bottom: 0; width: 30%; background: var(--mark); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { left: -30%; } to { left: 100%; } }
.tool.loading .out, .out.dim { opacity: .45; transition: opacity .2s; pointer-events: none; }
.tool .run:disabled { opacity: 1; cursor: progress; font-variant-numeric: tabular-nums; min-width: 148px; }
.skel { display: grid; gap: 10px; }
.skel-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 8px; }
.skel i, .skel b { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--sunk) 25%, var(--line) 50%, var(--sunk) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skel i { height: 64px; }
.skel b { height: 18px; }
.skel b:nth-child(odd) { width: 86%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.out.fresh > :first-child { animation: arrive .35s ease-out; }
@keyframes arrive { from { opacity: .3; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.err-box p + p { margin-top: 10px; }
.err-act { display: flex; align-items: center; gap: 12px; }

/* first-visit guide */
.tour { position: absolute; right: 16px; top: 64px; z-index: 5; width: min(380px, calc(100% - 32px)); background: var(--ink); color: var(--paper); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow); }
.tour h2 { color: var(--paper); font-size: 18px; }
.tour ol { margin: 10px 0 14px; padding-left: 20px; display: grid; gap: 8px; font-size: 14.5px; color: color-mix(in srgb, var(--paper) 82%, transparent); }
.tour b { color: var(--paper); }
.tour kbd { font: 12px var(--sans); border: 1px solid color-mix(in srgb, var(--paper) 40%, transparent); border-radius: 4px; padding: 0 4px; }
.tour .btn { --b: var(--mark); --f: #1b1400; }

/* tool tabs */
.tool-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; scrollbar-width: thin; flex: none; }
.tool-tabs button { border: 0; background: none; padding: 15px 12px 13px; font: 500 14.5px var(--sans); color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tool-tabs button:hover { color: var(--ink); }
.tool-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--mark); }
.tool { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tool[hidden] { display: none; }
.tool > .out, .tool .split, #askSim, #askRec { flex: 1; min-height: 0; }
#askSim, #askRec { display: flex; flex-direction: column; }
#askRec[hidden], #askSim[hidden] { display: none; }
.out { overflow: auto; padding: 16px; }
.split { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.split > * { min-height: 0; }
.split .code-in { border-right: 1px solid var(--line); background: var(--surface); }
.out.side { border-left: 1px solid var(--line); background: var(--surface); }
.out.side h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--ink-2); }
.empty { color: var(--ink-3); padding: 28px 8px; max-width: 52ch; }
.empty code { color: var(--ink-2); }
.err-box { border-left: 3px solid var(--waste); background: var(--surface); padding: 12px 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--ink); }
.busy { color: var(--ink-3); padding: 28px 8px; display: flex; gap: 10px; align-items: center; }
.busy::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--mark); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* compare */
.headline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.headline div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.headline div.jd { border-color: var(--mark); box-shadow: 0 0 0 3px var(--mark-soft); }
.headline b { display: block; font-size: 28px; letter-spacing: -.03em; font-weight: 720; line-height: 1.1; font-variant-numeric: tabular-nums; }
.headline span { font-size: 13.5px; color: var(--ink-3); }
.ftable { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.ftable th, .ftable td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ftable thead th { color: var(--ink-3); font-weight: 500; font-size: 13px; }
.ftable th:first-child, .ftable td:first-child { text-align: left; }
.ftable tbody tr { cursor: pointer; }
.ftable tbody tr:hover > * { background: var(--sunk); }
.ftable tbody tr[aria-selected="true"] > * { background: var(--cobalt-soft); }
.ftable tr.jd td:first-child { font-weight: 700; }
.ftable tr.jd .tbar i { background: var(--mark); }
.tbar { display: inline-block; width: 120px; height: 8px; border-radius: 999px; background: var(--sunk); margin-right: 10px; vertical-align: middle; overflow: hidden; }
.tbar i { display: block; height: 100%; background: var(--line-2); border-radius: inherit; }
.good { color: var(--ok); }
.bad { color: var(--waste); }
.muted { color: var(--ink-3); }
.table-scroll { overflow-x: auto; }
.preview { margin-top: 16px; }
.pv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.pv { min-width: 0; }
.preview-head .muted { font-size: 13px; margin-right: auto; }
.preview-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.preview-head h3 { font-size: 15px; font-weight: 650; }
.code-out { margin: 0; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; font: 12.5px/1.65 var(--mono); white-space: pre; overflow: auto; max-height: 60vh; color: var(--ink); }
.code-out.wrap-text { white-space: pre-wrap; word-break: break-word; }
.code-out .t0 { background: var(--tok-a); border-radius: 2px; }
.code-out .t1 { background: var(--tok-b); border-radius: 2px; }
.note { font-size: 13.5px; color: var(--ink-3); margin-top: 10px; }

/* stat line used by several tools */
.stats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 12px; font-size: 14.5px; color: var(--ink-2); align-items: baseline; }
.stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.stats .big { font-size: 22px; letter-spacing: -.02em; }
.stats .act { margin-left: auto; display: flex; gap: 6px; }

/* ask and query */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px 0; }
.form-grid.three { grid-template-columns: 1fr 2fr 1fr; padding-bottom: 4px; }
.form-grid label { display: grid; gap: 5px; font-size: 13.5px; color: var(--ink-2); }
.form-grid .field { width: 100%; max-width: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }
.chips button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 4px 10px; font: 12.5px var(--mono); color: var(--ink-2); cursor: pointer; }
.chips button:hover { color: var(--ink); border-color: var(--ink-3); }
.chips button.col { border-style: dashed; color: var(--cobalt); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); padding: 10px 16px 0; }
.route { display: grid; gap: 8px; }
.route-row { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); align-items: baseline; }
.route-row > span:first-child { color: var(--ink-3); font-size: 14px; }
.route-row.win { border-color: var(--mark); box-shadow: 0 0 0 3px var(--mark-soft); }
.answer { font-size: 26px; font-weight: 720; letter-spacing: -.02em; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.no { background: var(--waste-soft); color: var(--waste); }
.pill.neutral { background: var(--sunk); color: var(--ink-2); }
details.more { margin-top: 12px; }
details.more summary { cursor: pointer; color: var(--cobalt); font-size: 14px; }
details.refs { margin-top: 6px; }
.refs-list { font-family: var(--mono); font-size: 13px; max-height: 120px; overflow-y: auto; background: var(--sunk); padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 6px; word-break: break-all; }
details.more .code-out { margin-top: 8px; }

/* columns, tests */
.cols { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); border: 1px solid var(--line); }
.cols th, .cols td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cols td.vals { font: 12.5px var(--mono); color: var(--ink-2); max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suite { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px; }
.suite small { grid-column: 2 / -1; color: var(--ink-3); font-size: 13px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 14.5px; z-index: 60; box-shadow: var(--shadow); }

@media (max-width: 1100px) { .headline { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  body.app { height: auto; overflow: auto; }
  .pg { grid-template-columns: minmax(0, 1fr); }
  .resizer { display: none; }
  .tour { top: auto; bottom: 16px; position: fixed; }
  .pane-in { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { height: 42vh; flex: none; }
  .tool { min-height: 70vh; }
  .split { grid-template-columns: 1fr; }
  .split .code-in { min-height: 200px; border-right: 0; border-bottom: 1px solid var(--line); }
  .out.side { border-left: 0; border-top: 1px solid var(--line); }
  .tok-seg { display: none; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .route-row { grid-template-columns: 1fr; gap: 2px; }
  .bar .run { margin-left: 0; }
}

/* Explain: linked JSON <-> JDogo */
.x-caption { min-height: 44px; padding: 10px 14px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--mark); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 14.5px; color: var(--ink-2); }
.x-caption b { color: var(--ink); }
.x-grid .code-out { max-height: 46vh; }
.xk, .xv, .xc, .xf { border-radius: 2px; cursor: default; }
.xf { font-weight: 600; cursor: pointer; }
.xc:focus-visible, .xf:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 1px; }
.xv.on, .xc.on { background: var(--mark-soft); color: var(--mark-ink); box-shadow: 0 0 0 2px var(--mark-soft); }
.xf.on { background: var(--mark); color: #1b1400; box-shadow: 0 0 0 2px var(--mark); }
.xk.on { background: var(--waste-soft); color: var(--waste); text-decoration: line-through; }
.x-h { font-size: 16px; font-weight: 650; margin: 22px 0 10px; }
.x-costs { display: grid; gap: 4px; }
.x-cost { display: grid; grid-template-columns: minmax(140px, 1.2fr) 2fr minmax(150px, auto); gap: 12px; align-items: center; padding: 6px 8px; border-radius: var(--r-sm); }
.x-cost.on { background: var(--sunk); }
.x-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-name small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12.5px; white-space: normal; }
.x-bars { display: grid; gap: 3px; }
.x-bars i { display: block; height: 7px; border-radius: 999px; min-width: 2px; }
.x-bars .j { background: var(--line-2); }
.x-bars .d { background: var(--mark); }
.x-num { font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; white-space: nowrap; }
.x-num small { display: block; font-size: 12.5px; }
@media (max-width: 700px) { .x-cost { grid-template-columns: 1fr auto; } .x-bars { grid-column: 1 / -1; grid-row: 2; } }

/* recent, export, focus mode, shortcut sheet */
#recent { max-width: 170px; }
.export-row { display: flex; gap: 6px; margin-top: 8px; }
body.focus .topbar, body.focus .pane-in, body.focus .resizer { display: none; }
body.focus .pg { grid-template-columns: minmax(0, 1fr); }
body.focus .tool-tabs { padding-left: 16px; }
.keys-dlg { border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); padding: 22px 26px; width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.keys-dlg::backdrop { background: rgba(10, 13, 22, .45); }
.keys-dlg h2 { font-size: 20px; margin-bottom: 14px; }
.keys-dlg dl { margin: 0 0 18px; display: grid; gap: 8px; }
.keys-dlg dl div { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: baseline; }
.keys-dlg dd { margin: 0; color: var(--ink-2); }
.keys-dlg kbd { font: 500 12.5px var(--sans); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--paper); }

/* Why this format: the measured cost of the text shown, instruction included */
.why { margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.why.cheaper { border-color: var(--line-2); background: var(--sunk); }
.why h3 { font-size: 14.5px; font-weight: 600; margin: 0 0 4px; color: var(--ink); }
.why p { margin: 0; font-size: 14px; color: var(--ink-2); }
.why table { margin-top: 8px; border-collapse: collapse; font-size: 13.5px; }
.why td { padding: 2px 16px 2px 0; color: var(--ink-2); }
.why td + td { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.why tr.total td { border-top: 1px solid var(--line); padding-top: 4px; font-weight: 600; color: var(--ink); }
