:root {
  --ink: #222229;
  --muted: #6d747c;
  --line: #dce3e7;
  --line-soft: #eaf0f2;
  --surface: #ffffff;
  --canvas: #f5f8f9;
  --cyan: #08b9df;
  --cyan-dark: #058ba9;
  --cyan-soft: #e8f9fc;
  --success: #1b9b70;
  --danger: #c74646;
  --shadow: 0 20px 50px rgba(31, 46, 54, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(8, 185, 223, 0.08), transparent 31rem),
    linear-gradient(180deg, #fbfcfd 0%, var(--canvas) 32%, #f7f9fa 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button,
a,
input,
select,
textarea,
summary {
  outline-color: var(--cyan);
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(1px);
  pointer-events: none;
}

.ambient-one {
  top: 12vh;
  right: -13rem;
  width: 28rem;
  height: 28rem;
  border: 1px solid rgba(8, 185, 223, 0.13);
}

.ambient-two {
  bottom: 2vh;
  left: -8rem;
  width: 18rem;
  height: 18rem;
  background: rgba(8, 185, 223, 0.035);
}

.centered-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

#loading-view {
  align-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.loading-mark {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 32px;
}

.loading-mark span {
  display: block;
  width: 4px;
  height: 10px;
  border-radius: 8px;
  background: var(--cyan);
  animation: pulse-bar 0.9s ease-in-out infinite alternate;
}

.loading-mark span:nth-child(2) {
  height: 22px;
  animation-delay: 0.15s;
}

.loading-mark span:nth-child(3) {
  height: 15px;
  animation-delay: 0.3s;
}

@keyframes pulse-bar {
  to { transform: scaleY(0.45); opacity: 0.45; }
}

.login-card {
  width: min(100%, 440px);
  padding: 44px;
  border: 1px solid rgba(220, 227, 231, 0.88);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 80px rgba(30, 48, 56, 0.11);
  backdrop-filter: blur(18px);
}

.login-logo {
  display: block;
  width: 184px;
  height: auto;
  margin: 0 auto 28px;
}

.login-rule {
  width: 36px;
  height: 3px;
  margin: 0 0 28px;
  border-radius: 10px;
  background: var(--cyan);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan-dark);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 8vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.login-copy {
  margin: 0 0 30px;
  color: var(--muted);
  line-height: 1.6;
}

label,
.field > span {
  font-size: 13px;
  font-weight: 680;
}

.password-field {
  position: relative;
  margin-top: 9px;
}

input[type="password"],
input[type="text"],
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input[type="password"],
input[type="text"] {
  padding: 0 48px 0 14px;
}

select {
  appearance: none;
  padding: 0 40px 0 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236d747c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 13px center;
  background-repeat: no-repeat;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(8, 185, 223, 0.11);
  outline: none;
}

.icon-button {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  transform: translateY(-50%);
}

.icon-button:hover {
  background: var(--canvas);
}

.icon-button svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.form-error {
  min-height: 21px;
  margin: 8px 0 5px;
  color: var(--danger);
  font-size: 13px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 720;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  border: 1px solid var(--ink);
  color: #fff;
  background: var(--ink);
  box-shadow: 0 8px 18px rgba(34, 34, 41, 0.17);
}

.primary-button:not(:disabled):hover {
  background: #08080b;
  box-shadow: 0 10px 24px rgba(34, 34, 41, 0.23);
  transform: translateY(-1px);
}

.primary-button svg,
.secondary-button svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.full-width {
  width: 100%;
}

.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(27, 155, 112, 0.12);
}

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

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 10px max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(220, 227, 231, 0.85);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 120px;
  height: auto;
}

.brand-divider {
  width: 1px;
  height: 28px;
  margin: 0 15px;
  background: var(--line);
}

.brand-product {
  font-size: 14px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 22px;
}

.private-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.text-button,
.icon-text-button,
.help-button {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 680;
}

.text-button:hover,
.icon-text-button:hover {
  color: var(--cyan-dark);
}

.workspace {
  width: min(100% - 40px, 1180px);
  margin: 0 auto;
  padding: 58px 0 24px;
}

.intro-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 34px;
}

.intro-row h1 {
  margin: 0 0 9px;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.04;
  letter-spacing: -0.055em;
}

.intro-row > div > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.privacy-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  padding: 13px 15px;
  border: 1px solid #ccecf2;
  border-radius: 13px;
  color: var(--muted);
  background: rgba(232, 249, 252, 0.75);
  font-size: 12px;
  line-height: 1.45;
}

.privacy-pill svg {
  flex: 0 0 auto;
  width: 21px;
  fill: none;
  stroke: var(--cyan-dark);
  stroke-width: 1.8;
}

.privacy-pill strong {
  display: block;
  color: var(--ink);
}

.studio-grid {
  display: grid;
  gap: 18px;
}

.card {
  border: 1px solid rgba(220, 227, 231, 0.95);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.controls-card,
.script-card {
  padding: 28px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.compact-heading {
  align-items: center;
}

.card-heading > div:first-child {
  display: flex;
  align-items: center;
  gap: 11px;
}

.card-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

.step-number {
  color: var(--cyan-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 760;
}

.icon-text-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.icon-text-button svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.55fr repeat(3, 1fr);
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advanced-settings {
  margin-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.advanced-settings summary {
  width: fit-content;
  padding: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  padding: 20px 0 4px;
}

.range-field {
  display: grid;
  gap: 8px;
}

.range-field > span:first-child,
.range-labels {
  display: flex;
  justify-content: space-between;
}

.range-field output {
  color: var(--cyan-dark);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.range-labels small,
.toggle-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 450;
}

.toggle-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  position: relative;
  flex: 0 0 46px;
  width: 46px;
  height: 25px;
  border-radius: 20px;
  background: #cfd7db;
  transition: background 160ms ease;
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  content: "";
  transition: transform 160ms ease;
}

.toggle-row input:checked + .toggle {
  background: var(--cyan);
}

.toggle-row input:checked + .toggle::after {
  transform: translateX(21px);
}

.toggle-row input:focus-visible + .toggle {
  outline: 2px solid var(--cyan-dark);
  outline-offset: 3px;
}

.text-meta {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.tag-toolbar {
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: #f9fbfb;
}

.toolbar-topline {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 730;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.help-button {
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 10px;
}

.tag-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.tag-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.tag-group-label {
  margin-right: 2px;
  color: #8a9197;
  font-size: 10px;
  font-weight: 670;
}

.tag-button {
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid #d7e5e8;
  border-radius: 7px;
  color: #3f4a50;
  background: #fff;
  font-size: 11px;
  font-weight: 650;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.tag-button:hover {
  border-color: #9fdbe7;
  color: var(--cyan-dark);
  background: var(--cyan-soft);
}

.tags-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 280px;
  resize: vertical;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  color: var(--ink);
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.75;
}

textarea::placeholder {
  color: #a6adb2;
}

.script-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 2px 0;
  color: var(--muted);
  font-size: 11px;
}

.text-button.subtle {
  color: var(--muted);
  font-size: 11px;
}

.action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(120deg, #222229, #30343a);
  box-shadow: 0 18px 36px rgba(34, 34, 41, 0.16);
}

.action-panel strong,
.action-panel span {
  display: block;
}

.action-panel > div > span {
  margin-top: 3px;
  color: #aeb5ba;
  font-size: 12px;
}

.generate-button {
  min-width: 220px;
  border-color: var(--cyan);
  color: #102a30;
  background: var(--cyan);
  box-shadow: none;
}

.generate-button:not(:disabled):hover {
  color: #071b20;
  background: #2bc8e7;
  box-shadow: 0 8px 22px rgba(8, 185, 223, 0.22);
}

.button-default,
.button-loading {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid rgba(16, 42, 48, 0.22);
  border-top-color: #102a30;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.result-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 22px;
  margin-top: 18px;
  padding: 28px;
  border-color: #bfe8ef;
}

.result-icon {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 14px;
  color: var(--cyan-dark);
  background: var(--cyan-soft);
}

.result-icon svg {
  width: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.result-main {
  min-width: 0;
}

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.result-heading h2 {
  margin: 0 0 4px;
  font-size: 21px;
}

.result-heading p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.secondary-button {
  min-height: 42px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.secondary-button:hover {
  border-color: #a9dfe9;
  background: var(--cyan-soft);
  transform: translateY(-1px);
}

audio {
  width: 100%;
  height: 46px;
}

.temporary-reminder {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 28px 2px 8px;
  color: #8e959a;
  font-size: 11px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  max-width: min(400px, calc(100vw - 40px));
  padding: 13px 16px;
  border: 1px solid #e8c5c5;
  border-radius: 11px;
  color: #7c2e2e;
  background: #fff6f6;
  box-shadow: 0 16px 40px rgba(57, 22, 22, 0.15);
  font-size: 13px;
}

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

  .voice-field {
    grid-column: span 2;
  }

  .intro-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 22px;
  }

  .privacy-pill {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .site-header {
    min-height: 66px;
    padding: 9px 16px;
  }

  .brand img {
    width: 96px;
  }

  .brand-divider,
  .brand-product,
  .private-badge {
    display: none;
  }

  .workspace {
    width: min(100% - 24px, 1180px);
    padding-top: 36px;
  }

  .intro-row h1 {
    font-size: 39px;
  }

  .controls-card,
  .script-card,
  .result-card {
    padding: 20px;
  }

  .settings-grid,
  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .voice-field {
    grid-column: auto;
  }

  .advanced-grid {
    gap: 24px;
  }

  .card-heading {
    margin-bottom: 18px;
  }

  .tag-groups {
    display: grid;
    gap: 10px;
  }

  textarea {
    min-height: 250px;
    padding: 15px;
  }

  .action-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .generate-button {
    width: 100%;
  }

  .result-card {
    grid-template-columns: 1fr;
  }

  .result-icon {
    display: none;
  }

  .result-heading {
    flex-direction: column;
  }

  .secondary-button {
    width: 100%;
  }

  footer {
    flex-direction: column;
    gap: 6px;
  }

  .login-card {
    padding: 32px 24px;
  }
}

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