/* LesS/KEY web app. Visual language mirrored from kaizenkodo.org
   (~/Repos/Identity/website/main.css): washi-paper cream, ocean blue, hanko red,
   Poppins / Inter / JetBrains Mono. Light, responsive, restrained. */

:root {
  --cream: #f4f0e8;
  --paper: #fbf8f2;
  --ink: #15181b;
  --muted: #6a675e;
  --line: #ddd6c6;
  --ocean: #1b4161;
  --ocean-2: #2f6286;
  --deep: #0a2540;
  --seal: #e23b2e;
  --disp: "Poppins", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --maxw: 1320px;
  --gutter: clamp(16px, 3.5vw, 48px);
  --radius: 16px;
}

/* Self-hosted fonts, bundled with the app so it makes NO external requests and
   talks to no third party (no Google Fonts, no CDN). Latin subset only. */
@font-face { font-family:"Poppins"; font-style:normal; font-weight:600; font-display:swap; src:url("./assets/fonts/Poppins-600.woff2") format("woff2"); }
@font-face { font-family:"Poppins"; font-style:normal; font-weight:700; font-display:swap; src:url("./assets/fonts/Poppins-700.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-style:normal; font-weight:400; font-display:swap; src:url("./assets/fonts/Inter-400.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-style:normal; font-weight:500; font-display:swap; src:url("./assets/fonts/Inter-500.woff2") format("woff2"); }
@font-face { font-family:"Inter"; font-style:normal; font-weight:600; font-display:swap; src:url("./assets/fonts/Inter-600.woff2") format("woff2"); }
@font-face { font-family:"JetBrains Mono"; font-style:normal; font-weight:400; font-display:swap; src:url("./assets/fonts/JetBrainsMono-400.woff2") format("woff2"); }
@font-face { font-family:"JetBrains Mono"; font-style:normal; font-weight:500; font-display:swap; src:url("./assets/fonts/JetBrainsMono-500.woff2") format("woff2"); }
/* Masked-secret font: dots glyphs so the real chars stay selectable/copyable.
   WebKit/Blink use -webkit-text-security; Firefox falls back to this font. */
@font-face { font-family:"text-security-disc"; font-display:swap; src:url("./assets/fonts/text-security-disc.woff2") format("woff2"); }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; overflow-x: hidden; overscroll-behavior-x: none; }

body {
  min-height: 100%;
  overflow-x: hidden;             /* no sideways pan; page is single column */
  overscroll-behavior-x: none;    /* kill horizontal rubber-band / swipe-nav */
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    linear-gradient(rgba(27, 65, 97, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 65, 97, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gutter); }

/* Header */
.site {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244, 240, 232, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 14px; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.enso { width: 36px; height: 36px; display: block; flex: none; object-fit: contain; }
.wordmark { font-family: var(--disp); font-weight: 700; font-size: 22px; color: var(--ocean); letter-spacing: -0.01em; }
.tagline { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.nav-spacer { flex: 1; }
/* Always-visible link back to the main Kaizenkodo site. */
.backlink { display: inline-flex; align-items: center; gap: 5px; flex: none; font-family: var(--mono); font-size: 12px; letter-spacing: 0.03em; color: var(--muted); text-decoration: none; white-space: nowrap; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); }
.backlink:hover { color: var(--ocean); border-color: var(--ocean); background: rgba(27, 65, 97, 0.05); }
.backlink .arr { font-size: 14px; line-height: 1; }
/* Installed as a home-screen app (standalone launch): hide the back-to-site link.
   With it gone there's room, so show the wordmark again even on narrow phones
   (higher specificity than the <=540px hide, so it wins regardless of order). */
@media (display-mode: standalone) { .backlink { display: none; } }
html.standalone .backlink { display: none; }
html.standalone .wordmark { display: inline; }

/* Eyebrow label */
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ocean);
  display: inline-flex; align-items: center; gap: 9px; margin-bottom: 12px;
}
.eyebrow::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--seal); box-shadow: 0 0 0 3px rgba(226, 59, 46, 0.16);
}

/* minmax(0,1fr) lets the cards shrink below their content's intrinsic width, so
   the console's pre/no-wrap lines scroll inside it instead of widening the page. */
main { padding: clamp(20px, 3vw, 34px) 0 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(16px, 2.4vw, 24px); }

/* About / how-it-works (collapsible <details>) */
.about { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.about > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: clamp(14px, 2.2vw, 19px) clamp(16px, 2.6vw, 28px);
  font-family: var(--disp); font-weight: 600; font-size: clamp(16px, 2vw, 20px); color: var(--ocean);
}
.about > summary::-webkit-details-marker { display: none; }
.about > summary:hover { color: var(--ocean-2); }
/* attention badge; draws the eye to open the help panel; hidden once open */
.about-badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: #fff; background: var(--seal); border-radius: 999px; padding: 3px 10px; flex: none;
  animation: badgePulse 2.2s ease-out infinite;
}
@keyframes badgePulse {
  0% { box-shadow: 0 0 0 0 rgba(226, 59, 46, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(226, 59, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(226, 59, 46, 0); }
}
@media (prefers-reduced-motion: reduce) { .about-badge { animation: none; } }
.about-hint { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); }
.about[open] .about-badge, .about[open] .about-hint { display: none; }
@media (max-width: 680px) { .about-hint { display: none; } }
.about .about-toggle {
  margin-left: auto; width: 9px; height: 9px; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform .2s;
}
.about[open] .about-toggle { transform: rotate(-135deg); }
.about-body { padding: 0 clamp(16px, 2.6vw, 28px) clamp(16px, 2.6vw, 24px); }
.about-body p { color: var(--muted); font-size: 14.5px; }
.about-body > p:first-child { color: var(--ink); font-size: 15.5px; }
.about-body code { font-family: var(--mono); font-size: 12px; color: var(--ocean-2); background: rgba(27,65,97,.06); padding: 1px 5px; border-radius: 5px; }
.about-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin: 18px 0 6px; }
.about-col > div + div { margin-top: 16px; }   /* stacked blocks in one column */
.about-grid h4 { font-family: var(--disp); font-weight: 600; font-size: 14px; color: var(--ink); margin-bottom: 5px; }
.about-grid p { font-size: 13.5px; }
.about-note { font-family: var(--mono); font-size: 12px; margin-top: 10px; }
/* Privacy callout; make the "no server" promise visually prominent. */
.about-privacy {
  margin: 6px 0 2px; padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--line); border-left: 3px solid var(--ocean);
  background: rgba(27, 65, 97, 0.045); color: var(--ink); font-size: 14.5px;
}
.about-privacy strong { color: var(--ocean); }
@media (max-width: 680px) { .about-grid { grid-template-columns: 1fr; } }

/* Cards */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(16px, 2.6vw, 28px);
}
.card h2 { font-family: var(--disp); font-weight: 600; font-size: clamp(20px, 2.6vw, 27px); color: var(--ink); margin-bottom: 4px; }
.card .hint { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.card .hint code { font-family: var(--mono); font-size: 12.5px; color: var(--ocean-2); background: rgba(27,65,97,0.06); padding: 1px 5px; border-radius: 5px; }

/* Form fields */
.fields { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
/* Name autocomplete dropdown (custom; replaces the flaky native <datalist>). */
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 24px rgba(10, 16, 24, 0.12);
  max-height: 262px; overflow: auto; padding: 4px;
  /* a touch scroller of its own: the finger pans it, and the pan does not chain
     out to the sheet or the page behind it */
  touch-action: pan-y; overscroll-behavior: contain;
}
.suggest[hidden] { display: none; }
.suggest .opt {
  font-family: var(--mono); color: var(--ink);
  padding: 7px 10px; border-radius: 7px; cursor: pointer; min-width: 0;
  /* rows are targets, not text: no selection handles or callout on a long press */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.suggest .opt-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.suggest .opt-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest .opt-parent { font-size: 11px; color: var(--muted); white-space: nowrap; flex: none; }
.suggest .opt-comment {
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest .opt:hover, .suggest .opt.active { background: rgba(27, 65, 97, 0.08); }
.suggest .opt:hover .opt-name, .suggest .opt.active .opt-name { color: var(--ocean); }
.field label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
/* The master field's label doubles as its state line: the caption on the left,
   the "cached - forget" control on the right (hidden while nothing is cached). */
.field label.with-state { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
/* the caption yields first on a narrow phone; the control never wraps */
.field label.with-state > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lnk {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; white-space: nowrap;
  color: var(--ocean); background: transparent; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.lnk:hover { color: var(--deep); }
.lnk[hidden] { display: none; }
input[type="text"], input[type="password"] {
  /* 16px min: iOS Safari auto-zooms (and stays zoomed) when a focused input is
     under 16px. Keep all focusable fields >= 16px to stop that. */
  font-family: var(--mono); font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--ocean); box-shadow: 0 0 0 3px rgba(27, 65, 97, 0.12); }
/* Masked TEXT inputs (master, pass overlay): visually masked but type=text, so
   the browser never treats them as password fields, so no autofill / save / "suggest
   strong password". Firefox uses the bundled disc font. */
input.mask { -webkit-text-security: disc; }
@supports not (-webkit-text-security: disc) { input.mask { font-family: "text-security-disc", var(--mono); } }
/* Click the masked master field to reveal what you typed; click again to re-mask. */
#master { cursor: pointer; }
input.mask.revealed { -webkit-text-security: none; }
@supports not (-webkit-text-security: disc) { input.mask.revealed { font-family: var(--mono); } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
  font-family: var(--disp); font-weight: 600; font-size: 14px;
  background: var(--ocean); color: var(--cream);
  border: 1px solid var(--ocean); border-radius: 999px; padding: 10px 20px;
  transition: transform .15s, background .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); background: var(--deep); border-color: var(--deep); }
.btn:active { transform: none; }
.btn.ghost { background: transparent; color: var(--ocean); }
.btn.ghost:hover { background: rgba(27, 65, 97, 0.06); color: var(--ocean); border-color: var(--ocean); }
.btn.small { padding: 7px 15px; font-size: 13px; }
/* Confirmed states ("Correct ✓" / "Stored ✓"): same filled-ocean look for both. */
.btn.small.is-correct,
.btn.small.is-stored { background: var(--ocean); color: var(--cream); border-color: var(--ocean); }
.btn.small.is-correct:hover { background: var(--deep); border-color: var(--deep); }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
/* is-stored is disabled (re-storing is a no-op); keep it fully opaque, not dimmed. */
.btn.small.is-stored { opacity: 1; }
.btn[hidden] { display: none; }
/* Rotate between its two taps: filled, so the pending second tap is unmistakable. */
.btn.small.is-armed { background: var(--deep); color: var(--cream); border-color: var(--deep); }

/* Quick-gen result row */
/* Entry meta chips: parent / URL / e-mail of the stored entry behind the typed
   name. Quiet pills between the fields and the result — informative at a
   glance, one tap to copy (URL chip also opens via its ↗). */
.entry-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.entry-meta[hidden] { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--ocean); color: var(--ocean); }
.chip .k {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); flex: none;
}
.chip .v { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .chip-open { color: var(--muted); text-decoration: none; flex: none; padding: 0 2px; }
.chip .chip-open:hover { color: var(--ocean); }

.result {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-top: 20px; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; min-height: 58px;
}
.result .tag { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.result .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.result .len { font-family: var(--mono); font-size: 11px; color: var(--muted); }
/* Quick-gen result: dynamic font (scales down on narrow phones) and wraps so a
   long password stays inside the card. min-width:0 lets it shrink/wrap within
   the flex row. Scoped so the console table keeps its fixed-width alignment. */
.result .secret { font-size: clamp(13px, 4vw, 19px); white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }

/* Secret rendering: real text in the DOM, visually masked. Click toggles.
   Mask via -webkit-text-security on the MONO font so each disc keeps the mono
   advance width, so gen tables stay aligned. (No letter-spacing, no disc webfont
   here, both of which would break the column widths.) */
.secret {
  font-family: var(--mono);
  -webkit-text-security: disc;
  font-size: 19px; color: var(--ink);
  cursor: pointer; user-select: text; white-space: pre;
}
/* Reveal flips masking only; colour is reserved for correctness (below). */
.secret.revealed { -webkit-text-security: none; }
/* Quick-gen result: ocean = this master is marked correct; otherwise ink ("black"). */
.result .secret.correct { color: var(--ocean); font-weight: 500; }
/* Console keeps its old cue: a revealed secret turns ocean. */
.console-out .secret.revealed { color: var(--ocean); }
/* Firefox lacks -webkit-text-security: fall back to the disc webfont for masking
   (single-line result only; the console table is a WebKit/Blink concern). */
@supports not (-webkit-text-security: disc) {
  .secret { font-family: "text-security-disc", var(--mono); }
  .secret.revealed { font-family: var(--mono); }
}
.secret:empty::before { content: "type a name + master"; color: var(--muted); font-size: 14px; -webkit-text-security: none; font-family: var(--body); cursor: default; }

/* Console: collapsible <details>, same pattern as the help panel. Calm ocean
   badge — the pulsing red attention badge stays reserved for Help. */
.console-card .about-badge { background: var(--ocean); animation: none; }
/* The console hint is a hint, not the about lede (which .about-body > p:first-child styles). */
.console-body > p:first-child { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.console-out {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.55;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; height: var(--console-h, clamp(280px, 46vh, 560px));
  overflow: auto; white-space: pre;            /* no wrap, scroll left/right */
}
@supports (height: 100dvh) {
  .console-out { height: var(--console-h, clamp(280px, 46dvh, 560px)); }
}
.console-out > div { min-width: max-content; }
.console-out .cmd { color: var(--ocean); font-weight: 500; }
.console-out .err { color: var(--seal); }
.console-out .muted { color: var(--muted); }
.console-out .secret { font-size: 13.5px; vertical-align: baseline; }
/* Drag grip: adjusts --console-h (desktop + in-flow mobile); persisted in JS. */
.console-resize {
  height: 14px; margin: 2px 0 -2px; cursor: ns-resize; touch-action: none;
  display: flex; align-items: center; justify-content: center;
}
.console-resize::before {
  content: ""; width: 46px; height: 4px; border-radius: 999px;
  background: var(--line); transition: background .15s;
}
.console-resize:hover::before { background: var(--ocean-2); }
.console-in { display: flex; align-items: center; gap: 8px; margin-top: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; }
.console-in:focus-within { border-color: var(--ocean); box-shadow: 0 0 0 3px rgba(27,65,97,0.12); }
.console-in .prompt { font-family: var(--mono); color: var(--ocean); font-weight: 600; }
.console-in input { border: none; box-shadow: none; padding: 9px 0; background: transparent; }
.console-in input:focus { box-shadow: none; }

/* Phones: a taller, viewport-fitting console by default. svh (not vh) so the iOS
   toolbar can't clip it; dvh below tracks the live viewport where supported. */
@media (max-width: 680px) {
  .console-out { height: var(--console-h, clamp(240px, 60svh, 560px)); }
}
@supports (height: 100dvh) {
  @media (max-width: 680px) {
    .console-out { height: var(--console-h, clamp(240px, 64dvh, 560px)); }
  }
}

/* Shell mode: console input focused on a phone → the console fills the space
   above the software keyboard. Height + translateY come from visualViewport (JS,
   inline); 100svh is only the no-visualViewport fallback. */
@media (max-width: 680px) {
  body.shell-focus { overflow: hidden; }         /* freeze the page behind it */
  body.shell-focus .console-card {
    position: fixed; inset: 0 0 auto 0; z-index: 60;
    height: 100svh;                              /* JS overrides inline */
    margin: 0; border-radius: 0; border-left: 0; border-right: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: 8px; background: var(--paper);
  }
  body.shell-focus .console-card > summary,
  body.shell-focus .console-card .hint,
  body.shell-focus .console-resize { display: none; }
  /* the body becomes the flex column that fills the card (summary is hidden);
     <details> lays out its content inside an internal ::details-content box, so
     that wrapper must become transparent for the body to be the card's flex item.
     Scoped to shell-focus: unscoped it would defeat the closed-state hiding. */
  body.shell-focus .console-card::details-content { display: contents; }
  body.shell-focus .console-body {
    display: flex; flex-direction: column; gap: 8px;
    flex: 1 1 auto; min-height: 0; padding: 0;
  }
  body.shell-focus .console-out {
    flex: 1 1 auto; min-height: 0; height: auto; margin: 0;   /* grows, scrolls */
  }
  body.shell-focus .console-in { margin-top: 0; }
}

/* Quick-gen sheet: name or master focused on a phone with the software keyboard
   up -> the Quick password card lifts out of the flow and sits directly on the
   keyboard, so the fields, the suggestion list and the result are reachable
   without scrolling and without the prose on top pushing them under it.
   Bottom-anchored and only as tall as its content needs (JS sets `bottom` and
   `max-height` from visualViewport, see boot()): a full-height panel either
   leaves a void under the fields or, once the content is taller than the gap
   above the keyboard, squeezes the suggestion list to a single row and spills
   the fields over each other. 100svh is the no-visualViewport fallback. */
.sheet-done { display: none; }
@media (max-width: 680px) {
  body.qsheet { overflow: hidden; }              /* freeze the page behind it */
  body.qsheet #quickCard {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0; z-index: 60;
    max-height: 100svh;                          /* JS overrides inline */
    margin: 0; border-radius: var(--radius) var(--radius) 0 0;
    border-left: 0; border-right: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: 8px; background: var(--paper);
    box-shadow: 0 -10px 30px rgba(10, 16, 24, 0.10);
    overflow-y: auto; overscroll-behavior: contain;   /* last resort, tiny screen */
  }
  /* the prose is exactly what buries the fields under the keyboard; the name
     label goes too, its placeholder already says what the field is */
  body.qsheet #quickCard > .eyebrow,
  body.qsheet #quickCard > h2,
  body.qsheet #quickCard > .hint,
  body.qsheet #qnameField > label { display: none; }
  /* thumb-sized: it is the only way out of the sheet */
  body.qsheet .sheet-done { display: block; align-self: flex-end; padding: 6px; font-size: 13px; }
  /* The sheet is ONE flex column: the field wrappers dissolve, so the card's
     own items are the done link, the name input, the list, the master field,
     the chips and the result. Nested wrappers were the overlap bug — a wrapper
     absorbs the shrink, collapses below its content, and its children spill out
     of it onto the field underneath. With one level, shrink lands on the list,
     which is the only item that may give way. */
  body.qsheet .fields,
  body.qsheet #qnameField { display: contents; }
  body.qsheet .sheet-done,
  body.qsheet #qname,
  body.qsheet #masterField,
  body.qsheet .entry-meta,
  body.qsheet .result { flex: none; }
  /* the dropdown stops being a dropdown: an in-flow pane that scrolls */
  /* min-height stays 0: a floor here does not hold the layout, the flex pass
     lays the master field out after the shrunk height and the floor only
     repaints the box over it. The room comes from hiding what is not needed
     while choosing (below), not from a minimum here. */
  body.qsheet #qnames {
    position: static; flex: 1 1 auto; min-height: 0; max-height: none;
    margin-top: 0; box-shadow: none; background: transparent;
  }
  /* While the list is open you are choosing a name: the result and the entry
     chips describe an entry that is not picked yet, so the list gets their
     room. They come back the moment the list closes. */
  body.qsheet.qlist .entry-meta,
  body.qsheet.qlist .result { display: none; }
  /* Landscape, or a phone whose keyboard leaves almost nothing: the master
     field goes too while the list is open. Picking a name comes first, and it
     is back before you can type into it. (JS sets qtight from the measured
     viewport, a media query cannot see the keyboard.) */
  body.qsheet.qlist.qtight #masterField { display: none; }
  body.qsheet .result { margin-top: 0; padding: 10px 12px; min-height: 0; }
}
/* Thumb-sized suggestion rows on touch screens (7px is a mouse target). */
@media (pointer: coarse) {
  .suggest .opt { padding: 11px 12px; }
}

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--deep); color: var(--cream); font-family: var(--mono); font-size: 13px;
  padding: 10px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgba(10, 16, 24, 0.35);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 80;
}
.toast.show { opacity: 1; }

/* Tap-to-apply update bar (shown only when an update lands while you're mid-entry). */
.update-bar {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%);
  background: var(--ocean); color: var(--cream); font-family: var(--mono); font-size: 13px; font-weight: 600;
  border: none; cursor: pointer; padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(10, 16, 24, 0.35); z-index: 90;
}
.update-bar[hidden] { display: none; }
.update-bar:hover { background: var(--deep); }

/* Modal (import/export) */
.modal-bg {
  position: fixed; inset: 0; background: rgba(10, 16, 24, 0.45);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 90;
}
.modal-bg.show { display: flex; }
.modal { background: var(--paper); border-radius: 18px; border: 1px solid var(--line);
  width: 100%; max-width: 680px; padding: 24px; }
.modal h3 { font-family: var(--disp); font-weight: 600; margin-bottom: 10px; }
.modal textarea {
  width: 100%; height: 260px; resize: vertical; font-family: var(--mono); font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; outline: none; white-space: pre;
}
.modal textarea:focus { border-color: var(--ocean); }
.modal .row { display: flex; gap: 10px; margin-top: 14px; }
/* Import problem report: red, monospace, keeps the engine's error lines readable. */
.modal-status {
  font-family: var(--mono); font-size: 12px; color: var(--seal);
  border: 1px solid rgba(226, 59, 46, 0.35); border-radius: 8px;
  background: rgba(226, 59, 46, 0.06);
  padding: 8px 10px; margin-bottom: 10px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.modal-status[hidden] { display: none; }

/* padding-block only: keep .wrap's inline gutter so the footer lines up with the
   body cards instead of running to the window edge. */
.foot { color: var(--muted); font-family: var(--mono); font-size: 12px; text-align: center; padding-block: 8px 40px; }
.foot a { color: var(--ocean); text-decoration: none; border-bottom: 1px solid rgba(27, 65, 97, 0.3); }
.foot a:hover { border-bottom-color: var(--ocean); }
/* Version badge: a quiet mono pill under the footer prose (mirrors .backlink).
   Decent and out of the way; click opens the changelog overlay. */
.ver {
  display: inline-block; margin-top: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
  color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.ver:hover { color: var(--ocean); border-color: var(--ocean); background: rgba(27, 65, 97, 0.05); }
.ver:focus-visible { outline: none; border-color: var(--ocean); box-shadow: 0 0 0 3px rgba(27, 65, 97, 0.12); }

/* Changelog overlay body (inside the shared .modal). Scrolls if it ever grows. */
.changelog { max-height: 60vh; overflow: auto; margin-top: 4px; }
.cl-entry { padding: 16px 0; border-top: 1px solid var(--line); }
.cl-entry:first-child { border-top: none; padding-top: 2px; }
.cl-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.cl-ver { font-family: var(--disp); font-weight: 700; font-size: 16px; color: var(--ocean); letter-spacing: -0.01em; }
.cl-date { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--muted); }
/* "Latest" flag, pushed to the right edge of the newest release's head. */
.cl-latest {
  margin-left: auto; flex: none; align-self: center;
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: #fff; background: var(--seal); border-radius: 999px; padding: 2px 9px;
}
/* Release theme line under the version. */
.cl-title { font-family: var(--disp); font-weight: 600; font-size: 14px; color: var(--ink); margin: 0 0 12px; }
.changelog ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.changelog li { display: flex; align-items: baseline; gap: 12px; color: var(--ink); font-size: 14px; line-height: 1.5; }
/* Category tag in a fixed-width column, so the change text shares one clean left edge. */
.cl-tag {
  flex: none; width: 68px; text-align: center; box-sizing: border-box;
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 3px 0; border-radius: 6px; transform: translateY(-1px);
}
.cl-tag-new { color: var(--ocean); background: rgba(27, 65, 97, 0.10); }
.cl-tag-improved { color: var(--muted); background: rgba(106, 103, 94, 0.13); }
.cl-tag-fixed { color: var(--seal); background: rgba(226, 59, 46, 0.10); }
.cl-text { min-width: 0; }
.changelog code { font-family: var(--mono); font-size: 12px; color: var(--ocean-2); background: rgba(27,65,97,.06); padding: 1px 5px; border-radius: 5px; }
/* On phones the fixed tag column would crowd the text — let each item stack. */
@media (max-width: 540px) {
  .changelog li { flex-wrap: wrap; gap: 5px 10px; }
  .cl-tag { width: auto; padding: 3px 9px; }
}

@media (max-width: 680px) {
  .fields { grid-template-columns: 1fr; align-items: stretch; }
  .nav { gap: 9px; height: 60px; }
  .tagline { display: none; }
  body { font-size: 15px; }
  /* free space for the back link: the ensō icon alone carries the brand on phones */
  .backlink { padding: 5px 9px; }
  /* result row stacks cleanly on phones: the password on its own full-width line,
     then a tidy meta line (result + len ........ Copy / Store). */
  .result { align-items: center; row-gap: 12px; }
  .result .secret { order: 1; flex: 1 1 100%; font-size: clamp(15px, 5.2vw, 19px); }
  .result .tag { order: 2; }
  .result .len { order: 3; margin-right: auto; }
  .result .actions { order: 4; margin-left: 0; }
}
/* On narrow phones drop the wordmark so the back link + ensō + buttons all fit. */
@media (max-width: 540px) { .wordmark { display: none; } }
