:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #647078;
  --line: #d7dde1;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --field: #ffffff;
  --blue: #315fdc;
  --blue-dark: #2448a8;
  --green: #167a5b;
  --red: #b63d38;
  --gold: #b8821f;
  --shadow: 0 24px 70px rgba(23, 32, 38, 0.16);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f1ea;
  --muted: #aab2b9;
  --line: #34414b;
  --paper: #101417;
  --panel: #161d22;
  --field: #11181d;
  --blue: #7aa2ff;
  --blue-dark: #9bb8ff;
  --green: #66d0a7;
  --red: #ff8f86;
  --gold: #e4b85b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #f3f1ea;
    --muted: #aab2b9;
    --line: #34414b;
    --paper: #101417;
    --panel: #161d22;
    --field: #11181d;
    --blue: #7aa2ff;
    --blue-dark: #9bb8ff;
    --green: #66d0a7;
    --red: #ff8f86;
    --gold: #e4b85b;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(49, 95, 220, 0.14), transparent 34%),
    linear-gradient(120deg, rgba(49, 95, 220, 0.1), rgba(22, 122, 91, 0.08)),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.shell {
  width: min(860px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.workspace {
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
}

.brand {
  min-width: 0;
}

.brand-title {
  display: flex;
  align-items: center;
}

.brand-logo {
  display: block;
  width: min(300px, 52vw);
  height: 54px;
  object-fit: contain;
  object-position: left center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.15rem;
}

.theme-switch {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 4px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  overflow: hidden;
}

.theme-switch-indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px - 8px) / 3);
  border-radius: 6px;
  background: var(--blue);
  box-shadow: 0 8px 22px rgba(49, 95, 220, 0.26);
  transform: translateX(calc((100% + 4px) * var(--theme-switch-index, 0)));
  transition:
    transform 295ms cubic-bezier(0.2, 0.85, 0.2, 1),
    background-color 180ms ease,
    box-shadow 180ms ease;
  z-index: 0;
}

.theme-switch label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    color 160ms ease,
    transform 160ms ease;
}

.theme-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-switch label:has(input:checked) {
  color: #fff;
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch-indicator,
  .theme-switch label {
    transition: none;
  }
}

.layout {
  min-height: 0;
}

.composer {
  padding: 24px;
}

.field-label,
.control span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

textarea {
  display: block;
  width: 100%;
  min-height: 360px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--field);
  line-height: 1.5;
  outline: none;
}

textarea:focus,
select:focus,
input:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 95, 220, 0.16);
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr);
  gap: 16px;
  margin-top: 18px;
}

select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
}

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

#speedValue {
  color: var(--gold);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
}

.primary {
  color: #fff;
  background: var(--blue);
}

.primary:hover {
  background: var(--blue-dark);
}

.primary:disabled {
  background: #9ba8c9;
  cursor: wait;
}

.secondary {
  color: var(--ink);
  background: var(--field);
  border-color: var(--line);
}

.meta {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.88rem;
}

.progress-wrap {
  margin-top: 16px;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 260ms ease;
}

.progress-label {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.form-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.form-message:empty {
  display: none;
}

.form-message.error {
  color: var(--red);
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 720px);
    padding: 10px 0;
  }

  .topbar,
  .layout,
  .controls {
    display: block;
  }

  .topbar {
    padding: 18px;
  }

  .theme-switch {
    margin-top: 14px;
    width: 100%;
  }

  .brand-logo {
    width: min(270px, 100%);
    height: 46px;
  }

  .composer {
    padding: 18px;
  }

  textarea {
    min-height: 260px;
  }

  .control {
    display: block;
    margin-top: 16px;
  }

  .actions {
    flex-wrap: wrap;
  }

  .primary,
  .secondary {
    flex: 1 1 150px;
  }

  .meta {
    flex: 1 0 100%;
    margin-left: 0;
  }
}
