/* ============================================================
   EasyVoice — liquid glass theme
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #eef1f8;
  --blob-1: #9ec5ff;
  --blob-2: #ffc2df;
  --blob-3: #b9f0dc;

  --glass: rgba(255, 255, 255, 0.52);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --glass-soft: rgba(255, 255, 255, 0.34);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-edge: rgba(15, 23, 42, 0.07);
  --highlight: rgba(255, 255, 255, 0.9);
  --shadow: 0 1px 1px rgba(15, 23, 42, 0.04), 0 12px 40px -12px rgba(30, 41, 80, 0.22);

  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --on-accent: #ffffff;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --focus: #2563eb;

  --ok: #047857;
  --ok-soft: rgba(16, 185, 129, 0.16);
  --bad: #b91c1c;
  --bad-soft: rgba(239, 68, 68, 0.14);
  --warn: #92400e;
  --warn-soft: rgba(245, 158, 11, 0.18);

  --track: rgba(15, 23, 42, 0.12);
  --radius-lg: 24px;
  --radius: 16px;
  --radius-sm: 12px;
  --blur: blur(28px) saturate(170%);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #070a12;
    --blob-1: #1d4ed8;
    --blob-2: #9d174d;
    --blob-3: #047857;

    --glass: rgba(22, 27, 40, 0.55);
    --glass-strong: rgba(30, 36, 52, 0.75);
    --glass-soft: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-edge: rgba(0, 0, 0, 0.4);
    --highlight: rgba(255, 255, 255, 0.14);
    --shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 16px 48px -12px rgba(0, 0, 0, 0.7);

    --text: #f1f5f9;
    --text-2: #cbd5e1;
    --text-3: #94a3b8;
    --accent: #60a5fa;
    --accent-2: #a78bfa;
    --on-accent: #06101f;
    --accent-soft: rgba(96, 165, 250, 0.16);
    --focus: #93c5fd;

    --ok: #6ee7b7;
    --ok-soft: rgba(16, 185, 129, 0.18);
    --bad: #fca5a5;
    --bad-soft: rgba(239, 68, 68, 0.18);
    --warn: #fcd34d;
    --warn-soft: rgba(245, 158, 11, 0.16);

    --track: rgba(255, 255, 255, 0.14);
    --blob-opacity: 0.38;
  }
}

/* Users who ask for less transparency get solid surfaces. */
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: var(--bg); --glass-strong: var(--bg); --blur: none; }
  .backdrop { display: none; }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang HK", "Noto Sans HK", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
code, pre, kbd { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85em; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: 999px; background: var(--accent); color: var(--on-accent); }
.skip:focus { top: 12px; }

:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 10px; }

/* ---------- animated backdrop ---------- */
.backdrop { position: fixed; inset: 0; overflow: hidden; z-index: -1; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: var(--blob-opacity, 0.7); }
.b1 { width: 55vw; height: 55vw; left: -12vw; top: -18vw; background: var(--blob-1); animation: drift1 26s ease-in-out infinite alternate; }
.b2 { width: 45vw; height: 45vw; right: -10vw; top: 10vh; background: var(--blob-2); animation: drift2 32s ease-in-out infinite alternate; }
.b3 { width: 50vw; height: 50vw; left: 20vw; bottom: -25vw; background: var(--blob-3); animation: drift3 28s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(8vw, 6vh) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-6vw, 10vh) scale(0.9); } }
@keyframes drift3 { to { transform: translate(-10vw, -6vh) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } * { transition: none !important; } }

/* ---------- glass surface ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--highlight), inset 0 0 0 1px var(--glass-edge), var(--shadow);
  border-radius: var(--radius-lg);
}

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100%;
}
.main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel {
  position: sticky; top: 20px;
  height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; padding: 12px 16px 32px; }
  .panel { position: static; height: auto; max-height: none; }
}

/* ---------- top bar ---------- */
.topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 999px; }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 4px 14px -4px var(--accent); }
.brand h1 { font-size: 16px; font-weight: 700; }
.brand p { margin: 0; font-size: 12px; color: var(--text-3); }
.status { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--glass-border); color: var(--text-2); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.chip.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }

/* ---------- editor ---------- */
.editor { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.editor-head { display: flex; align-items: center; gap: 12px; }
.title-input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 4px 2px;
  font-size: 20px; font-weight: 650; letter-spacing: -0.01em;
}
.title-input::placeholder { color: var(--text-3); opacity: .7; }
.title-input:focus-visible { outline-offset: 0; }
.counter { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-3); padding: 3px 10px; border-radius: 999px; background: var(--glass-soft); }
.counter.warn { color: var(--warn); background: var(--warn-soft); }
.counter.bad { color: var(--bad); background: var(--bad-soft); }

#text {
  width: 100%; min-height: 220px; resize: vertical;
  padding: 16px 18px; border-radius: var(--radius);
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.06);
  font-size: 18px; line-height: 1.8;
}
#text::placeholder { color: var(--text-3); }

.tools { display: flex; flex-direction: column; gap: 8px; }
.tool-row { display: flex; gap: 10px; align-items: flex-start; }
.tool-label { flex: 0 0 48px; font-size: 12px; font-weight: 600; color: var(--text-3); padding-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips .sep { width: 1px; height: 18px; background: var(--track); margin: 0 4px; }
.tool-hint { margin: 0 0 0 58px; font-size: 12px; color: var(--warn); }
.tool-hint:empty { display: none; }
#soundTags.off .pill { opacity: .45; }

.pill {
  border: 1px solid var(--glass-border); background: var(--glass-soft);
  border-radius: 999px; padding: 4px 11px; font-size: 13px; cursor: pointer;
  box-shadow: inset 0 1px 0 var(--highlight);
  transition: background .15s, transform .1s, border-color .15s;
}
.pill:hover { background: var(--accent-soft); border-color: transparent; }
.pill:active { transform: scale(.96); }

.editor-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding-top: 4px; border-top: 1px solid var(--track); }
.summary { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.summary span { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--glass-border); color: var(--text-2); }
.summary span b { color: var(--text); font-weight: 600; }
#mixCount.bad { color: var(--bad); font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--glass-border); background: var(--glass-strong);
  border-radius: 999px; padding: 9px 16px; cursor: pointer; font-weight: 550;
  box-shadow: inset 0 1px 0 var(--highlight), 0 1px 2px rgba(0,0,0,.06);
  transition: transform .1s, filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--glass-soft); }
.btn.primary {
  color: var(--on-accent); border-color: transparent; padding: 11px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 8px 24px -8px var(--accent);
}
.btn kbd { font-size: 11px; opacity: .75; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,.2); }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border-radius: 12px; border: 1px solid var(--glass-border); background: var(--glass-soft); cursor: pointer;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.text-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 4px 2px; font-size: 13px; font-weight: 550; align-self: flex-start; }
.text-btn.danger { color: var(--bad); }

/* ---------- messages ---------- */
#messages:empty { display: none; }
#messages { display: flex; flex-direction: column; gap: 8px; }
.msg {
  padding: 10px 14px; border-radius: var(--radius-sm); white-space: pre-wrap; font-size: 14px;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
}
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.info { background: var(--accent-soft); color: var(--text); }

/* ---------- result ---------- */
.result { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.result-head h3 { font-size: 17px; }
.result-head time { font-size: 12px; color: var(--text-3); }
.result audio { width: 100%; height: 44px; border-radius: 999px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 0; }
.stat { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--glass-border); }
.stat dt { font-size: 11px; color: var(--text-3); }
.stat dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; word-break: break-all; }
.trace { font-size: 11px; color: var(--text-3); }
.subs { max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.subs button { text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 10px; cursor: pointer; display: flex; gap: 10px; }
.subs button:hover { background: var(--accent-soft); }
.subs span { color: var(--text-3); font: 11px/1.9 ui-monospace, Menlo, monospace; flex: none; }

/* ---------- panel ---------- */
.tabs { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); margin: 12px; padding: 4px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--glass-border); flex: none; }
.tabs button { position: relative; z-index: 1; border: 0; background: none; padding: 8px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.tabs button[aria-selected="true"] { color: var(--text); }
.tab-indicator {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 999px;
  background: var(--glass-strong); box-shadow: inset 0 1px 0 var(--highlight), 0 2px 8px rgba(15,23,42,.12);
  transition: transform .25s cubic-bezier(.3,.7,.4,1);
}
.tabs[data-active="history"] .tab-indicator { transform: translateX(100%); }
.tabs[data-active="usage"] .tab-indicator { transform: translateX(200%); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; font-size: 11px; line-height: 18px; background: var(--accent-soft); color: var(--accent); }

.pane { flex: 1; overflow-y: auto; padding: 0 12px 16px; overscroll-behavior: contain; }
.pane[hidden] { display: none; }

.preset-bar { display: flex; gap: 6px; margin-bottom: 10px; }
.preset-bar select { flex: 1; min-width: 0; }

/* collapsible groups */
.group { border-radius: var(--radius); background: var(--glass-soft); border: 1px solid var(--glass-border); margin-bottom: 8px; }
.group summary {
  list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 650; font-size: 14px;
  display: flex; align-items: center; gap: 8px; border-radius: var(--radius);
}
.group summary::-webkit-details-marker { display: none; }
.group summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.group[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.summary-tag { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--track); color: var(--text-2); }
.summary-tag.on { background: var(--accent-soft); color: var(--accent); }
.group-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.group-body.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.note { margin: 0; font-size: 12px; color: var(--text-3); }

.field { display: flex; flex-direction: column; gap: 6px; }
.label { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.label output { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text); background: var(--glass-strong); padding: 0 8px; border-radius: 999px; font-size: 12px; }
.label em { font-style: normal; font-weight: 400; color: var(--text-3); font-size: 11px; }

select, input[type="search"], .field textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--highlight);
}
.field textarea { resize: vertical; font-size: 13px; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:disabled { opacity: .5; cursor: not-allowed; }

/* range slider */
input[type="range"] {
  --p: 50%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0, var(--accent-2) var(--p), var(--track) var(--p));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--track); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%;
  background: #fff; border: 0.5px solid rgba(0,0,0,.08);
  box-shadow: 0 2px 6px rgba(15,23,42,.25), inset 0 -1px 2px rgba(0,0,0,.06);
  transition: transform .12s;
}
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 6px rgba(15,23,42,.25); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]:focus-visible { outline-offset: 4px; }

/* switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; font-size: 14px; font-weight: 550; }
.switch-row small { display: block; font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.switch {
  -webkit-appearance: none; appearance: none; flex: none; cursor: pointer;
  width: 46px; height: 28px; border-radius: 999px; position: relative; margin: 0;
  background: var(--track); transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.25); transition: transform .2s cubic-bezier(.3,.7,.4,1);
}
.switch:checked { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline-offset: 3px; border-radius: 999px; }

/* segmented */
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 999px; background: var(--track); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: block; text-align: center; padding: 6px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-2); transition: background .2s; }
.segmented input:checked + span { background: var(--glass-strong); color: var(--text); box-shadow: 0 1px 4px rgba(15,23,42,.15), inset 0 1px 0 var(--highlight); }
.segmented input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 1px; }

/* voice cards */
.voice-list { display: flex; flex-direction: column; gap: 6px; }
.voice-card {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid var(--glass-border); background: var(--glass-soft);
  transition: background .15s, border-color .15s;
}
.voice-card input { position: absolute; opacity: 0; }
.voice-card .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-weight: 700; font-size: 14px; }
.voice-card .avatar { background: linear-gradient(135deg, hsl(var(--h) 75% 62%), hsl(calc(var(--h) + 50) 70% 55%)); }
.voice-list:not(.expanded) .voice-card.extra:not(:has(input:checked)) { display: none; }
.rec { font-size: 10.5px; font-weight: 700; padding: 1px 7px; margin-left: 6px; border-radius: 999px; color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2)); vertical-align: 1px; }
.more-btn {
  width: 100%; margin-top: 6px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px dashed var(--glass-border); background: transparent; color: var(--accent); font-size: 13px; font-weight: 600;
}
.more-btn:hover { background: var(--accent-soft); }
.more-btn::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
.more-btn[aria-expanded="true"]::after { transform: rotate(-135deg) translateY(-1px); }
.voice-card .desc { display: block; font-size: 11.5px; color: var(--text-3); }
.voice-card .name { font-weight: 600; font-size: 14px; }
.voice-card code { display: block; font-size: 11px; color: var(--text-3); }
.voice-card .check { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--track); display: grid; place-items: center; }
.voice-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.voice-card:has(input:checked) .check { border-color: var(--accent); background: var(--accent); }
.voice-card:has(input:checked) .check::after { content: ""; width: 6px; height: 10px; border: solid var(--on-accent); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.voice-card:has(input:focus-visible) { outline: 2.5px solid var(--focus); outline-offset: 2px; }

.dim { display: flex; flex-direction: column; gap: 12px; transition: opacity .2s; }
.dim:not(.on) { opacity: .45; pointer-events: none; }

/* ---------- history ---------- */
.history-tools { display: flex; gap: 6px; margin-bottom: 10px; position: sticky; top: 0; z-index: 2; }
.toggle-chip { position: relative; flex: none; }
.toggle-chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.toggle-chip span:not(.sr-only) { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--glass-strong); border: 1px solid var(--glass-border); color: var(--text-3); font-size: 16px; }
.toggle-chip input:checked + span { color: #d97706; background: var(--warn-soft); }
.toggle-chip input:focus-visible + span { outline: 2.5px solid var(--focus); outline-offset: 2px; }

.history { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history li.item {
  padding: 12px; border-radius: var(--radius); background: var(--glass-soft); border: 1px solid var(--glass-border);
  transition: border-color .15s, background .15s;
}
.history li.item.active { border-color: var(--accent); background: var(--accent-soft); }
.h-top { display: flex; gap: 10px; align-items: flex-start; }
.h-play {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 4px 12px -4px var(--accent);
}
.h-body { flex: 1; min-width: 0; }
.h-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-text { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.h-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.h-meta span { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--track); color: var(--text-2); }
.fav { border: 0; background: none; cursor: pointer; font-size: 17px; line-height: 1; padding: 4px; color: var(--text-3); border-radius: 8px; }
.fav.on { color: #f59e0b; }
.h-actions { display: flex; gap: 2px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--track); }
.h-actions button, .h-actions a {
  border: 0; background: none; padding: 5px 9px; border-radius: 8px; cursor: pointer; font-size: 12.5px; font-weight: 550;
  color: var(--text-2); text-decoration: none;
}
.h-actions button:hover, .h-actions a:hover { background: var(--glass-strong); color: var(--text); }
.h-actions .del { margin-left: auto; color: var(--bad); }
.h-actions .del:hover { background: var(--bad-soft); color: var(--bad); }
.empty { text-align: center; color: var(--text-3); padding: 40px 0; font-size: 14px; }

/* ---------- dialog ---------- */
dialog.glass { padding: 0; width: min(760px, calc(100vw - 32px)); color: var(--text); background: var(--glass-strong); }
dialog::backdrop { background: rgba(10, 14, 25, 0.35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog form { padding: 18px 20px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.dialog-head h3 { font-size: 15px; font-family: ui-monospace, Menlo, monospace; }
dialog pre { margin: 0; max-height: 65vh; overflow: auto; padding: 14px; border-radius: var(--radius-sm); background: var(--glass-soft); border: 1px solid var(--glass-border); font-size: 12.5px; }

/* ---------- misc ---------- */
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--track); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }

@media (max-width: 600px) {
  .topbar { border-radius: var(--radius-lg); }
  .tool-row { flex-direction: column; gap: 4px; }
  .tool-label { flex: none; padding: 0; }
  .tool-hint { margin-left: 0; }
  .editor-foot { flex-direction: column; align-items: stretch; }
  .actions { justify-content: flex-end; }
  .group-body.two { grid-template-columns: 1fr; }
}

/* ---------- usage ---------- */
.usage-block { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.block-head h3 { font-size: 14px; }
.sub-head { margin: 4px 0 0; font-size: 12px; color: var(--text-3); font-weight: 600; }
.usage-block .stats { grid-template-columns: repeat(2, 1fr); }
.usage-block .note a { color: var(--accent); }
.meter { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--glass-strong); border: 1px solid var(--glass-border); }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; }
.meter-top b { font-size: 20px; font-variant-numeric: tabular-nums; }
.meter-bar { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.meter.low .meter-bar i { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.meter-foot { font-size: 11.5px; color: var(--text-3); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 7px 6px; text-align: right; border-bottom: 1px solid var(--track); }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { font-size: 11px; color: var(--text-3); font-weight: 600; }
.table tr.current td { color: var(--accent); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.cost-chip b { color: var(--accent) !important; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); padding: 28px 24px; display: flex; flex-direction: column; gap: 16px; }
.login-card input[type="password"] {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 var(--highlight);
}
.login-card .btn.primary { justify-content: center; }

/* ---------- voice preview ---------- */
.voice-card .check { margin-left: 8px; }
.sample-btn {
  margin-left: auto; flex: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; color: var(--accent);
  border: 1px solid var(--glass-border); background: var(--glass-strong); box-shadow: inset 0 1px 0 var(--highlight);
  transition: transform .1s, background .15s;
}
.sample-btn:hover { background: var(--accent-soft); }
.sample-btn:active { transform: scale(.92); }
.sample-btn .i-stop { display: none; }
.sample-btn.playing { color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; animation: pulse 1.4s ease-in-out infinite; }
.sample-btn.playing .i-play { display: none; }
.sample-btn.playing .i-stop { display: block; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 6px var(--accent-soft); } }
