/* ═══════════════════════════════════════════════════
   TTS Studio — Studio Page  (dark navy theme)
   ═══════════════════════════════════════════════════ */
:root {
  --bg:           #0a0c10;
  --bg-elevated:  #12151c;
  --surface:      #181c26;
  --surface-hover:#1e2430;
  --border:       rgba(255,255,255,0.08);
  --border-hover: rgba(91,140,255,0.3);
  --text:         #f0f2f7;
  --muted:        #94a0b8;
  --accent:       #5b8cff;
  --accent-2:     #3dd6c5;
  --success:      #3dd68c;
  --danger:       #ff5f5f;
  --radius:       10px;
  --radius-sm:    7px;
  --sidebar-w:    248px;
  --topbar-h:     52px;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

html,body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }

body { display: flex; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; color: #8eb0ff; }
button { font-family: inherit; cursor: pointer; }
input,textarea,select { font-family: inherit; }

/* Author CSS (display:flex) must not override the hidden attribute. */
[hidden] { display: none !important; }

/* scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ════════════════════════ SIDEBAR ════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.sidebar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.sidebar-brand-name {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.sidebar-brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

.sidebar-section-label {
  padding: 14px 18px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  opacity: 0.7;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
  user-select: none;
}
.sidebar-item svg { flex-shrink: 0; }
.sidebar-item:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.sidebar-item.active {
  color: #0a0c10;
  background: var(--accent-2);
  font-weight: 700;
}
.sidebar-item.active svg { stroke: #0a0c10; }

/* user section at bottom — Ivoi-style profile bar */
.sidebar-user {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
  position: relative;
}

.sidebar-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.sidebar-user-btn:hover { background: var(--surface-hover); border-color: var(--border-hover); }

.sidebar-avatar-wrap {
  position: relative;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}
.sidebar-avatar-fallback,
.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-avatar-fallback {
  background: var(--accent-2);
  color: #0a0c10;
  font-size: 0.85rem;
  font-weight: 800;
}
.sidebar-avatar {
  position: absolute;
  inset: 0;
  object-fit: cover;
  border: none;
}

.sidebar-user-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.25;
}
.sidebar-username {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}
.sidebar-user-hint {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.sidebar-user-chevron { flex-shrink: 0; color: var(--muted); transition: transform 0.2s; }
.sidebar-user-btn[aria-expanded="true"] .sidebar-user-chevron { transform: rotate(180deg); }

.sidebar-user-menu {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  z-index: 20;
}
.sidebar-user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--muted);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.sidebar-user-menu-item:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-user-menu-item.danger { color: var(--danger); }
.sidebar-user-menu-item.danger:hover { background: rgba(255,95,95,0.08); color: var(--danger); }

/* ════════════════════════ STUDIO BODY ════════════════════════ */
.studio-body {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ════════════════════════ TOPBAR ════════════════════════ */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  padding: 5px;
  border-radius: 5px;
  align-items: center;
  justify-content: center;
}
.topbar-hamburger:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.topbar-login { display: flex; align-items: center; gap: 8px; }
.topbar-login-hint { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.topbar-user { display: flex; align-items: center; gap: 8px; }

/* Avoid flashing login/register before session is known */
html:not(.auth-ready) #topbarAuthArea,
html:not(.auth-ready) #sidebarName,
html:not(.auth-ready) #sidebarUserHint,
html:not(.auth-ready) #accountNotLogged {
  visibility: hidden;
}
html.auth-in:not(.auth-ready) #topbarLogin {
  display: none !important;
}
html.auth-in:not(.auth-ready) #topbarUser {
  display: flex !important;
}
.topbar-avatar-wrap { width: 28px; height: 28px; }
.topbar-avatar-wrap .sidebar-avatar-fallback,
.topbar-avatar-wrap .sidebar-avatar {
  width: 28px; height: 28px; font-size: 0.78rem;
}
.topbar-username { font-size: 0.85rem; color: var(--text); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  transition: border-color 0.15s, color 0.15s;
}
.btn-logout:hover { border-color: rgba(255,95,95,0.4); color: var(--danger); }
.btn-logout-lg { padding: 7px 16px; font-size: 0.85rem; }

/* ════════════════════════ TAB PANELS ════════════════════════ */
.tab-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ════════════════════════ SYNTH LAYOUT ════════════════════════ */
.synth-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* Left workspace */
.synth-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  gap: 12px;
  overflow-y: auto;
}

/* Controls bar */
.controls-bar {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ctrl-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

/* Voice picker button */
.voice-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 11px;
  font-size: 0.88rem;
  font-weight: 500;
  min-width: 160px;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.voice-picker-btn:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.voice-picker-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.voice-picker-name { flex: 1; text-align: left; }

/* Speed — Ivoi-style framed control */
.speed-frame {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 32px;
  padding: 0 8px;
  width: auto;
  min-width: 0;
}
.speed-frame-icon {
  color: var(--muted);
  flex-shrink: 0;
  width: 12px;
  height: 12px;
}
.speed-frame-val {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.speed-range {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent-2) 0%, var(--accent-2) 33.33%, rgba(255,255,255,0.12) 33.33%);
  outline: none;
  width: 72px;
  flex: 0 0 72px;
  cursor: pointer;
}
.speed-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(61,214,197,0.22);
  cursor: pointer;
  border: none;
}
.speed-range::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}
.speed-range::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent-2);
  border: none;
  cursor: pointer;
}

/* Format buttons */
.fmt-group { display: flex; }
.fmt-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.fmt-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.fmt-btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
.fmt-btn.active { background: rgba(91,140,255,0.15); border-color: rgba(91,140,255,0.4); color: var(--accent); }
.fmt-btn:not(.active):hover { color: var(--text); border-color: var(--border-hover); }

/* Convert button */
.ctrl-convert { margin-left: auto; }
.btn-convert {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-2);
  color: #0a0c10;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  transition: filter 0.15s, transform 0.15s;
  box-shadow: 0 3px 12px rgba(61,214,197,0.22);
}
.btn-convert:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-convert:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Textarea */
.text-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 180px;
  transition: border-color 0.2s;
}
.text-wrap:focus-within { border-color: rgba(91,140,255,0.3); }
.text-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.7;
  padding: 14px 16px;
  resize: none;
  min-height: 160px;
}
.text-input::placeholder { color: var(--muted); opacity: 0.6; }
.text-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.12);
  gap: 12px;
  flex-wrap: wrap;
}
.char-count { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.login-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #ff9f9f;
}

/* Processing */
.processing-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(91,140,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-center { display: flex; justify-content: center; padding: 24px; }

/* ════════════════════════ RESULTS PANEL ════════════════════════ */
.results-panel {
  width: 400px;
  min-width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  overflow: hidden;
}
.results-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.results-panel-title { font-size: 0.85rem; font-weight: 600; }
.results-badge {
  background: rgba(91,140,255,0.15);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.retain-note {
  margin: 0;
  padding: 8px 12px;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #f0d9a8;
  background: rgba(255, 179, 71, 0.1);
  border-top: 1px solid rgba(255, 179, 71, 0.22);
  border-bottom: 1px solid rgba(255, 179, 71, 0.12);
  flex-shrink: 0;
}
.retain-note strong { color: #ffd38a; font-weight: 800; }
.retain-note-page {
  margin-top: 10px;
  border: 1px solid rgba(255, 179, 71, 0.22);
  border-radius: 10px;
}
.results-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px 12px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.pager[hidden] { display: none; }
.pager-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.78rem;
  cursor: pointer;
}
.pager-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager-btn:disabled { opacity: 0.4; cursor: default; }
.pager-info { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 0.83rem;
  text-align: center;
}

/* Result item — Ivoi-style history card */
.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeUp 0.25s ease both;
  transition: border-color 0.15s;
  transform-origin: center top;
}
.result-item.is-leaving {
  pointer-events: none;
  overflow: hidden;
  animation: dissolveOut 2s ease forwards;
}
@keyframes dissolveOut {
  0% {
    opacity: 1;
    filter: blur(0) saturate(1);
    transform: scale(1) translateY(0);
  }
  45% {
    opacity: 0.55;
    filter: blur(3px) saturate(0.7);
    transform: scale(0.98) translateY(-4px);
  }
  100% {
    opacity: 0;
    filter: blur(14px) saturate(0.2);
    transform: scale(0.92) translateY(-12px);
  }
}
.result-item:hover { border-color: var(--border-hover); }
@keyframes fadeUp { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 10px;}
.result-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.result-date {
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-align: right;
  white-space: nowrap;
}
.result-remain {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--accent-2);
  background: rgba(61, 214, 197, 0.12);
  border: 1px solid rgba(61, 214, 197, 0.28);
  white-space: nowrap;
}
.result-remain.warn {
  color: #ffd38a;
  background: rgba(255, 179, 71, 0.12);
  border-color: rgba(255, 179, 71, 0.35);
}
.result-remain.urgent {
  color: #ff8a8a;
  background: rgba(255, 95, 95, 0.12);
  border-color: rgba(255, 95, 95, 0.32);
}
.result-meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.result-voice-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 0;
  flex-shrink: 1;
}
.result-voice-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-voice-line svg { flex-shrink: 0; }
.result-tags {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.result-tag,
.result-speed {
  font-size: 0.68rem;
  font-weight: 650;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255,255,255,0.03);
}
.result-speed {
  color: var(--accent-2);
  border-color: rgba(61,214,197,0.28);
}
.result-chars {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.ap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 4px 8px 4px 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.ap-audio { display: none; }
.ap-play,
.ap-mute {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(91,140,255,0.18);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ap-play:hover,
.ap-mute:hover { background: rgba(91,140,255,0.3); color: #8eb0ff; }
.ap.is-playing .ap-play { background: rgba(61,214,197,0.18); color: var(--accent-2); }
.ap-mute { background: transparent; color: var(--muted); width: 22px; height: 22px; }
.ap-mute:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.ap.is-muted .ap-mute { color: var(--danger); }
.ap-time {
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 2.2em;
}
.ap-dur { text-align: right; }
.ap-seek {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  outline: none;
  cursor: pointer;
}
.ap-seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: transparent;
}
.ap-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid #0e1a22;
  box-shadow: 0 0 0 1px rgba(61,214,197,0.35);
}
.ap-seek::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  border: none;
}
.ap-seek::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent-2);
}
.ap-seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid #0e1a22;
}
.result-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.result-actions-btns { display: flex; gap: 6px; margin-left: auto; }
.result-status { font-size: 0.71rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.result-status.completed { background: rgba(61,214,140,0.12); color: var(--success); }
.result-status.failed    { background: rgba(255,95,95,0.1);  color: var(--danger); }
.result-status.pending,
.result-status.queued { background: rgba(148,160,184,0.1); color: var(--muted); }
.win-spin {
  width: 11px;
  height: 11px;
  display: inline-block;
  flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 28%, currentColor 78%, transparent 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  animation: spin 0.75s linear infinite;
}
.result-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 650;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.result-btn:hover { border-color: var(--border-hover); color: var(--text); }
.result-btn-dl {
  background: rgba(91,140,255,0.14);
  border-color: rgba(91,140,255,0.35);
  color: var(--accent);
}
.result-btn-dl:hover { background: rgba(91,140,255,0.22); color: #8eb0ff; }
.result-btn.danger {
  background: rgba(255,95,95,0.1);
  border-color: rgba(255,95,95,0.28);
  color: var(--danger);
}
.result-btn.danger:hover { background: rgba(255,95,95,0.16); color: var(--danger); }

/* ════════════════════════ PAGE CONTENT (history/account) ════════════════════════ */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.page-header h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.page-header p  { font-size: 0.83rem; color: var(--muted); }

/* History list */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  animation: fadeUp 0.25s ease both;
}
.history-item:hover { border-color: var(--border-hover); }
.history-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history-voice { font-size: 0.76rem; color: var(--accent); font-weight: 600; }
.history-date  { font-size: 0.73rem; color: var(--muted); margin-left: auto; }
.history-text  { font-size: 0.83rem; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-actions { display: flex; gap: 7px; align-items: center; }

/* Account */
.account-notlogged p { color: var(--muted); margin-bottom: 14px; font-size: 0.88rem; }
.account-info {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  flex-wrap: wrap;
}
.account-avatar-wrap { width: 56px; height: 56px; flex-shrink: 0; }
.account-avatar-wrap .sidebar-avatar-fallback,
.account-avatar-wrap .sidebar-avatar {
  width: 56px; height: 56px; font-size: 1.2rem;
}
.account-details { flex: 1; min-width: 0; }
.account-name  { font-size: 1rem; font-weight: 700; }
.account-email { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
/* ════════════════════════ SUBTITLE TAB ════════════════════════ */
.info-banner {
  background: rgba(91,140,255,0.1);
  border: 1px solid rgba(91,140,255,0.22);
  color: #c5d4f5;
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.info-banner strong { color: var(--text); font-weight: 700; }

.title-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.9rem;
  outline: none;
  flex-shrink: 0;
}
.title-input:focus { border-color: rgba(91,140,255,0.35); }
.title-input::placeholder { color: var(--muted); }

.dropzone {
  flex: 1;
  min-height: 220px;
  border: 1.5px dashed rgba(255,255,255,0.14);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover,
.dropzone:focus {
  border-color: var(--accent-2);
  background: rgba(61,214,197,0.04);
  outline: none;
}
.dropzone.is-dragover {
  border-color: var(--accent-2);
  background: rgba(61,214,197,0.08);
}
.dropzone.has-file {
  cursor: default;
  border-style: solid;
  border-color: var(--border);
  background: var(--surface);
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  padding: 0;
  overflow: hidden;
}
.dropzone-empty p {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}
.dropzone-sample {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-2);
}
.dropzone-sample:hover { color: #6eecdf; }

.voice-hint {
  background: rgba(91,140,255,0.1);
  border: 1px solid rgba(91,140,255,0.2);
  color: #c5d4f5;
  font-size: 0.82rem;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.cue-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  height: 100%;
}
.cue-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cue-panel-count { font-size: 0.88rem; font-weight: 700; }
.cue-panel-actions { display: flex; align-items: center; gap: 10px; }
.cue-replace {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 650;
  padding: 4px 6px;
}
.cue-replace:hover { text-decoration: underline; }
.cue-delete {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 650;
  padding: 4px 6px;
}
.cue-delete:hover { text-decoration: underline; }
.cue-list {
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.cue-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 12px;
}
.cue-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
  min-width: 132px;
}
.cue-text {
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.45;
}

.notice-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(6, 8, 14, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.notice-overlay.is-open { display: flex; }
.notice-overlay.is-danger .notice-icon {
  background: rgba(255,95,95,0.12);
  color: var(--danger);
}
.notice-actions {
  display: flex;
  gap: 8px;
}
.notice-actions .notice-ok { width: auto; flex: 1; }
.notice-cancel {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 700;
}
.notice-cancel:hover { border-color: var(--border-hover); }
.notice-ok.is-danger {
  background: var(--danger);
  color: #fff;
}
.notice-card {
  width: 100%;
  max-width: 380px;
  background: #161b26;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.notice-icon {
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,95,95,0.12);
  color: var(--danger);
}
.notice-overlay.is-success .notice-icon {
  background: rgba(61,214,197,0.12);
  color: var(--accent-2);
}
.notice-overlay.is-info .notice-icon {
  background: rgba(91,140,255,0.12);
  color: var(--accent);
}
.notice-title {
  font-size: 1.02rem;
  font-weight: 750;
  margin-bottom: 6px;
}
.notice-msg {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
}
.notice-ok {
  width: 100%;
  background: var(--accent-2);
  color: #0a0c10;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 700;
}
.notice-ok:hover { filter: brightness(1.06); }

.account-tier  {
  display: inline-block;
  margin-top: 7px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(61,214,197,0.1);
  color: var(--accent-2);
  border: 1px solid rgba(61,214,197,0.2);
}

/* ════════════════════════ VOICE MODAL ════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(6, 8, 14, 0.72);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.is-open {
  display: flex;
  animation: overlayIn 0.18s ease both;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #141820;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  width: 100%;
  max-width: 980px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 28px 80px rgba(0,0,0,0.55);
  animation: modalIn 0.2s ease both;
  overflow: hidden;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.98) translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  padding: 18px 22px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title-row h3 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.modal-count {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  background: none;
  padding: 0;
  border-radius: 0;
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.modal-filters {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-search-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}
.modal-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.modal-search {
  width: 100%;
  height: 38px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0 12px 0 34px;
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-search:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(61,214,197,0.15);
}
.modal-search::placeholder { color: var(--muted); }

.modal-select {
  height: 38px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 0 12px;
  font-size: 0.84rem;
  outline: none;
  cursor: pointer;
  min-width: 132px;
}
.modal-select:focus { border-color: var(--accent-2); }

.modal-clear-btn {
  height: 38px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}
.modal-clear-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 22px 22px;
}
.voice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.voice-card {
  background: #1a1f2a;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 188px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.voice-card:hover {
  border-color: rgba(255,255,255,0.14);
  transform: translateY(-1px);
}
.voice-card.selected {
  border: 1.5px solid var(--accent-2);
  box-shadow: 0 0 0 3px rgba(61,214,197,0.12);
}
.voice-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 20px;
}
.voice-card-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.voice-card-info { flex: 1; min-width: 0; }
.voice-card-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-card-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-2);
  color: #0a0c10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voice-card-desc {
  font-size: 0.8rem;
  color: #9aa6bd;
  line-height: 1.5;
  min-height: 2.4em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  flex: 1;
}
.voice-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.voice-tag {
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
}
.voice-card-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: auto;
}
.voice-card-action-btn {
  background: none;
  border: none;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voice-card-action-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.voice-card-action-btn.is-copied { color: var(--accent-2); }
.voice-card-use-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}
.voice-card-use-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.voice-card.selected .voice-card-use-btn {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #0a0c10;
}

.modal-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ════════════════════════ RESPONSIVE ════════════════════════ */
@media (max-width: 900px) {
  .results-panel { width: 300px; }
  .voice-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-hamburger { display: flex; }
  .results-panel { display: none; }
  .ctrl-convert { margin-left: 0; }
}

@media (max-width: 560px) {
  .controls-bar { flex-direction: column; align-items: stretch; }
  .ctrl-convert { align-self: flex-end; }
  .modal { max-height: 92vh; }
  .voice-grid { grid-template-columns: 1fr; }
}
