:root {
  color-scheme: light dark;
  --text: light-dark(#27382f, #e2e9e1);
  --page: light-dark(#f6f7f4, #141c17);
  --brand-background: light-dark(#e5ece2, #29392c);
  --muted: light-dark(#69756b, #a9b5a7);
  --indicator: light-dark(#71936b, #9abc8e);
  --intro-text: light-dark(#748075, #a9b5a7);
  --surface: light-dark(#fff, #1d2821);
  --border: light-dark(#e1e6dd, #3b4a3e);
  --shadow: light-dark(#27382f04, #00000026);
  --field-border: light-dark(#e5e9e1, #3b4a3e);
  --field: light-dark(#fcfdfb, #18221b);
  --placeholder: light-dark(#9aa398, #96a591);
  --readonly: light-dark(#f7f9f5, #222e25);
  --focus: light-dark(#6f9068, #a2c391);
  --subtle: light-dark(#939c90, #a1ae9b);
  --select-text: light-dark(#465444, #d2dfcc);
  --speed-background: light-dark(#edf2e8, #31412b);
  --speed-text: light-dark(#52714c, #bed9ad);
  --accent: light-dark(#54784b, #a2c391);
  --divider: light-dark(#edf0e9, #344331);
  --play-background: light-dark(#355b36, #a5c997);
  --play-text: light-dark(#fff, #182b18);
  --play-hover: light-dark(#294a2a, #bddbad);
  --stop-text: light-dark(#657160, #cfddc5);
  --stop-background: light-dark(#f1f4ee, #32412d);
  --stop-hover: light-dark(#e7ece2, #41533b);
  --status-text: light-dark(#7d8778, #acb9a5);
  --error: light-dark(#a63e30, #ffada0);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--page);
  font-synthesis: none;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

body { margin: 0; }

main {
  width: min(100% - 48px, 760px);
  margin: 0 auto;
  padding: 38px 0 28px;
}

header, .brand, .voice-badge, .text-heading, .text-footer,
.speed-heading, .range-labels, .playback, .playback-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header { flex-wrap: wrap; gap: 16px; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.theme-setting { display: flex; align-items: center; gap: 3px; }
.theme-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 8px; border-radius: 8px; background: transparent; color: var(--muted); }
.theme-button svg { width: 18px; height: 18px; }
.theme-button:hover { background: var(--stop-background); color: var(--text); }
.theme-button[aria-pressed="true"] { background: var(--brand-background); color: var(--text); }
.theme-notice { color: var(--error); font-size: 12px; line-height: 1.5; }
.brand { gap: 10px; font-size: 17px; font-weight: 650; letter-spacing: -0.5px; }
.brand-icon { display: grid; place-items: center; width: 35px; height: 35px; background: var(--brand-background); border-radius: 11px; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
.brand-icon svg { width: 21px; height: 21px; }
.voice-badge { gap: 7px; color: var(--muted); font-size: 11px; }
.voice-badge span { width: 6px; height: 6px; border-radius: 50%; background: var(--indicator); }

.intro { margin: 55px 0 28px; }
h1 { margin: 0; font-size: clamp(36px, 6vw, 48px); line-height: 1.13; font-weight: 550; letter-spacing: -2px; }
.intro p { color: var(--intro-text); font-size: 15px; line-height: 1.6; margin: 16px 0 0; }

.reader { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 8px 26px var(--shadow); }
label { font-size: 12px; font-weight: 600; }
button, select, textarea, input { font: inherit; }
button, select, input[type="range"] { cursor: pointer; }
button { border: 0; }
button:disabled, select:disabled, input:disabled { cursor: default; }
.text-button { padding: 5px 0 5px 12px; background: transparent; color: var(--muted); font-size: 12px; }
.text-button:hover:not(:disabled) { color: var(--text); }
.text-button:disabled { opacity: 0.4; }

textarea {
  display: block;
  width: 100%;
  min-height: 240px;
  max-height: 65vh;
  resize: vertical;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--field-border);
  border-radius: 9px;
  background: var(--field);
  color: var(--text);
  font-size: 15px;
  line-height: 1.75;
}

textarea::placeholder { color: var(--placeholder); }
textarea[readonly] { background: var(--readonly); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
textarea:focus-visible { outline-offset: 1px; }
.text-footer { gap: 12px; margin-top: 10px; color: var(--subtle); font-size: 11px; }
.settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 140px; gap: 16px; margin: 22px 0 0; padding-top: 22px; border-top: 1px solid var(--divider); }
.language-setting, .voice-setting { min-width: 0; }
select { display: block; width: 100%; margin-top: 9px; padding: 11px 30px 11px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--select-text); font-size: 13px; text-overflow: ellipsis; }
select:disabled { opacity: 0.6; }
.speed-heading output { padding: 3px 7px; border-radius: 5px; background: var(--speed-background); color: var(--speed-text); font-size: 11px; font-weight: 650; }
input[type="range"] { display: block; width: 100%; height: 17px; margin: 11px 0 3px; accent-color: var(--accent); }
.range-labels { color: var(--subtle); font-size: 10px; }
.playback { gap: 16px; margin-top: 22px; }
.playback-buttons { justify-content: flex-start; gap: 10px; flex-shrink: 0; }
.play-button, .stop-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 11px 20px; border-radius: 8px; font-size: 13px; font-weight: 550; }
.play-button { min-width: 110px; background: var(--play-background); color: var(--play-text); }
.play-button:hover:not(:disabled) { background: var(--play-hover); }
.play-button:disabled { opacity: 0.45; }
.stop-button { padding-inline: 12px; color: var(--stop-text); background: var(--stop-background); }
.stop-button:hover:not(:disabled) { background: var(--stop-hover); }
.stop-button:disabled { opacity: 0.4; }
.pause-symbol, .play-button[data-mode="playing"] .play-symbol { display: none; }
.play-button[data-mode="playing"] .pause-symbol { display: block; }
#status { margin: 0; color: var(--status-text); text-align: right; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
#status.error { color: var(--error); }
.editing-hint, .download-hint { margin: 14px 0 0; color: var(--status-text); font-size: 11px; line-height: 1.6; }
footer { margin-top: 24px; text-align: center; }
.coffee-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--brand-background); color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.5; text-decoration: none; }
.coffee-button:hover { background: var(--stop-hover); }
.noscript { color: var(--error); text-align: center; }

@media (max-width: 640px) {
  main { width: calc(100% - 24px); padding-top: 12px; }
  header { flex-wrap: nowrap; gap: 8px; }
  .brand { gap: 8px; font-size: 16px; white-space: nowrap; }
  .brand-icon { width: 32px; height: 32px; border-radius: 10px; }
  .header-actions { gap: 0; }
  .voice-badge { display: none; }
  .theme-button { width: 44px; height: 44px; }
  .intro {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .reader { margin-top: 12px; padding: 14px; border-radius: 14px; }
  .text-button { min-width: 44px; min-height: 44px; }
  textarea { min-height: clamp(160px, 28svh, 240px); margin-top: 4px; padding: 12px; font-size: 16px; }
  .text-footer { margin-top: 8px; }
  .text-footer > :last-child { display: none; }
  .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0 0; padding-top: 14px; }
  select { min-height: 44px; margin-top: 6px; padding: 10px 26px 10px 8px; font-size: 16px; }
  .speed-setting { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
  .speed-heading { gap: 8px; }
  input[type="range"] { height: 44px; margin: 0; }
  .range-labels { display: none; }
  .playback { align-items: stretch; flex-direction: column; gap: 8px; margin-top: 14px; }
  .playback-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .play-button { grid-column: 1 / -1; }
  .stop-button { min-width: 80px; }
  #status { text-align: left; }
  footer { margin-top: 16px; }
}
