:root {
  --page: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #17202b;
  --muted: #647184;
  --line: #d9e0e7;
  --line-strong: #bec8d3;
  --brand: #275fc8;
  --brand-dark: #1f4da7;
  --brand-soft: #edf3ff;
  --success: #167456;
  --success-soft: #eaf7f1;
  --warning: #9a5b0b;
  --warning-soft: #fff6e6;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 18px 50px rgba(30, 45, 61, 0.09);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.drop-zone:focus-visible {
  outline: 3px solid rgba(39, 95, 200, 0.23);
  outline-offset: 2px;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.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;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 28px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 44px;
  margin-bottom: 48px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.66);
}

.header-nav a {
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  text-decoration: none;
}

.header-nav a:hover {
  color: var(--ink);
  background: var(--surface);
}

.header-nav a.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  align-items: end;
  gap: 48px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  margin-bottom: 13px;
  font-size: clamp(32px, 4vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.hero-copy {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.hero-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #cdd8eb;
  border-radius: 10px;
  background: #f8faff;
}

.hero-note > svg {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: var(--brand);
}

.hero-note strong,
.hero-note span {
  display: block;
}

.hero-note strong {
  margin-bottom: 3px;
  font-size: 13px;
}

.hero-note span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tool-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.mode-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 76px;
  padding: 12px 20px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.mode-tab + .mode-tab {
  border-left: 1px solid var(--line);
}

.mode-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  background: transparent;
  content: "";
}

.mode-tab.active {
  background: var(--surface);
}

.mode-tab.active::after {
  background: var(--brand);
}

.mode-tab > span:last-child {
  text-align: left;
}

.mode-tab strong,
.mode-tab small {
  display: block;
}

.mode-tab strong {
  margin-bottom: 2px;
  font-size: 14px;
}

.mode-tab small {
  color: var(--muted);
  font-size: 12px;
}

.tab-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 9px;
  background: #e8edf3;
  color: var(--muted);
}

.mode-tab.active .tab-icon {
  background: var(--brand-soft);
  color: var(--brand);
}

.tab-icon svg {
  width: 20px;
  height: 20px;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  min-height: 560px;
}

.workflow {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 24px;
  padding: 34px 38px 38px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-number {
  display: inline-grid;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.section-heading h2,
.model-fieldset legend strong {
  display: block;
  margin: 1px 0 3px;
  font-size: 15px;
  line-height: 1.3;
}

.section-heading p,
.model-fieldset legend small {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.drop-zone {
  min-height: 152px;
  padding: 18px;
  border: 1px dashed #9faebe;
  border-radius: 10px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--brand);
  background: #f5f8ff;
}

.drop-empty {
  display: flex;
  min-height: 114px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.drop-empty strong {
  margin-top: 4px;
  color: var(--ink);
  font-size: 14px;
}

.drop-empty small {
  margin-top: 5px;
  color: #8692a1;
  font-size: 11px;
}

.upload-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
}

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

.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-weight: 750;
  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
}

.file-selection {
  display: flex;
  min-height: 114px;
  align-items: center;
  gap: 14px;
  cursor: default;
}

.file-icon {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
}

.file-icon svg {
  width: 24px;
  height: 24px;
}

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

.file-copy strong,
.file-copy small {
  display: block;
}

.file-copy strong {
  overflow: hidden;
  margin-bottom: 4px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy small {
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: #f0f3f6;
}

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

.form-section {
  display: grid;
  gap: 13px;
  padding-top: 1px;
}

.message-field {
  padding-left: 37px;
}

.message-field > label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 750;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.hex-input-wrap {
  display: flex;
  align-items: center;
  height: 44px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.hex-input-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(39, 95, 200, 0.12);
}

.hex-input-wrap > span {
  padding-left: 12px;
  color: #8a96a5;
  font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.hex-input-wrap input {
  min-width: 0;
  height: 100%;
  flex: 1;
  padding: 0 8px 0 4px;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: 14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
}

.hex-input-wrap small {
  padding-right: 11px;
  color: #8a96a5;
  font-size: 10px;
  white-space: nowrap;
}

.field-help,
.field-error {
  margin: 6px 0 0;
  font-size: 11px;
}

.field-help {
  color: var(--muted);
}

.field-error {
  color: var(--danger);
}

.secondary-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
}

.secondary-button:hover {
  border-color: #a9b5c2;
  background: var(--surface-soft);
}

.secondary-button svg {
  width: 16px;
  height: 16px;
}

.model-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.model-fieldset legend {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-bottom: 12px;
  padding: 0;
}

.model-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-left: 37px;
}

.model-option {
  position: relative;
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.model-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.model-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.model-option > span:nth-child(2) {
  flex: 1;
}

.model-option strong,
.model-option small {
  display: block;
}

.model-option strong {
  margin-bottom: 2px;
  font-size: 13px;
}

.model-option small {
  color: var(--muted);
  font-size: 11px;
}

.radio-mark {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}

.model-option input:checked ~ .radio-mark {
  border: 5px solid var(--brand);
}

.primary-button,
.download-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
}

.primary-button {
  margin-top: auto;
  cursor: pointer;
}

.primary-button:not(:disabled):hover,
.download-button:hover {
  background: var(--brand-dark);
}

.primary-button:disabled {
  background: #aeb8c5;
  cursor: not-allowed;
}

.primary-button svg,
.download-button svg {
  width: 18px;
  height: 18px;
}

.button-loading {
  display: none;
}

.primary-button.loading .button-label {
  display: none;
}

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

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.form-error {
  padding: 10px 12px;
  border: 1px solid #f0bbb6;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.result-rail {
  display: flex;
  min-width: 0;
  align-items: stretch;
  padding: 28px;
  border-left: 1px solid var(--line);
  background: var(--surface-soft);
}

.rail-placeholder,
.result-card {
  width: 100%;
  align-self: center;
}

.rail-placeholder {
  color: var(--muted);
  text-align: center;
}

.rail-icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--brand);
}

.rail-icon svg {
  width: 27px;
  height: 27px;
}

.rail-placeholder h3 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 15px;
}

.rail-placeholder > p {
  margin: 0 auto 22px;
  font-size: 12px;
  line-height: 1.6;
}

.detail-list {
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  list-style: none;
  text-align: left;
}

.detail-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.detail-list li:last-child {
  border-bottom: 0;
}

.detail-list strong {
  color: var(--ink);
}

.callout {
  padding: 12px;
  border: 1px solid #ebd6b5;
  border-radius: 8px;
  background: var(--warning-soft);
  text-align: left;
}

.callout strong,
.callout span {
  display: block;
}

.callout strong {
  margin-bottom: 3px;
  color: var(--warning);
  font-size: 11px;
}

.callout span {
  font-size: 11px;
  line-height: 1.45;
}

.result-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(37, 52, 69, 0.07);
}

.result-card.success {
  border-color: #bcded0;
}

.result-card.not-found {
  border-color: #e7d1ad;
}

.result-status {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 18px;
}

.status-icon {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}

.not-found .status-icon {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.result-status p {
  margin: 0 0 2px;
  color: var(--success);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.not-found .result-status p {
  color: var(--warning);
}

.result-status h3 {
  margin: 0;
  font-size: 16px;
}

.result-card audio {
  display: block;
  width: 100%;
  height: 38px;
  margin-bottom: 18px;
}

.result-details {
  margin: 0 0 16px;
  border-top: 1px solid var(--line);
}

.result-details > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.result-details dt {
  color: var(--muted);
  font-size: 11px;
}

.result-details dd {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 740;
  text-align: right;
}

.result-details code {
  padding: 3px 5px;
  border-radius: 4px;
  background: #edf1f5;
  font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
}

.full-width {
  width: 100%;
  margin-top: 9px;
}

.result-explanation {
  margin: -4px 0 17px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.quality-note {
  margin: -6px 0 16px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.copy-value {
  display: flex;
  align-items: center;
  gap: 5px;
}

.copy-value button {
  padding: 2px 4px;
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 10px;
  font-weight: 760;
  cursor: pointer;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.toggle-row label {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 750;
}

.toggle-row p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  margin: 0 !important;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch > span:not(.sr-only) {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #b9c2cc;
  transition: background 150ms ease;
}

.switch > span:not(.sr-only)::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  content: "";
  transition: transform 150ms ease;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: calc(100% - 44px);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 3px 0;
  color: #818d9a;
  font-size: 11px;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 28px, 680px);
  }

  .app-header {
    align-items: flex-start;
    margin-bottom: 36px;
  }

  .header-nav a {
    padding: 8px 9px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 20px;
  }

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

  .result-rail {
    min-height: 360px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: 100%;
    padding-top: 0;
  }

  .app-header {
    display: block;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }

  .brand {
    margin-bottom: 12px;
  }

  .header-nav {
    width: 100%;
    overflow-x: auto;
  }

  .header-nav a {
    flex: 1 0 auto;
    text-align: center;
  }

  .hero {
    padding: 0 16px;
  }

  h1 {
    font-size: 32px;
  }

  .tool-card {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .mode-tab {
    min-height: 68px;
    padding: 10px;
  }

  .workflow,
  .result-rail {
    padding: 24px 18px;
  }

  .input-row,
  .model-options {
    grid-template-columns: 1fr;
  }

  .message-field,
  .model-options {
    padding-left: 0;
  }

  footer {
    display: grid;
    padding: 16px;
  }
}

@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;
  }
}

/* Lunch dark theme */
:root {
  --page: #020617;
  --surface: #0f172a;
  --surface-soft: #111c30;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: #334155;
  --line-strong: #475569;
  --brand: #22d3ee;
  --brand-dark: #67e8f9;
  --brand-soft: rgba(34, 211, 238, 0.12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.11);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.11);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

body {
  background:
    radial-gradient(circle at 18% 0%, rgba(8, 145, 178, 0.13), transparent 34rem),
    var(--page);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.brand-mark {
  background: var(--brand);
  color: #082f49;
}

.header-nav {
  background: rgba(15, 23, 42, 0.72);
}

.header-nav a:hover {
  color: var(--ink);
  background: #1e293b;
}

.header-nav a.active {
  color: #a5f3fc;
  background: var(--brand-soft);
}

.hero-note {
  border-color: rgba(34, 211, 238, 0.3);
  background: rgba(8, 47, 73, 0.38);
}

.tool-card {
  background: rgba(15, 23, 42, 0.94);
}

.tab-icon,
.upload-icon,
.file-icon {
  background: #1e293b;
}

.mode-tab.active .tab-icon {
  background: var(--brand-soft);
}

.drop-zone:hover,
.drop-zone.dragging {
  background: rgba(8, 47, 73, 0.3);
}

.hex-input-wrap input {
  background: transparent;
  color: var(--ink);
}

.hex-input-wrap > span,
.hex-input-wrap small,
.drop-empty small {
  color: #64748b;
}

.icon-button:hover,
.secondary-button:hover {
  background: #1e293b;
}

.model-option:has(input:checked) {
  background: var(--brand-soft);
}

.radio-mark {
  background: #0f172a;
}

.primary-button,
.download-button {
  color: #082f49;
}

.primary-button:not(:disabled):hover,
.download-button:hover {
  color: #020617;
}

.primary-button:disabled {
  background: #475569;
  color: #94a3b8;
}

.rail-icon,
.detail-list,
.result-card {
  background: #0f172a;
}

.callout {
  border-color: rgba(251, 191, 36, 0.3);
}

.result-details code {
  background: #1e293b;
}

.toggle-row {
  background: #111c30;
}

.toast {
  background: #e2e8f0;
  color: #0f172a;
}

@media (max-width: 620px) {
  .app-header {
    background: #0f172a;
  }
}
