/* Random Word Generator.
   Layout concept: one column built for a thumb. The generator is the hero, a dark result panel that
   holds the word, with the Generate button directly beneath it in easy reach. Plain reading text follows.
   Colour: plum ink and a lilac-grey paper, one hot pink for actions. Type: Bricolage Grotesque for the
   words and controls, Atkinson Hyperlegible for reading. */
:root {
  --paper: #f4f1f6;
  --surface: #ffffff;
  --ink: #261632;
  --muted: #6b5f75;
  --line: #ddd6e3;
  --accent: #c41e63;
  --on-accent: #ffffff;
  --panel: #261632;
  --on-panel: #fbf7fd;
  --panel-dim: #b9a9c6;
  --chip: #ebe5ef;
  --focus: #1f6feb;
  --display: 'Bricolage Grotesque', 'Helvetica Neue', Arial, sans-serif;
  --body: 'Atkinson Hyperlegible', 'Helvetica Neue', Arial, sans-serif;
  --gutter: 16px;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #150e1b;
    --surface: #1f1628;
    --ink: #f2ecf6;
    --muted: #a898b4;
    --line: #382a45;
    --accent: #ff6fa3;
    --on-accent: #2a0a18;
    --panel: #2b1c38;
    --on-panel: #fbf7fd;
    --panel-dim: #a898b4;
    --chip: #2a1f35;
    --focus: #7db0ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #150e1b; --surface: #1f1628; --ink: #f2ecf6; --muted: #a898b4; --line: #382a45;
  --accent: #ff6fa3; --on-accent: #2a0a18; --panel: #2b1c38; --on-panel: #fbf7fd; --panel-dim: #a898b4;
  --chip: #2a1f35; --focus: #7db0ff; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; touch-action: pan-x pan-y; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

main, .top, .foot { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding-block: 12px; padding-top: max(12px, env(safe-area-inset-top, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.mark { display: inline-grid; grid-auto-flow: column; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--ink); color: var(--paper); font-family: var(--display); font-weight: 800; font-size: 16px; line-height: 1; letter-spacing: -0.5px; flex: none; }
.mark span:last-child { color: var(--accent); font-weight: 700; margin-left: -1px; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name .tld { color: var(--muted); font-weight: 500; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 12px; font-size: 28px; line-height: 1; }
.icon-btn:active { background: var(--chip); }

/* ---------- hero ---------- */
.hero { padding-top: 10px; padding-bottom: 14px; }
.hero h1 { margin: 0 0 6px; font-family: var(--display); font-size: 30px; line-height: 1.08; font-weight: 800; letter-spacing: -0.8px; font-variation-settings: 'wdth' 85; text-wrap: balance; }
.hero p { margin: 0; color: var(--muted); font-size: 16px; max-width: 34ch; }

/* ---------- generator ---------- */
.gen { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 12px; }
.result { position: relative; background: var(--panel); color: var(--on-panel); border-radius: var(--radius); min-height: 232px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding: 20px 14px 52px; }
.result-body { display: flex; flex-direction: column; justify-content: center; align-items: center; flex: 1; width: 100%; min-width: 0; }
.result-word { font-family: var(--display); font-weight: 800; font-size: clamp(40px, 14vw, 72px); line-height: 1.02; letter-spacing: -1.5px; text-align: center; font-variation-settings: 'wdth' 90; width: 100%; white-space: nowrap; overflow: hidden; -webkit-user-select: text; user-select: text; }
.result-word .ch, .result-list .w .ch { display: inline-block; animation: drop 0.32s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 22ms); }
@keyframes drop { from { opacity: 0; transform: translateY(0.38em); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .result-word .ch, .result-list .w .ch { animation: none; } }
.result-list { list-style: none; margin: 0; padding: 0; width: 100%; max-height: 330px; overflow-y: auto; counter-reset: w; align-self: stretch; }
.result-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 4px; border-bottom: 1px solid rgba(255,255,255,0.12); font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -0.4px; }
.result-list li:last-child { border-bottom: 0; }
.result-list .w { min-width: 0; overflow-wrap: anywhere; }
.result-list .sv { flex: none; width: 40px; height: 40px; border: 0; background: transparent; color: var(--panel-dim); display: grid; place-items: center; border-radius: 10px; }
.result-list .sv[aria-pressed="true"] { color: var(--accent); }
.result-list .sv[aria-pressed="true"] svg { fill: currentColor; }
.result-tools { position: absolute; right: 8px; bottom: 6px; display: flex; gap: 2px; }
.tool { width: 44px; height: 44px; border: 0; background: transparent; color: var(--panel-dim); display: grid; place-items: center; border-radius: 12px; }
.tool:active { background: rgba(255,255,255,0.1); }
.tool[aria-pressed="true"] { color: var(--accent); }
.tool[aria-pressed="true"] svg { fill: currentColor; }

.go { display: block; width: 100%; margin-top: 10px; min-height: 64px; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.3px; box-shadow: 0 3px 0 rgba(0,0,0,0.22); transition: transform 0.06s, box-shadow 0.06s; }
.go:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.22); }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 220px; }
.label { font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--muted); }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.stepper button { width: 46px; min-height: 46px; border: 0; background: transparent; font-size: 24px; line-height: 1; font-family: var(--display); }
.stepper button:active { background: var(--chip); }
.stepper input { width: 52px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; background: transparent; font-size: 18px; font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; border-radius: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 46px; padding: 0 14px; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; font-family: var(--display); font-weight: 600; font-size: 15px; }
.chips button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.more-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 14px; padding: 0 4px; min-height: 48px; border: 0; border-top: 1px solid var(--line); background: transparent; font-family: var(--display); font-weight: 700; font-size: 16px; }
.more-toggle svg { transition: transform 0.2s; }
.more-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.more { padding: 4px 4px 4px; display: grid; gap: 14px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.box { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 16px; text-transform: none; }
.box::placeholder { color: var(--muted); opacity: 0.8; }
.size-row { display: grid; grid-template-columns: 1.1fr 1.2fr 0.8fr; gap: 8px; }
.link-btn { justify-self: start; border: 0; background: transparent; color: var(--accent); font-family: var(--display); font-weight: 700; font-size: 15px; padding: 10px 0; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }

.note { margin: 12px 2px 0; font-size: 13px; color: var(--muted); }
.rev.small { min-height: 1.6em; }
.rev { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.saved-bar { display: flex; align-items: center; justify-content: space-between; width: 100%; margin: 12px 0 0; min-height: 52px; padding: 0 16px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); font-family: var(--display); font-weight: 700; font-size: 16px; }
.badge { min-width: 30px; height: 28px; padding: 0 9px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- reading text ---------- */
.prose { padding-top: 34px; padding-bottom: 12px; }
.prose h2 { font-family: var(--display); font-size: 22px; line-height: 1.2; letter-spacing: -0.4px; margin: 34px 0 10px; font-weight: 800; font-variation-settings: 'wdth' 90; text-wrap: balance; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin: 0 0 14px; max-width: 62ch; }
.uses { margin: 0; display: grid; gap: 16px; }
.uses dt { font-family: var(--display); font-weight: 700; font-size: 17px; }
.uses dd { margin: 2px 0 0; color: var(--muted); max-width: 62ch; }
details { border-top: 1px solid var(--line); }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { list-style: none; cursor: pointer; padding: 15px 28px 15px 0; position: relative; font-family: var(--display); font-weight: 700; font-size: 17px; min-height: 52px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; position: absolute; right: 4px; top: 11px; font-size: 24px; font-weight: 500; color: var(--accent); }
details[open] summary::after { content: '–'; }
details p { color: var(--muted); padding-bottom: 6px; }
.suggest { margin-top: 4px; }
.suggest .label { display: block; margin-bottom: 8px; }
.suggest-row { display: flex; gap: 8px; }
.send { min-width: 84px; border: 0; border-radius: 12px; background: var(--ink); color: var(--paper); font-family: var(--display); font-weight: 700; padding: 0 16px; }
.thanks { margin: 10px 0 0 !important; color: var(--muted); }

/* ---------- footer ---------- */
.foot { padding-top: 26px; padding-bottom: 36px; border-top: 1px solid var(--line); margin-top: 26px; }
.foot, .foot * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.foot nav { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.foot nav a, .foot-link { font-family: var(--display); font-weight: 600; font-size: 15px; text-decoration: none; padding: 10px 0; min-height: 44px; display: inline-flex; align-items: center; border: 0; background: transparent; }
.foot .small { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.foot-link { color: inherit; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(21, 14, 27, 0.55); animation: fade 0.18s both; }
.sheet-panel { position: relative; width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 14px 18px calc(18px + env(safe-area-inset-bottom, 0px)); animation: rise 0.24s cubic-bezier(.2,.8,.2,1) both; margin: 0; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet-backdrop, .sheet-panel { animation: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h2 { font-family: var(--display); font-size: 22px; margin: 0; font-weight: 800; letter-spacing: -0.4px; }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list li + li { border-top: 1px solid var(--line); }
.menu-list button, .menu-list a { display: flex; width: 100%; align-items: center; min-height: 54px; padding: 0; border: 0; background: transparent; text-align: left; text-decoration: none; font-family: var(--display); font-weight: 600; font-size: 18px; }
.cookie-intro { margin: 0 0 8px; color: var(--muted); font-size: 15px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle span { display: flex; flex-direction: column; gap: 2px; }
.toggle b { font-family: var(--display); font-size: 16px; }
.toggle small { color: var(--muted); font-size: 14px; line-height: 1.4; }
.toggle input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.ref-row { padding: 12px 0; border-top: 1px solid var(--line); }
.ref-row .label { display: block; margin-bottom: 6px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.btn { min-height: 50px; border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-family: var(--display); font-weight: 700; font-size: 16px; padding: 0 14px; }
.btn.ghost { background: var(--chip); color: var(--ink); }
.empty { color: var(--muted); margin: 8px 0; }
.saved-list { list-style: none; margin: 0 0 4px; padding: 0; }
.saved-list li { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); min-height: 50px; font-family: var(--display); font-weight: 700; font-size: 20px; }
.saved-list button { border: 0; background: transparent; color: var(--muted); width: 44px; height: 44px; font-size: 22px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 999px; font-family: var(--display); font-weight: 600; font-size: 15px; z-index: 80; }

/* simple pages (about, privacy, terms) */
.page { padding-top: 8px; padding-bottom: 20px; }
.page h1 { font-family: var(--display); font-size: 32px; line-height: 1.1; margin: 8px 0 14px; font-weight: 800; letter-spacing: -0.8px; }
.page h2 { font-family: var(--display); font-size: 20px; margin: 26px 0 8px; font-weight: 800; }
.page p, .page li { max-width: 62ch; }

/* ---------- entry mode (hidden keypad grid) ---------- */
html.entry-mode, html.entry-mode body { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ---------- performer area: same look as onemilliondigits Settings ---------- */
.perf-overlay { position: fixed; inset: 0; z-index: 100; background: #fff; overflow-y: auto; color: #333; font-family: 'Open Sans', system-ui, sans-serif; font-size: 14px; line-height: 1.5; color-scheme: light; -webkit-user-select: text; user-select: text; }
.perf-overlay .perf-box { max-width: 560px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top, 0px)) 18px 90px; }
.perf-overlay .perf-narrow { padding-top: max(40px, env(safe-area-inset-top, 0px)); }
.perf-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.perf-title { font-size: 20px; font-weight: 700; color: #333; }
.perf-close { width: 44px; height: 44px; border: 0; background: transparent; font-size: 30px; line-height: 1; color: #666; }
.perf-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: #666; margin-bottom: 14px; }
.perf-meta b { color: #333; }
.perf-meta a { color: #337ab7; text-decoration: none; font-size: 13px; }
.perf-section { border-top: 1px solid #ddd; padding: 14px 0 6px; }
.perf-h { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: #333; }
.perf-note { font-size: 14px; color: #666; margin: 0 0 18px; }
.perf-hint { font-size: 12px; color: #999; margin: 6px 0 10px; line-height: 1.5; }
.perf-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.perf-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #666; }
.perf-input { width: 100%; min-height: 40px; padding: 0.55rem 0.65rem; border: 1px solid #ddd; border-radius: 4px; background: #fff; color: #333; font-size: 16px; font-family: inherit; }
.perf-pin { width: 100%; padding: 0.6rem 0.7rem; border: 1px solid #ddd; border-radius: 4px; font-family: 'Courier New', Courier, monospace; font-size: 16px; margin-bottom: 0.6rem; outline: none; letter-spacing: 0.3em; text-align: center; background: #fff; color: #333; }
.perf-error { font-size: 12.5px; color: #c0392b; margin-bottom: 0.8rem; }
.perf-row { display: flex; gap: 10px; margin: 8px 0; }
.perf-primary { flex: 1; min-height: 44px; background: #337ab7; color: #fff; border: 0; border-radius: 4px; font-weight: 600; font-size: 14px; font-family: inherit; }
.perf-secondary { flex: 1; min-height: 44px; background: #fff; color: #666; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; font-family: inherit; }
.perf-seg { display: flex; border: 1px solid #ddd; border-radius: 4px; overflow: hidden; }
.perf-seg button { flex: 1; min-height: 42px; border: 0; background: #fff; color: #666; font-weight: 600; font-family: inherit; font-size: 14px; }
.perf-seg button[aria-checked="true"] { background: #337ab7; color: #fff; }
.perf-check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 13px; color: #333; }
.perf-check input { width: 20px; height: 20px; accent-color: #337ab7; }
.slot-row { display: grid; grid-template-columns: 26px 1fr 90px; gap: 8px; align-items: center; margin-bottom: 8px; }
.slot-row .n { font-weight: 700; color: #666; text-align: center; }
.perf-sticky { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 10px 18px calc(10px + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid #ddd; max-width: none; }
.perf-sticky .perf-primary, .perf-sticky .perf-secondary { max-width: 270px; }
.perf-saved { position: fixed; left: 0; right: 0; bottom: 68px; text-align: center; font-size: 13px; color: #5cb85c; pointer-events: none; }
.perf-saved.bad { color: #c0392b; }
.perf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.perf-grid button { min-height: 58px; border: 1px solid #ddd; background: #fff; border-radius: 4px; font-family: inherit; font-size: 12px; color: #666; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.perf-grid button b { font-size: 17px; color: #333; }
.perf-grid button:active { background: #eef4fa; }
.perf-practice-out { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0; }
.perf-practice-out span { font-family: 'Courier New', Courier, monospace; font-size: 20px; letter-spacing: 0.15em; min-height: 28px; }
.perf-practice-out .perf-secondary { flex: none; padding: 0 16px; }
.perf-guide p { margin: 0 0 14px; font-size: 13.5px; color: #333; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.page-h { font-family: var(--display); font-size: 34px; line-height: 1.05; letter-spacing: -0.8px; margin: 0 0 18px; font-weight: 800; font-variation-settings: 'wdth' 88; }

/* Browse section: long enough to scroll through, and cut short on demand */

.quick .stepper { display: flex; width: 100%; }
.quick .stepper input { flex: 1 1 auto; min-width: 0; width: auto; }
.quick .stepper button { flex: none; }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; font-family: var(--display); font-weight: 600; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }

/* ---------- auto-pair and the performer page ---------- */
.pair-btn { display: block; width: 100%; min-height: 64px; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.3px; }
.pair-btn.stop { background: var(--chip); color: var(--ink); }
.pair-btn:disabled { opacity: 0.6; }
.pair-status { margin: 10px 0 12px; color: var(--muted); font-size: 15px; min-height: 2.6em; }
.is-armed .pair-status { color: var(--ink); }
.pair-flash { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; background: #1c9c5b; color: #fff; font-family: var(--display); font-weight: 800; font-size: 56px; opacity: 0; transition: opacity 0.15s; }
.pair-flash.go { opacity: 1; animation: pairpulse 1.3s ease-out both; }
@keyframes pairpulse { 0% { opacity: 1; } 35% { opacity: 0.15; } 55% { opacity: 1; } 100% { opacity: 0; } }
.perform { max-width: 520px; margin: 0 auto; padding-block: max(20px, env(safe-area-inset-top, 0px)) 40px; display: grid; gap: 14px; }
.perform-title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 30px; letter-spacing: -0.8px; }
.perform .perf-section { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.perform .perf-fields label, .perform .perf-check, .perform .perf-hint { color: var(--ink); }
.perform .perf-input { background: var(--paper); color: var(--ink); border-color: var(--line); }
.perform .perf-primary, .perform .perf-secondary { min-height: 48px; }
.perf-box .pair-status { color: #555; }
.perf-box .is-armed .pair-status { color: #222; }
.perf-box .pair-btn.stop { background: #eee; color: #333; }
.perform .perf-primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.pair-gap { margin-top: 16px; }

/* ---------- Settings, PIN and Tips overlays: same look as the performer page ---------- */
.perf-overlay { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45; color-scheme: light dark; }
.perf-overlay .perf-box { max-width: 520px; padding: max(20px, env(safe-area-inset-top, 0px)) var(--gutter) 110px; display: grid; gap: 14px; align-content: start; }
.perf-overlay .perf-narrow { padding-top: max(40px, env(safe-area-inset-top, 0px)); }
.perf-overlay .perf-top { margin: 0; }
.perf-overlay .perf-title { font-family: var(--display); font-weight: 800; font-size: 30px; letter-spacing: -0.8px; color: var(--ink); }
.perf-overlay .perf-close { color: var(--muted); }
.perf-overlay .perf-meta { margin: 0; color: var(--muted); font-size: 15px; }
.perf-overlay .perf-meta b { color: var(--ink); }
.perf-overlay .perf-meta a { color: var(--accent); font-size: 15px; font-weight: 600; }
.perf-overlay .perf-section { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.perf-overlay .perf-h { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ink); }
.perf-overlay .perf-note, .perf-overlay .perf-hint, .perf-overlay .perf-guide p { color: var(--ink); font-size: 15px; }
.perf-overlay .perf-hint { margin: 8px 0 10px; }
.perf-overlay .perf-fields label { color: var(--ink); font-size: 13px; }
.perf-overlay .perf-input, .perf-overlay .perf-pin { background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
.perf-overlay .perf-error, .perf-overlay .perf-saved.bad { color: #c0392b; }
.perf-overlay .perf-saved { color: #1c9c5b; }
.perf-overlay .perf-primary { background: var(--accent); color: var(--on-accent); border-radius: 10px; min-height: 48px; font-family: var(--display); font-weight: 700; font-size: 16px; }
.perf-overlay .perf-secondary { background: var(--surface); color: var(--muted); border: 1px solid var(--line); border-radius: 10px; min-height: 48px; font-family: var(--display); font-weight: 600; font-size: 16px; }
.perf-overlay .perf-seg { border-color: var(--line); border-radius: 10px; }
.perf-overlay .perf-seg button { background: var(--surface); color: var(--muted); font-family: var(--display); min-height: 46px; }
.perf-overlay .perf-seg button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }
.perf-overlay .perf-check { color: var(--ink); font-size: 15px; }
.perf-overlay .perf-check input { accent-color: var(--accent); }
.perf-overlay .perf-sticky { background: var(--surface); border-top: 1px solid var(--line); }
.perf-overlay .perf-grid button { background: var(--paper); border-color: var(--line); color: var(--muted); border-radius: 8px; }
.perf-overlay .perf-grid button b { color: var(--ink); }
.perf-overlay .perf-grid button:active { background: var(--chip); }
.perf-overlay .perf-practice-out span { color: var(--ink); }
.perf-overlay .pair-status { color: var(--muted); }
.perf-overlay .is-armed .pair-status { color: var(--ink); }
.perf-overlay .pair-btn.stop { background: var(--chip); color: var(--ink); }

/* Settings: centred Active Performance block */
.perf-overlay .perf-center { text-align: center; }
.perf-overlay .perf-center .perf-seg { max-width: 260px; margin: 0 auto 12px; }
.perf-overlay .perf-armfor { max-width: 260px; margin: 0 auto 8px; text-align: left; }

/* Tighter Settings spacing */
.perf-overlay .perf-box { gap: 10px; }
.perf-overlay .perf-section { padding: 12px; }
.perf-overlay .perf-h { margin-bottom: 6px; }
.perf-overlay .perf-hint { margin: 6px 0 8px; font-size: 14px; line-height: 1.4; }
.perf-overlay .pair-status, .perform .pair-status { margin: 6px 0 0; min-height: 0; font-size: 14px; }
.perf-overlay .pair-status:empty, .perform .pair-status:empty { display: none; }
.perf-overlay .pair-gap, .perform .pair-gap { margin-top: 12px; }
.perf-overlay .perf-fields { margin-bottom: 6px; }
.perf-overlay .perf-row, .perform .perf-row { margin: 6px 0; }
.perf-overlay .perf-seg { margin-bottom: 6px; }

/* Sliding On/Off switches, wider gaps between blocks */
.perf-swrow { display: flex; align-items: center; gap: 12px; margin: 2px 0 6px; }
.perf-switch { position: relative; flex: none; width: 64px; height: 36px; border: 0; border-radius: 18px; background: #c9c9cf; padding: 0; transition: background 0.18s; -webkit-tap-highlight-color: transparent; }
.perf-switch .perf-knob { position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.18s; }
.perf-switch[aria-checked="true"] { background: var(--accent, #337ab7); }
.perf-switch[aria-checked="true"] .perf-knob { transform: translateX(28px); }
.perf-swtext { font-weight: 700; font-size: 15px; color: var(--ink, #222); min-width: 2.5em; }
.perf-wide { width: 100%; flex: 1 1 100%; }
.perf-overlay .perf-box { gap: 20px; }
.perf-overlay .perf-sub { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line, #ddd); }
.perf-overlay .perf-sub:empty { display: none; }
.perf-overlay .perf-tight { padding-bottom: 8px; }
.perform .perf-sub { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line, #ddd); }
.perform .perf-box, .perform main { row-gap: 20px; }
.perform .perf-section { margin-bottom: 20px; }
.perf-overlay .pair-gap { margin-top: 0; }

/* Titles read white on the dark theme */
@media (prefers-color-scheme: dark) {
  .perf-overlay .perf-h, .perform .perf-h { color: #fff; }
}

/* Switch: a ring that opens out once when it is turned on or off */
.perf-switch.ping-on { animation: swpingon 0.65s ease-out; }
.perf-switch.ping-off { animation: swpingoff 0.5s ease-out; }
@keyframes swpingon { from { box-shadow: 0 0 0 0 var(--accent); } to { box-shadow: 0 0 0 12px transparent; } }
@keyframes swpingoff { from { box-shadow: 0 0 0 0 #9a93a3; } to { box-shadow: 0 0 0 9px transparent; } }

/* Activate button: when armed, a light runs around the border and the button breathes */
.pair-btn { position: relative; overflow: hidden; isolation: isolate; transition: transform 0.2s; }
.pair-btn.stop, .perf-overlay .pair-btn.stop, .perf-box .pair-btn.stop { background: transparent; color: var(--on-panel, #fff); }
.pair-btn.stop::before { content: ''; position: absolute; left: 50%; top: 50%; width: 220%; aspect-ratio: 1; margin: -110% 0 0 -110%; background: conic-gradient(from 0deg, transparent 0 62%, var(--accent) 92%, #fff 100%); animation: pairspin 3s linear infinite; z-index: -2; }
.pair-btn.stop::after { content: ''; position: absolute; inset: 2px; border-radius: calc(var(--radius) - 2px); background: var(--panel, #261632); z-index: -1; }
.pair-btn.stop { animation: pairbreath 3.2s ease-in-out infinite; }
.pair-btn.just { animation: pairpop 0.9s cubic-bezier(.2,.9,.3,1.2); }
.pair-btn.just::after { animation: pairflash 0.9s ease-out; }
@keyframes pairspin { to { transform: rotate(360deg); } }
@keyframes pairbreath { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,111,163,0); } 50% { box-shadow: 0 0 22px 2px rgba(255,111,163,0.35); } }
@keyframes pairpop { 0% { transform: scale(0.96); } 55% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes pairflash { 0% { background: var(--accent); } 100% { background: var(--panel, #261632); } }
@media (prefers-reduced-motion: reduce) {
  .pair-btn.stop::before, .pair-btn.stop, .pair-btn.just, .pair-btn.just::after, .perf-switch.ping-on, .perf-switch.ping-off { animation: none; }
  .pair-btn.stop::before { background: var(--accent); }
}

/* Mode row and the black screen */
.pair-mode { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
.pair-mode label { min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink, #222); }
.pair-mode .pair-go { width: 100%; min-width: 0; padding: 0; min-height: 44px; }
.bm { position: fixed; inset: 0; z-index: 100000; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.bm-dot { position: absolute; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); width: 10px; height: 10px; border-radius: 50%; display: none; }
.bm-l { left: calc(18px + env(safe-area-inset-left, 0px)); }
.bm-r { right: calc(18px + env(safe-area-inset-right, 0px)); }
.bm.ok .bm-dot { display: block; background: #1fd16a; box-shadow: 0 0 8px #1fd16a; }
.bm.fail .bm-dot { display: block; background: #e5342b; box-shadow: 0 0 8px #e5342b; }

/* Notification dropdown on /perform */
.pair-notify { border: 1px solid var(--line, #ddd); border-radius: 12px; padding: 0 12px; }
.pair-notify summary { cursor: pointer; padding: 12px 0; font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ink); list-style: none; }
.pair-notify summary::-webkit-details-marker { display: none; }
.pair-notify summary::after { content: '+'; float: right; color: var(--muted); }
.pair-notify[open] summary::after { content: '\2212'; }
.pn-body { padding-bottom: 12px; display: grid; gap: 8px; }
.pn-fields { display: grid; gap: 10px; }
.pn-fields label, .pn-body .perf-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink); }
.perform .perf-sub#notifyMount { margin-top: 12px; padding-top: 0; border-top: 0; }
@media (prefers-color-scheme: dark) { .pair-notify .perf-h { color: #fff; } }
.perform .perf-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; min-height: 44px; font-family: var(--display); font-weight: 600; }

/* Go Dark: the Activate button in Black Screen mode */
.pair-btn.dark, .perf-overlay .pair-btn.dark, .perform .pair-btn.dark { background: #07040a; color: #f2ecf6; border: 1px solid var(--line, #382a45); }

/* ===================== Design pass: Settings and /perform ===================== */
.perform, .perf-overlay { --card-r: 22px; }
.perform { gap: 18px; }
.perf-overlay .perf-box { gap: 18px; }
.perform-title { text-align: center; font-size: 32px; letter-spacing: -1px; }

.perform .perf-section, .perf-overlay .perf-section {
  border-radius: var(--card-r); padding: 20px 18px; text-align: center;
  box-shadow: 0 14px 34px -26px rgba(38, 22, 50, 0.55);
}
@media (prefers-color-scheme: dark) {
  .perform .perf-section, .perf-overlay .perf-section { box-shadow: 0 14px 34px -22px rgba(0, 0, 0, 0.8); }
}
.perform .perf-h, .perf-overlay .perf-h { font-size: 18px; margin-bottom: 12px; text-align: center; letter-spacing: -0.2px; }
.perform .perf-hint, .perf-overlay .perf-hint { text-align: center; color: var(--muted); font-size: 14px; line-height: 1.45; margin: 10px auto 14px; max-width: 36ch; }
.perform .perf-fields, .perf-overlay .perf-fields { text-align: left; gap: 12px; margin-bottom: 12px; }
.perform .perf-fields label, .perf-overlay .perf-fields label, .pn-fields label { color: var(--muted); font-size: 13px; font-weight: 600; gap: 6px; text-align: left; display: flex; flex-direction: column; }
.perform .perf-input, .perf-overlay .perf-input { min-height: 48px; border-radius: 12px; font-size: 16px; padding: 0.6rem 0.8rem; }
.perform .perf-input:focus, .perf-overlay .perf-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.perform .perf-primary, .perf-overlay .perf-primary { border-radius: 14px; min-height: 52px; font-family: var(--display); font-weight: 700; font-size: 17px; transition: transform 0.12s, filter 0.12s; }
.perform .perf-secondary, .perf-overlay .perf-secondary { border-radius: 14px; min-height: 48px; }
.perform .perf-primary:active, .perf-overlay .perf-primary:active, .pair-btn:active, .perform .perf-secondary:active, .perf-overlay .perf-secondary:active { transform: scale(0.98); }
.perf-wide { width: 100%; }
.perform .perf-row, .perf-overlay .perf-row { margin: 10px 0; }
.perf-overlay .perf-sticky { background: color-mix(in srgb, var(--paper) 82%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }

/* Activate / Go Dark button */
.pair-btn { min-height: 72px; border-radius: 18px; font-size: 24px; margin-top: 2px; }
.pair-btn:disabled { opacity: 0.45; }

/* Status chip with a state dot */
.perform .pair-status, .perf-overlay .pair-status { display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center; margin: 12px auto 4px; padding: 8px 14px; border-radius: 14px; background: var(--chip); color: var(--muted); font-size: 14px; line-height: 1.35; width: fit-content; max-width: 100%; }
.perform .pair-status:empty, .perf-overlay .pair-status:empty { display: none; }
.pair-status[data-state]::before { content: ''; flex: none; width: 9px; height: 9px; border-radius: 50%; background: #9a93a3; }
.pair-status[data-state="ok"]::before { background: #1fd16a; box-shadow: 0 0 0 0 rgba(31, 209, 106, 0.6); animation: dotpulse 1.8s ease-out infinite; }
.pair-status[data-state="warn"]::before { background: #f0a020; }
.is-armed .pair-status { color: var(--ink); }
@keyframes dotpulse { 0% { box-shadow: 0 0 0 0 rgba(31, 209, 106, 0.55); } 100% { box-shadow: 0 0 0 9px rgba(31, 209, 106, 0); } }

/* Mode select, centred under the button */
.pair-mode { margin-top: 14px; }
.pair-mode label { text-align: left; color: var(--muted); font-size: 13px; font-weight: 600; }

/* Switches: centred, with the state beside them */
.perform .perf-swrow, .perf-overlay .perf-swrow { justify-content: center; margin: 4px 0 6px; }
.perf-switch { width: 72px; height: 40px; border-radius: 20px; }
.perf-switch .perf-knob { width: 34px; height: 34px; top: 3px; left: 3px; transition: transform 0.22s cubic-bezier(.3,1.4,.5,1); }
.perf-switch[aria-checked="true"] .perf-knob { transform: translateX(32px); }
.perf-swtext { min-width: 2.2em; text-align: left; }

/* Sub-blocks inside a card */
.perform .perf-sub, .perf-overlay .perf-sub { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.perform .perf-sub:empty, .perf-overlay .perf-sub:empty { display: none; }
.perform .perf-sub#notifyMount, .perf-overlay .perf-sub#notifyMount { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Notification dropdown */
.pair-notify { border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; margin-top: 14px; text-align: left; background: var(--paper); }
.pair-notify summary { text-align: center; font-size: 15px; font-weight: 600; color: var(--muted); padding: 13px 0; position: relative; }
.pair-notify summary::after { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); transition: transform 0.2s; content: '\25BE'; float: none; font-size: 16px; }
.pair-notify[open] summary::after { content: '\25BE'; transform: translateY(-50%) rotate(180deg); }
.pair-notify[open] summary { color: var(--ink); }
.pn-body { padding: 4px 0 14px; }
.pn-body .perf-hint { margin-top: 4px; }

/* Push success flash */
.perf-primary.done { background: #1fa95b !important; color: #fff !important; }

/* Permissions card */
#permSection { border-color: var(--accent); }
#permSection .perf-primary + .perf-primary { margin-top: 10px; }

/* Plain notes (push result, microphone meter) get no chip */
.perform .pair-status:not([data-state]), .perf-overlay .pair-status:not([data-state]) { background: none; padding: 2px 0; font-size: 13px; width: auto; display: block; margin: 8px auto 0; }
.perform .pair-status:not([data-state]):empty, .perf-overlay .pair-status:not([data-state]):empty { display: none; }

/* Admin block */
.admin-card { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); display: grid; gap: 6px; text-align: center; }
.admin-name { font-family: var(--display); font-weight: 700; font-size: 17px; }
.admin-line { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.admin-act { font-family: ui-monospace, Menlo, monospace; font-weight: 700; font-size: 20px; letter-spacing: 1px; padding: 8px 0; user-select: all; -webkit-user-select: all; }
.admin-card .perf-secondary { width: 100%; margin-top: 6px; }
