/* ===================================================================
   Design tokens
   =================================================================== */
:root {
  --bg: #ffffff;
  --surface: #fafaf9;
  --surface-raised: #ffffff;
  --surface-hover: #f4f4f2;
  --border: #ebeae6;
  --border-strong: #d9d7d0;

  --text: #111113;
  --text-dim: #5d5c57;
  --text-faint: #9b998f;

  /* Ink is the primary action colour; gold is a rare, refined highlight */
  --accent: #111113;
  --accent-hover: #2b2b30;
  --on-accent: #ffffff;
  --accent-dim: #d9d7d0;
  --accent-wash: rgba(17, 17, 19, 0.04);
  --gold: #a9834c;
  --gold-wash: rgba(169, 131, 76, 0.1);

  --danger: #c4323a;
  --danger-wash: rgba(196, 50, 58, 0.07);
  --success: #17794a;
  --success-wash: rgba(23, 121, 74, 0.08);

  --font-display: "Inter", system-ui, sans-serif;
  --font-serif: "Instrument Serif", "Times New Roman", serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --ring: var(--ring);
  --accent-line: var(--accent-line);
  --glow: rgba(169, 131, 76, 0.13);
  --glow-2: rgba(17, 17, 19, 0.035);
  --nav-bg: rgba(255, 255, 255, 0.82);
  --overlay: rgba(17, 17, 19, 0.38);
  --selection: #ece3d3;
  --card-bg: #ffffff;
  --btn-shadow: 0 1px 2px rgba(17,17,19,.18), inset 0 1px 0 rgba(255,255,255,.12);
  --btn-shadow-hover: 0 6px 18px rgba(17,17,19,.20);
  color-scheme: light;

  --shadow-sm: 0 1px 2px rgba(17, 17, 19, 0.04), 0 1px 1px rgba(17, 17, 19, 0.03);
  --shadow-md: 0 4px 16px rgba(17, 17, 19, 0.06), 0 1px 3px rgba(17, 17, 19, 0.04);
  --shadow-lg: 0 18px 48px rgba(17, 17, 19, 0.10), 0 4px 12px rgba(17, 17, 19, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

input {
  font-family: inherit;
}

::selection {
  background: var(--selection);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===================================================================
   Waveform mark (signature motif — frozen, not looping)
   =================================================================== */
.waveform-mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 28px;
}

.waveform-mark span {
  display: block;
  width: 3px;
  background: var(--gold);
  border-radius: 1px;
}

/* ===================================================================
   Login page
   =================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-mark {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.login-mark .waveform-mark { height: 40px; gap: 4px; }
.login-mark .waveform-mark span { width: 4px; }

.login-heading {
  text-align: center;
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.login-sub {
  text-align: center;
  margin: 0 0 36px;
  font-size: 14px;
  color: var(--text-dim);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.field input:hover { border-color: var(--border-strong); }

.field input:focus {
  border-color: var(--accent);
  outline: none;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.form-error {
  display: none;
  background: var(--danger-wash);
  border: 1px solid rgba(196, 50, 58, 0.3);
  color: var(--danger);
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.form-error.visible { display: block; }

.login-foot {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ===================================================================
   Dashboard — top bar
   =================================================================== */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
}

.topbar-search {
  flex: 1;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-faint);
  font-size: 13px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13px;
  color: var(--text-dim);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: var(--surface-raised); color: var(--text); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
}

/* ===================================================================
   Dashboard — workspace
   =================================================================== */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 40px;
  min-width: 0;
}

.canvas textarea {
  flex: 1;
  width: 100%;
  resize: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  line-height: 1.6;
  font-family: var(--font-body);
}

.canvas textarea::placeholder { color: var(--text-faint); }

.canvas-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.canvas-footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.canvas-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn-outline {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn-outline:hover { border-color: var(--border-strong); color: var(--text); }

.btn-generate {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-generate:hover { background: var(--accent-hover); }

.btn-generate:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ===================================================================
   Player boxes — processing / error / ready states.
   Exactly one of these three is visible at a time; a non-functional
   Download control must never be reachable in the processing or error
   states, so it simply doesn't exist in their markup.
   =================================================================== */
.player-box {
  margin-top: 18px;
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  font-size: 13px;
}

.player-box.visible { display: flex; }

.player-box--processing { color: var(--text-dim); }

.player-box--error {
  color: var(--danger);
  background: var(--danger-wash);
  border-color: rgba(196, 50, 58, 0.3);
}

.ap-error-icon { width: 18px; height: 18px; flex-shrink: 0; }

.ap-spinner {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: ap-spin 0.8s linear infinite;
}

@keyframes ap-spin {
  to { transform: rotate(360deg); }
}

/* ===================================================================
   Audio player — the "ready" state
   =================================================================== */
.audio-player {
  margin-top: 18px;
  display: none;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.audio-player.visible { display: flex; }

.audio-player audio { display: none; }

.ap-top-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ap-play-btn {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.ap-play-btn:hover { background: var(--accent-hover); }
.ap-play-btn:active { transform: scale(0.94); }

.ap-icon { width: 20px; height: 20px; }
.ap-play-btn .ap-icon { width: 18px; height: 18px; }

.ap-seek-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ap-seek-track {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
}

.ap-seek-buffered,
.ap-seek-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  border-radius: 2px;
  pointer-events: none;
}

.ap-seek-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.ap-seek-buffered { background: var(--border-strong); z-index: 1; }
.ap-seek-fill { background: var(--accent); z-index: 2; }

.ap-seek-handle {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px var(--ring);
  pointer-events: none;
  z-index: 3;
}

.ap-seek-input {
  position: relative;
  z-index: 4;
  width: 100%;
  margin: 0;
  height: 20px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.ap-seek-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: transparent;
}

.ap-seek-input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
}

.ap-seek-input::-moz-range-track { background: transparent; }

.ap-time-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.ap-download-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.ap-download-btn:hover { border-color: var(--accent); color: var(--accent); }

.ap-download-btn:disabled {
  opacity: 0.5;
  cursor: default;
  border-color: var(--border);
  color: var(--text-dim);
}

.ap-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.ap-volume-block {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ap-icon-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.ap-icon-btn:hover { color: var(--text); background: var(--surface-raised); }

.ap-volume-slider {
  width: 100px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
}

.ap-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.ap-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
}

.ap-speed-block {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.ap-speed-select {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
}

@media (max-width: 560px) {
  .ap-top-row { flex-wrap: wrap; }
  .ap-seek-block { order: 3; width: 100%; }
  .ap-download-btn span { display: none; }
  .ap-bottom-row { flex-wrap: wrap; }
}

.canvas-error {
  display: none;
  margin-top: 14px;
  background: var(--danger-wash);
  border: 1px solid rgba(196, 50, 58, 0.3);
  color: var(--danger);
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.canvas-error.visible { display: block; }

/* ===================================================================
   Dashboard — settings rail
   =================================================================== */
.rail {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  padding: 24px 24px 40px;
  overflow-y: auto;
}

.rail-tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.rail-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 0 0 12px;
  border-bottom: 2px solid transparent;
}

.rail-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.rail-panel { display: none; }
.rail-panel.active { display: block; }

.promo-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 26px;
  position: relative;
}

.promo-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent-wash);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.promo-mark .waveform-mark { height: 18px; gap: 2px; }
.promo-mark .waveform-mark span { width: 2px; }

.promo-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 4px;
}

.promo-body {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.5;
}

.promo-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1;
}

.field-group { margin-bottom: 26px; }

.field-group-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.select-row:hover { border-color: var(--border-strong); }

.select-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.select-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d9c3a0, #a9834c);
  flex-shrink: 0;
}

.chev { color: var(--text-faint); }

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 10px;
}

.slider-row-label { font-weight: 500; }
.slider-row-value { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; }

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--border-strong);
  border-radius: 2px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: none;
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: none;
}

.slider-caps {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 8px;
}

/* History panel */
.history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.history-item-text {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--text);
  line-height: 1.4;
}

.history-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.history-item-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.history-empty {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 40px 0;
}

@media (max-width: 860px) {
  .rail { display: none; }
  .canvas { padding: 24px; }
}

/* ===================================================================
   Admin page
   =================================================================== */
.admin-main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 48px 24px;
}

.admin-inner {
  width: 100%;
  max-width: 520px;
}

.admin-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  margin: 0 0 4px;
}

.admin-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 28px;
}

.admin-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 32px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field { flex: 1; }

.form-success {
  display: none;
  background: var(--success-wash);
  border: 1px solid rgba(23, 121, 74, 0.3);
  color: var(--success);
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.form-success.visible { display: block; }

.user-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.user-list-heading h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  margin: 0;
}

.user-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.user-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-row-name {
  font-size: 14px;
}

.user-row-name .tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 8px;
}

.user-row-credits {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.user-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.user-row-access {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.user-row-access-edit {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.user-row-access-edit.visible { display: flex; }

.user-row-access-edit input[type="time"] {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 4px 6px;
}

.user-list-empty {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

.admin-hint {
  font-size: 12px;
  color: var(--text-faint);
  margin: -6px 0 16px;
}

/* ===================================================================
   Modal (voice ID entry)
   =================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.visible { display: flex; }

.modal-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 22px;
  margin: 16px;
}

.modal-label {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.modal-body-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 18px;
}

.modal-input {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
}

.modal-input:focus {
  border-color: var(--accent);
  outline: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
}

.btn-secondary:hover { border-color: var(--border-strong); color: var(--text); }

.modal-actions .btn-primary {
  width: auto;
  margin-top: 0;
  padding: 10px 18px;
}

/* ===================================================================
   Voice picker (searchable voice selection)
   A wider modal that hosts a search field and a scrollable list of
   every available voice. Results are filtered client-side from a
   catalog fetched once, so typing stays instant.
   =================================================================== */
.modal-card-wide { max-width: 560px; }

.voice-search {
  position: relative;
  display: flex;
  align-items: center;
}

.voice-search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}

.voice-search-input {
  padding-left: 36px;
  padding-right: 38px;
  font-family: var(--font-sans);
}

.voice-search-clear {
  position: absolute;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.voice-search-clear:hover { background: var(--surface-hover); color: var(--text); }

.voice-search-meta {
  margin: 8px 2px 0;
  font-size: 12px;
  color: var(--text-faint);
  min-height: 15px;
}

.voice-list {
  margin-top: 10px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.voice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
}

.voice-row:last-child { border-bottom: none; }
.voice-row:hover,
.voice-row.active { background: var(--surface-hover); }
.voice-row.selected { background: var(--accent-wash); }

.voice-row-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.voice-row-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-row-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-row-meta {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: capitalize;
  white-space: nowrap;
}

.voice-list-state {
  padding: 22px 16px;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

.voice-list-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
}

.voice-list-error p { margin: 0; }

.voice-list-error .btn-small {
  padding: 8px 14px;
  font-size: 12px;
}

/* ===================================================================
   Backend credit refresh toast
   Intentionally NOT a .modal-overlay: the rest of the app must stay
   usable while the shared backend credit pool refreshes, so this is a
   corner toast rather than a screen-blocking dialog. Only the Generate
   button is disabled while it's visible.
   =================================================================== */
.refresh-toast {
  display: none;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  align-items: center;
  gap: 14px;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
}

.refresh-toast.visible {
  display: flex;
  animation: refresh-toast-in 0.2s ease;
}

@keyframes refresh-toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.refresh-toast-ring {
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.refresh-toast-ring-svg {
  width: 36px;
  height: 36px;
  transform: rotate(-90deg);
}

.refresh-toast-ring-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}

.refresh-toast-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100.5;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.refresh-toast-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
}

.refresh-toast-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.refresh-toast-body {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
}

.canvas-error.info {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: var(--accent);
}
/* ===================================================================
   API panel (dashboard rail)
   =================================================================== */
.api-panel-intro {
  margin-bottom: 20px;
}

.api-panel-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  margin: 0 0 6px;
}

.api-panel-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.api-docs-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.api-docs-link:hover { text-decoration: underline; }

.api-key-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
}

.api-key-box-label {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.api-key-preview {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 8px;
  word-break: break-all;
}

.api-key-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin: 0 0 12px;
}

.api-key-reveal {
  border: 1px solid var(--accent-line);
  background: var(--accent-wash);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
}

.api-key-reveal-label {
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 8px;
}

.api-key-reveal-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 10px;
  word-break: break-all;
  user-select: all;
}

.api-key-error {
  display: none;
  font-size: 12px;
  color: var(--danger);
  background: var(--danger-wash);
  border: 1px solid rgba(196, 50, 58, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.api-key-error.visible { display: block; }

.access-window-label {
  color: var(--text-faint);
}

/* -------------------------------------------------------------------
   Credit purchase affordances (added with the payment flow)
   -------------------------------------------------------------------
   New accounts start at 0 credits, so the footer needs to (a) always
   offer a way to buy more and (b) say plainly why Generate won't work
   yet. Both live in the existing footer row; the notice wraps onto its
   own line so it doesn't crowd the balance read-out. */

.canvas-footer-left {
  flex-wrap: wrap;
  row-gap: 6px;
}

.buy-credits-link {
  color: var(--accent);
  font-family: var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
}

.buy-credits-link:hover {
  color: var(--text);
}

.credits-label--empty {
  color: var(--danger);
}

.zero-credits-notice {
  flex-basis: 100%;
  color: var(--text-dim);
  font-family: var(--font-body);
}

.zero-credits-notice[hidden] {
  display: none;
}

/* ===================================================================
   Admin: payment order review panel
   -------------------------------------------------------------------
   Mirrors the visual language of the user rows above it, with two extra
   signals that matter for this screen: a status pill (so the queue can be
   scanned at a glance) and a clearly destructive-vs-constructive pair of
   actions.
   =================================================================== */

.admin-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.admin-badge[hidden] { display: none; }

.payment-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
}

.filter-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-wash);
}

.payment-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.payment-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.payment-row-who {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.payment-ref {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

.payment-row .tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

.payment-row-mid {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.payment-row-mid strong {
  color: var(--text);
  font-weight: 600;
}

.payment-row-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}

.payment-row-note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--border-strong);
}

.payment-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* Status pills — kept here (not just on the marketing pages) because the
   admin panel is the screen where the status actually gets decided. */
.status-pill {
  display: inline-block;
  font-size: 11px;
  border-radius: 999px;
  padding: 2px 9px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.status-pill--pending { color: var(--text-dim); }

.status-pill--verification_required {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-wash);
}

.status-pill--approved {
  color: var(--success);
  border-color: rgba(23, 121, 74, 0.3);
  background: var(--success-wash);
}

.status-pill--rejected {
  color: var(--danger);
  border-color: rgba(196, 50, 58, 0.3);
  background: var(--danger-wash);
}


/* ===================================================================
   Premium white theme — dashboard & app refinements
   =================================================================== */
.login-heading { font-family: var(--font-serif); font-weight: 400; font-size: 30px; }
.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.login-page {
  background: radial-gradient(ellipse 60% 50% at 50% 0%, var(--glow), transparent 70%), var(--bg);
}
.btn-primary { border-radius: 999px; }
.btn-generate { border-radius: 999px; }
.modal-overlay .modal, .modal-card { box-shadow: var(--shadow-lg); border-radius: var(--radius-lg); }


/* ===================================================================
   Dark theme — black with crimson, taken from the wolf-sigil logo.
   Applied via <html data-theme="dark"> (see theme.js).
   =================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0a0b;
  --surface: #111113;
  --surface-raised: #151517;
  --surface-hover: #1c1c1f;
  --border: #242427;
  --border-strong: #35353a;

  --text: #f4f2ee;
  --text-dim: #a5a39c;
  --text-faint: #6f6d66;

  --accent: #e5383b;
  --accent-hover: #f24f52;
  --on-accent: #ffffff;
  --accent-dim: #5a1a1c;
  --accent-wash: rgba(229, 56, 59, 0.10);
  --gold: #ff5b4f;
  --gold-wash: rgba(255, 91, 79, 0.12);

  --danger: #ff6b70;
  --danger-wash: rgba(255, 107, 112, 0.10);
  --success: #4cd08a;
  --success-wash: rgba(76, 208, 138, 0.10);

  --ring: rgba(229, 56, 59, 0.28);
  --accent-line: rgba(229, 56, 59, 0.45);
  --glow: rgba(229, 56, 59, 0.20);
  --glow-2: rgba(229, 56, 59, 0.06);
  --nav-bg: rgba(10, 10, 11, 0.78);
  --overlay: rgba(0, 0, 0, 0.7);
  --selection: #5a1a1c;
  --card-bg: #111113;
  --btn-shadow: 0 1px 2px rgba(0,0,0,.5), 0 0 0 1px rgba(229,56,59,.35), 0 4px 18px rgba(229,56,59,.18);
  --btn-shadow-hover: 0 0 0 1px rgba(242,79,82,.55), 0 8px 28px rgba(229,56,59,.34);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(229, 56, 59, 0.08);
}

/* Theme toggle button + logo images (shared by every page) */
.theme-toggle {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  padding: 0;
  transition: background .2s ease, border-color .2s ease, transform .15s ease;
}
.theme-toggle:hover { background: var(--surface-hover); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.brand-logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  object-fit: cover;
  display: block;
  box-shadow: 0 0 0 1px var(--border), 0 2px 8px rgba(0,0,0,.18);
}
.hero-logo {
  width: 104px; height: 104px;
  border-radius: 28px;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  box-shadow: 0 0 0 1px var(--border-strong), var(--shadow-lg), 0 0 60px var(--glow);
}
.auth-logo, .login-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  box-shadow: 0 0 0 1px var(--border-strong), var(--shadow-md), 0 0 36px var(--glow);
}
.topbar .brand-logo { width: 26px; height: 26px; border-radius: 8px; }
.topbar-title { display: flex; align-items: center; gap: 10px; }

.floating-toggle { position: fixed; top: 18px; right: 18px; z-index: 60; }
.topbar-right .theme-toggle { width: 34px; height: 34px; }

/* Smooth cross-fade when switching theme */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .25s ease, border-color .25s ease, color .25s ease, box-shadow .25s ease !important;
}
