/* ============================================================
   9UY — Shared App Design System
   One stylesheet for every deck app. Replaces Tailwind + the
   per-app copies of the old "core 9UY" styles.

   Theming: dark is the default; light is applied automatically
   via prefers-color-scheme. No class toggling is required.
   Apps only need app-specific styles for their own components.
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  /* Let the browser theme native widgets (select popups, date pickers,
     scrollbars) to match the page instead of always rendering them light. */
  color-scheme: dark;

  /* surfaces */
  --bg:            #0a0a0a;
  --bg-panel:      rgba(17, 24, 39, 0.50);
  --bg-panel-solid:#111111;
  --bg-deep:       rgba(0, 0, 0, 0.22);
  --code-bg:       #171717;

  /* text */
  --fg:            #d4d4d8;
  --fg-bright:     #ffffff;
  --fg-strong:     #e5e7eb;
  --text-muted:    #9ca3af;
  /* --text-dim as text must clear 4.5:1 on the darkest shared surfaces too
     (#0a0a0a – #171717): #71717a was only ~4.1:1 on #0a0a0a. Stays below
     --text-muted so the two levels keep their order. */
  --text-dim:      #8b8b94;

  /* lines */
  --border:        #262626;
  --border-hover:  #3f3f46;
  --border-strong: #52525b;

  /* accents */
  --accent:        #10b981;
  --accent-blue:   #3b82f6;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --info:          #38bdf8;

  /* --accent used as *text*: on a dark surface it is already readable, but
     the light value (#059669) is only ~3.5:1 on a light one, so light mode
     swaps in the darker green below. Fills and borders keep --accent. */
  --accent-text:   var(--accent);

  /* effects */
  --grid-line:     rgba(255, 255, 255, 0.03);
  --hover-bg:      rgba(255, 255, 255, 0.05);
  --active-bg:     rgba(255, 255, 255, 0.10);
  --focus-ring:    var(--border-strong);
  --selection-bg:  #ffffff;
  --selection-fg:  #000000;
  --shadow-panel:  0 10px 40px -10px rgba(0, 0, 0, 0.5);

  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;

    --bg:            #f7f7f8;
    --bg-panel:      rgba(255, 255, 255, 0.72);
    --bg-panel-solid:#ffffff;
    --bg-deep:       rgba(0, 0, 0, 0.035);
    --code-bg:       #f4f4f5;

    --fg:            #3f3f46;
    --fg-bright:     #09090b;
    --fg-strong:     #18181b;
    --text-muted:    #71717a;
    --text-dim:      #71717a;

    --border:        #e4e4e7;
    --border-hover:  #c4c4c8;
    --border-strong: #a1a1aa;

    --accent:        #059669;
    --accent-blue:   #2563eb;
    --danger:        #dc2626;
    --warning:       #b45309;
    --info:          #0284c7;
    --accent-text:   #065f46;

    --grid-line:     rgba(0, 0, 0, 0.045);
    --hover-bg:      rgba(0, 0, 0, 0.045);
    --active-bg:     rgba(0, 0, 0, 0.08);
    --selection-bg:  #09090b;
    --selection-fg:  #ffffff;
    --shadow-panel:  0 10px 40px -12px rgba(0, 0, 0, 0.18);
  }
}

/* ── Reset / base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--fg);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 30px 30px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

main { flex-grow: 1; }

::selection { background: var(--selection-bg); color: var(--selection-fg); }

img, svg, canvas { max-width: 100%; }

/* ── Utilities ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex !important; }

/* A small semantic colour set so app JS can swap states without
   depending on Tailwind utility classes. */
.text-green-500 { color: #22c55e !important; }
.text-green-400 { color: #4ade80 !important; }
.text-yellow-400{ color: #facc15 !important; }
.text-yellow-500{ color: var(--warning) !important; }
.text-red-500   { color: var(--danger) !important; }
.text-amber-500 { color: var(--warning) !important; }
.text-gray-500  { color: var(--text-muted) !important; }
.text-gray-600  { color: var(--text-muted) !important; }
.text-white     { color: var(--fg-bright) !important; }
.text-muted     { color: var(--text-muted) !important; }
.border-gray-500 { border-color: var(--border-strong) !important; }
.hover\:text-green-400:hover  { color: #4ade80 !important; }
.hover\:text-yellow-400:hover { color: #facc15 !important; }
.w-8 { width: 2rem; }
.h-8 { height: 2rem; }

/* ── Scanline overlay ──────────────────────────────────────── */
.scanline {
  position: fixed;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(0, 0, 0, 0.15) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 100;
  opacity: 0.2;
}

/* Blinking cursor used in headers */
.block-cursor {
  display: inline-block;
  width: 0.6ch;
  height: 0.9em;
  background: var(--fg-bright);
  vertical-align: middle;
  margin-left: 4px;
  animation: cursor-blink 1s step-end infinite;
}
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ── Header ────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  /* A control-heavy app header is wider than a 320px viewport. Let the brand
     and the action cluster fall onto separate lines rather than pushing the
     header (and with it the document) past the viewport. */
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.app-header .header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.app-header .header-brand .deck-link {
  color: var(--text-muted);
  display: flex;
  flex-shrink: 0;
}

.back-link, .feedback-link, .deck-link {
  color: var(--text-muted);
  transition: color 0.15s ease, transform 0.1s ease;
  text-decoration: none;
  display: flex;
  align-items: center;
}
.back-link:hover, .feedback-link:hover, .deck-link:hover { color: var(--fg-bright); }
.deck-link:active { transform: scale(0.94); }

/* Apps that supply the shell's header controls themselves mark them up as
   <button> rather than <a>. A bare button keeps its UA chrome — in dark mode
   that is a filled grey box with a white border, around every header icon —
   so strip it here rather than in each app. */
button.back-link, button.feedback-link, button.deck-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  appearance: none;
}
.back-link svg, .feedback-link svg, .deck-link svg { width: 1.5rem; height: 1.5rem; }

.app-title {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-bright);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  /* Wrap the controls themselves when the cluster alone is wider than the
     viewport, and allow the cluster to be narrower than its content. */
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.status-indicator {
  font-size: 0.625rem;
  color: var(--accent-text);
  text-transform: uppercase;
  letter-spacing: -0.03em;
  font-weight: 700;
}
.status-indicator.error  { color: var(--danger); }
.status-indicator.active { animation: blink 2s infinite; }
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ── Footer ────────────────────────────────────────────────── */
.app-footer {
  width: 100%;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(4px);
  margin-top: auto;
  position: relative;
  z-index: 10;
}
.app-footer .footer-inner {
  max-width: 1400px;
  margin-inline: auto;
  padding: 2.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-align: center;
}
@media (min-width: 768px) {
  .app-footer .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}
.app-footer a, .app-footer button {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}
.app-footer a:hover, .app-footer button:hover { color: var(--fg-bright); }
.app-footer .footer-sep { color: var(--text-dim); }
.app-footer .footer-disclaimer { font-weight: 700; color: var(--text-muted); margin: 0; }

/* ── Main container ────────────────────────────────────────── */
.app-container {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin-inline: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  z-index: 10;
}
.app-container--sm  { max-width: 40rem; }
.app-container--md  { max-width: 56rem; }
.app-container--lg  { max-width: 64rem; }
.app-container--xl  { max-width: 72rem; }
.app-container--2xl { max-width: 80rem; }
.app-container--center { align-items: center; justify-content: center; }

/* ── Panels / cards ────────────────────────────────────────── */
.panel, .card, .editor-panel, .inspector-panel {
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.25s ease;
}
.panel:hover, .card:hover,
.editor-panel:hover, .inspector-panel:hover { border-color: var(--border-hover); }
.editor-panel:focus-within { border-color: var(--border-hover); }

.card { padding: 1.25rem; }

.panel-header, .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.card-header { border-bottom: none; background: transparent; padding: 0 0 1rem; }

.panel-label, .card-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}
.panel-label svg, .card-title svg { width: 13px; height: 13px; }

.panel-actions { display: flex; align-items: center; gap: 0.25rem; }

.panel-footer {
  padding: 0.3rem 0.875rem;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.char-count { font-size: 0.65rem; color: var(--text-dim); }

/* ── Layout helpers ────────────────────────────────────────── */
.split-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
}
@media (min-width: 900px) {
  .split-layout { flex-direction: row; }
}
.split-layout > * { flex: 1 1 0; min-width: 0; }

.editors-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  flex-shrink: 0;
  align-items: stretch;
}
.editors-row > * { min-width: 0; }
@media (max-width: 700px) {
  .editors-row { grid-template-columns: 1fr; }
}

/* ── Toolbars ──────────────────────────────────────────────── */
.toolbar, .import-bar, .inspector-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
  flex-wrap: wrap;
}
.inspector-header { justify-content: space-between; }
.inspector-header h2 {
  font-size: 0.875rem;
  margin: 0;
  color: var(--fg-bright);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.toolbar-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--border);
  margin: 0 0.5rem;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.diff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.mode-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ── Buttons ───────────────────────────────────────────────── */
.icon-button, .action-btn, .btn {
  background: transparent;
  color: var(--fg);
  border: 1px solid transparent;
  border-radius: 0.375rem;
  padding: 0.4rem 0.6rem;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  transition: all 0.18s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
  user-select: none;
  text-decoration: none;
}
.icon-button:hover, .action-btn:hover, .btn:hover {
  background: var(--hover-bg);
  border-color: var(--border-hover);
  color: var(--fg-bright);
}
.icon-button:active, .btn:active { transform: scale(0.97); }
.icon-button:focus-visible, .btn:focus-visible, .action-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}
.icon-button svg, .action-btn svg { width: 14px; height: 14px; }
.icon-button:disabled, .btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary, .icon-button.primary {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent-text);
}
.btn-primary:hover, .icon-button.primary:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-color: var(--accent);
  color: var(--fg-bright);
}
.btn-danger { border-color: var(--border-hover); color: var(--text-muted); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); color: var(--danger); }

/* Tab / segmented controls */
.tab-btn, .op-btn, .mode-btn, .fmt-tab, .flag-btn {
  font-family: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  user-select: none;
}
.tab-btn, .op-btn {
  font-size: 0.625rem;
  padding: 0.5rem 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.tab-btn:hover, .op-btn:hover, .mode-btn:hover, .fmt-tab:hover, .flag-btn:hover {
  color: var(--fg-bright);
  background: var(--hover-bg);
}
.tab-btn.active, .op-btn.active, .mode-btn.active, .fmt-tab.active {
  color: var(--fg-bright);
  background: var(--active-bg);
  border-color: var(--border-hover);
}

/* Preset / choice grid (timer-style apps) */
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
@media (min-width: 768px) { .preset-grid { gap: 1rem; } }
.preset-btn {
  font-family: inherit;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.75rem 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.18s ease;
}
.preset-btn:hover { color: var(--fg-bright); border-color: var(--border-hover); }
.preset-btn.active { color: var(--fg-bright); background: var(--active-bg); border-color: var(--border-strong); }
.tab-btn.active { color: var(--bg); background: var(--fg-bright); border-color: var(--fg-bright); }

.mode-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow: hidden;
}
.mode-btn { font-size: 0.65rem; padding: 0.3rem 0.7rem; border-radius: 0; }
.mode-btn + .mode-btn { border-left: 1px solid var(--border); }

/* ── Segmented bar (mode / tab pickers) ────────────────────── */
.tab-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-deep);
  width: fit-content;
  flex-wrap: wrap;
}

/* ── Split panes (editor / output) ─────────────────────────── */
.split-panes {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
  min-height: 400px;
}
@media (min-width: 1024px) {
  .split-panes { flex-direction: row; }
}
.split-panes > .editor-panel { flex: 1; min-width: 0; }
.editor-panel .pane-body { position: relative; flex: 1; display: flex; min-height: 0; }
.editor-panel textarea { flex: 1; resize: none; }

/* ── Form fields ───────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 0.5rem; }
.field-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}
.field-input, .import-bar input[type="text"], .lang-select, input[type="text"], input[type="number"], input[type="search"], input[type="url"], input[type="date"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg-strong);
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 0.55rem 0.8rem;
  border-radius: 0.375rem;
  outline: none;
  transition: border-color 0.18s ease;
}
.field-input:hover, .import-bar input[type="text"]:hover { border-color: var(--border-hover); }
.field-input:focus, .import-bar input[type="text"]:focus,
.lang-select:focus, input:focus, textarea:focus { border-color: var(--border-strong); }
.field-input::placeholder, textarea::placeholder, input::placeholder { color: var(--text-dim); }

textarea, .field-textarea {
  width: 100%;
  background: transparent;
  color: var(--fg-strong);
  border: 1px solid transparent;
  padding: 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  white-space: pre;
  tab-size: 2;
}
.field-textarea { background: var(--bg); border-color: var(--border); border-radius: 0.375rem; }

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.18s;
}
.check-label:hover { color: var(--fg-bright); }
.check-label input[type="checkbox"] { accent-color: var(--accent); width: 12px; height: 12px; cursor: pointer; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* Hide number-input spinners */
.hide-arrows::-webkit-outer-spin-button,
.hide-arrows::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.hide-arrows { -moz-appearance: textfield; appearance: textfield; }

/* ── Messages / status ─────────────────────────────────────── */
.validation-msg {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.validation-msg.valid   { color: var(--accent-text); }
.validation-msg.invalid { color: var(--danger); }
.placeholder-text { color: var(--text-dim); text-align: center; margin-top: 2rem; font-style: italic; }

.status-message, .error-banner {
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  text-align: center;
}
.status-message.error, .error-banner {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}
.status-message.loading {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent-text);
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.form-notice {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  border-radius: 0.375rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.6;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  font-size: 0.6rem;
  border-radius: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

/* Two-up form row (contact / any name pair) */
.name-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.badge, .match-badge, .stats-pill {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.match-badge.no-matches { color: var(--text-dim); }
.match-badge.has-matches { color: var(--warning); }

/* ── Size meter ────────────────────────────────────────────── */
.size-meter { margin-bottom: 0.5rem; }
.size-meter-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.size-meter-bar {
  height: 100%;
  background: var(--fg);
  width: 0%;
  transition: width 0.3s ease, background 0.3s ease;
}
.size-meter-bar.size-warn  { background-color: var(--warning); }
.size-meter-bar.size-error { background-color: var(--danger); }
.size-meter-label {
  font-size: 0.625rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.25rem;
  text-align: right;
}
.size-hint { font-size: 0.75rem; color: var(--text-muted); line-height: 1.5; }
.option-group { margin-bottom: 1.5rem; }
.option-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}
.option-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; cursor: pointer; }

/* ── Big display / action row (timer-style apps) ───────────── */
.app-display, .custom-display-wrapper {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s;
}
.app-display.ringing, .custom-display-wrapper.ringing { border-color: var(--danger); }

.time-inputs { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; flex-grow: 1; }
.time-input-row { display: flex; align-items: center; gap: 0.5rem; }
.time-input { width: 4rem; text-align: center; font-size: 1.25rem; }
.time-sep { color: var(--text-muted); font-size: 1.25rem; }
.display-value {
  font-size: clamp(2.75rem, 12vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--fg-bright);
  font-variant-numeric: tabular-nums;
}
.timer-pulse { animation: flashAlert 1s infinite alternate; }
@keyframes flashAlert {
  0%   { color: var(--danger); }
  100% { color: color-mix(in srgb, var(--danger) 60%, white); }
}

.actions-row {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  display: flex;
  justify-content: center;
  gap: 2rem;
}
.actions-row .action-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  transition: color 0.18s;
}
.actions-row .action-button svg { width: 1.5rem; height: 1.5rem; }
.actions-row .action-button.primary:hover { color: var(--accent-text); }
.actions-row .action-button.danger:hover  { color: var(--danger); }
.actions-row .action-button:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Regex-family components ───────────────────────────────── */
.pattern-wrap {
  display: flex;
  align-items: stretch;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.pattern-wrap:focus-within { border-color: var(--border-strong); }
.pattern-wrap.error { border-color: var(--danger); }
.pattern-slash {
  display: flex;
  align-items: center;
  padding: 0 0.625rem;
  color: var(--text-dim);
  font-size: 1.125rem;
  user-select: none;
  flex-shrink: 0;
}
.pattern-wrap input {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0.625rem 0;
  font-size: 0.9375rem;
}
.pattern-wrap input:focus { border: none; }
.flag-btn {
  border-radius: 0;
  border-left: 1px solid var(--border);
  font-size: 0.75rem;
  padding: 0 0.625rem;
  color: var(--text-dim);
}
.flag-btn.active { color: var(--fg-bright); background: var(--border); }

.error-msg { font-size: 0.625rem; color: var(--danger); letter-spacing: 0.05em; padding: 4px 2px; min-height: 18px; }
.warn-msg  { font-size: 0.625rem; color: var(--warning); letter-spacing: 0.05em; padding: 4px 2px; }

.section-label {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* ── Offline indicator + About bottom-sheet ───────────────────
   Rendered by assets/js/shell.js and styled in api.css, which every app
   loads — including the ones with no design system yet. Keep them there so
   one implementation covers the whole suite.
   ──────────────────────────────────────────────────────────── */

/* ── Scrollbars ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── Reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
