:root {
  --bg1: #f2f5fa;
  --bg2: #e7edf7;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.74);
  --glass-input: rgba(255, 255, 255, 0.65);
  --stroke: rgba(255, 255, 255, 0.75);
  --stroke2: rgba(120, 135, 165, 0.16);
  --ink: #17202b;
  --ink2: #586577;
  --ink3: #94a0b3;
  --accent: #0a7cff;
  --accent2: #5e5ce6;
  --ok: #30b158;
  --warn: #ff9f0a;
  --shadow: 0 12px 40px rgba(23, 45, 90, 0.13), 0 2px 8px rgba(23, 45, 90, 0.06);
  --shadow-sm: 0 4px 18px rgba(23, 45, 90, 0.09);
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 13px;
  --blur: saturate(180%) blur(22px);
}

:root[data-theme="dark"] {
  --bg1: #0c1017;
  --bg2: #131a24;
  --glass: rgba(30, 38, 50, 0.55);
  --glass-strong: rgba(34, 42, 56, 0.78);
  --glass-input: rgba(44, 54, 70, 0.6);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke2: rgba(255, 255, 255, 0.08);
  --ink: #eef2f7;
  --ink2: #a0adc0;
  --ink3: #6b7789;
  --shadow: 0 14px 44px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 18px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] body::before { opacity: 0.45; }
:root[data-theme="dark"] body::after { opacity: 0.45; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  margin: 0; padding: 0;
  background: linear-gradient(168deg, var(--bg1) 0%, var(--bg2) 100%) fixed;
  overscroll-behavior-y: none;
}

body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: transparent;
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body.sheet-open { overflow: hidden; }

body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(70px);
}

body::before {
  width: 520px; height: 420px;
  top: -160px; right: -120px;
  background: radial-gradient(closest-side, rgba(90, 180, 250, 0.4), transparent);
}

body::after {
  width: 560px; height: 480px;
  bottom: -200px; left: -160px;
  background: radial-gradient(closest-side, rgba(120, 110, 235, 0.28), transparent);
}

/* ---------- header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  max-width: 760px;
  margin: 0 auto;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  background: linear-gradient(to bottom, var(--glass-strong), color-mix(in srgb, var(--glass-strong) 78%, transparent));
  border-bottom: 1px solid var(--stroke2);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-logo {
  width: 36px;
  height: 36px;
  display: block;
  flex: none;
  filter: drop-shadow(0 2px 7px rgba(23, 45, 90, 0.22));
}

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0;
  background: linear-gradient(90deg, #ef4444, #f97316, #eab308, #22c55e, #14b8a6, #3b82f6, #ec4899, #ef4444);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbow-move 3s linear infinite;
}

.brand .sub {
  font-size: 11px;
  color: var(--ink3);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 600;
}

.net-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 5px 11px;
  box-shadow: var(--shadow-sm);
}

.net-pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px rgba(48, 177, 88, 0.8);
  transition: background 0.3s;
}

.net-pill.offline .dot { background: var(--warn); box-shadow: 0 0 6px rgba(255, 159, 10, 0.8); }

.head-actions { display: flex; align-items: center; gap: 8px; }

.icon-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 34px;
  height: 30px;
  padding: 0 9px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink2);
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: color 0.2s, transform 0.15s;
}

.icon-pill:active { transform: scale(0.94); }

.icon-pill svg { width: 15px; height: 15px; }

/* ---------- segmented control ---------- */

.segmented {
  position: relative;
  display: flex;
  padding: 3px;
  background: var(--glass);
  border: 1px solid var(--stroke2);
  border-radius: 999px;
  box-shadow: inset 0 1px 3px rgba(23, 45, 90, 0.06);
}

.segmented button {
  flex: 1;
  position: relative;
  z-index: 2;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink2);
  padding: 8px 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s;
}

.segmented button.active { color: var(--ink); }

.segmented .seg-thumb {
  position: absolute;
  z-index: 1;
  top: 3px;
  bottom: 3px;
  left: 0;
  border-radius: 999px;
  background: var(--glass-strong);
  box-shadow: 0 2px 10px rgba(23, 45, 90, 0.14), 0 0 0 0.5px var(--stroke2);
  transition: transform 0.32s cubic-bezier(0.3, 0.9, 0.3, 1);
}

.segmented.small button { font-size: 13px; padding: 6px 0; }

/* ---------- layout ---------- */

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 18px calc(150px + env(safe-area-inset-bottom));
}

.view { animation: fadeUp 0.34s cubic-bezier(0.3, 0.9, 0.3, 1); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }

.source-row { margin-bottom: 12px; }

/* ---------- chips ---------- */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0 10px;
  margin: 0 -18px;
  padding-left: 18px;
  padding-right: 18px;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2);
  background: var(--glass);
  border: 1px solid var(--stroke2);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.22s;
  white-space: nowrap;
}

.chip .cat-dot { width: 7px; height: 7px; border-radius: 50%; }

.chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 5px 16px rgba(10, 124, 255, 0.35);
}

.chip.active .cat-dot { background: #fff !important; }

/* ---------- search ---------- */

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--glass-input);
  border: 1px solid var(--stroke2);
  border-radius: var(--r-sm);
  padding: 0 13px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s, border-color 0.25s;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(10, 124, 255, 0.16), var(--shadow-sm);
}

.search-box svg { width: 17px; height: 17px; color: var(--ink3); flex: 0 0 auto; }

.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  padding: 12px 0;
  outline: none;
  -webkit-appearance: none;
}

.search-box input::placeholder { color: var(--ink3); }

/* ---------- template list ---------- */

.tpl-list { display: flex; flex-direction: column; gap: 10px; }

/* ---------- my templates ---------- */

.my-tpl-wrap { margin-bottom: 16px; }

.my-tpl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink2);
  padding: 0 4px 8px;
  letter-spacing: 0.3px;
}

.my-tpl-count { font-weight: 600; color: var(--ink3); }

.my-tpl-card {
  border-color: rgba(10, 124, 255, 0.28);
  background: linear-gradient(135deg, rgba(10, 124, 255, 0.07), rgba(94, 92, 230, 0.07)), var(--glass);
}

.my-tpl-card .star { flex: 0 0 auto; width: 15px; height: 15px; color: var(--accent); }

.my-tpl-card .del-btn {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--ink3);
  font-size: 17px;
  line-height: 1;
  padding: 6px 4px 6px 10px;
  cursor: pointer;
  border-radius: 8px;
}

.my-tpl-card .del-btn:active { color: var(--danger, #ff453a); }

.tpl-card {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.25s, background 0.25s;
}

.tpl-card:active { transform: scale(0.982); }

@media (hover: hover) {
  .tpl-card:hover { box-shadow: var(--shadow); background: var(--glass-strong); }
}

.tpl-card .t-body { flex: 1; min-width: 0; }

.tpl-card .t-title {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tpl-card .t-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink3);
}

.tpl-card .t-meta .cat-dot { width: 6px; height: 6px; border-radius: 50%; }

.tpl-card .t-en { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tpl-card .chev { flex: 0 0 auto; width: 17px; height: 17px; color: var(--ink3); }

.empty {
  text-align: center;
  color: var(--ink3);
  font-size: 14px;
  padding: 46px 0;
}

/* ---------- cards / forms ---------- */

.card {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--r-md);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink2);
  margin-bottom: 11px;
  letter-spacing: 0.3px;
}

textarea {
  width: 100%;
  border: 1px solid var(--stroke2);
  background: var(--glass-input);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  padding: 12px 13px;
  resize: vertical;
  outline: none;
  transition: box-shadow 0.25s, border-color 0.25s;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(10, 124, 255, 0.15);
}

.free-meta { display: flex; justify-content: flex-end; font-size: 12px; color: var(--ink3); margin-top: 7px; }

/* ---------- variable form ---------- */

.var-rows { display: flex; flex-direction: column; }

.vr-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px 14px;
  padding: 15px 2px 17px;
  border-bottom: 1px dashed var(--stroke2);
}

.vr-ctrl { display: flex; flex-direction: column; min-width: 0; }

.vr-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink2);
  margin-bottom: 4px;
}

.vr-ctrl:has(.need) .vr-label { color: #d97b00; }

.vr-select, .vr-input {
  width: 100%;
  border: 1px solid var(--stroke2);
  background: var(--glass-input);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
  transition: box-shadow 0.25s, border-color 0.25s;
  -webkit-appearance: none;
  appearance: none;
}

.vr-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a0b3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 30px;
}

.vr-select:focus, .vr-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(10, 124, 255, 0.15);
}

.vr-select.need, .vr-input.need {
  border-color: rgba(255, 159, 10, 0.62);
  background-color: rgba(255, 159, 10, 0.1);
}

.vr-input.need::placeholder { color: #d97b00; }

.vr-input.hidden { display: none; }

.vr-lang { padding: 12px 2px 5px; }

.vr-lang + .vr-lang { border-top: 1px dashed var(--stroke2); margin-top: 9px; }

.vr-lang-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink3);
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.vr-line {
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--ink);
  padding: 6px 0;
}

.vs-val {
  color: var(--accent);
  font-weight: 700;
}

.vs-val.empty {
  color: #d97b00;
  font-weight: 700;
  letter-spacing: 0.5px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.vr-input.shake, .vr-select.shake {
  animation: shake 0.3s 2;
  border-color: var(--warn);
  box-shadow: 0 0 0 3.5px rgba(255, 159, 10, 0.18);
}

.text-btn {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 8px;
}

.text-btn:active { opacity: 0.6; }

/* ---------- common info chips ---------- */

.qc-card .card-head { margin-bottom: 10px; }

.qc-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.qc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--stroke2);
  background: var(--glass-input);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  max-width: 100%;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.qc-chip:active { transform: scale(0.96); }
.qc-chip:hover { border-color: var(--accent); }

.qc-chip.empty { border-style: dashed; color: var(--ink2); }

.qc-chip-label { font-size: 12px; font-weight: 600; color: var(--ink2); white-space: nowrap; }

.qc-chip-val {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
  font-weight: 500;
}

.qc-chip-edit { color: var(--accent); font-size: 12px; line-height: 1; opacity: 0.8; padding-left: 2px; }

.qc-chip.editing { padding: 2px 6px 2px 12px; border-color: var(--accent); box-shadow: 0 0 0 3.5px rgba(10, 124, 255, 0.15); }

.qc-chip-input {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  width: 120px;
  padding: 4px 0;
}

.hint {
  margin-top: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--warn);
  background: rgba(255, 159, 10, 0.12);
  border-radius: 9px;
  padding: 7px 11px;
}

/* ---------- voice & speed controls ---------- */

.controls-card { display: flex; flex-direction: column; gap: 14px; }

.ctrl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.ctrl-label { font-size: 13px; font-weight: 700; color: var(--ink2); flex: 0 0 auto; }

.voice-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass-input);
  border: 1px solid var(--stroke2);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.22s, box-shadow 0.22s;
  max-width: 62%;
}

.voice-pick:active { transform: scale(0.98); }

.voice-pick .v-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.voice-pick .v-gender {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(10, 124, 255, 0.12);
  border-radius: 6px;
  padding: 1.5px 6px;
  flex: 0 0 auto;
}

.voice-pick svg { width: 13px; height: 13px; color: var(--ink3); flex: 0 0 auto; }

.speed-row { display: flex; align-items: center; gap: 12px; }

.speed-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), rgba(120, 135, 165, 0.25) var(--fill, 50%));
  outline: none;
  cursor: pointer;
}

.speed-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(23, 45, 90, 0.3);
}

.speed-val {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: right;
}

/* ---------- primary button ---------- */

.btn-primary {
  position: relative;
  width: 100%;
  border: 0;
  border-radius: var(--r-md);
  padding: 15px 0;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 10px 26px rgba(10, 124, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.25s, filter 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.btn-primary:active { transform: scale(0.98); }

.btn-primary:disabled { filter: saturate(0.4) brightness(1.05); cursor: default; }

.btn-primary .spinner {
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 2.2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  display: none;
}

.btn-primary.busy .spinner { display: block; }

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

/* ---------- sheets ---------- */

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 22, 34, 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s;
}

.sheet-mask.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  z-index: 70;
  left: 0; right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 760px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-bottom: 0;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -18px 60px rgba(15, 30, 60, 0.25);
  transform: translateY(104%);
  transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
  visibility: hidden;
}

.sheet.show { transform: translateY(0); visibility: visible; }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px 11px;
  border-bottom: 1px solid var(--stroke2);
  flex: 0 0 auto;
}

.sheet-title { flex: 1; min-width: 0; text-align: center; }

.sheet-title h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-title span { font-size: 11.5px; color: var(--ink3); }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 15px 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.icon-btn {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--stroke2);
  border-radius: 50%;
  background: var(--glass);
  color: var(--ink2);
  cursor: pointer;
  transition: transform 0.18s, background 0.22s, color 0.22s;
}

.icon-btn:active { transform: scale(0.92); }

.icon-btn svg { width: 18px; height: 18px; }

.icon-btn.ghost { visibility: hidden; }

.sheet-foot {
  flex: 0 0 auto;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--stroke2);
}

.editor-sheet .segmented { margin-bottom: 13px; }

/* ---------- voice list ---------- */

.voice-list { padding-top: 6px; }

.pack-card {
  margin: 6px 4px 10px;
  padding: 13px 15px;
  border-radius: var(--r-sm);
  background: rgba(10, 124, 255, 0.07);
  border: 1px solid rgba(10, 124, 255, 0.22);
}

.pack-card .pack-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
}

.pack-card .pack-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink3);
  flex: 0 0 auto;
}

.pack-card .pack-dot.ok { background: #2fbf71; }

.pack-card .pack-sub { font-size: 12px; color: var(--ink3); margin-top: 4px; line-height: 1.45; }

.pack-card .pack-sub.ok { color: #1f9d5c; }

.pack-card .pack-sub.err { color: #d9534f; }

.pack-card .pack-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(120, 135, 165, 0.22);
  margin-top: 9px;
  overflow: hidden;
}

.pack-card .pack-bar i {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: transform 0.4s;
}

.pack-card .pack-btn {
  margin-top: 9px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  cursor: pointer;
  font-family: inherit;
}

.voice-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink3);
  letter-spacing: 0.8px;
  padding: 15px 4px 7px;
}

.voice-group-title:first-child { padding-top: 4px; }

.voice-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid transparent;
}

.voice-row:active { background: rgba(120, 135, 165, 0.12); }

.voice-row.selected {
  background: rgba(10, 124, 255, 0.1);
  border-color: rgba(10, 124, 255, 0.35);
}

.voice-row .vr-main { flex: 1; min-width: 0; }

.voice-row .vr-name {
  font-size: 15px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 7px;
}

.voice-row .vr-name .rec {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 6px;
  padding: 1.5px 6px;
}

.voice-row .vr-desc { font-size: 12px; color: var(--ink3); margin-top: 2px; }

.voice-row .vr-check { width: 18px; height: 18px; color: var(--accent); flex: 0 0 auto; visibility: hidden; }

.voice-row.selected .vr-check { visibility: visible; }

.voice-row .vr-chev { width: 16px; height: 16px; color: var(--ink3); flex: 0 0 auto; }

.preview-btn {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--stroke2);
  background: var(--glass);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.16s;
}

.preview-btn:active { transform: scale(0.9); }

.preview-btn svg { width: 15px; height: 15px; }

.preview-btn.loading svg { display: none; }

.preview-btn.loading::after {
  content: "";
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(10, 124, 255, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

/* ---------- player ---------- */

.player {
  position: fixed;
  z-index: 50;
  left: 0; right: 0;
  bottom: 0;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  max-width: 760px;
  margin: 0 auto;
  transform: translateY(120%);
  transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none;
}

.player.show { transform: translateY(0); pointer-events: auto; }

.player-glass {
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  box-shadow: 0 -4px 20px rgba(23, 45, 90, 0.14), 0 16px 44px rgba(23, 45, 90, 0.22);
  padding: 12px 16px 13px;
}

.player-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}

.player-info { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }

.player-voice {
  font-size: 12.5px;
  font-weight: 750;
  color: var(--accent);
  flex: 0 0 auto;
}

.player-title {
  font-size: 12.5px;
  color: var(--ink3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-top .icon-btn { width: 30px; height: 30px; border: 0; background: transparent; }

.player-top .icon-btn svg { width: 15px; height: 15px; }

.player-main { display: flex; align-items: center; gap: 13px; }

.play-btn {
  flex: 0 0 auto;
  width: 50px; height: 50px;
  border-radius: 50%;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 20px rgba(10, 124, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.18s;
}

.play-btn:active { transform: scale(0.93); }

.play-btn svg { width: 23px; height: 23px; }

.play-btn .ic-pause { display: none; }

.play-btn.playing .ic-play { display: none; }

.play-btn.playing .ic-pause { display: block; }

.progress-wrap { flex: 1; min-width: 0; cursor: pointer; padding: 8px 0 4px; touch-action: none; }

.progress-track {
  position: relative;
  height: 5px;
  border-radius: 3px;
  background: rgba(120, 135, 165, 0.25);
  overflow: visible;
}

.progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

.progress-fill::after {
  content: "";
  position: absolute;
  right: -7px; top: 50%;
  transform: translateY(-50%) scale(0);
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(23, 45, 90, 0.35);
  transition: transform 0.2s;
}

.progress-wrap:hover .progress-fill::after,
.progress-wrap.dragging .progress-fill::after { transform: translateY(-50%) scale(1); }

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink3);
  font-variant-numeric: tabular-nums;
  margin-top: 5px;
}

.loop-btn.active {
  background: rgba(10, 124, 255, 0.14);
  border-color: rgba(10, 124, 255, 0.4);
  color: var(--accent);
}

/* ---------- footer ---------- */

.ft {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 18px;
  padding: 18px 16px calc(26px + env(safe-area-inset-bottom));
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.ft a, .ft .rt {
  text-decoration: none;
  background: linear-gradient(90deg, #ef4444, #f97316, #eab308, #22c55e, #14b8a6, #3b82f6, #ec4899, #ef4444);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbow-move 3s linear infinite;
}

.ft a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  -webkit-text-fill-color: inherit;
  background: none;
}

.ft .fi-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.ft .fi-item img { width: 15px; height: 17px; }

@keyframes rainbow-move {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  max-width: min(86vw, 480px);
  background: rgba(28, 36, 50, 0.92);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  .brand h1 { font-size: 25px; }
  .tpl-card { padding: 16px 18px; }
}

@media (min-width: 900px) {
  .editor-sheet { max-width: 1000px; }
}

@media (max-width: 480px) {
  .app-header { padding-left: 14px; padding-right: 14px; }
  main { padding-left: 14px; padding-right: 14px; }
  .brand { gap: 7px; min-width: 0; }
  .brand-logo { width: 30px; height: 30px; }
  .brand h1 { font-size: 19px; white-space: nowrap; }
  .brand .sub { display: none; }
  .head-actions { gap: 6px; flex: none; }
  .icon-pill { min-width: 30px; height: 28px; padding: 0 8px; font-size: 11.5px; }
  .net-pill { font-size: 11px; padding: 4px 9px; gap: 5px; }
}

/* ---------- extra languages & play order ---------- */

.lang-extra { margin: 0 0 12px; }
.lang-extra-label { font-size: 12px; font-weight: 600; color: var(--ink3); margin-bottom: 7px; letter-spacing: 0.3px; }
.lang-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lang-chip {
  border: 1px solid var(--stroke2);
  background: var(--glass-input);
  border-radius: 999px;
  padding: 5px 13px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}
.lang-chip:active { transform: scale(0.96); }
.lang-chip.active { background: var(--accent); border-color: transparent; color: #fff; }

.xl-card { margin-bottom: 12px; }
.xl-card .xl-voice { font-size: 12px; font-weight: 600; color: var(--ink3); }
.xl-card textarea { font-size: 14px; }

.order-card { margin-top: 12px; }
.order-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--stroke2);
}
.order-row:last-child { border-bottom: 0; padding-bottom: 0; }
.order-idx {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(10, 124, 255, 0.14);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.order-lang { flex: 1; font-size: 14px; font-weight: 600; color: var(--ink); }
.order-btns { display: flex; gap: 4px; }
.order-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--stroke2);
  background: var(--glass-input);
  border-radius: 9px;
  color: var(--ink2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.order-btn svg { width: 15px; height: 15px; }
.order-btn:active { transform: scale(0.92); }
.order-btn:disabled { opacity: 0.3; cursor: default; }

.fav-btn.active { color: var(--warn); }
.fav-btn.active svg path { fill: currentColor; }
