/* ---- Shell: icon rail + main column ------------------------------------ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.rail {
  width: 72px;
  flex: 0 0 72px;
  background: var(--block);
  color: var(--block-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.rail-link {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--block-ink-3);
  font-size: 16px;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  border: none;
  background: transparent;
  cursor: pointer;
}
.rail-link:hover {
  color: var(--block-ink);
  background: rgba(245, 245, 240, 0.06);
}
.rail-link.active {
  color: var(--accent-ink);
  background: var(--accent);
}

.rail-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-4);
  display: inline-block;
}
.status-dot.ok { background: var(--accent); }
.status-dot.warn { background: var(--accent-2); }
.status-dot.err { background: var(--danger); }

.rail-theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--block-line);
  background: transparent;
  color: var(--block-ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.rail-theme-toggle:hover {
  color: var(--block-ink);
  border-color: var(--block-ink-2);
}

/* ---- Main column --------------------------------------------------------- */

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 40px 60px;
}

.main-inner {
  max-width: 1240px;
  margin: 0 auto;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink-2);
}

.hero {
  margin-bottom: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.hero-line {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: 1.02;
  margin: 0;
}
.hero-line .accent-mark {
  color: var(--ink);
  position: relative;
}
.hero-line .accent-mark::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: 0.06em;
  height: 0.28em;
  background: var(--accent);
  z-index: -1;
  border-radius: 3px;
}

.hero-sub {
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 1rem;
  max-width: 46ch;
}

/* ---- Cards / panels ------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head .index {
  display: inline-block;
  color: var(--ink-4);
  font-family: var(--font-mono);
  margin-right: 8px;
}

/* ---- Buttons -------------------------------------------------------------- */

.btn-lime {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px 26px;
  font-weight: 700;
  font-size: var(--fs-body);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn-lime:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-lime:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-weight: 600;
  font-size: var(--fs-small);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-outline:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--ink-2);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.pill:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.pill .count {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 0.7em;
}
.pill.active .count {
  color: var(--accent-ink);
  opacity: 0.65;
}

/* ---- Dark block (player chrome) ------------------------------------------ */

.block {
  background: var(--block);
  color: var(--block-ink);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
}

.block .micro {
  color: var(--block-ink-3);
}

/* Inside block chrome the accent is theme-constant, so the dark slab looks
   identical in light and dark mode. */
.block .btn-lime {
  background: var(--block-accent);
}

/* ---- View switching --------------------------------------------------- */

.view { display: none; }
.view.active {
  display: block;
  animation: view-in 220ms var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none; }
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Script panel -------------------------------------------------------- */

.script-field {
  width: 100%;
  background: #bdb1b124;
  border: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 140px;
  padding: 15px;
  border-radius: 8px;
}
.script-field:focus {
  outline: none;
}
.script-field::placeholder {
  color: var(--ink-4);
}

.field-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* Tactile press feedback, applied briefly on click via JS. */
.chip-pop {
  animation: chip-pop 260ms var(--ease);
}
@keyframes chip-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .chip-pop { animation: none; }
}

.direction-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  padding: 12px 16px;
  font-family: inherit;
  font-size: var(--fs-body);
}
.direction-input::placeholder {
  color: var(--ink-4);
}
.direction-input:focus {
  outline: none;
  border-color: var(--line-strong);
}

/* ---- Voice search + facets ------------------------------------------------ */

.voice-search-wrap {
  position: relative;
  margin-bottom: 14px;
}
.voice-search-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 13px;
}
.voice-search {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink);
  padding: 10px 16px 10px 38px;
  font-family: inherit;
  font-size: var(--fs-small);
}
.voice-search:focus {
  outline: none;
  border-color: var(--line-strong);
}
.voice-search::placeholder {
  color: var(--ink-3);
}

.facet-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.facet-group:last-of-type {
  margin-bottom: 14px;
}

/* ---- Voice list / rows ---------------------------------------------------- */

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 420px;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

.voice-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  background: transparent;
  width: 100%;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.voice-row:hover {
  background: var(--surface-2);
}
.voice-row.selected {
  background: var(--surface-2);
  border-color: var(--accent);
}
.voice-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.voice-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface-2);
}
.voice-row.selected .voice-avatar {
  background: var(--accent);
  color: var(--accent-ink);
}

.voice-info {
  min-width: 0;
  flex: 1;
}
.voice-info-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.voice-name {
  font-weight: 700;
  font-size: var(--fs-body);
  color: var(--ink);
}
.voice-lang {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--ink-3);
  text-transform: uppercase;
}
.voice-desc {
  font-size: var(--fs-small);
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-row-check {
  flex: 0 0 auto;
  color: var(--accent);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.voice-row.selected .voice-row-check {
  opacity: 1;
}

.voice-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--ink-3);
  font-size: var(--fs-small);
}

.voice-more-hint {
  padding: 10px 8px 2px;
  color: var(--ink-3);
  font-size: var(--fs-small);
}

/* Staggered reveal when the filtered set changes. */
@media (prefers-reduced-motion: no-preference) {
  .voice-row.enter {
    animation: row-in 200ms var(--ease) both;
  }
}
@keyframes row-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Voice cards (Voices view grid) --------------------------------------- */

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.voice-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.voice-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.voice-card.selected {
  border-color: var(--accent);
}
.voice-card .voice-info-top {
  margin-bottom: 6px;
}
.voice-card .voice-desc {
  white-space: normal;
  margin-bottom: 10px;
  line-height: 1.45;
}
.voice-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-chip-sm {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
}

/* ---- Player dock ----------------------------------------------------------- */

.dock-wrap {
  position: sticky;
  bottom: 0;
  padding-top: 16px;
  margin-top: 8px;
  background: linear-gradient(to top, var(--paper) 60%, transparent);
  z-index: 5;
}

.dock {
  background: var(--block);
  color: var(--block-ink);
  border-radius: var(--radius-xl);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.dock-play {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--block-accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.dock-play:hover:not(:disabled) { transform: scale(1.05); }
.dock-play:active:not(:disabled) { transform: scale(0.95); }
.dock-play:disabled { opacity: 0.4; cursor: not-allowed; }

.dock-ripple-canvas {
  position: absolute;
  inset: -18px;
  width: calc(100% + 36px);
  height: calc(100% + 36px);
  pointer-events: none;
}

.dock-body {
  flex: 1;
  min-width: 0;
}
.dock-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.dock-meta-label {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--block-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dock-meta-usage {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--block-ink-3);
  white-space: nowrap;
}
.dock-wave {
  width: 100%;
  height: 34px;
  cursor: pointer;
  display: block;
}
.dock-time {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--block-ink-3);
  margin-top: 4px;
}

.dock-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}
.dock-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--block-line);
  background: transparent;
  color: var(--block-ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.dock-btn:hover:not(:disabled) {
  color: var(--block-ink);
  border-color: var(--block-ink-2);
}
.dock-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---- Session history strip -------------------------------------------------- */

.history-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  margin-top: 20px;
}
.history-item {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 8px 14px 8px 8px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.history-item:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}
.history-item .voice-avatar {
  width: 26px;
  height: 26px;
  font-size: 11px;
}
.history-item-text {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item-play {
  color: var(--ink-3);
  font-size: 11px;
}

/* ---- Costs view ------------------------------------------------------------- */

.rate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.rate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.rate-card.featured {
  border-color: var(--accent);
}
.rate-card-price {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  margin: 8px 0 2px;
}
.rate-card-price span {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-3);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-tile-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin-top: 4px;
}

.calc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.calc-input {
  width: 160px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-mono);
  color: var(--ink);
}
.calc-input:focus {
  outline: none;
  border-color: var(--line-strong);
}
.calc-results {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.calc-result {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  color: var(--ink-2);
}
.calc-result b {
  color: var(--ink);
}

/* ---- Status dot pulse while generating ------------------------------------- */

.status-dot.busy {
  background: var(--accent-2);
  animation: dot-pulse 900ms ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .status-dot.busy { animation: none; }
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---- Theme toggle icon transition -------------------------------------------- */

.theme-toggle-btn i {
  display: inline-block;
  transition: transform var(--dur-med) var(--ease);
}
.theme-toggle-btn.spin i {
  animation: icon-flip 400ms var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .theme-toggle-btn.spin i { animation: none; }
}
@keyframes icon-flip {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(160deg) scale(0.7); }
  100% { transform: rotate(180deg) scale(1); }
}

/* ---- Toast (error / info) --------------------------------------------------- */

.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: var(--fs-small);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Responsive ------------------------------------------------------------- */

@media (max-width: 991px) {
  .main { padding: 20px 18px 90px; }
  .rail { width: 60px; flex: 0 0 60px; }
  .dock { flex-wrap: wrap; }
  .dock-actions { order: 3; width: 100%; justify-content: flex-end; }
}

@media (max-width: 575px) {
  .rail { display: none; }
  .app-shell { flex-direction: column; }
  .main { padding: 16px 14px 84px; }
  .dock-wrap { bottom: 64px; }
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--block);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--block-line);
}
.mnav-link {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--block-ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
}
.mnav-link.active {
  color: var(--accent-ink);
  background: var(--block-accent);
}

/* ---- Voice clone: record/upload row ------------------------------------ */
.clone-sample-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.clone-file { flex: 1 1 160px; min-width: 140px; }
.clone-preview { width: 100%; margin-top: 10px; }
#recordBtn.is-recording {
  color: #fff; border-color: #e5484d; background: #e5484d;
  animation: recPulse 1.2s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(229, 72, 77, 0); }
}

/* ---- Delivery control range sliders ------------------------------------ */
.ctrl-range {
  width: 100%; margin-top: 6px; accent-color: var(--accent, #6c5ce7);
  cursor: pointer;
}
