:root {
  --brand-red: #ff3131;
  --brand-accent: #ff914d;
  --ink-on-light: #0f0f0f;
  --bg: #131313;
  --bg-elevated: #1a1a1a;
  --bg-card: #1f1f1f;
  --border: #2e2e2e;
  --border-strong: #404040;
  --text: #eef0f5;
  --muted: #9ca3af;
  --accent: #ff914d;
  --accent-dim: #e67333;
  --accent-2: #ffb380;
  --danger: #f472b6;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.5);
  --font: "Outfit", system-ui, sans-serif;
  --content-max: 1080px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 100% 80% at 50% -30%, rgba(255, 145, 77, 0.14), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(255, 49, 49, 0.07), transparent 50%),
    radial-gradient(900px 480px at 0% 20%, rgba(255, 145, 77, 0.05), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--ink-on-light);
  font-weight: 700;
  border-radius: 8px;
}
.skip-link:focus {
  left: 0.5rem;
}

.wrap {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.site-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem 1rem;
  padding: max(0.85rem, env(safe-area-inset-top, 0px)) 0 1.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  background-color: var(--bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}
@media (max-width: 720px) {
  .site-bar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }
  .site-brand {
    grid-column: 1;
    grid-row: 1;
  }
  .site-nav {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }
  .site-tagline {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    padding-top: 0.25rem;
  }
}

.site-nav {
  grid-column: 3;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}
.site-nav a {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
}
.site-nav a:hover {
  color: var(--accent);
}

.site-brand {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-self: start;
  text-decoration: none;
  color: inherit;
}
.site-brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}
.site-logo {
  display: block;
  height: clamp(2.5rem, 7vw, 4rem);
  width: auto;
  max-width: min(100%, 24rem);
  object-fit: contain;
}
.site-tagline {
  grid-column: 2;
  justify-self: center;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--brand-red);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  text-align: center;
}

.file-warn {
  display: none;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(244, 114, 182, 0.45);
  background: rgba(244, 114, 182, 0.08);
  color: #fecdd3;
  font-size: 0.95rem;
}
.file-warn code {
  font-size: 0.88em;
}
.file-warn a {
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
}
.file-warn a:hover {
  color: var(--accent);
}

.hero {
  margin-bottom: 1rem;
}
.hero h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 3.8vw, 2.05rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.hero .lede {
  margin: 0;
  color: var(--muted);
  max-width: 44rem;
  font-size: 0.98rem;
  line-height: 1.45;
}

.flow {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}

.flow > .panel {
  width: 100%;
  align-self: stretch;
  box-sizing: border-box;
}

/* Tool column on home: single stack (input → styles → actions) */
.flow > .panel-input {
  padding: 1rem 1.15rem 1.1rem;
}
.flow > .section-title {
  margin: 0.5rem 0 0.4rem;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel-input {
  min-height: 0;
}
.panel-result {
  border-color: rgba(255, 145, 77, 0.35);
  box-shadow: 0 20px 56px rgba(255, 145, 77, 0.08), var(--shadow);
}
.panel-result label {
  color: var(--accent);
}
.panel label {
  display: block;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

textarea {
  flex: 1;
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.9rem 1rem;
  font: inherit;
  font-size: 1rem;
}
textarea:focus {
  outline: 2px solid rgba(255, 145, 77, 0.45);
  outline-offset: 2px;
  border-color: var(--border-strong);
}
textarea:focus-visible {
  outline: 2px solid rgba(255, 145, 77, 0.55);
}
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#output {
  min-height: 200px;
  white-space: pre-wrap;
  word-break: break-word;
}

.field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin-bottom: 0.5rem;
}
.field-head label {
  margin-bottom: 0;
}
.field-hint {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.char-toolbar {
  margin-top: 0.55rem;
}
.char-meter-wrap {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
}
.char-meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.12s ease, background 0.2s ease;
}
.char-meter-fill.warn {
  background: linear-gradient(90deg, #fbbf24, #f97316);
}
.char-meter-fill.danger {
  background: linear-gradient(90deg, #fb7185, #ef4444);
}

.char-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-top: 0.45rem;
}
.char-count {
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.char-count.warn {
  color: #fbbf24;
}
.char-count.danger {
  color: #fb923c;
}
.char-note {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  margin-top: 0.15rem;
  max-width: 38rem;
}

button.ghost.small {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
}
.is-hidden {
  display: none !important;
}

.section-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.voices-scroll-wrap {
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
}
.voices {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding: 0.25rem 0.15rem 0.65rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--border) transparent;
}
.voices::-webkit-scrollbar {
  height: 6px;
}
.voices::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

.voice-card {
  position: relative;
  flex: 0 0 auto;
  width: 148px;
  scroll-snap-align: start;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 0.65rem 0.7rem 0.55rem;
  background: var(--bg-elevated);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.12s, background 0.15s, box-shadow 0.15s;
  font: inherit;
  color: inherit;
}
.voice-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.voice-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.voice-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: linear-gradient(155deg, rgba(255, 145, 77, 0.14), var(--bg-elevated));
  box-shadow: 0 0 0 1px rgba(255, 145, 77, 0.3);
}
.voice-card .emoji {
  font-size: 1.2rem;
  line-height: 1;
  margin-bottom: 0.2rem;
}
.voice-card .name {
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.2;
}
.voice-card .hint {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.2rem;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  padding: 0.35rem 0 0.15rem;
  margin-bottom: 0.35rem;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0;
  align-items: center;
}

button.primary,
button.ghost,
button.danger-ghost {
  border-radius: 999px;
  padding: 0.65rem 1.35rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
}
button.primary {
  background: linear-gradient(125deg, #d9734a, var(--accent), #ffb88a);
  color: var(--ink-on-light);
  box-shadow: 0 10px 32px rgba(255, 145, 77, 0.3);
}
button.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
button.primary:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:focus-visible {
  outline: 2px solid var(--muted);
  outline-offset: 2px;
}
button.danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(244, 114, 182, 0.35);
}

.panel-tts {
  margin-top: 0.5rem;
}
.speak-row {
  margin-top: 0.85rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}
.speak-row label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}
.panel-tts .speak-row {
  border-top: none;
  padding-top: 0;
  margin-top: 0.65rem;
}

select.voice-select {
  flex: 1;
  min-width: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
}
select.voice-select:focus {
  outline: 2px solid rgba(255, 145, 77, 0.45);
  outline-offset: 2px;
}

.sliders {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
  width: 100%;
}
.slider-field {
  flex: 1;
  min-width: 140px;
}
.slider-field span {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.status {
  min-height: 1.25rem;
  font-size: 0.88rem;
  color: var(--accent);
  margin-top: 0;
  text-align: right;
  flex: 1 1 140px;
}
@media (max-width: 520px) {
  .status {
    text-align: left;
    flex-basis: 100%;
  }
}
.status.err {
  color: #fb923c;
}

.guide-section {
  margin-top: 2.5rem;
  padding: 1.35rem 1.2rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(19, 19, 19, 0.9);
  box-sizing: border-box;
  width: 100%;
  max-width: none;
}
.guide-section h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.2rem, 2.5vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.guide-section h3 {
  margin: 1.35rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}
.guide-section p {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.65;
}
.guide-section p strong,
.guide-section ol strong {
  color: #c9d1e0;
  font-weight: 600;
}
.howto-steps {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.65;
}
.howto-steps li {
  margin-bottom: 0.35rem;
}
.faq-dl {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
}
.faq-dl dt {
  margin-top: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.faq-dl dt:first-child {
  margin-top: 0;
}
.faq-dl dd {
  margin: 0.25rem 0 0;
  padding-left: 0;
  color: var(--muted);
}
.site-footer {
  margin-top: 2.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.site-footer a {
  color: var(--accent);
}
.site-footer a:hover {
  text-decoration: underline;
}

/* -- Mobile: fit primary actions in view, comfortable taps -- */
@media (max-width: 640px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  .wrap {
    padding-left: max(0.85rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.85rem, env(safe-area-inset-right, 0px));
    padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
  }

  .site-bar {
    gap: 0.45rem 0.65rem;
    padding-top: max(0.55rem, env(safe-area-inset-top, 0px));
    padding-bottom: 0.65rem;
    margin-bottom: 0.65rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
  }

  .site-logo {
    height: clamp(1.85rem, 11vw, 2.35rem);
    max-width: min(100%, 12.5rem);
  }

  .site-tagline {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    line-height: 1.25;
    padding-top: 0.15rem;
  }

  .site-nav a {
    font-size: 0.82rem;
  }

  .file-warn {
    padding: 0.65rem 0.75rem;
    font-size: 0.88rem;
  }

  .hero {
    margin-bottom: 0.55rem;
  }

  .hero h1 {
    font-size: clamp(1.2rem, 5.2vw, 1.45rem);
    line-height: 1.2;
    margin-bottom: 0.3rem;
  }

  .hero .lede {
    font-size: 0.88rem;
    line-height: 1.38;
  }

  .flow {
    gap: 0.4rem;
  }

  .flow > .panel-input {
    padding: 0.65rem 0.75rem 0.75rem;
  }

  .flow > .section-title {
    margin: 0.35rem 0 0.3rem;
  }

  .panel {
    padding: 0.8rem 0.85rem 0.95rem;
  }

  .panel-input textarea {
    min-height: 112px;
    padding: 0.7rem 0.8rem;
    font-size: 16px;
  }

  .panel-result textarea {
    min-height: 140px;
    padding: 0.7rem 0.8rem;
    font-size: 16px;
  }

  .field-head {
    margin-bottom: 0.35rem;
  }

  .char-toolbar-row {
    margin-top: 0.35rem;
  }

  .char-note {
    font-size: 0.66rem;
    line-height: 1.3;
    margin-top: 0.1rem;
  }

  .voices {
    padding-bottom: 0.5rem;
    gap: 0.45rem;
    scroll-padding: 0 0.5rem;
  }

  .voice-card {
    min-height: 4.5rem;
    padding: 0.55rem 0.6rem 0.5rem;
  }

  .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding-top: 0.25rem;
    margin-bottom: 0.25rem;
  }

  .action-bar .actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

  .action-bar .actions button {
    width: 100%;
    min-height: 46px;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
    touch-action: manipulation;
  }

  .action-bar .status {
    text-align: center;
    width: 100%;
    flex: none;
  }

  .guide-section {
    margin-top: 1.75rem;
    padding: 1.1rem 1rem 1.25rem;
  }

  .site-footer {
    margin-top: 2rem;
    padding-top: 1.25rem;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .panel-tts .speak-row {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-tts .speak-row .voice-select {
    min-width: 0;
    width: 100%;
  }

  .panel-tts .speak-row button {
    min-height: 46px;
    width: 100%;
  }

  .sliders {
    flex-direction: column;
  }
}

@media (max-width: 640px) and (min-width: 380px) {
  .panel-input textarea {
    min-height: 120px;
  }
}
