/* 402lounge admin portal. Colours from prototype/DESIGN.md §2, layout after the app (§6e),
   with a smaller sidebar. Light only, like the rest of 402lounge. */

:root {
  --fog: #ECEBE7;
  --paper: #FAFAF8;
  --box: #F3F2EE;
  --white: #FFFFFF;
  --ink: #3A3D44;
  --text: #4B4E56;
  --muted: #5E616A;
  --faint: #9A9DA5;
  --line: #DEDCD6;
  --line-in: #E6E4DF;
  --row: #F0EFEB;
  --hover: #E4E3DE;
  --row-hover: #F7F6F3;
  --edge: #B9B7B0;
  --edge-soft: #C9C7C1;
  --accent: #A9D2FF;
  --accent-light: #D6E9FF;
  --digits: #86B9EE;
  --series-1: #5A93D6;
  --series-rest: #D3D5DA;
  --ok: #2E8B57;
  --ok-bg: #E3F1E8;
  --warn: #7A5A10;
  --warn-bg: #F3E6C9;
  --danger: #8A2B1E;
  --danger-bg: #F6E3DF;
  --danger-line: #E2B7AE;
  --display: 'Funnel Display', 'Funnel Sans', system-ui, sans-serif;
  --sans: 'Funnel Sans', system-ui, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--fog); color: var(--ink); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--muted); }
button, input, select, textarea { font-family: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.r { text-align: right; }
.wrap { overflow-wrap: anywhere; }

/* Shell ------------------------------------------------------------------------------- */

.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); height: 100vh; overflow: hidden; }
.side { height: 100vh; padding: 12px 10px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; scrollbar-width: none; }
.side::-webkit-scrollbar { display: none; }
.logo { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 8px; margin-bottom: 8px; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.02em; color: var(--ink); }
.logo:hover { color: var(--ink); }
.logo i { display: grid; grid-template-columns: repeat(2, 8px); grid-template-rows: repeat(2, 8px); }
.logo i b:nth-child(1), .logo i b:nth-child(4) { background: var(--accent); border-radius: 8px 0 8px 0; }
.logo i b:nth-child(2) { background: var(--ink); border-radius: 0 8px 0 0; }
.logo i b:nth-child(3) { background: var(--ink); border-radius: 0 0 0 8px; }
.logo .pill { font-family: var(--sans); font-size: 11.5px; font-weight: 600; letter-spacing: 0; padding: 2px 7px; border-radius: 10px; background: var(--accent-light); color: var(--ink); }
.logo.small { margin: 0; font-size: 16px; min-height: 0; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 8px; border-radius: 5px; font-size: 13.5px; font-weight: 500; white-space: nowrap; color: var(--ink); }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--paper); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.nav svg { flex: 0 0 16px; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.nav a[aria-current="page"] svg { color: var(--ink); }
.nav .badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); font-size: 11.5px; font-weight: 600; display: inline-grid; place-items: center; }
.group { margin: 14px 8px 4px; font-size: 12px; color: var(--faint); }
.sbottom { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.cta { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; border-radius: 5px; background: var(--ink); color: var(--white); font-weight: 600; font-size: 13.5px; }
.cta:hover { background: #2F3238; color: var(--white); }
.acct { display: flex; align-items: center; gap: 9px; padding: 8px 4px 2px; border-top: 1px solid var(--line); }
.av { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; text-transform: uppercase; }
.who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.who b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.out { border: 0; background: none; padding: 4px; font-size: 12.5px; white-space: nowrap; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.out:hover { color: var(--ink); }

.stage { min-width: 0; height: 100vh; padding: 10px 10px 10px 0; }
.panel { position: relative; height: 100%; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.phead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 20px; padding: 18px 24px 16px; border-bottom: 1px solid var(--line-in); }
.ptitle { min-width: 0; }
.phead h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 28px; letter-spacing: -0.025em; line-height: 1.05; }
.phead p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.phead p:empty { display: none; }
.pact { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 10px; }
.pbody { flex: 1 1 auto; min-height: 0; overflow: auto; scrollbar-width: none; padding: 18px 24px 24px; display: flex; flex-direction: column; gap: 14px; transition: opacity .15s ease; }
.pbody::-webkit-scrollbar { display: none; }
.pbody.loading { opacity: .55; pointer-events: none; }

.mtop, .scrim { display: none; }

/* Controls ----------------------------------------------------------------------------- */

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 6px; background: var(--line-in); }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(58, 61, 68, .12); }
.seg .n { font-weight: 500; color: var(--faint); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 13px; border-radius: 4px; border: 1px solid var(--edge); background: var(--paper); color: var(--ink); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--white); }
.btn.dark:hover { background: #2F3238; color: var(--white); }
.btn.danger { border-color: var(--danger-line); color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn[disabled] { color: var(--faint); border-color: var(--line); background: var(--paper); cursor: default; }
.ulink { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.tbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.search { position: relative; flex: 1 1 220px; max-width: 320px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }
.search input { width: 100%; height: 36px; padding: 0 12px 0 33px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); color: var(--ink); font-size: 13.5px; }
.search input:focus, .field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--digits); }
.tcount { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 3px; border: 1px solid var(--line); background: var(--white); font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--ink); }
.tag.ok { border-color: transparent; background: var(--ok-bg); color: var(--ok); }
.tag.warn { border-color: transparent; background: var(--warn-bg); color: var(--warn); }
.tag.danger { border-color: transparent; background: var(--danger-bg); color: var(--danger); }
.tag.accent { border-color: transparent; background: var(--accent-light); color: var(--ink); }
.tag.plain { background: var(--box); border-color: transparent; color: var(--text); }
.dot { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 1; }
.dot.ok { background: var(--line-in); color: var(--ink); }
.dot.warn { background: var(--warn-bg); color: var(--warn); }
.dot.wait { background: var(--accent-light); color: var(--ink); }

/* Tiles, boxes ------------------------------------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { display: block; background: var(--box); border: 1px solid var(--line-in); border-radius: 6px; padding: 12px 16px; color: var(--ink); min-width: 0; }
a.tile:hover { border-color: var(--edge-soft); color: var(--ink); }
.tile span { display: block; font-size: 13px; color: var(--muted); }
.tile b { display: block; margin-top: 5px; font-family: var(--sans); font-weight: 600; font-size: 24px; letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile b small { font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.tile em { display: block; margin-top: 4px; font-style: normal; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box { background: var(--box); border: 1px solid var(--line-in); border-radius: 6px; padding: 16px 18px; min-width: 0; }
.box h2 { margin: 0; font-size: 15px; font-weight: 600; }
.box .sub { margin: 4px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.bhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; min-height: 30px; margin-bottom: 10px; }
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
.duo.wide { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.note { margin: 0; padding: 10px 12px; border-radius: 6px; background: var(--accent-light); font-size: 13px; line-height: 1.5; color: var(--ink); }
.note.warn { background: var(--warn-bg); color: #5C4510; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line-in); font-size: 13.5px; }
.line:first-of-type { border-top: 0; }
.line span:first-child { color: var(--muted); }
.line .mono { white-space: nowrap; }
.sact { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.funnel { display: flex; flex-direction: column; gap: 8px; }
.fstep { display: grid; grid-template-columns: 140px minmax(0, 1fr) 70px 52px; gap: 12px; align-items: center; font-size: 13.5px; }
.fstep i { display: block; height: 8px; border-radius: 4px; background: var(--line-in); position: relative; overflow: hidden; }
.fstep i b { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--series-1); }
.fstep em { font-style: normal; color: var(--muted); font-size: 12.5px; }

/* Tables ------------------------------------------------------------------------------- */

.tcard { background: var(--white); border: 1px solid var(--line-in); border-radius: 6px; overflow: hidden; min-width: 0; }
.trow { display: grid; gap: 12px; align-items: center; min-height: 40px; padding: 0 14px; border-top: 1px solid var(--row); font-size: 13.5px; }
.trow > * { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow.head { min-height: 34px; border-top: 0; background: var(--paper); color: var(--muted); font-size: 12.5px; font-weight: 500; }
.trow.click { cursor: pointer; transition: background-color .12s ease; }
.trow.click:hover { background: var(--row-hover); }
.trow.click:focus-visible { outline: 2px solid var(--digits); outline-offset: -2px; }
.trow b { font-weight: 600; }
.trow small { color: var(--faint); font-size: 12px; }
.trow .two { display: flex; flex-direction: column; line-height: 1.25; padding: 4px 0; }
.trow .two small { overflow: hidden; text-overflow: ellipsis; }
.tfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; padding: 0 14px; border-top: 1px solid var(--row); background: var(--paper); font-size: 13px; color: var(--muted); }
.pg { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.pgb { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); color: var(--ink); font-size: 15px; cursor: pointer; }
.pgb[disabled] { color: var(--edge-soft); cursor: default; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px 24px; text-align: center; }
.empty b { font-size: 15px; font-weight: 600; }
.empty p { margin: 6px 0 0; max-width: 520px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.empty .acts { display: flex; gap: 8px; margin-top: 14px; }
.sbar { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.sbar i { display: block; height: 6px; border-radius: 3px; background: var(--line-in); position: relative; overflow: hidden; }
.sbar i b { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--series-1); }
.sbar em { font-style: normal; font-size: 12.5px; color: var(--muted); text-align: right; }

/* Charts ------------------------------------------------------------------------------- */

.chart { position: relative; width: 100%; min-height: 40px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line-in); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: default; }
.chart .col:hover .mark, .chart .col:focus .mark { filter: brightness(1.08); }
.chart .col:focus { outline: none; }
.chart .col:focus .hit { fill: rgba(90, 147, 214, .08); }
.tip { position: absolute; z-index: 5; pointer-events: none; min-width: 140px; padding: 8px 10px; border-radius: 6px; background: var(--white); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(58, 61, 68, .14); font-size: 12.5px; }
.tip .d { color: var(--muted); margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.tip .row i { width: 10px; height: 2px; border-radius: 1px; flex: 0 0 10px; }
.tip .row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .row span { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; }
.ctable { margin-top: 8px; font-size: 12.5px; }
.ctable summary { cursor: pointer; color: var(--muted); width: max-content; }
.ctable table { width: 100%; margin-top: 6px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ctable th, .ctable td { padding: 4px 6px; border-top: 1px solid var(--line-in); text-align: right; font-weight: 400; }
.ctable th:first-child, .ctable td:first-child { text-align: left; }
.ctable th { color: var(--muted); }
.ctable .scroller { max-height: 240px; overflow: auto; scrollbar-width: thin; }
.chartnote { margin: 0; padding: 22px 0; text-align: center; font-size: 13px; color: var(--muted); }

/* Side sheet ----------------------------------------------------------------------------- */

.scrim2 { position: absolute; inset: 0; z-index: 20; background: rgba(58, 61, 68, .18); animation: fadein .2s ease; }
.sheet { position: absolute; top: 0; right: 0; bottom: 0; z-index: 21; width: 480px; max-width: 100%; display: flex; flex-direction: column; background: var(--paper); border-left: 1px solid var(--line); box-shadow: -14px 0 34px rgba(58, 61, 68, .12); animation: sheetin .26s cubic-bezier(.22, 1, .36, 1); }
.sheet.wide { width: 640px; }
.shead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-in); }
.shead .lbl { margin: 0; font-size: 12.5px; color: var(--muted); }
.shead h2 { margin: 3px 0 0; font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -0.02em; line-height: 1.1; overflow-wrap: anywhere; }
.shead .sub2 { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.xbtn { flex: 0 0 32px; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); color: var(--ink); cursor: pointer; font-size: 16px; }
.sbody { flex: 1 1 auto; overflow: auto; scrollbar-width: none; padding: 0 20px 10px; }
.sbody::-webkit-scrollbar { display: none; }
.ssec { padding: 14px 0; border-bottom: 1px solid var(--line-in); }
.ssec:last-child { border-bottom: 0; }
.ssec h3 { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kv { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 13.5px; line-height: 1.45; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.slist { display: flex; flex-direction: column; }
.slist > div, .slist > a { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding: 6px 0; border-top: 1px solid var(--line-in); font-size: 13.5px; }
.slist > :first-child { border-top: 0; }
.slist .l { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.slist .l small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.slist .rgt { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.sfoot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line-in); background: var(--box); }
pre.json { margin: 0; padding: 10px 12px; border-radius: 6px; background: var(--white); border: 1px solid var(--line-in); font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.copyline { display: flex; gap: 8px; align-items: flex-start; }
.copyline p { flex: 1 1 auto; margin: 0; padding: 10px 12px; border-radius: 6px; background: var(--white); border: 1px solid var(--line-in); font-size: 13.5px; line-height: 1.5; }

/* Forms --------------------------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.field > span em { font-style: normal; font-weight: 400; color: var(--faint); }
.field input, .field textarea, .field select { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--edge-soft); border-radius: 4px; background: var(--white); color: var(--ink); font-size: 13.5px; }
.field textarea { resize: vertical; line-height: 1.5; }
.field textarea.code { font-family: var(--mono); font-size: 12.5px; }
.field small { font-size: 12px; color: var(--muted); }
.frow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.err { margin: 0; padding: 8px 10px; border-radius: 5px; background: var(--danger-bg); color: var(--danger); font-size: 13px; }

/* Editor -------------------------------------------------------------------------------- */

.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.editor .preview { background: var(--white); border: 1px solid var(--line-in); border-radius: 6px; padding: 18px 22px; min-height: 420px; font-size: 15px; line-height: 1.6; color: var(--text); overflow-wrap: anywhere; }
.preview h1, .preview h2, .preview h3 { color: var(--ink); font-family: var(--display); letter-spacing: -0.02em; line-height: 1.15; }
.preview h1 { font-size: 30px; margin: 0 0 12px; }
.preview h2 { font-size: 22px; margin: 22px 0 8px; }
.preview h3 { font-size: 18px; margin: 18px 0 6px; }
.preview p { margin: 0 0 12px; }
.preview img { max-width: 100%; border-radius: 6px; }
.preview pre { padding: 10px 12px; background: var(--box); border-radius: 6px; white-space: pre-wrap; font-family: var(--mono); font-size: 13px; }
.preview code { font-family: var(--mono); font-size: 13px; background: var(--box); padding: 1px 4px; border-radius: 3px; }
.preview pre code { background: none; padding: 0; }
.preview table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 14px; }
.preview th, .preview td { text-align: left; vertical-align: top; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line-in); }
.preview th { color: var(--ink); font-weight: 600; }
.preview blockquote { margin: 0 0 12px; padding-left: 14px; border-left: 3px solid var(--accent); color: var(--muted); }
.preview a { text-decoration: underline; text-underline-offset: 3px; }
.preview .cover { width: 100%; max-height: 240px; object-fit: cover; margin-bottom: 14px; }
.editbar { display: flex; flex-wrap: wrap; gap: 6px; }

/* Login, toast, dialog ---------------------------------------------------------------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.lcard { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 26px 26px 22px; }
.lcard .logo { padding: 0; margin: 0 0 18px; }
.lcard h1 { margin: 0; font-family: var(--display); font-size: 24px; letter-spacing: -0.02em; }
.lcard p { margin: 6px 0 16px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.lcard .qr { display: block; width: 184px; height: 184px; margin: 4px auto 10px; background: var(--white); border: 1px solid var(--line-in); border-radius: 6px; padding: 8px; }
.lcard .secret { display: block; margin: 0 0 14px; text-align: center; font-family: var(--mono); font-size: 12.5px; letter-spacing: .06em; color: var(--text); overflow-wrap: anywhere; }
.lcard .btn { width: 100%; min-height: 40px; margin-top: 4px; }
.lcard .code input { font-family: var(--mono); font-size: 20px; letter-spacing: .3em; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; max-width: min(560px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 6px; background: var(--ink); color: var(--white); font-size: 13.5px; box-shadow: 0 8px 24px rgba(58, 61, 68, .2); }
.toast.bad { background: var(--danger); }
.dlg-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(58, 61, 68, .28); display: grid; place-items: center; padding: 16px; animation: fadein .15s ease; }
.dlg { width: 100%; max-width: 460px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 44px rgba(58, 61, 68, .22); }
.dlg h2 { margin: 0; padding: 18px 20px 0; font-family: var(--display); font-size: 21px; letter-spacing: -0.02em; }
.dlg .dbody { padding: 10px 20px 16px; font-size: 13.5px; line-height: 1.5; color: var(--text); }
.dlg .dbody > p { margin: 0 0 12px; }
.dlg .dfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line-in); background: var(--box); border-radius: 0 0 8px 8px; }

@keyframes sheetin { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Narrow screens ------------------------------------------------------------------------ */

@media (max-width: 1180px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .duo, .duo.wide, .editor { grid-template-columns: minmax(0, 1fr); }
  .hide-md { display: none !important; }
}

@media (max-width: 860px) {
  .app { display: block; height: auto; min-height: 100vh; overflow: visible; }
  .mtop { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px; position: sticky; top: 0; z-index: 30; background: var(--fog); border-bottom: 1px solid var(--line); }
  .burger { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); cursor: pointer; }
  .side { position: fixed; top: 0; left: 0; bottom: 0; z-index: 41; width: 248px; background: var(--fog); transform: translateX(-100%); transition: transform .22s ease; }
  .side.open { transform: none; box-shadow: 8px 0 24px rgba(58, 61, 68, .12); }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(58, 61, 68, .25); }
  .stage { height: auto; padding: 10px 16px 16px; }
  .panel { height: auto; overflow: visible; }
  .phead { padding: 16px; }
  .phead h1 { font-size: 24px; }
  .pbody { overflow: visible; padding: 14px 16px 18px; }
  .sheet, .sheet.wide { position: fixed; width: 100%; }
  .scrim2 { position: fixed; }
  .hide-sm { display: none !important; }
  /* Rows become small cards: the first cell on its own line, the rest after it. */
  .trow.head { display: none; }
  .trow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 0; padding: 9px 14px; }
  .trow > * { flex: 0 1 auto; max-width: 100%; }
  .trow > :first-child { flex: 1 0 100%; }
  .trow .r { text-align: left; }
  .trow .sbar { width: 120px; }
  .frow { grid-template-columns: minmax(0, 1fr); }
  .fstep { grid-template-columns: 110px minmax(0, 1fr) 56px; }
  .fstep em { display: none; }
}

@media (max-width: 560px) {
  .tiles, .tiles.three { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .scrim2, .dlg-scrim { animation: none; }
  .side, .trow.click, .pbody { transition: none; }
}
