:root {
  color-scheme: light;
  --ink: #111113;
  --muted: #6e6e73;
  --line: #dedee3;
  --soft-line: #ececf1;
  --panel: #ffffff;
  --wash: #f5f5f7;
  --wash-2: #fbfbfd;
  --blue: #0071e3;
  --blue-dark: #0057b8;
  --green: #0f766e;
  --rose: #a84e63;
  --amber: #b9821c;
  --danger: #be4b38;
  --spring: 260ms cubic-bezier(0.16, 1, 0.3, 1);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(47, 124, 246, 0.12), transparent 32%),
    radial-gradient(circle at 86% 6%, rgba(15, 118, 110, 0.13), transparent 28%),
    linear-gradient(180deg, #f9fafb 0%, #eef1f6 48%, #f8f9fb 100%);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(17, 17, 19, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 19, 0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 72%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 36px 24px 124px;
}

.app-shell[hidden],
.auth-gate[hidden] {
  display: none !important;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(560px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 68px rgba(27, 35, 52, 0.14);
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.auth-tab-bar {
  margin-top: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.65fr);
  align-items: stretch;
  gap: 24px;
  margin-bottom: 18px;
}

.hero-shell {
  min-height: 410px;
  padding: 32px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background:
    radial-gradient(circle at 84% 14%, rgba(47, 124, 246, 0.25), transparent 32%),
    radial-gradient(circle at 10% 84%, rgba(15, 118, 110, 0.22), transparent 30%),
    #111113;
  color: white;
  box-shadow: 0 34px 98px rgba(17, 17, 19, 0.28);
}

.hero-shell .micro,
.hero-shell .subtle {
  color: rgba(255, 255, 255, 0.72);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.micro {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(44px, 6.8vw, 96px);
  line-height: 0.95;
}

h1 span {
  display: block;
}

h2 {
  font-size: clamp(32px, 4.8vw, 56px);
  line-height: 1;
}

h3 {
  font-size: 18px;
  line-height: 1.15;
}

.subtle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.hero-copy .subtle {
  max-width: 640px;
  font-size: 16px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.hero-actions span {
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 12px;
  font-weight: 820;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
}

.hero-stage {
  position: relative;
  display: grid;
  align-content: center;
  gap: 16px;
  min-width: 0;
}

.provider-card {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 16px 50px rgba(27, 35, 52, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

.hero-shell .provider-card {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.hero-shell .provider-card span,
.hero-shell .provider-card strong {
  color: white;
}

.provider-card::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(15, 118, 110, 0.12);
}

.hero-device {
  position: relative;
  min-height: 270px;
  overflow: hidden;
  border: 1px solid rgba(17, 17, 19, 0.12);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.13), transparent 26%),
    linear-gradient(145deg, #111113, #20222a);
  color: white;
  box-shadow: 0 26px 74px rgba(17, 17, 19, 0.24);
}

.hero-device::before,
.hero-device::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.hero-device::before {
  width: 220px;
  height: 220px;
  right: -50px;
  top: -58px;
  background: rgba(47, 124, 246, 0.22);
  filter: blur(4px);
}

.hero-device::after {
  width: 120px;
  height: 120px;
  left: -24px;
  bottom: -38px;
  background: rgba(15, 118, 110, 0.32);
}

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  z-index: 2;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.86), transparent);
  box-shadow: 0 0 26px rgba(255, 255, 255, 0.42);
  animation: scanMove 3.8s ease-in-out infinite;
}

@keyframes scanMove {
  0%, 100% { transform: translateY(-42px); opacity: 0.15; }
  50% { transform: translateY(108px); opacity: 1; }
}

.hero-orbit {
  position: absolute;
  right: 32px;
  top: 26px;
  width: 178px;
  height: 178px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  animation: spin 18s linear infinite;
}

.hero-orbit span {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 16px 38px rgba(0, 0, 0, 0.25);
}

.hero-orbit span:nth-child(1) { left: 50%; top: -18px; background: #2f7cf6; }
.hero-orbit span:nth-child(2) { right: -18px; top: 50%; background: #0f766e; }
.hero-orbit span:nth-child(3) { left: 50%; bottom: -18px; background: #a84e63; }
.hero-orbit span:nth-child(4) { left: -18px; top: 50%; background: #b9821c; }

.hero-status-panel {
  position: absolute;
  left: 24px;
  top: 28px;
  z-index: 2;
  display: grid;
  gap: 12px;
  width: min(46%, 240px);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
}

.hero-status-panel div {
  display: grid;
  gap: 7px;
}

.hero-status-panel strong {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.hero-status-panel i {
  display: block;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.hero-status-panel i::before {
  content: "";
  display: block;
  width: var(--w);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f7cf6, #0f766e);
  animation: statusFlow 2.8s ease-in-out infinite;
}

@keyframes statusFlow {
  50% { filter: brightness(1.28); transform: translateX(4px); }
}

.wave-stack {
  position: absolute;
  right: 26px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 44px;
}

.wave-stack i {
  width: 6px;
  height: 36%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  animation: heroWave 1.2s ease-in-out infinite;
}

.wave-stack i:nth-child(2) { height: 64%; animation-delay: 80ms; }
.wave-stack i:nth-child(3) { height: 90%; animation-delay: 160ms; }
.wave-stack i:nth-child(4) { height: 58%; animation-delay: 240ms; }
.wave-stack i:nth-child(5) { height: 78%; animation-delay: 320ms; }
.wave-stack i:nth-child(6) { height: 42%; animation-delay: 400ms; }

@keyframes heroWave {
  50% { transform: scaleY(0.42); opacity: 0.52; }
}

.render-chip {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 2;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 800;
}

.provider-card span,
.task-card small,
label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.provider-card strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.mode-tab {
  position: relative;
  min-height: 84px;
  padding: 18px 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background:
    radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(47, 124, 246, 0.12), transparent 30%),
    rgba(255, 255, 255, 0.78);
  text-align: left;
  color: var(--muted);
  box-shadow: 0 14px 40px rgba(27, 35, 52, 0.06);
  transition: transform var(--spring), box-shadow var(--spring), border-color var(--spring), background var(--spring);
}

.mode-tab::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 0;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--spring);
}

.mode-tab:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 54px rgba(27, 35, 52, 0.11);
}

.mode-tab strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.mode-tab span {
  display: block;
  margin-top: 6px;
  font-size: 13px;
}

.mode-tab.is-active {
  border-color: rgba(0, 113, 227, 0.4);
  background: white;
  box-shadow: 0 18px 55px rgba(0, 113, 227, 0.14);
}

.mode-tab.is-active::after {
  transform: scaleX(1);
}

.mode-panel {
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  background:
    radial-gradient(circle at 96% 5%, rgba(47, 124, 246, 0.09), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(251, 251, 253, 0.88) 100%);
  padding: 30px;
  box-shadow: 0 26px 80px rgba(27, 35, 52, 0.1);
  backdrop-filter: blur(14px);
}

.mode-panel.is-visible {
  display: block;
  animation: panelIn 380ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 22px;
}

.flow-pills {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.flow-pills span {
  padding: 8px 12px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.product-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.composer,
.status-column {
  display: grid;
  gap: 14px;
}

.status-column {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
  align-items: start;
  scroll-margin-top: 24px;
  outline: none;
}

.status-column > .advanced-panel {
  grid-column: 1 / -1;
}

.status-column.is-result-focus .media-frame,
.status-column:focus-visible .media-frame {
  border-color: rgba(0, 113, 227, 0.48);
  box-shadow: 0 28px 76px rgba(47, 124, 246, 0.2);
}

.flow-card,
.task-card,
.input-tile,
.advanced-panel {
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 8px;
  background:
    radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(47, 124, 246, 0.1), transparent 32%),
    rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(27, 35, 52, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.86);
  transition: transform var(--spring), box-shadow var(--spring), border-color var(--spring), background-position var(--spring);
}

.flow-card:hover,
.task-card:hover,
.input-tile:hover,
.advanced-panel:hover {
  border-color: rgba(47, 124, 246, 0.18);
  transform: translateY(-2px);
  box-shadow: 0 26px 62px rgba(27, 35, 52, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.flow-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  animation: cardRise 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.flow-card.is-collapsed {
  gap: 0;
  padding-bottom: 20px;
}

.flow-card.is-collapsed > :not(.flow-card-head) {
  display: none;
}

.flow-card:nth-child(2) { animation-delay: 70ms; }
.flow-card:nth-child(3) { animation-delay: 140ms; }

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

.flow-card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}

.flow-card-head > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 11px;
  background:
    linear-gradient(145deg, #252832, #111113);
  color: white;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(17, 17, 19, 0.2);
}

.flow-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.collapse-toggle {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: auto;
  flex: 0 0 auto;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  transition: transform var(--spring), color var(--spring), background var(--spring);
}

.collapse-toggle::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: -3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.flow-card.is-collapsed .collapse-toggle {
  color: var(--ink);
  transform: rotate(-90deg);
}

.flow-card-head:hover .collapse-toggle {
  background: white;
  color: var(--blue);
}

.mode-grid,
.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.option-grid:not(.two-cols) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.input-tile {
  position: relative;
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
}

.input-tile::after {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: -1;
  border-radius: 8px;
  background: rgba(47, 124, 246, 0.08);
  opacity: 0;
  transform: scale(0.98);
  transition: opacity var(--spring), transform var(--spring);
}

.input-tile:hover::after {
  opacity: 1;
  transform: scale(1);
}

.input-tile strong {
  font-size: 14px;
}

label {
  display: block;
}

label span {
  margin-bottom: 8px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  padding: 12px 13px;
  resize: vertical;
  transition: border-color var(--spring), box-shadow var(--spring), transform var(--spring), background var(--spring);
}

textarea:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(0, 113, 227, 0.16);
  border-color: var(--blue);
  background: white;
  box-shadow: 0 12px 28px rgba(47, 124, 246, 0.08);
}

.primary,
.secondary {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 760;
  transition: transform var(--spring), box-shadow var(--spring), background var(--spring), border-color var(--spring);
}

.primary {
  padding: 0 18px;
  background:
    linear-gradient(135deg, #2f7cf6, #0057b8);
  color: white;
  box-shadow: 0 16px 34px rgba(47, 124, 246, 0.22);
}

.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 44px rgba(47, 124, 246, 0.28);
}

.secondary {
  padding: 0 14px;
  border: 1px solid rgba(17, 17, 19, 0.12);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(27, 35, 52, 0.05);
}

.secondary:hover {
  transform: translateY(-1px);
  background: white;
  box-shadow: 0 14px 30px rgba(27, 35, 52, 0.09);
}

.primary:active,
.secondary:active,
.mode-tab:active {
  transform: translateY(1px) scale(0.99);
}

.wide { width: 100%; }

button.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.upload-row,
.record-controls {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 48px;
  padding: 8px;
  border: 1px dashed rgba(17, 17, 19, 0.12);
  border-radius: 8px;
  background: rgba(248, 249, 251, 0.72);
  transition: border-color var(--spring), background var(--spring), transform var(--spring);
}

.upload-row:hover,
.record-controls:hover,
.upload-row.is-drag-over {
  border-color: rgba(47, 124, 246, 0.36);
  background: rgba(47, 124, 246, 0.055);
}

.compact-row { margin-bottom: 0; }

.upload-row select {
  flex: 1 1 220px;
  width: auto;
  min-width: 0;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.file-name,
.upload-status {
  color: var(--muted);
  font-size: 13px;
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.helper-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.helper-note a {
  color: var(--blue);
  font-weight: 780;
  text-decoration: none;
}

.helper-note a:hover {
  text-decoration: underline;
}

.template-guide {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 8px;
  background: rgba(248, 249, 251, 0.86);
}

.template-guide strong {
  font-size: 14px;
}

.template-guide ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.step-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.step-choice {
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 16px;
  text-align: left;
  border: 1px solid rgba(17, 17, 19, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(27, 35, 52, 0.05);
  transition: transform var(--spring), border-color var(--spring), background var(--spring), box-shadow var(--spring);
}

.step-choice:hover,
.step-choice.is-active {
  border-color: rgba(47, 124, 246, 0.46);
  background: rgba(47, 124, 246, 0.06);
  box-shadow: 0 16px 34px rgba(27, 35, 52, 0.08);
  transform: translateY(-1px);
}

.step-choice strong {
  font-size: 16px;
}

.step-choice span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.template-method-panel {
  display: grid;
  gap: 10px;
}

.template-method-panel[hidden] {
  display: none;
}

.template-validation {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--green);
  font-size: 13px;
  line-height: 1.45;
}

.template-validation.is-error {
  border-color: rgba(190, 75, 56, 0.26);
  background: rgba(190, 75, 56, 0.08);
  color: var(--danger);
}

.check-line {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 8px;
  background: rgba(248, 249, 251, 0.72);
}

.check-line input {
  width: auto;
}

.audio-quality-line {
  margin-top: 10px;
}

.tab-bar {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 8px;
  background: rgba(248, 249, 251, 0.78);
}

.tab {
  flex: 1;
  padding: 10px 14px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  transition: transform var(--spring), background var(--spring), color var(--spring), box-shadow var(--spring);
}

.tab.is-active {
  color: var(--ink);
  background: white;
  box-shadow: 0 8px 20px rgba(27, 35, 52, 0.08);
}

.tab:hover {
  transform: translateY(-1px);
}

.tab-panel {
  padding-top: 12px;
}

.record-timer {
  min-width: 46px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.media-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid rgba(17, 17, 19, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 45%, rgba(47, 124, 246, 0.16), transparent 32%),
    #050608;
  color: white;
  box-shadow: 0 24px 70px rgba(17, 17, 19, 0.18);
}

.media-frame::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  pointer-events: none;
}

.media-frame::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  animation: mediaScan 4.2s ease-in-out infinite;
}

@keyframes mediaScan {
  0%, 100% { transform: translateY(-120px); opacity: 0; }
  50% { transform: translateY(120px); opacity: 1; }
}

.media-frame video,
.input-tile video,
audio {
  width: 100%;
}

.media-frame video {
  width: 100%;
  display: block;
  height: auto;
  max-height: min(72vh, 680px);
  object-fit: contain;
  border-radius: 6px;
  background: #050608;
}

.video-stage {
  display: grid;
  place-items: center;
  width: 100%;
}

.video-stage video {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(72vh, 680px);
  object-fit: contain;
}

.media-frame.has-video {
  align-content: center;
  gap: 12px;
  min-height: 0;
  padding: 18px;
}

.media-frame.has-video::before,
.media-frame.has-video::after {
  display: none;
}

.video-meta {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  font-weight: 680;
}

.video-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.video-actions a,
.video-actions button {
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
  transition: background var(--spring), transform var(--spring), border-color var(--spring);
}

.video-actions button {
  cursor: pointer;
}

.video-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.video-actions a:hover,
.video-actions button:hover,
.video-actions button.is-active {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.media-frame span {
  color: rgba(255, 255, 255, 0.62);
  font-weight: 750;
}

.input-tile video {
  max-height: 260px;
  background: #050608;
}

.task-card {
  position: relative;
  padding: 18px;
  overflow: hidden;
}

.task-card::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(15, 118, 110, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.task-card strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.task-card span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.task-card strong.is-running {
  color: var(--green);
}

.task-card strong.is-running::after {
  content: "";
  display: inline-block;
  width: 0.65em;
  height: 0.65em;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--green);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.advanced-panel {
  padding: 12px;
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.advanced-panel[open] {
  display: grid;
  gap: 12px;
}

pre {
  min-height: 180px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  background: white;
  white-space: pre-wrap;
}

.upload-debug {
  display: grid;
  gap: 8px;
}

.upload-progress {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--wash);
}

.upload-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background:
    linear-gradient(90deg, #2f7cf6, #0f766e);
  transition: width 180ms ease;
}

.upload-debug strong {
  color: var(--muted);
  font-size: 13px;
}

.upload-debug pre {
  min-height: 0;
  border-color: #f0c8bf;
  background: #fff7f5;
  color: var(--danger);
}

.upload-debug pre:empty {
  display: none;
}

.upload-provider-note {
  margin: 4px 0 0;
  padding: 6px 10px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
}

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

.motion-off .task-card strong.is-running::after,
.motion-off .scan-line,
.motion-off .wave-stack i,
.motion-off .media-frame::after {
  animation: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 104px;
  max-width: 380px;
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.activity-dock {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 42vw) auto auto;
  align-items: center;
  gap: 14px;
  width: min(1120px, calc(100vw - 32px));
  padding: 14px 16px 14px 18px;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 18px 60px rgba(30, 41, 59, 0.16);
  backdrop-filter: blur(22px) saturate(1.2);
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--spring), transform var(--spring), border-color var(--spring);
}

.activity-dock:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.activity-dock.is-error {
  border-color: rgba(190, 75, 56, 0.36);
}

.activity-dock.is-success {
  border-color: rgba(15, 118, 110, 0.26);
}

.activity-dock-copy {
  min-width: 0;
}

.activity-dock-copy strong,
.activity-dock-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-dock-copy strong {
  font-size: 14px;
}

.activity-dock-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.activity-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(17, 17, 19, 0.08);
}

.activity-track span {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--activity-progress, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

.activity-dock.is-error .activity-track span {
  background: linear-gradient(90deg, var(--danger), var(--amber));
}

.activity-dock.is-running .activity-track span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: activityShimmer 1.4s ease-in-out infinite;
}

@keyframes activityShimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.activity-state {
  min-width: 64px;
  padding: 7px 10px;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 999px;
  background: rgba(17, 17, 19, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.activity-dock.is-running .activity-state {
  color: var(--blue-dark);
}

.activity-dock.is-success .activity-state {
  color: var(--green);
}

.activity-dock.is-error .activity-state {
  color: var(--danger);
}

.activity-close {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  transition: transform var(--spring), background var(--spring);
}

.activity-close:hover {
  background: white;
  transform: translateY(-1px);
}

@media (max-width: 980px) {
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .provider-card {
    width: 100%;
  }

  .mode-tabs,
  .product-grid,
  .status-column,
  .mode-grid,
  .step-choice-grid,
  .option-grid,
  .option-grid:not(.two-cols) {
    grid-template-columns: 1fr;
  }

  .mode-panel {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 20px 12px 112px;
  }

  .upload-row,
  .record-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-row > *,
  .record-controls > * {
    width: 100%;
  }

  .activity-dock {
    bottom: 12px;
    grid-template-columns: 1fr auto;
    gap: 10px;
    width: calc(100vw - 20px);
    padding: 12px;
  }

  .activity-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .activity-state {
    grid-column: 1;
    grid-row: 3;
    text-align: left;
  }

  .activity-close {
    grid-column: 2;
    grid-row: 1;
  }

  .toast {
    right: 12px;
    bottom: 150px;
    left: 12px;
    max-width: none;
  }

}

/* Voice Choice Grid & Card Styling */
.voice-selection-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
  margin-bottom: 20px;
}

.voice-selection-container .field-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.voice-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 8px;
  background: var(--wash-2);
}

.voice-choice-grid::-webkit-scrollbar {
  width: 6px;
}
.voice-choice-grid::-webkit-scrollbar-track {
  background: transparent;
}
.voice-choice-grid::-webkit-scrollbar-thumb {
  background: rgba(17, 17, 19, 0.12);
  border-radius: 3px;
}
.voice-choice-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(17, 17, 19, 0.24);
}

.voice-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  text-align: left;
  border: 1px solid rgba(17, 17, 19, 0.08);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(27, 35, 52, 0.03);
  transition: transform var(--spring), border-color var(--spring), background var(--spring), box-shadow var(--spring);
  cursor: pointer;
  outline: none;
}

.voice-card:hover {
  border-color: rgba(47, 124, 246, 0.3);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 24px rgba(27, 35, 52, 0.06);
  transform: translateY(-1px);
}

.voice-card.is-active {
  border-color: var(--blue);
  background: rgba(0, 113, 227, 0.04);
  box-shadow: 0 12px 28px rgba(0, 113, 227, 0.08);
  transform: translateY(-1px);
}

.voice-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.voice-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.voice-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
}

.voice-badge.female {
  background: rgba(168, 78, 99, 0.1);
  color: var(--rose);
}

.voice-badge.male {
  background: rgba(0, 113, 227, 0.1);
  color: var(--blue);
}

.voice-desc {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  flex-grow: 1;
}

.voice-card-actions {
  display: flex;
  align-items: center;
  width: 100%;
  margin-top: 4px;
}

.play-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  background: transparent;
  padding: 4px 0;
  transition: opacity var(--spring);
}

.play-action-btn:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.preview-tts-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 8px;
}

@media (max-width: 600px) {
  .voice-choice-grid {
    grid-template-columns: 1fr;
  }
}

.history-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(420px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.history-list-panel,
.history-detail-shell {
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 42px rgba(27, 35, 52, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.history-list-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-detail-shell {
  overflow: visible;
}

.history-detail-shell[open] {
  display: flex;
  flex-direction: column;
}

.history-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
}

.history-section-head h3 {
  margin: 0;
  font-size: 18px;
}

.history-section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.history-detail-shell > summary {
  flex: 0 0 auto;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid rgba(27, 35, 52, 0.08);
}

.history-detail-shell > summary::-webkit-details-marker {
  display: none;
}

.history-detail-shell > summary::after {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform var(--spring), border-color var(--spring);
}

.history-detail-shell[open] > summary::after {
  transform: rotate(225deg);
}

.history-detail-shell > summary:hover::after {
  border-color: var(--blue);
}

.history-container {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 0 18px 18px;
}

/* --- Generation History Grid & Card Styling --- */
.history-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 10px;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  padding: 2px 12px 18px 2px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(47, 124, 246, 0.36) transparent;
}

.history-grid::-webkit-scrollbar {
  width: 8px;
}

.history-grid::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(47, 124, 246, 0.34);
  background-clip: content-box;
}

.history-item-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 10px;
  background:
    radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(47, 124, 246, 0.05), transparent 32%),
    rgba(255, 255, 255, 0.85);
  padding: 16px;
  color: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(27, 35, 52, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.86);
  transition: transform var(--spring), box-shadow var(--spring), border-color var(--spring);
}

.history-item-card:hover,
.history-item-card.is-active {
  border-color: rgba(47, 124, 246, 0.18);
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(27, 35, 52, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.history-item-card.is-active {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(47, 124, 246, 0.32);
}

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

.history-item-time {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.history-item-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.history-item-status.completed {
  background: rgba(15, 118, 110, 0.1);
  color: var(--green);
}

.history-item-status.processing {
  background: rgba(185, 130, 28, 0.1);
  color: var(--amber);
}

.history-item-status.failed {
  background: rgba(190, 75, 56, 0.1);
  color: var(--danger);
}

.history-item-body {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 16px;
  flex-grow: 1;
}

.history-item-info {
  margin: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-info span {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-info strong {
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
}

.history-item-actions {
  font-size: 11px;
  color: var(--blue);
  font-weight: 700;
  margin-top: auto;
}

.history-detail {
  display: grid;
  flex: 0 0 auto;
  gap: 14px;
  padding: 18px 18px 0;
}

.history-detail-summary {
  display: grid;
  gap: 10px;
}

.history-detail-row {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(27, 35, 52, 0.08);
}

.history-detail-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.history-detail-row strong,
.history-detail-row a {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.history-detail-row a {
  color: var(--blue);
  text-decoration: none;
}

.history-output-frame {
  flex: 0 0 auto;
  margin: 18px;
  min-height: 360px;
  width: calc(100% - 36px);
}

.history-output-frame.has-video {
  min-height: 520px;
}

.history-empty {
  text-align: center;
  padding: 2rem 0;
  width: 100%;
}

.share-btn:disabled,
.download-btn:disabled {
  opacity: 0.72;
  cursor: progress;
}

@media (max-width: 900px) {
  .history-layout {
    grid-template-columns: 1fr;
  }

  .history-grid {
    max-height: min(62dvh, 560px);
  }

  .history-output-frame.has-video {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .history-detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
