:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #68706b;
  --paper: #f8f4ea;
  --canvas: #e8e1d3;
  --line: rgba(23, 32, 29, 0.16);
  --accent: #df573c;
  --accent-dark: #b83a27;
  --moss: #2e473e;
  --prompt-font-size: 52px;
  --prompt-line-height: 1.55;
  --prompt-color: #f7f3e8;
  --prompt-bg: #0d1110;
  --prompt-align: left;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
  touch-action: manipulation;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 255, 255, 0.78), transparent 28rem),
    radial-gradient(circle at 88% 90%, rgba(46, 71, 62, 0.12), transparent 32rem),
    repeating-linear-gradient(120deg, rgba(23, 32, 29, 0.025) 0 1px, transparent 1px 9px),
    var(--canvas);
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
  touch-action: manipulation;
}

input[type="range"],
input[type="color"],
.segmented-control,
.switch-row,
.brand {
  touch-action: manipulation;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
.reader:focus-visible {
  outline: 3px solid rgba(223, 87, 60, 0.42);
  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;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding-bottom: 10px;
}

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

.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  padding: 9px 8px;
  border-radius: 10px;
  background: var(--ink);
  box-shadow: 0 5px 14px rgba(23, 32, 29, 0.18);
}

.brand-mark i {
  display: block;
  align-self: center;
  height: 2px;
  border-radius: 2px;
  background: var(--paper);
}

.brand-mark i:nth-child(2) {
  width: 76%;
}

.brand-mark i:nth-child(3) {
  width: 52%;
  background: var(--accent);
}

.brand strong,
.brand small {
  display: block;
}

.brand > span:last-child {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.brand strong {
  font-family: "Songti SC", STSong, serif;
  font-size: 22px;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 0;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
}

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

.local-badge > i {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #5f8e72;
  box-shadow: 0 0 0 4px rgba(95, 142, 114, 0.13);
}

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

.local-copy strong {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.local-copy small {
  margin-top: 2px;
  color: #8a8f8a;
  font-family: Georgia, "Songti SC", serif;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.72fr);
  gap: 22px;
  align-items: start;
  padding-top: 12px;
}

.workspace > *,
.control-column,
.settings-card,
.script-card {
  min-width: 0;
  max-width: 100%;
}

.script-card,
.settings-card {
  border: 1px solid rgba(23, 32, 29, 0.13);
  background: rgba(248, 244, 234, 0.88);
  box-shadow: 0 18px 55px rgba(42, 39, 32, 0.1);
  backdrop-filter: blur(18px);
}

.script-card {
  min-height: calc(100dvh - 126px);
  padding: clamp(20px, 3vw, 40px);
  border-radius: 18px 6px 18px 18px;
}

.settings-card {
  padding: 24px;
  border-radius: 6px 18px 18px 18px;
}

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

.section-heading.compact {
  margin-bottom: 18px;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--accent-dark);
  font-family: Georgia, "Songti SC", serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

h1,
h2 {
  margin: 0;
  font-family: "Songti SC", STSong, serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}

h1 {
  font-size: clamp(28px, 3.3vw, 48px);
}

h2 {
  font-size: 21px;
}

.text-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--muted);
  background: none;
  cursor: pointer;
}

.text-button:hover {
  color: var(--accent-dark);
}

#scriptInput {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: calc(100dvh - 270px);
  resize: vertical;
  padding: clamp(18px, 2.4vw, 30px);
  border: 1px solid rgba(23, 32, 29, 0.13);
  border-radius: 7px 16px 7px 16px;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.62)),
    repeating-linear-gradient(to bottom, transparent 0 35px, rgba(23, 32, 29, 0.055) 35px 36px);
  font-family: "Songti SC", STSong, serif;
  font-size: clamp(19px, 1.8vw, 25px);
  line-height: 1.65;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: pre-wrap;
  caret-color: var(--accent);
  box-shadow: inset 0 1px 10px rgba(23, 32, 29, 0.035);
}

#scriptInput::placeholder {
  color: #96978e;
}

.script-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.script-meta strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.control-column {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 22px;
  padding-bottom: 106px;
}

.preview-window {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 28px 24px;
  border-radius: 12px 4px 12px 4px;
  color: var(--prompt-color);
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.08), transparent 48%),
    var(--prompt-bg);
}

.preview-window::before,
.preview-window::after {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 1px;
  content: "";
  background: var(--accent);
}

.preview-window::before {
  top: 50%;
}

.preview-window::after {
  right: 12px;
  left: auto;
  top: 50%;
}

.preview-window p {
  display: -webkit-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-weight: 650;
  font-size: var(--prompt-font-size);
  line-height: var(--prompt-line-height);
  text-align: var(--prompt-align);
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.preview-window > span {
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.preview-window.is-mirrored p {
  transform: scaleX(-1);
}

.setting-list {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px 16px;
  align-items: center;
  color: var(--ink);
  font-size: 13px;
}

.setting-row output {
  min-width: 62px;
  color: var(--muted);
  font-family: Georgia, serif;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.setting-row input[type="range"] {
  grid-column: 1 / -1;
}

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.color-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.color-row > label {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12px;
}

.color-control {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type="color"] {
  width: 31px;
  height: 31px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

.color-control output {
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 10px;
}

.choice-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
}

.choice-row legend {
  float: left;
  width: 90px;
  padding: 0;
  font-size: 13px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(23, 32, 29, 0.045);
}

.segmented-control label {
  position: relative;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  min-height: 35px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.segmented-control input:checked + span {
  color: var(--paper);
  background: var(--moss);
  box-shadow: 0 3px 10px rgba(46, 71, 62, 0.18);
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  cursor: pointer;
}

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

.switch-row strong {
  font-size: 13px;
  font-weight: 500;
}

.switch-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

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

.switch-row i {
  position: relative;
  width: 47px;
  height: 27px;
  border-radius: 999px;
  background: #c9c7bf;
  transition: background 180ms ease;
}

.switch-row i::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  content: "";
  background: white;
  box-shadow: 0 2px 5px rgba(23, 32, 29, 0.22);
  transition: transform 180ms ease;
}

.switch-row input:checked + i {
  background: var(--accent);
}

.switch-row input:checked + i::after {
  transform: translateX(20px);
}

.start-button {
  display: flex;
  width: 100%;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 18px 24px;
  border: 0;
  border-radius: 6px 16px 16px 16px;
  color: #fff8ed;
  background:
    linear-gradient(120deg, transparent 60%, rgba(255, 255, 255, 0.08)),
    var(--accent);
  box-shadow: 0 14px 30px rgba(184, 58, 39, 0.23);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(184, 58, 39, 0.3);
}

.start-button small,
.start-button strong {
  display: block;
  text-align: left;
}

.start-button small {
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.start-button strong {
  font-family: "Songti SC", STSong, serif;
  font-size: 23px;
  letter-spacing: 0.08em;
}

.start-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  font-size: 25px;
}

.start-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
  padding: 18px 4px 4px;
  color: var(--muted);
  text-align: center;
}

.footer-icon {
  display: block;
  width: 36px;
  height: 36px;
  margin-bottom: 3px;
  border-radius: 9px;
  box-shadow: 0 5px 14px rgba(23, 32, 29, 0.13);
}

.footer-identity {
  display: grid;
  gap: 3px;
  justify-items: center;
}

.footer-identity strong {
  color: var(--ink);
  font-family: "Songti SC", STSong, serif;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.footer-identity a {
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 11px;
  text-decoration: none;
}

.footer-identity a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-privacy {
  color: #9b9e98;
  font-size: 10px;
  letter-spacing: 0.06em;
}

@media (min-width: 901px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .app-header {
    min-height: 44px;
    padding-bottom: 3px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    padding: 8px 7px;
  }

  .brand strong {
    font-size: 19px;
  }

  .brand small {
    font-size: 10px;
  }

  .workspace {
    min-height: 0;
    height: 100%;
    padding-top: 6px;
    align-items: stretch;
  }

  .site-footer {
    min-height: 42px;
    flex-direction: row;
    gap: 12px;
    margin-top: 4px;
    padding: 6px 4px 0;
  }

  .footer-identity {
    display: flex;
    gap: 12px;
    align-items: baseline;
  }

  .footer-identity strong {
    font-size: 12px;
  }

  .footer-identity a {
    padding-left: 12px;
    border-left: 1px solid var(--line);
    font-size: 10px;
  }

  .footer-icon {
    width: 22px;
    height: 22px;
    margin: 0;
    border-radius: 6px;
  }

  .footer-privacy {
    padding-left: 12px;
    border-left: 1px solid var(--line);
    font-size: 9px;
  }

  .script-card {
    display: flex;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    padding: clamp(20px, 2.2vw, 32px);
    overflow: hidden;
  }

  .script-card .section-heading {
    flex: 0 0 auto;
    margin-bottom: 18px;
  }

  #scriptInput {
    min-height: 0;
    flex: 1 1 auto;
    resize: none;
  }

  .script-meta {
    flex: 0 0 auto;
  }

  .control-column {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0;
    position: relative;
    top: auto;
    height: 100%;
    min-height: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  .settings-card {
    display: flex;
    height: 100%;
    min-height: 0;
    flex-direction: column;
    padding: 20px;
    border-bottom: 0;
    border-radius: 6px 18px 0 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(23, 32, 29, 0.22) transparent;
    scrollbar-width: thin;
  }

  .settings-card .section-heading {
    margin-bottom: 14px;
  }

  .preview-window {
    flex: 1 1 146px;
    min-height: clamp(168px, 20dvh, 190px);
    max-height: none;
  }

  .preview-window p {
    display: block;
    max-height: 100%;
    -webkit-line-clamp: unset;
  }

  .setting-list {
    flex: 0 0 auto;
    gap: clamp(12px, 1.8dvh, 20px);
    margin-top: clamp(14px, 2dvh, 24px);
  }

  .start-button {
    position: relative;
    z-index: 12;
    right: auto;
    bottom: auto;
    width: 100%;
    min-width: 0;
    min-height: 92px;
    border: 1px solid rgba(23, 32, 29, 0.13);
    border-top: 0;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 18px 55px rgba(42, 39, 32, 0.14);
  }

  .start-note {
    position: absolute;
    z-index: 13;
    left: 24px;
    right: 78px;
    bottom: 10px;
    width: auto;
    color: rgba(255, 248, 237, 0.7);
    pointer-events: none;
    text-align: left;
    transform: translateY(-4px);
  }

  .start-button > span:first-child {
    padding-bottom: 18px;
  }
}

@media (min-width: 901px) and (max-height: 850px) {
  .settings-card {
    padding: 14px 16px;
  }

  .settings-card .section-heading {
    margin-bottom: 8px;
  }

  .settings-card h2 {
    font-size: 18px;
  }

  .settings-card .eyebrow {
    margin-bottom: 3px;
  }

  .preview-window {
    flex: 1 1 118px;
    min-height: 118px;
    height: auto;
    max-height: none;
    padding: 18px 20px;
  }

  .preview-window p {
    font-size: var(--prompt-font-size);
  }

  .setting-list {
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin-top: 10px;
  }

  .setting-row,
  .color-row {
    grid-column: 1 / -1;
  }

  .setting-row {
    gap: 3px 14px;
  }

  .setting-row input[type="range"] {
    height: 18px;
  }

  .color-row > label {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 7px 9px;
  }

  .color-control output {
    display: none;
  }

  input[type="color"] {
    width: 27px;
    height: 27px;
  }

  .choice-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .choice-row legend {
    width: auto;
  }

  .segmented-control span {
    min-height: 30px;
  }

  .switch-row {
    min-height: 52px;
  }

  .switch-row small {
    display: none;
  }

  .start-button {
    right: auto;
    bottom: auto;
    width: 100%;
    min-height: 70px;
    padding: 12px 16px 12px 20px;
  }

  .start-button strong {
    font-size: 21px;
  }

  .start-button > span:first-child {
    padding-bottom: 15px;
  }

  .start-icon {
    width: 42px;
    height: 42px;
  }

  .start-note {
    left: 20px;
    right: 68px;
    bottom: 5px;
    width: auto;
    font-size: 9px;
  }
}

.reveal {
  animation: rise-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.reveal-two {
  animation-delay: 80ms;
}

.reveal-three {
  animation-delay: 150ms;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.player-view {
  --bar-bg: color-mix(in srgb, var(--prompt-bg) 76%, transparent);
  position: fixed;
  z-index: 50;
  inset: 0;
  overflow: hidden;
  color: var(--prompt-color);
  background: var(--prompt-bg);
}

.reader {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-y;
}

.reader::-webkit-scrollbar {
  display: none;
}

.prompt-track {
  width: min(1120px, 100%);
  min-width: 0;
  min-height: 100%;
  margin: 0 auto;
  padding-inline: clamp(28px, 8vw, 128px);
}

.prompt-spacer {
  min-height: 43dvh;
}

.prompt-text {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: var(--prompt-font-size);
  font-weight: 650;
  line-height: var(--prompt-line-height);
  letter-spacing: 0.025em;
  text-align: var(--prompt-align);
  text-wrap: pretty;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: pre-wrap;
}

.prompt-track.is-mirrored {
  transform: scaleX(-1);
}

.reading-guide {
  position: fixed;
  z-index: 52;
  top: 50%;
  right: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.reading-guide i {
  display: block;
  width: clamp(16px, 3vw, 40px);
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(223, 87, 60, 0.5);
}

.player-bar {
  position: fixed;
  z-index: 55;
  right: 0;
  left: 0;
  transition: opacity 220ms ease, transform 220ms ease;
}

.player-top {
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 18px max(16px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, var(--bar-bg), transparent);
}

.player-top .player-button:last-child {
  justify-self: end;
}

.player-button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid color-mix(in srgb, var(--prompt-color) 22%, transparent);
  border-radius: 999px;
  color: var(--prompt-color);
  background: color-mix(in srgb, var(--prompt-bg) 70%, transparent);
  backdrop-filter: blur(15px);
  cursor: pointer;
}

.player-status {
  min-width: 104px;
  padding: 8px 14px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--prompt-color) 78%, transparent);
  background: color-mix(in srgb, var(--prompt-bg) 72%, transparent);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-align: center;
  backdrop-filter: blur(15px);
}

.player-controls {
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 74px)) minmax(62px, 82px);
  gap: 8px;
  justify-content: center;
  padding: 38px max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: linear-gradient(to top, var(--bar-bg), transparent);
}

.control-button,
.speed-readout {
  display: grid;
  min-height: 62px;
  place-content: center;
  border-radius: 13px;
  text-align: center;
}

.control-button {
  border: 1px solid color-mix(in srgb, var(--prompt-color) 18%, transparent);
  color: var(--prompt-color);
  background: color-mix(in srgb, var(--prompt-bg) 62%, transparent);
  backdrop-filter: blur(18px);
  cursor: pointer;
}

.control-button.primary {
  border-color: var(--accent);
  background: var(--accent);
}

.control-button span {
  font-family: Georgia, serif;
  font-size: 23px;
  line-height: 1;
}

.control-button .playback-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  margin: 0 auto;
  font-size: 0;
}

.playback-icon::before,
.playback-icon::after {
  position: absolute;
  content: "";
}

.playback-icon.is-pause::before,
.playback-icon.is-pause::after {
  top: 1px;
  width: 5px;
  height: 18px;
  border-radius: 2px;
  background: currentColor;
}

.playback-icon.is-pause::before {
  left: 3px;
}

.playback-icon.is-pause::after {
  right: 3px;
}

.playback-icon.is-play::before {
  top: 1px;
  left: 4px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 14px solid currentColor;
}

.control-button small,
.speed-readout small {
  margin-top: 5px;
  font-size: 9px;
  letter-spacing: 0.05em;
}

.speed-readout {
  color: color-mix(in srgb, var(--prompt-color) 78%, transparent);
  background: color-mix(in srgb, var(--prompt-bg) 48%, transparent);
  font-variant-numeric: tabular-nums;
}

.speed-readout strong {
  color: var(--prompt-color);
  font-family: Georgia, serif;
  font-size: 20px;
}

.player-view.controls-hidden .player-top {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-18px);
}

.player-view.controls-hidden .player-controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
}

.countdown {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--prompt-color);
  background: color-mix(in srgb, var(--prompt-bg) 74%, transparent);
  backdrop-filter: blur(8px);
}

.countdown span {
  display: grid;
  width: clamp(112px, 28vw, 180px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--prompt-color) 35%, transparent);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: clamp(58px, 15vw, 104px);
  animation: countdown-pulse 760ms ease both;
}

@keyframes countdown-pulse {
  from {
    opacity: 0;
    transform: scale(0.75);
  }
}

.toast {
  position: fixed;
  z-index: 100;
  top: 50%;
  left: 50%;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff8ed;
  background: var(--ink);
  box-shadow: 0 12px 38px rgba(23, 32, 29, 0.28);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, calc(-50% + 12px));
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%);
}

body.player-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .app-shell {
    padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

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

  .script-card {
    min-height: auto;
    padding: 20px;
  }

  #scriptInput {
    min-height: 48dvh;
  }

  .control-column {
    position: static;
  }

  .start-note {
    margin-bottom: 8px;
  }
}

@media (max-width: 560px) {
  .app-header {
    min-height: 51px;
    padding-bottom: 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 19px;
  }

  .local-badge {
    max-width: none;
    flex: 0 0 auto;
    justify-content: flex-end;
    text-align: right;
    white-space: nowrap;
  }

  .local-copy strong {
    font-size: 11px;
  }

  .local-copy small {
    font-size: 8px;
  }

  .workspace {
    gap: 14px;
    padding-top: 8px;
  }

  .script-card,
  .settings-card {
    border-radius: 13px;
  }

  .script-card,
  .settings-card {
    padding: 16px;
  }

  h1 {
    font-size: 27px;
  }

  #scriptInput {
    min-height: 40dvh;
    max-height: 60dvh;
    padding: 16px;
    font-size: 18px;
  }

  .section-heading {
    margin-bottom: 16px;
  }

  .preview-window {
    min-height: 190px;
  }

  .preview-window p {
    font-size: var(--prompt-font-size);
    -webkit-line-clamp: 2;
  }

  .setting-list {
    gap: 17px;
    margin-top: 20px;
  }

  .setting-row input[type="range"] {
    height: 30px;
  }

  .color-row {
    grid-template-columns: 1fr;
  }

  .choice-row {
    display: block;
  }

  .choice-row legend {
    float: none;
    width: 100%;
    margin-bottom: 8px;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control span {
    min-height: 42px;
    font-size: 13px;
  }

  .prompt-track {
    padding-inline: clamp(20px, 6vw, 32px);
  }

  .player-controls {
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    gap: 6px;
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .control-button,
  .speed-readout {
    min-height: 58px;
    border-radius: 11px;
  }

  .player-button {
    min-height: 39px;
    padding-inline: 12px;
    font-size: 12px;
  }

  .player-status {
    min-width: 86px;
    padding-inline: 10px;
    font-size: 10px;
  }

  .start-button {
    position: sticky;
    z-index: 8;
    bottom: max(8px, env(safe-area-inset-bottom));
    min-height: 78px;
    border: 1px solid rgba(255, 255, 255, 0.18);
  }

  .site-footer {
    margin-top: 18px;
    padding: 18px 4px max(8px, env(safe-area-inset-bottom));
  }

  .footer-identity strong {
    font-size: 12px;
  }

  .footer-identity a,
  .footer-privacy {
    font-size: 9px;
  }

  .footer-identity a,
  .footer-privacy {
    padding-left: 0;
    border-left: 0;
  }

  .footer-icon {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 380px) {
  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
  }

  .brand > span:last-child {
    gap: 6px;
  }

  .brand strong {
    font-size: 17px;
  }

  .brand small {
    padding-left: 6px;
    font-size: 9px;
  }

  .local-badge {
    gap: 6px;
  }

  .local-copy strong {
    font-size: 10px;
    letter-spacing: 0.01em;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .prompt-spacer {
    min-height: 38dvh;
  }

  .prompt-track {
    width: min(1180px, 100%);
    padding-inline: max(74px, calc(env(safe-area-inset-left) + 44px));
  }

  .player-top {
    grid-template-columns: auto 1fr auto;
    padding-block: max(8px, env(safe-area-inset-top)) 14px;
  }

  .player-controls {
    right: max(10px, env(safe-area-inset-right));
    bottom: 50%;
    left: auto;
    grid-template-columns: repeat(2, 56px);
    gap: 6px;
    width: auto;
    padding: 8px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--prompt-bg) 58%, transparent);
    transform: translateY(50%);
    backdrop-filter: blur(18px);
  }

  .player-controls .speed-readout {
    grid-column: 1 / -1;
  }

  .player-view.controls-hidden .player-controls {
    transform: translate(18px, 50%);
  }
}

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