/* ---------------------------------------------------------------------------
   Application styles
   A printed, workshop-like look: paper ground, ink type, hard offset shadows,
   one warm accent. No gradients, no glows.
--------------------------------------------------------------------------- */
:root {
  --paper: #f4f1ea;
  --card: #fffdf8;
  --card-2: #efebe1;
  --ink: #16140f;
  --ink-2: #3f3b33;
  --muted: #736d61;
  --line: #ddd6c7;
  --line-2: #c7bfad;
  --accent: #bf3f26;        /* vermillion */
  --accent-ink: #8f2f1c;
  --green: #2c6049;
  --blue: #2a4d7a;
  --gold: #a9762a;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 3px 3px 0 var(--ink);
  --shadow-soft: 0 2px 10px rgba(22, 20, 15, .08);
  --font: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--paper); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2.1rem; } h2 { font-size: 1.6rem; } h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code, pre { font-family: var(--mono); font-size: .88em; }
code { background: var(--card-2); padding: 1px 5px; border-radius: 4px; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.container-wide { max-width: 1600px; margin: 0 auto; padding: 0 20px; }
.page { padding-block: 34px 72px; min-height: 60vh; }
.muted { color: var(--muted); } .small { font-size: .86em; } .center { text-align: center; }
.mt { margin-top: 24px; } .mb { margin-bottom: 24px; } .mt-sm { margin-top: 12px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }

/* Header ------------------------------------------------------------------ */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--paper); border-bottom: 1px solid var(--line-2); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 700; font-size: 1.12rem; color: var(--ink); letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; flex: none; object-fit: contain; }
/* The uploaded logo carries the name itself, so it gets the room the mark and the name shared. */
.brand-logo { display: block; height: 38px; width: auto; max-width: 240px; object-fit: contain; }
@media (max-width: 640px) { .brand-logo { height: 32px; max-width: 180px; } }

/* Every control in the nav is one height, one type size and one corner – links, the button, the
   wallet, the profile menu and the language picker line up as a single row. Plain links are
   borderless; the three things that carry state (wallet, profile, language) are outlined chips. */
.nav { display: flex; gap: 4px; align-items: center; --nav-h: 36px; }
.nav > a, .nav-menu > summary, .nav .lang-current { display: inline-flex; align-items: center; gap: 7px;
  height: var(--nav-h); padding: 0 12px; border-radius: var(--radius); border: 1px solid transparent;
  color: var(--ink-2); font-family: inherit; font-weight: 500; font-size: .92rem; line-height: 1; white-space: nowrap; }
.nav > a:hover { color: var(--ink); background: var(--card-2); text-decoration: none; }
.nav > a.btn { color: #fff; border-color: var(--accent-ink); font-weight: 600; margin: 0 4px; }
.nav > a.btn:hover { transform: none; box-shadow: none; background: var(--accent-ink); }
.nav-svg { width: 18px; height: 18px; flex: none; }
.nav > a.nav-icon { width: var(--nav-h); padding: 0; justify-content: center; }
.nav > a.nav-credits, .nav-menu > summary, .nav .lang-current { border-color: var(--line-2); background: var(--card); }
.nav > a.nav-credits { font-variant-numeric: tabular-nums; }
.nav > a.nav-credits .nav-svg { color: var(--accent); width: 16px; height: 16px; }
.nav > a.nav-credits:hover, .nav-menu > summary:hover, .nav-menu[open] > summary, .nav .lang-current:hover { border-color: var(--ink); color: var(--ink); background: var(--card); }
.nav-user img { width: 22px; height: 22px; border-radius: 50%; margin-left: -4px; }
.nav-toggle { display: none; background: var(--card); border: 1px solid var(--line-2); color: var(--ink); border-radius: var(--radius); padding: 5px 10px; font-size: 1.05rem; }
@media (max-width: 880px) {
  .nav { display: none; position: absolute; top: 62px; left: 0; right: 0; background: var(--card); border-bottom: 1px solid var(--line-2); flex-direction: column; align-items: stretch; padding: 10px 20px; box-shadow: var(--shadow-soft); }
  body.nav-open .nav { display: flex; }
  .nav-toggle { display: block; }
}

/* The profile menu is a <details>, so it opens without JavaScript; app.js only closes it again
   on a click elsewhere. */
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; cursor: pointer; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-caret { font-size: .7rem; color: var(--muted); }
.nav-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 180px; padding: 6px;
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  display: flex; flex-direction: column; }
.nav-menu-list a { padding: 7px 10px; border-radius: var(--radius); color: var(--ink-2); font-size: .92rem; }
.nav-menu-list a:hover { background: var(--card-2); color: var(--ink); text-decoration: none; }
@media (max-width: 880px) {
  .nav-menu-list { position: static; box-shadow: none; border: 0; padding: 0 0 0 12px; background: none; min-width: 0; }
  .nav > a.nav-credits, .nav > a.nav-icon, .nav > a.btn, .nav-menu > summary { align-self: flex-start; }
  .nav > a.btn { margin: 4px 0; }
}

/* Buttons ----------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius); border: 1.5px solid var(--ink); background: var(--card); color: var(--ink); font-family: inherit; font-weight: 600; font-size: .93rem; cursor: pointer; transition: transform .1s, box-shadow .1s, background .1s; white-space: nowrap; }
.btn:hover { text-decoration: none; background: #fff; transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(0, 0); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--accent); border-color: var(--accent-ink); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); box-shadow: 2px 2px 0 var(--ink); }
.btn-ghost { border-color: var(--line-2); background: transparent; font-weight: 500; }
.btn-ghost:hover { box-shadow: none; transform: none; background: var(--card-2); }
.btn-danger { border-color: var(--accent-ink); color: var(--accent-ink); background: #fff; }
.btn-success { border-color: var(--green); color: #fff; background: var(--green); }
.btn-sm { padding: 6px 12px; font-size: .84rem; border-width: 1px; }
.btn-lg { padding: 14px 26px; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* Surfaces ---------------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 22px; }
.card-sm { padding: 15px; }
.card h2, .card h3 { margin-top: 0; }
.stat { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 16px 18px; }
.stat .value { font-family: var(--display); font-size: 1.65rem; font-weight: 600; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .83rem; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: .74rem; font-weight: 600; background: var(--card-2); border: 1px solid var(--line-2); color: var(--ink-2); letter-spacing: .02em; }
.badge-success { background: #e4efe6; color: var(--green); border-color: #bcd6c3; }
.badge-warn { background: #f6ead2; color: var(--gold); border-color: #e2cda3; }
.badge-danger { background: #f7e2dd; color: var(--accent-ink); border-color: #e5bfb4; }
.badge-accent { background: #ece6f0; color: var(--blue); border-color: #c9d3e2; }

/* Charts (admin traffic) ---------------------------------------------------
   One hue for the marks, hairline grid, labels in text colours. The bars are
   plain HTML so a long page URL stays readable text instead of clipped SVG. */
.chart { margin: 0; }
/* The plot stretches to the width it is given and keeps a readable height; the strokes hold their
   thickness (non-scaling-stroke) and every label is HTML on top, so nothing is squeezed flat on a
   phone. Positions are percentages, which is exactly how the SVG maps its own coordinates here. */
.chart-plot { position: relative; height: 260px; margin-left: 46px; }
.chart-plot svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-axis { position: absolute; left: -46px; width: 40px; text-align: right; transform: translateY(-50%);
  font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--card); pointer-events: none; }
.chart-flag { position: absolute; transform: translate(-50%, -160%); font-size: .78rem; font-weight: 600;
  color: var(--ink); white-space: nowrap; pointer-events: none; }
.chart-flag-end { transform: translate(-105%, -60%); }
.chart-dates { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted);
  margin: 4px 0 0 46px; }
/* The marks sit in the plot's own box, so a percentage here is the same percentage the SVG used. */
.chart-readout { font-size: .84rem; color: var(--ink-2); margin-bottom: 8px; min-height: 1.3em; }
.chart-readout b { font-weight: 600; }
.chart-cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ink); opacity: 0;
  pointer-events: none; }
.chart-cursor.on { opacity: .45; }
.chart-cursor-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--card); opacity: 0; }
.chart-cursor.on .chart-cursor-dot { opacity: 1; }
.chart-plot { cursor: crosshair; }
@media (max-width: 620px) { .chart-plot { height: 200px; } }
.chart-table { margin-top: 10px; }
.chart-table summary { font-size: .8rem; color: var(--muted); cursor: pointer; }
.chart-table .table-wrap { max-height: 260px; overflow-y: auto; margin-top: 8px; }

.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 11rem) 1fr auto; gap: 10px; align-items: center; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; color: var(--ink-2); }
.bar-track { background: var(--card-2); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.bar-value { font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
@media (max-width: 620px) {
  .bar-list li { grid-template-columns: 1fr auto; }
  .bar-list .bar-track { grid-column: 1 / -1; }
}

/* Forms ------------------------------------------------------------------- */
label { display: block; font-size: .83rem; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; letter-spacing: .01em; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--line-2); color: var(--ink); border-radius: var(--radius); padding: 10px 12px; font-size: .94rem; font-family: inherit; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 2px 2px 0 var(--line-2); }
input:disabled, select:disabled, textarea:disabled { background: var(--card-2); color: var(--muted); }
textarea { min-height: 104px; resize: vertical; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23736d61' stroke-width='1.6' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: .93rem; color: var(--ink); cursor: pointer; font-weight: 400; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.help { font-size: .8rem; color: var(--muted); margin-top: 5px; font-weight: 400; }
.form-narrow { max-width: 440px; margin: 0 auto; }

/* Flash ------------------------------------------------------------------- */
.flash { padding: 11px 15px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; border-left-width: 4px; font-size: .93rem; }
.flash-success { background: #e8f1ea; border-color: #9cc0a8; color: #1f4a38; }
.flash-error { background: #fae9e4; border-color: #d6a294; color: var(--accent-ink); }
.flash-info { background: #eeeae2; border-color: var(--line-2); color: var(--ink-2); }

/* Tables ------------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--card); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; background: var(--card-2); }
.table tr:hover td { background: #fffefb; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line-2); border-radius: var(--radius-lg); }

/* Tool cards -------------------------------------------------------------- */
.tool-card { display: block; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 18px; color: var(--ink); transition: transform .12s, box-shadow .12s; }
.tool-card:hover { text-decoration: none; transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.tool-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tool-icon { font-size: 1.6rem; line-height: 1; width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius); }
.tool-icon-lg { font-size: 2.6rem; width: 78px; height: 78px; border-radius: var(--radius-lg); }
.tool-price { font-weight: 700; font-size: .88rem; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.tool-price.free { color: var(--green); }
.tool-card h3 { margin: 0 0 3px; font-size: 1.05rem; }
.tool-card p { color: var(--muted); font-size: .88rem; margin: 0 0 10px; min-height: 2.5em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-card-meta { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; }
.tool-card-author { margin-top: 5px; }
.tool-card.painted { background: var(--tc-bg); color: var(--tc-ink); border-color: rgba(0,0,0,.12); }
.tool-card.painted p, .tool-card.painted .muted { color: inherit; opacity: .78; }
.tool-card.painted .tool-icon { background: rgba(255,255,255,.72); border-color: rgba(0,0,0,.08); }
.tool-card.painted .tool-price { color: inherit; background: rgba(255,255,255,.22); padding: 2px 8px; border-radius: 999px; }
.stars { color: var(--gold); letter-spacing: 1px; }

/* Plans ------------------------------------------------------------------- */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(225px, 1fr)); gap: 18px; }
.plan { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 24px; position: relative; display: flex; flex-direction: column; }
.plan.highlight { border: 1.5px solid var(--ink); box-shadow: var(--shadow); }
.plan .plan-badge { position: absolute; top: -11px; left: 22px; background: var(--ink); color: var(--paper); font-size: .7rem; font-weight: 600; padding: 3px 10px; border-radius: 3px; letter-spacing: .06em; text-transform: uppercase; }
.plan h3 { font-size: 1.15rem; }
.plan .price { font-family: var(--display); font-size: 2.1rem; font-weight: 600; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: .85rem; font-weight: 400; color: var(--muted); font-family: var(--font); }
.plan ul { list-style: none; padding: 0; margin: 16px 0 20px; color: var(--ink-2); font-size: .9rem; flex: 1; }
.plan li { padding: 5px 0 5px 20px; position: relative; border-bottom: 1px solid var(--line); }
.plan li::before { content: '·'; position: absolute; left: 4px; color: var(--accent); font-weight: 700; font-size: 1.3em; line-height: 1; }

/* Tabs -------------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 13px; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; font-family: inherit; }
.tabs a.active, .tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* Runner ------------------------------------------------------------------ */
.runner-frame { width: 100%; height: 72vh; min-height: 470px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; }

/* Builder ----------------------------------------------------------------- */
.mismatch { border-color: var(--accent); border-left: 3px solid var(--accent); }
.mismatch ul { margin: 0 0 10px; padding-left: 18px; color: var(--ink-2); }
.mismatch li { padding: 2px 0; }

.builder { display: grid; grid-template-columns: 335px 1fr; gap: 16px; height: calc(100vh - 62px - 40px); min-height: 620px; }
.builder-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.builder-main { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.builder-tabs { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.builder-tabs button { background: var(--card); border: 1px solid var(--line-2); color: var(--ink-2); padding: 6px 12px; border-radius: var(--radius); font-weight: 600; font-size: .84rem; cursor: pointer; font-family: inherit; }
.builder-tabs button:hover { background: #fff; }
.builder-tabs button.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.builder-pane { flex: 1; min-height: 0; display: none; }
.pane-switch { display: inline-flex; align-self: flex-start; gap: 2px; padding: 3px; margin-bottom: 10px; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); flex-shrink: 0; }
.pane-switch button { background: transparent; border: 0; color: var(--ink-2); padding: 5px 12px; border-radius: calc(var(--radius) - 2px); font-weight: 600; font-size: .84rem; cursor: pointer; font-family: inherit; }
.pane-switch button:hover { color: var(--ink); }
.pane-switch button.active { background: var(--ink); color: var(--paper); }
.builder-pane.active { display: flex; flex-direction: column; }
.builder-pane textarea.code { flex: 1; width: 100%; min-height: 0; resize: none; background: #fffdf8; border-radius: var(--radius-lg); }

/* Code editor: a textarea with a coloured copy of the same text painted behind it. The two boxes
   need the same metrics down to the pixel, or the caret drifts away from the letters – so every
   property that decides where a character lands is set on both at once. */
.builder-pane textarea.code, .editor-paint {
  font-family: var(--mono); font-size: 13px; line-height: 1.6; tab-size: 2;
  white-space: pre; letter-spacing: normal; word-spacing: normal;
  padding: 10px 12px; border-width: 1px; border-style: solid; border-radius: var(--radius-lg);
}
.editor { position: relative; flex: 1; min-height: 0; }
.editor > .editor-paint, .editor > textarea.code { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; }
/* Border of its own colour would draw twice: the textarea on top carries the visible one, this
   keeps only its width so both content boxes start in the same place. */
.editor-paint { overflow: hidden; background: #fffdf8; color: var(--ink); border-color: transparent; }
.editor-paint > code { background: none; padding: 0; border-radius: 0; font: inherit; }
.editor > textarea.code { overflow: auto; background: transparent; color: transparent; caret-color: var(--ink); }
/* Translucent, because the letters being selected are painted on the layer underneath:
   an opaque selection would hide both them and their colour. */
.editor > textarea.code::selection { background: rgba(42, 77, 122, .26); color: transparent; }

.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--muted); font-style: italic; }
.token.punctuation, .token.operator { color: #8a8375; }
.token.tag, .token.keyword, .token.selector, .token.atrule, .token.rule, .token.symbol { color: var(--accent-ink); }
.token.attr-name, .token.regex, .token.variable, .token.entity, .token.url { color: var(--gold); }
.token.string, .token.attr-value, .token.char, .token.inserted { color: var(--green); }
.token.number, .token.boolean, .token.constant, .token.property, .token.unit { color: var(--blue); }
.token.function, .token.class-name, .token.builtin { color: #6a3f9e; }
.token.deleted { color: var(--accent); }
.token.important, .token.bold { font-weight: 600; }
.token.italic { font-style: italic; }
.builder-pane iframe { flex: 1; width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; }
.chat { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding: 13px; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); }
.msg { padding: 9px 12px; border-radius: var(--radius); font-size: .87rem; white-space: pre-wrap; word-break: break-word; max-width: 100%; }
.msg-user { background: var(--ink); color: var(--paper); align-self: flex-end; border-bottom-right-radius: 2px; }
.msg-ai { background: var(--card-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 2px; }
.msg-sys { color: var(--accent-ink); background: #fae9e4; border: 1px solid #e5bfb4; font-size: .84rem; }
.chat-form textarea { min-height: 76px; font-size: .9rem; }
.chat-empty { color: var(--muted); font-size: .87rem; }
.chat-empty ul { padding-left: 0; margin: 10px 0 0; list-style: none; }
.chat-empty li { cursor: pointer; padding: 6px 10px; border: 1px dashed var(--line-2); border-radius: var(--radius); margin-bottom: 6px; color: var(--ink-2); }
.chat-empty li:hover { border-style: solid; background: #fff; color: var(--ink); }
.typing::after { content: ''; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* attachments in the chat ---------------------------------------------------- */
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 6px 4px 8px;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--card-2); font-size: .78rem; }
.attach-chip.is-pending { opacity: .6; }
.attach-chip.is-error { border-color: #e5bfb4; background: #fae9e4; color: var(--accent-ink); }
.attach-icon { flex: none; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 11rem; }
.attach-size { color: var(--muted); font-size: .72rem; flex: none; }
.attach-remove { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 2px; }
.attach-remove:hover { color: var(--accent-ink); }
.chat-form.is-dropping textarea { border-color: var(--accent); background: #fffdf8; }
#attach-btn[disabled] { opacity: .45; cursor: not-allowed; }

/* "still working" bubble ---------------------------------------------------- */
.building { display: block; white-space: normal; min-width: 15rem; }
.building-line { display: flex; align-items: center; gap: 8px; }
.building-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.3s ease-in-out infinite; }
.building-time { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: .74rem; font-variant-numeric: tabular-nums; }
.building-note { color: var(--muted); font-size: .78rem; margin-top: 6px; }
.build-progress { display: block; height: 3px; margin-top: 9px; background: var(--line); border-radius: 2px; overflow: hidden; }
.build-progress span { display: block; height: 100%; width: 32%; border-radius: 2px; background: var(--accent); animation: slide 1.7s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(420%); } }
@keyframes pulse { 0%, 100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .building-dot, .build-progress span, .typing::after { animation: none; }
  .build-progress span { width: 100%; opacity: .35; }
}
/* A pane cut into sections (Settings): a list to jump with, and the sections scrolling beside it. */
.section-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 190px 1fr; gap: 14px; }
.section-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; padding-top: 2px; }
.section-nav a { display: block; padding: 7px 11px; border-radius: var(--radius); color: var(--ink-2); font-size: .88rem; font-weight: 500; border-left: 3px solid transparent; }
.section-nav a:hover { background: var(--card); text-decoration: none; color: var(--ink); }
.section-nav a.active { background: var(--card); border-left-color: var(--accent); color: var(--ink); font-weight: 600; }
.section-body { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-right: 4px; }
.section-body > form { display: flex; flex-direction: column; gap: 14px; }
.settings-section { scroll-margin-top: 8px; }
.settings-section > h3 { margin-bottom: 4px; }
.settings-section > h3 + p { margin-bottom: 16px; }
.settings-danger { border-color: #e5bfb4; }
.settings-danger > h3 { color: var(--accent-ink); }
.section-savebar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; background: var(--paper); border-top: 1px solid var(--line-2); margin-top: auto; }

/* Design tab: the choices on the left, the tool as it will look on the right. */
.design { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 14px; }
.design-panel { display: flex; flex-direction: column; min-height: 0; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); overflow: hidden; }
.design-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 0; }
.design-intro { padding: 10px 16px 4px; margin: 0; }
.design-group { border-bottom: 1px solid var(--line); padding: 0 16px; }
.design-group:last-child { border-bottom: 0; }
.design-group > summary { cursor: pointer; list-style: none; padding: 13px 0; font-weight: 600; display: flex; flex-direction: column; gap: 1px; position: relative; padding-right: 22px; }
.design-group > summary::-webkit-details-marker { display: none; }
.design-group > summary::after { content: '▸'; position: absolute; right: 2px; top: 13px; color: var(--muted); transition: transform .15s; }
.design-group[open] > summary::after { transform: rotate(90deg); }
.design-group > summary small { font-weight: 400; color: var(--muted); font-size: .78rem; }
.design-group[open] { padding-bottom: 12px; }
.dfield { margin-bottom: 14px; }
.dfield > label:first-child { font-size: .8rem; }
.dfield[hidden] { display: none; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 999px; font-size: .8rem; font-weight: 500; color: var(--ink-2); background: #fff; transition: background .12s, color .12s, border-color .12s; }
.seg label:hover span { border-color: var(--ink-2); }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); padding: 0; border: 0; background: none; }
.range-row output { min-width: 4.2em; text-align: right; font-family: var(--mono); font-size: .8rem; color: var(--ink-2); }
.color-row { display: flex; align-items: center; gap: 6px; }
.color-row input[type="color"] { width: 38px; height: 34px; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; cursor: pointer; flex: none; }
.color-row.is-empty input[type="color"] { opacity: .35; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.color-row input[type="text"] { flex: 1; font-family: var(--mono); font-size: .85rem; }
.color-clear { border: 1px solid var(--line-2); background: #fff; border-radius: var(--radius); width: 30px; height: 34px; cursor: pointer; color: var(--muted); font-size: 1.05rem; }
.color-clear:hover { color: var(--accent-ink); border-color: var(--accent-ink); }
.color-row.is-empty .color-clear { visibility: hidden; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; font-weight: 500; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { position: relative; width: 36px; height: 20px; flex: none; border-radius: 999px; background: var(--line-2); transition: background .15s; }
.switch-ui::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.preset { display: flex; flex-direction: column; gap: 5px; padding: 5px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; cursor: pointer; font-family: inherit; text-align: left; }
.preset:hover { border-color: var(--ink-2); }
.preset.active { border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.preset-swatch { display: grid; place-items: center; height: 54px; border-radius: 6px; }
.preset-swatch > span { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 5px; font-weight: 700; font-size: .8rem; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.preset-swatch i { display: inline-block; width: 14px; height: 8px; border-radius: 3px; }
.preset-name { font-size: .76rem; font-weight: 600; color: var(--ink-2); padding: 0 2px; }
.design-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { border: 1px dashed var(--line-2); background: #fff; border-radius: var(--radius); padding: 5px 9px; font: inherit; font-size: .8rem; color: var(--ink-2); cursor: pointer; text-align: left; }
.chip:hover { border-style: solid; color: var(--ink); }
.design-actions { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line-2); background: var(--card-2); flex-wrap: wrap; }
#design-state { flex: 1; }
.design-actions-break { flex-basis: 100%; height: 0; }
.design-actions .btn { flex: 1; }
.linkish { border: 0; background: none; padding: 0; font-family: inherit; color: var(--accent-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
#design-state.is-dirty { color: var(--gold); font-weight: 600; }
.design-stage { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.design-devices { display: flex; gap: 3px; justify-content: center; }
.design-devices button { background: var(--card); border: 1px solid var(--line-2); color: var(--ink-2); padding: 4px 11px; border-radius: 999px; font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer; }
.design-devices button.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.design-frame { flex: 1; min-height: 0; display: flex; justify-content: center; background: repeating-linear-gradient(135deg, var(--card-2) 0 8px, var(--paper) 8px 16px); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 10px; overflow: auto; }
.design-frame iframe { flex: none; width: 100%; height: 100%; min-height: 0; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; transition: width .25s ease; }
.design-frame[data-device="phone"] iframe { width: 390px; }
.design-frame[data-device="tablet"] iframe { width: 820px; }
@media (max-width: 1280px) {
  .design { grid-template-columns: 1fr; }
  .design-stage { min-height: 60vh; }
}
@media (max-width: 760px) {
  .section-layout { grid-template-columns: 1fr; }
  .section-nav { flex-direction: row; flex-wrap: wrap; }
  .section-nav a { border-left: 0; border-bottom: 2px solid transparent; }
  .section-nav a.active { border-bottom-color: var(--accent); }
}
@media (max-width: 980px) {
  .builder { grid-template-columns: 1fr; height: auto; }
  .builder-side { order: 2; }
  .builder-main { min-height: 68vh; }
  .chat { max-height: 38vh; }
}

/* Footer ------------------------------------------------------------------ */
.footer { border-top: 1px solid var(--line-2); padding: 26px 0; color: var(--muted); font-size: .86rem; background: var(--card-2); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 15px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }

/* Misc -------------------------------------------------------------------- */
.hero-small { padding: 18px 0 6px; }
.hero-small h1 { font-size: 2.3rem; }
.breadcrumbs { font-size: .83rem; color: var(--muted); margin-bottom: 12px; }
pre.code-block { background: #fffdf8; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 13px; overflow-x: auto; font-size: .83rem; }
.progress { height: 7px; background: var(--card-2); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.filters { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 20px; }
.chip { padding: 5px 11px; border-radius: 3px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font-size: .84rem; }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip:hover { text-decoration: none; border-color: var(--ink); }

/* Guided tour ------------------------------------------------------------- */
.tour-block { position: fixed; inset: 0; z-index: 9000; cursor: default; }
.tour-ring { position: fixed; z-index: 9001; border-radius: var(--radius); pointer-events: none;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 9999px rgba(22, 20, 15, .58); transition: all .18s ease; }
.tour-ring.is-empty { box-shadow: 0 0 0 9999px rgba(22, 20, 15, .58); }
.tour-pop { position: fixed; z-index: 9002; width: min(340px, calc(100vw - 24px)); background: var(--card);
  border: 1px solid var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 16px 17px 13px; }
.tour-pop h3 { font-size: 1.05rem; margin: 0 0 6px; }
.tour-pop p { margin: 0 0 12px; font-size: .9rem; color: var(--ink-2); }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-count { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tour-btns { display: flex; gap: 6px; }
/* .btn sets display, which beats the browser's own rule for [hidden] */
.tour-btns [hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .tour-ring { transition: none; } }

/* Help page --------------------------------------------------------------- */
.help-page { max-width: 820px; margin: 0 auto; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; }
.help-toc a { color: var(--ink-2); }
.help-defs { margin: 0; }
.help-defs dt { font-weight: 600; margin-top: 14px; }
.help-defs dt:first-child { margin-top: 0; }
.help-defs dd { margin: 3px 0 0; color: var(--ink-2); }
.help-steps { margin: 0; padding-left: 20px; }
.help-steps li { margin-bottom: 10px; color: var(--ink-2); }
.help-list { margin: 0; padding-left: 20px; }
.help-list li { margin-bottom: 10px; color: var(--ink-2); }
.help-page section h2 { font-size: 1.35rem; }
.help-page section[id] { scroll-margin-top: 78px; }

/* Feedback on a tool ------------------------------------------------------ */
.fb-form { border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 12px; background: var(--card-2); }
.fb-kind { width: 170px; margin: 0; }
.fb-text { flex: 1; min-width: 0; margin: 0; }
@media (max-width: 560px) {
  .fb-form .row { flex-direction: column; align-items: stretch; }
  .fb-kind { width: auto; }
}
.fb-item { display: flex; gap: 14px; align-items: flex-start; border-top: 1px solid var(--line); padding: 14px 0; }
.fb-item.is-done .fb-body { color: var(--muted); }
.fb-item.is-hidden { opacity: .72; }
.fb-vote-form { margin: 0; flex: none; }
.fb-vote { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 50px; padding: 6px 4px;
  border: 1.5px solid var(--line-2); border-radius: var(--radius); background: var(--card); color: var(--ink-2);
  font-family: inherit; font-weight: 600; cursor: pointer; line-height: 1.1; }
.fb-vote:hover:not(:disabled) { border-color: var(--ink); background: #fff; }
.fb-vote:disabled { cursor: default; opacity: .6; }
.fb-vote.is-voted { border-color: var(--accent); color: var(--accent-ink); background: #fbeee9; }
.fb-arrow { font-size: .72rem; }
.fb-count { font-variant-numeric: tabular-nums; font-size: .95rem; }
.fb-main { flex: 1; min-width: 0; }
.fb-body { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; }
.fb-reply { margin-top: 9px; padding: 9px 11px; border-left: 3px solid var(--accent); background: var(--card-2); border-radius: 0 var(--radius) var(--radius) 0; }
.fb-actions { margin-top: 10px; gap: 6px; align-items: flex-start; }
.fb-actions form { margin: 0; }
.fb-actions details { margin: 0; }
.fb-actions summary { display: inline-flex; list-style: none; cursor: pointer; }
.fb-actions summary::-webkit-details-marker { display: none; }
.fb-actions details[open] { width: 100%; }

/* Private beta landing ----------------------------------------------------- */
.beta-page { background: var(--paper); }
.beta-wrap { min-height: 100vh; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; padding: 0 22px; }
.beta-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 0; }
.beta-main { flex: 1; padding: 36px 0 64px; }
.beta-kicker { display: inline-block; font-family: var(--mono); font-size: .74rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent-ink); border-bottom: 2px solid var(--accent); padding-bottom: 3px; margin-bottom: 26px; }
.beta-main h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); line-height: 1.04; letter-spacing: -.025em; margin: 0 0 20px; font-weight: 600; }
.beta-lead { font-size: 1.12rem; color: var(--ink-2); max-width: 34em; margin: 0 0 30px; }
.beta-points { list-style: none; margin: 0 0 36px; padding: 0; border-top: 1px solid var(--line); }
.beta-points li { border-bottom: 1px solid var(--line); padding: 13px 0 13px 26px; position: relative; color: var(--ink-2); }
.beta-points li::before { content: '—'; position: absolute; left: 0; color: var(--accent); }
.beta-points strong { color: var(--ink); }
.beta-cta { margin-bottom: 30px; }
.beta-request { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 24px; scroll-margin-top: 20px; }
.beta-request h2 { font-size: 1.4rem; margin: 0; }
.beta-request form { margin-top: 20px; }
.beta-request-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.beta-request .field { min-width: 0; }
.beta-request textarea { min-height: 120px; }
.beta-request .flash { margin-top: 20px; }
.beta-request a { overflow-wrap: anywhere; }
.beta-note { font-size: .9rem; color: var(--muted); max-width: 40em; margin: 14px 0 0; }
.beta-foot-note { font-size: .88rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 18px; margin: 0; }
.beta-bottom { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border-top: 1px solid var(--line-2); padding: 18px 0 26px; font-size: .84rem; color: var(--muted); }
.beta-bottom a { color: var(--muted); margin-left: 14px; }
@media (max-width: 560px) {
  .beta-request { padding: 18px; }
  .beta-request-row { grid-template-columns: 1fr; gap: 0; }
  .beta-main h1 br { display: none; }
  .beta-bottom a { margin: 0 14px 0 0; }
}

/* Invitations waiting for the signed-in person --------------------------- */
.invite-waiting { border-left: 3px solid var(--accent); }
.invite-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding: 12px 0 0; margin-top: 12px; }
.invite-row form { margin: 0; }

/* Trying a paid tool before buying it ------------------------------------- */
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--card-2); border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 10px 14px; font-size: .9rem; }
.preview-bar form { margin: 0; }
.runner-frame.is-preview { border-top-left-radius: 0; border-top-right-radius: 0; }

/* Language picker ---------------------------------------------------------
   A plain list of links behind a button: every language is a real address a
   crawler can follow, and it works with JavaScript off – the button only
   opens the list, the links do the rest. */
.lang-picker { position: relative; display: inline-block; }
.lang-current { background: none; border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 5px 10px; font: inherit; font-size: .85rem; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.4; }
.lang-current:hover { border-color: var(--ink); }
.lang-picker .lang-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  margin: 0; padding: 6px; list-style: none; min-width: 178px;
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); display: none; }
.lang-picker.open .lang-list { display: block; }
.lang-picker .lang-list a { display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius); font-size: .9rem; text-decoration: none; color: inherit; }
.lang-picker .lang-list a:hover { background: var(--card-2); }
.lang-picker .lang-list a.is-current { font-weight: 600; background: var(--card-2); }

/* On a phone the nav collapses into a menu, so there the picker sits in the flow of that menu
   instead of floating over the page. Outside the nav (the beta page) it stays a button. */
@media (max-width: 880px) {
  .nav .lang-picker { display: block; }
  .nav .lang-picker .lang-list { position: static; display: flex; flex-wrap: wrap; gap: 2px;
    box-shadow: none; border: 0; padding: 0; min-width: 0; background: none; }
  .nav .lang-current { display: none; }
  .nav .lang-picker .lang-list a { padding: 6px 8px; font-size: .85rem; }
}

/* The beta page has no nav, so the picker sits beside the sign-in button. */
.beta-top-right { display: inline-flex; align-items: center; gap: 10px; }
