:root {
  color-scheme: dark;
  --bg: #121416;
  --surface: #1a1d20;
  --surface-2: #22272b;
  --line: #343b40;
  --text: #eef1f2;
  --muted: #9aa4aa;
  --accent: #f3bfd2;
  --accent-strong: #ffe0ea;
  --button-secondary: #c7dff2;
  --button-secondary-hover: #e0effb;
  --button-primary: #b9dfc7;
  --button-primary-hover: #d8f0df;
  --button-primary-border: #96c9a8;
  --button-primary-text: #183a28;
  --button-text: #30242a;
  --danger: #e69b91;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", sans-serif;
}
button, textarea { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 64px; }
.topbar, .panel-heading, .panel-footer, .result-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { margin-bottom: 28px; }
.eyebrow, .panel-kicker { margin: 0 0 7px; color: var(--muted); font-size: 11px; letter-spacing: 1.5px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 5vw, 44px); font-weight: 650; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 18px; font-weight: 600; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr); align-items: stretch; }
.panel, .result-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 14px 34px rgba(0, 0, 0, .14); }
.panel { min-height: 390px; padding: 22px; display: flex; flex-direction: column; }
.connector { display: grid; place-items: center; color: var(--accent); font-size: 24px; }
.panel-heading { align-items: flex-start; margin-bottom: 18px; }
.panel-heading .ghost-button { padding: 6px 12px; font-size: 13px; }
textarea { width: 100%; min-height: 235px; flex: 1; resize: vertical; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--text); padding: 16px; line-height: 1.65; outline: none; }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(145, 199, 177, .12); }
#program-code { font-family: Consolas, "Malgun Gothic", monospace; font-size: 13px; }
.panel-footer { margin-top: 16px; color: var(--muted); font-size: 12px; }
.code-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: nowrap; min-width: 0; }
.audio-progress-wrap { display: flex; align-items: center; gap: 7px; color: var(--muted); font: 10px Consolas, monospace; white-space: nowrap; }
.audio-progress { width: 108px; height: 16px; accent-color: #a9d6b7; cursor: pointer; }
.audio-progress:disabled { cursor: not-allowed; opacity: .45; }
.primary-button, .ghost-button { border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; color: var(--button-text); transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.primary-button { min-width: 124px; min-height: 48px; border-color: var(--button-primary-border); background: var(--button-primary); color: var(--button-primary-text); font-size: 16px; font-weight: 700; }
.panel-footer .primary-button { min-width: 88px; min-height: 36px; padding: 7px 11px; font-size: 14px; }
.primary-button:hover { border-color: var(--button-primary-hover); background: var(--button-primary-hover); }
.primary-button:active { transform: translateY(1px); }
.ghost-button { border-color: var(--button-secondary); background: var(--button-secondary); }
.ghost-button:hover { border-color: var(--button-secondary-hover); background: var(--button-secondary-hover); }
.result-panel { margin-top: 22px; padding: 22px; }
.result-heading { align-items: flex-start; margin-bottom: 16px; }
.tts-button { width: 34px; min-width: 34px; height: 34px; padding: 0; display: grid; place-items: center; font-size: 15px; line-height: 1; }
.result-state { color: var(--muted); font: 11px Consolas, monospace; letter-spacing: 1px; }
.result-state.ok { color: var(--accent-strong); }
.result-state.error { color: var(--danger); }
.result-state.working { color: #e7c88e; }
pre { min-height: 92px; margin: 0; overflow: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--line); border-radius: 9px; background: #101214; padding: 16px; font: 15px/1.6 Consolas, "Malgun Gothic", monospace; }
.error-output { min-height: 0; margin-top: 10px; color: var(--danger); }
button:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .45; filter: saturate(.55); }
@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 620px); padding-top: 22px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .workspace { grid-template-columns: 1fr; gap: 10px; }
  .connector { transform: rotate(90deg); height: 24px; }
  .panel { min-height: 330px; padding: 16px; }
  .result-panel { padding: 16px; }
  .code-actions { justify-content: flex-start; flex-wrap: wrap; }
  .audio-progress-wrap { order: -1; flex-basis: 100%; }
  .audio-progress { flex: 1; width: auto; min-width: 130px; }
}
