:root {
  color-scheme: dark;
  --bg: #08090d;
  --bg-raised: #0e1016;
  --surface: #11141b;
  --surface-2: #171a23;
  --surface-3: #1d2130;
  --text: #f5f6fa;
  --text-strong: #ffffff;
  --muted: #98a1b3;
  --muted-2: #6f788b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #8b7cff;
  --accent-soft: #b9aaff;
  --accent-2: #4fd1c5;
  --accent-ink: #0b0716;
  --success: #4ade9a;
  --danger: #ff7a8a;
  --warning: #ffd36b;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 11px;
  --shadow-card: 0 26px 80px rgba(0, 0, 0, 0.38);
  --shadow-cta: 0 14px 36px rgba(124, 92, 255, 0.28);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(1000px 620px at 90% -12%, rgba(139, 124, 255, 0.18), transparent 62%),
    radial-gradient(760px 520px at -18% 8%, rgba(79, 209, 197, 0.09), transparent 60%),
    linear-gradient(180deg, #08090d 0%, #090a0f 50%, #08090d 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.46), transparent 62%);
}

.app {
  position: relative;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 26px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: #f4f6f2;
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1;
}

.brand-name {
  font-size: 18px;
  font-weight: 780;
  letter-spacing: -0.045em;
}

.brand-sub {
  color: var(--muted-2);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

.status-pill.busy {
  color: var(--warning);
  border-color: rgba(255, 211, 107, 0.25);
  background: rgba(255, 211, 107, 0.07);
}

.status-pill.busy .status-dot {
  animation: pulse 1.8s ease-in-out infinite;
}

.status-pill.success {
  color: var(--success);
}

.hero {
  padding: 4px 2px 24px;
  animation: rise 0.65s var(--ease-out) both;
}

.kicker {
  margin: 0 0 12px;
  color: var(--accent-soft);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(38px, 10.5vw, 58px);
  line-height: 0.95;
  letter-spacing: -0.06em;
  font-weight: 800;
  color: var(--text-strong);
}

.hero h1 span {
  color: transparent;
  background: linear-gradient(100deg, #ffffff 6%, #c4b8ff 48%, #72e4d7 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-sub {
  max-width: 38ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
}

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)),
    var(--surface);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 14px;
  animation: rise 0.7s var(--ease-out) both;
}

.auth-error {
  text-align: center;
  padding: 30px 22px;
}

.auth-icon,
.failure-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  color: var(--accent-soft);
  background: rgba(139, 124, 255, 0.08);
}

.auth-icon svg,
.failure-icon svg {
  width: 26px;
  height: 26px;
}

.auth-error h2,
.failure-card h2 {
  margin: 0 0 8px;
  font-size: 21px;
  letter-spacing: -0.03em;
}

.auth-error p {
  max-width: 34ch;
  margin: 0 auto;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.composer {
  padding: 16px;
}

.composer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.composer-head label,
.section-label,
.field-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0.04em;
}

.char-count {
  color: var(--muted-2);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

textarea,
input[type="text"] {
  width: 100%;
  color: var(--text);
  background: #0a0c12;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  font: inherit;
  font-size: 15px;
  line-height: 1.48;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
  resize: vertical;
}

textarea::placeholder,
input::placeholder {
  color: #646d7e;
}

textarea:focus,
input[type="text"]:focus {
  background: #0c0e15;
  border-color: rgba(139, 124, 255, 0.62);
  box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.14);
}

.idea-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px -2px 20px;
  padding: 2px;
}

.idea-chip {
  position: relative;
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.idea-chip::before {
  content: "";
  position: absolute;
  inset: -6px -2px;
}

.idea-chip:hover,
.idea-chip:focus-visible {
  color: var(--text);
  background: rgba(139, 124, 255, 0.1);
  border-color: rgba(139, 124, 255, 0.3);
}

.idea-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.section-label {
  margin: 0 0 9px 2px;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.preset {
  position: relative;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.16s var(--ease-out),
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.preset:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line-strong);
}

.preset:active {
  transform: scale(0.985);
}

.preset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.preset.selected {
  border-color: rgba(139, 124, 255, 0.65);
  background:
    linear-gradient(145deg, rgba(139, 124, 255, 0.16), rgba(79, 209, 197, 0.05)),
    #121420;
  box-shadow:
    inset 0 0 0 1px rgba(139, 124, 255, 0.2),
    0 10px 28px rgba(60, 45, 140, 0.16);
}

.preset.selected::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(79, 209, 197, 0.12);
}

.preset-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--accent-soft);
  background: rgba(139, 124, 255, 0.1);
}

.preset.selected .preset-icon {
  color: #dfd7ff;
  background: rgba(139, 124, 255, 0.2);
}

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

.preset-title {
  display: block;
  max-width: 100%;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.preset-desc {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.custom-field {
  display: block;
  margin: 0 0 15px;
}

.custom-field .field-label {
  display: block;
  margin: 0 0 7px 2px;
}

.voice-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  margin: 2px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
}

.voice-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--accent-2);
  background: rgba(79, 209, 197, 0.09);
}

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

.voice-copy {
  flex: 1;
  min-width: 0;
}

.voice-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.voice-copy code {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-family: "SF Mono", ui-monospace, "Cascadia Code", Menlo, monospace;
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.icon-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.icon-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.voice-editor {
  margin: 0 0 15px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #0b0d13;
  animation: reveal 0.22s var(--ease-out) both;
}

.voice-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.45;
}

.hint code {
  color: var(--muted);
}

.primary,
.ghost,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.16s var(--ease-out),
    filter 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.primary {
  color: var(--accent-ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, #b6a7ff 0%, #8b7cff 42%, #6ce3d6 100%);
  box-shadow: var(--shadow-cta);
  padding: 13px 18px;
}

.primary:hover {
  filter: brightness(1.06);
}

.primary:active,
.ghost:active,
.button-link:active,
.icon-button:active {
  transform: scale(0.98);
}

.primary:focus-visible,
.ghost:focus-visible,
.button-link:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

.primary:disabled {
  opacity: 0.52;
  cursor: default;
  filter: none;
  box-shadow: none;
}

.primary.small {
  min-height: 42px;
  padding: 10px 14px;
  font-size: 12.5px;
}

.ghost {
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.035);
  padding: 11px 15px;
  font-size: 12.5px;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ghost svg,
.button-link svg {
  width: 17px;
  height: 17px;
}

.button-link {
  flex: 1;
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.035);
  padding: 11px 15px;
  font-size: 12.5px;
}

.submit {
  width: 100%;
  min-height: 52px;
  margin-top: 2px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.submit-spark {
  width: 18px;
  height: 18px;
}

.submit-arrow {
  width: 18px;
  height: 18px;
  margin-left: auto;
  opacity: 0.72;
}

.submit:disabled .submit-arrow {
  display: none;
}

.error-text {
  margin: 10px 2px 0;
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.5;
}

.job-card {
  border-color: rgba(139, 124, 255, 0.26);
  background:
    radial-gradient(500px 220px at 100% 0%, rgba(139, 124, 255, 0.13), transparent 70%),
    var(--surface);
}

.job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.job-head h2,
.failure-card h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.job-percent {
  color: var(--accent-soft);
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  margin-bottom: 10px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b7cff, #c39cff 52%, #4fd1c5);
  box-shadow: 0 0 18px rgba(139, 124, 255, 0.42);
  transition: width 0.45s var(--ease-out);
}

.progress.indeterminate .progress-bar {
  width: 34% !important;
  animation: shimmer 1.4s ease-in-out infinite;
}

.job-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11.5px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 16px;
}

.step {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition:
    color 0.3s ease,
    border-color 0.3s ease;
}

.step.active {
  color: var(--text);
  border-color: var(--accent);
}

.step.done {
  color: var(--success);
  border-color: rgba(74, 222, 154, 0.55);
}

.job-note {
  margin: 14px 0 0;
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.5;
}

.success-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--success);
  background: rgba(74, 222, 154, 0.1);
  border: 1px solid rgba(74, 222, 154, 0.28);
}

.success-mark svg {
  width: 18px;
  height: 18px;
}

.result-card video {
  width: 100%;
  max-height: 58vh;
  display: block;
  margin: 0 0 13px;
  border-radius: var(--radius-lg);
  background: #000;
}

.result-actions {
  display: flex;
  gap: 8px;
}

.result-actions .primary {
  flex: 0 0 auto;
}

.failure-card {
  border-color: rgba(255, 122, 138, 0.3);
}

.failure-card .failure-icon {
  margin: 0 0 14px;
  color: var(--danger);
  background: rgba(255, 122, 138, 0.08);
  border-color: rgba(255, 122, 138, 0.22);
}

.failure-card .error-text {
  margin: 8px 0 16px;
}

.history {
  margin-top: 24px;
  animation: rise 0.75s var(--ease-out) both;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 10px;
}

.section-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.history-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.022);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line-strong);
}

.history-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.history-thumb {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--accent-soft);
  background: rgba(139, 124, 255, 0.1);
}

.history-thumb svg {
  width: 18px;
  height: 18px;
}

.history-copy {
  flex: 1;
  min-width: 0;
}

.history-topic {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 10px;
}

.history-status {
  flex: 0 0 auto;
  padding: 5px 7px;
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  font-size: 9.5px;
  font-weight: 650;
  white-space: nowrap;
}

.history-status.done {
  color: var(--success);
  background: rgba(74, 222, 154, 0.09);
}

.history-status.failed {
  color: var(--danger);
  background: rgba(255, 122, 138, 0.09);
}

.history-status.running {
  color: var(--warning);
  background: rgba(255, 211, 107, 0.09);
}

.empty {
  padding: 22px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted-2);
  font-size: 11.5px;
  text-align: center;
}

.footer {
  padding: 26px 8px 6px;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-align: center;
}

code {
  font-family: "SF Mono", ui-monospace, "Cascadia Code", Menlo, monospace;
}

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

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-130%);
  }
  100% {
    transform: translateX(330%);
  }
}

@media (max-width: 370px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

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

  .preset {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
