:root {
  /* dark theme (default) */
  --bg-0: #0a1018;
  --bg-1: #131c2a;
  --bg-2: #1c2738;
  --border: #2b3a52;
  --text: #e2ebf5;
  --text-dim: #95a5be;
  --text-muted: #6b7c95;
  --accent: #7eb6e6;
  --accent-soft: rgba(126, 182, 230, 0.12);
  --accent-strong: #9bc7ee;
  --on-accent: #0a1422;
  --success: #7cd1a4;
  --danger: #e0796b;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
  --body-bg: radial-gradient(ellipse at top, #1a2638 0%, var(--bg-0) 55%);
  --topbar-bg: rgba(10, 16, 24, 0.6);
  --radius: 14px;
  --radius-sm: 8px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", -apple-system, system-ui, sans-serif;
}

body[data-theme="light"] {
  --bg-0: #f3f6fb;
  --bg-1: #ffffff;
  --bg-2: #e9eef6;
  --border: #d9e0ea;
  --text: #1a2638;
  --text-dim: #4a5870;
  --text-muted: #8190a8;
  --accent: #3a7cb7;
  --accent-soft: rgba(58, 124, 183, 0.10);
  --accent-strong: #2c6aa3;
  --on-accent: #ffffff;
  --success: #2c8f5e;
  --danger: #c25646;
  --shadow: 0 8px 30px -10px rgba(58, 124, 183, 0.25), 0 1px 3px rgba(0, 0, 0, 0.06);
  --body-bg: radial-gradient(ellipse at top, #e6eef8 0%, var(--bg-0) 55%);
  --topbar-bg: rgba(255, 255, 255, 0.75);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--body-bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  transition: background 0.4s ease, color 0.2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

/* ---- topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.theme-toggle, .demos-trigger {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  margin-left: 6px;
}
.demos-trigger svg { width: 18px; height: 18px; }
.demos-trigger:hover { color: var(--accent); border-color: var(--accent); }
.demos-trigger:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.demos-menu { position: relative; }
.demos-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-width: 200px;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 100;
}
.demos-menu.open .demos-dropdown,
.demos-menu:hover .demos-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.demos-dropdown a {
  display: block;
  padding: 9px 14px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  font-family: inherit;
}
.demos-dropdown a:hover { background: var(--bg-1); color: var(--accent); }
.demos-dropdown a.active { color: var(--accent); background: var(--accent-soft); }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(15deg); }
.theme-toggle:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.lang-toggle {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  font-family: ui-monospace, monospace;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  margin-left: 6px;
}
.lang-toggle:hover { color: var(--accent); border-color: var(--accent); }
.lang-toggle:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.lang-toggle.busy { opacity: 0.6; cursor: wait; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark { font-size: 22px; color: var(--accent); transform: rotate(-15deg); }
.brand-name { font-family: var(--serif); font-size: 22px; letter-spacing: 0.5px; }
.nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}
.nav a {
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  transition: all 0.2s ease;
}
.nav a:hover { color: var(--text); background: var(--bg-2); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }

.credits-icon {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
}
.credits-icon:hover { color: var(--accent); border-color: var(--accent); }
.credits-icon:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.credits-icon svg { width: 16px; height: 16px; }
.credits-icon.c-warn   { color: var(--accent); border-color: var(--accent); }
.credits-icon.c-danger { color: var(--danger); border-color: var(--danger); }

.credits-icon[data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-weight: 400;
  white-space: pre-line;
  width: max-content;
  max-width: 280px;
  text-align: left;
  line-height: 1.7;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 100;
}
.credits-icon[data-tip]::after {
  content: '';
  position: absolute;
  top: calc(100% + 4px);
  right: 10px;
  border: 6px solid transparent;
  border-bottom-color: var(--border);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 100;
}
.credits-icon:hover::before,
.credits-icon:hover::after {
  opacity: 1;
  transform: translateY(0);
}

/* ---- layout ---- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.4fr);
  gap: 28px;
}
@media (max-width: 900px) {
  .page { grid-template-columns: 1fr; }
}

.col-form { min-width: 0; }
.col-output { min-width: 0; }

/* ---- card ---- */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }
/* Library card sits in col-output. Add a top gap ONLY when there is a visible sibling above (output card or orb wrap). */
.library-card { margin-top: 0; }
#output:not(:empty) ~ .library-card { margin-top: 20px; }
.library-orb-wrap:not(:empty) + .library-card { margin-top: 0; }

.card-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 4px;
  letter-spacing: 0.3px;
}
.card-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 16px;
}

/* ---- form ---- */
.field { margin-bottom: 12px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field-hint { color: var(--text-muted); font-size: 12px; margin-top: 5px; }

.info-i {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 12px;
  text-align: center;
  margin-left: 5px;
  cursor: help;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
  transition: all 0.15s ease;
}
.info-i:hover { color: var(--accent); border-color: var(--accent); }

.info-i[data-tip]::before,
.info-i[data-tip]::after {
  content: '';
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 100;
}
.info-i[data-tip]::before {
  content: attr(data-tip);
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  text-align: left;
  line-height: 1.5;
  box-shadow: var(--shadow);
  font-family: var(--sans);
}
.info-i[data-tip]::after {
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 6px solid transparent;
  border-top-color: var(--border);
  width: 0;
  height: 0;
}
.info-i[data-tip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.info-i[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

input[type="text"], textarea, select {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2395a5be' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 L6 6 L10.5 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
body[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%234a5870' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 L6 6 L10.5 1.5'/%3E%3C/svg%3E");
}
select:hover {
  border-color: var(--accent);
}
select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%237eb6e6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 L6 6 L10.5 1.5'/%3E%3C/svg%3E");
}
body[data-theme="light"] select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%233a7cb7' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 L6 6 L10.5 1.5'/%3E%3C/svg%3E");
}
select option { background: var(--bg-1); color: var(--text); }
input[type="text"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-1);
}
textarea { resize: vertical; min-height: 60px; line-height: 1.45; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
  max-height: 92px;
  overflow: hidden;
  position: relative;
  transition: max-height 0.3s ease;
}
.chips.expanded { max-height: 1200px; }
.chips::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(to bottom, transparent, var(--bg-1));
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.chips.expanded::after { opacity: 0; }
.chips-toggle {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  user-select: none;
}
.chips-toggle:hover { color: var(--accent-strong); }
.chip {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--text); border-color: var(--accent); }

.radio-row { display: flex; gap: 5px; flex-wrap: nowrap; }
.radio-row label {
  flex: 1 1 0;
  min-width: 0;
  background: var(--bg-0);
  border: 1px solid var(--border);
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.radio-row.voice-row label {
  padding: 8px 4px;
}
.radio-row.voice-row label svg {
  display: block;
  margin: 0 auto;
  width: 22px;
  height: 22px;
  color: var(--text-dim);
  transition: color 0.15s ease;
}
.radio-row.voice-row label:hover svg { color: var(--text); }
.radio-row.voice-row label:has(input:checked) svg { color: var(--accent); }

.voice-pick, .bg-pick {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.voice-pick .voice-row { flex: 1; }
.bg-pick select { flex: 1; }
.bg-pick .voice-preview-btn { width: 38px; padding: 0; }
.voice-preview-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.voice-preview-btn:hover { color: var(--accent); border-color: var(--accent); }
.voice-preview-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.voice-preview-btn.playing { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.voice-more {
  margin-top: 10px;
  min-width: 0;
  max-width: 100%;
}
.voice-more > summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  list-style: none;
  user-select: none;
  padding: 6px 0;
  transition: color 0.15s ease;
}
.voice-more > summary::-webkit-details-marker { display: none; }
.voice-more > summary::marker { display: none; }
.voice-more > summary::before {
  content: "▸";
  display: inline-block;
  color: var(--accent);
  width: 14px;
  margin-right: 2px;
  transition: transform 0.2s ease;
}
.voice-more[open] > summary::before { content: "▾"; }
.voice-more > summary:hover { color: var(--accent); }
.voice-more-count {
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  margin-left: 8px;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: none;
}

.voice-list {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-0);
  padding: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.voice-list::-webkit-scrollbar { width: 6px; }
.voice-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.voice-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.voice-row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--bg-2);
  transition: background 0.12s ease;
  position: relative;
}
.voice-row-item:last-child { border-bottom: none; }
.voice-row-item:hover { background: var(--bg-2); }
.voice-row-item:has(input:checked) {
  background: var(--accent-soft);
}
.voice-row-item:has(input:checked)::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.voice-row-item:has(input:checked) .vr-name { color: var(--accent); }
.voice-row-item input[type="radio"] { display: none; }
.voice-row-item .vr-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-family: var(--sans);
}
.voice-row-item .vr-preview {
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.voice-row-item .vr-preview:hover { color: var(--accent); border-color: var(--accent); }
.voice-row-item .vr-preview.playing { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.voice-row-item .vr-badge {
  font-size: 9px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-1);
  border-radius: 999px;
  padding: 1px 7px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.voice-row-item:has(input:checked) .vr-badge {
  color: var(--accent);
  border-color: var(--accent);
}
.vr-badge.vr-library {
  color: var(--text-dim);
  border-color: var(--text-muted);
}
.voice-row-item:has(input:checked) .vr-badge.vr-library {
  color: var(--accent);
  border-color: var(--accent);
}
.voice-row-item .vr-lang {
  font-size: 9px;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  flex-shrink: 0;
}

.voice-list-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--bg-2);
  background: var(--bg-1);
  position: sticky;
  top: 0;
  z-index: 1;
}
.vl-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.4px;
}
.vl-toggle:hover { color: var(--text); border-color: var(--accent); }
.vl-toggle.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.voice-list-empty {
  padding: 24px;
  text-align: center;
  font-style: italic;
  color: var(--text-muted);
  font-size: 13px;
}
.radio-row label:hover { border-color: var(--accent); }
.radio-row input[type="radio"] { display: none; }
.radio-row input[type="radio"]:checked + span { color: var(--accent); font-weight: 500; }
.radio-row label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-2 > .field { min-width: 0; }
@media (max-width: 600px) { .row-2 { grid-template-columns: 1fr; } }

details.advanced {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.voice-more {
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}
/* When normalize + voice-more share a row, remove the dashed top on voice-more (the row itself separates) and align vertically */
.row-extras { align-items: start; margin-top: 14px; }
.row-extras .voice-more { margin-top: 0; border-top: none; padding-top: 0; }
.row-extras .field { margin-bottom: 0; }
details.advanced > summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.5px;
  list-style: none;
  user-select: none;
  padding: 4px 0;
}
details.advanced > summary::before {
  content: "▸ ";
  color: var(--accent);
  transition: transform 0.2s;
  display: inline-block;
}
details.advanced[open] > summary::before { content: "▾ "; }

.slider-row { display: flex; align-items: center; gap: 14px; padding: 4px 0; }
.slider-row input[type="range"] { flex: 1; }
.slider-val {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--accent);
  min-width: 42px;
  text-align: right;
  padding: 3px 8px;
  background: var(--bg-0);
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ---- range slider — custom themed ---- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  outline: none;
}
/* webkit (Chrome/Safari) — track + fill via gradient driven by --fill (set by JS) */
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--fill, 50%),
    var(--bg-2) var(--fill, 50%),
    var(--bg-2) 100%
  );
  border-radius: 2px;
  border: 1px solid var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-1);
  margin-top: -7px;
  box-shadow: 0 0 0 1px var(--accent), 0 0 10px rgba(126, 182, 230, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: grab;
}
input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus::-webkit-slider-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 0 1px var(--accent-strong), 0 0 16px rgba(126, 182, 230, 0.6);
}
input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.1); }

/* firefox */
input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--bg-2);
  border-radius: 2px;
  border: 1px solid var(--border);
}
input[type="range"]::-moz-range-progress {
  background: var(--accent);
  height: 4px;
  border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-1);
  box-shadow: 0 0 0 1px var(--accent), 0 0 10px rgba(126, 182, 230, 0.35);
  cursor: grab;
}
input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:focus::-moz-range-thumb {
  transform: scale(1.2);
  box-shadow: 0 0 0 1px var(--accent-strong), 0 0 16px rgba(126, 182, 230, 0.6);
}

/* ---- checkbox — themed ---- */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-0);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: all 0.15s ease;
  vertical-align: middle;
}
input[type="checkbox"]:hover { border-color: var(--accent); }
input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.btn-row { display: flex; gap: 8px; margin-top: 18px; }
.btn {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: transparent; transform: none; }
.btn.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn.btn-danger { background: transparent; border: 1px solid rgba(226, 109, 109, 0.5); color: #e26d6d; }
.btn.btn-danger:hover { background: rgba(226, 109, 109, 0.12); border-color: #e26d6d; color: #e26d6d; transform: none; }

/* ---- deleted-recordings (settings) ---- */
.trash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  margin-bottom: 8px;
}
.trash-item-info { min-width: 0; }
.trash-item-input { font-family: var(--serif); font-size: 16px; color: var(--text); }
.trash-item-meta { font-size: 11px; color: var(--text-muted); font-family: ui-monospace, monospace; margin-top: 2px; }
.trash-item-actions { flex: none; display: flex; gap: 8px; }

/* ---- breath game (loading state) ---- */
.breathing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 20px 40px;
  text-align: center;
  min-height: 380px;
}
.breath-orb {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(126,182,230,0.85) 0%, rgba(126,182,230,0.18) 60%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-accent);
  font-family: var(--serif);
  font-size: 19px;
  font-style: italic;
  transform: scale(0.6);
  opacity: 0.65;
  box-shadow: 0 0 60px -10px rgba(126, 182, 230, 0.4);
}
.breath-orb.in {
  transform: scale(1.15);
  opacity: 1;
  transition: transform 4s cubic-bezier(0.45, 0, 0.55, 1), opacity 4s ease;
}
.breath-orb.out {
  transform: scale(0.6);
  opacity: 0.65;
  transition: transform 6s cubic-bezier(0.45, 0, 0.55, 1), opacity 6s ease;
}
.breath-phase {
  user-select: none;
  letter-spacing: 0.5px;
  color: var(--on-accent);
  text-shadow: 0 0 8px rgba(220, 235, 255, 0.6);
}
.breath-counter {
  margin-top: 26px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 1px;
}
.breathing-text {
  margin-top: 18px;
  font-family: var(--serif);
  font-size: 19px;
  font-style: italic;
  color: var(--text-dim);
  min-height: 28px;
  transition: opacity 0.4s ease;
}
.breathing-stage {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}
.breath-hint {
  margin-top: 22px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Legacy class kept for compatibility (used in wizard) */
.breathing-orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, var(--accent-soft) 70%, transparent 100%);
  animation: breathe-mini 4s ease-in-out infinite;
}
@keyframes breathe-mini {
  0%, 100% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ---- demo pages ---- */
.demo-canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-0);
  border: 1px solid var(--border);
  margin-top: 20px;
}
.demo-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 520px;
  cursor: crosshair;
}
.demo-canvas-wrap:fullscreen,
.demo-canvas-wrap:-webkit-full-screen {
  background: var(--bg-0);
  border-radius: 0;
  border: none;
  margin: 0;
}
.demo-canvas-wrap:fullscreen canvas,
.demo-canvas-wrap:-webkit-full-screen canvas {
  width: 100vw;
  height: 100vh;
}
.demo-bar {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 2;
}
.demo-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--text-dim);
  background: rgba(12, 16, 20, 0.65);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.85;
}

/* ---- letter / output text ---- */
.letter {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.75;
  color: var(--text);
  padding: 8px 4px;
  white-space: pre-wrap;
}
.letter em { color: var(--accent-strong); font-style: italic; }

.audio-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-0);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.audio-wrap audio { flex: 1; }
.meta-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.meta-pill {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
}

/* ---- library ---- */
.library {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lib-item {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lib-item:hover { border-color: var(--accent); }
.lib-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.lib-item-input {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.lib-item-date { font-size: 11px; color: var(--text-muted); font-family: ui-monospace, monospace; }
.lib-del {
  flex: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.15s ease;
}
.lib-item:hover .lib-del { opacity: 0.85; }
.lib-del:hover { opacity: 1; color: #e26d6d; background: rgba(226, 109, 109, 0.12); }
.lib-item-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.lib-empty { color: var(--text-muted); text-align: center; padding: 40px 20px; font-style: italic; }

.library {
  max-height: 360px;   /* fallback; JS measures the form card height and overrides via inline style */
  overflow: hidden;
  position: relative;
  transition: max-height 0.35s ease;
}
.library.expanded { max-height: 4000px !important; }
.library::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: linear-gradient(to bottom, transparent, var(--bg-1));
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.library.expanded::after,
.library.unbounded::after { opacity: 0; }
.library.unbounded { max-height: none; overflow: visible; }
.library-toggle {
  display: block;
  margin: 10px auto 0;
  background: transparent;
  border: none;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: inherit;
  padding: 6px 10px;
}
.library-toggle:hover { color: var(--accent-strong); }
.play-countdown {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
  text-align: center;
  font-family: ui-monospace, monospace;
  letter-spacing: 1px;
  opacity: 0.8;
}
.inline-text {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--bg-0);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  max-height: 400px;
  overflow-y: auto;
}
.inline-text .letter {
  font-size: 16px;
  line-height: 1.7;
}

.inline-player-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}
.inline-player-row .inline-player {
  flex: 1;
  margin-top: 0 !important;
}
.inline-dl {
  padding: 8px 14px;
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.play-orb {
  width: 56px;
  height: 56px;
  margin: 16px auto 6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(126,182,230,0.65) 0%, rgba(126,182,230,0.16) 60%, transparent 100%);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 1.2s ease;
  animation: play-breathe 10s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  pointer-events: none;
}
body[data-theme="light"] .play-orb {
  background: radial-gradient(circle, rgba(58,124,183,0.55) 0%, rgba(58,124,183,0.12) 60%, transparent 100%);
}
.play-orb.in   { opacity: 0.9; }
.play-orb.out  { opacity: 0; }
@keyframes play-breathe {
  0%, 100% { transform: scale(0.55); }
  40%      { transform: scale(1.05); }
}

.library-orb-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  margin-bottom: 0;
  transition: min-height 0.4s ease, margin 0.4s ease;
}
.library-orb-wrap:empty {
  display: none;
}
.library-orb-wrap:not(:empty) {
  min-height: 260px;
  margin-bottom: 18px;
}
.library-orb-wrap .play-orb {
  width: 224px;
  height: 224px;
  margin: 0;
  filter: blur(0.3px);
}

.lib-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 12px;
}
.lib-filter button {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  transition: all 0.15s ease;
}
.lib-filter button:hover { color: var(--text); border-color: var(--accent); }
.lib-filter button.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---- wizard (hakkimda) ---- */
.wizard {
  max-width: 720px;
  margin: 0 auto;
}
.wizard-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 32px;
  justify-content: center;
}
.wp-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  cursor: pointer;
}
.wp-dot.filled { background: var(--accent); border-color: var(--accent); }
.wp-dot.current { transform: scale(1.4); box-shadow: 0 0 0 3px var(--accent-soft); }
.wizard-question { min-height: 320px; }
.wq-num { font-family: ui-monospace, monospace; color: var(--accent); font-size: 13px; }
.wq-label {
  font-family: var(--serif);
  font-size: 28px;
  margin: 8px 0 12px;
  line-height: 1.3;
}
.wq-help { color: var(--text-dim); margin-bottom: 16px; font-size: 14px; }
.wq-current {
  background: var(--bg-0);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
  white-space: pre-wrap;
  color: var(--text-dim);
  font-family: var(--serif);
  margin-bottom: 16px;
}
.wq-current.empty { font-style: italic; color: var(--text-muted); }

.wizard-done {
  text-align: center;
  padding: 60px 20px;
}
.wizard-done h2 { font-family: var(--serif); font-size: 32px; color: var(--accent); }

/* ---- footer ---- */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 28px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  font-family: ui-monospace, monospace;
}
.footer code { color: var(--accent); }

/* ---- alerts ---- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.alert.alert-error { background: rgba(224, 121, 107, 0.08); border-color: var(--danger); color: var(--danger); }
.alert.alert-warn  { background: rgba(212, 165, 116, 0.08); border-color: var(--accent); color: var(--accent); }
.alert pre { margin: 6px 0 0; font-size: 12px; white-space: pre-wrap; }
