@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-1Thin.ttf") format("truetype");
  font-style: normal;
  font-weight: 100;
  font-display: swap;
}

@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-2ExtraLight.ttf") format("truetype");
  font-style: normal;
  font-weight: 200;
  font-display: swap;
}

@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-3Light.ttf") format("truetype");
  font-style: normal;
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-4Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-5Medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-6SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-7Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-8ExtraBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 800;
  font-display: swap;
}

@font-face {
  font-family: "Paperlogy";
  src: url("/api/tts-proxy.php?path=/public/font/Paperlogy-9Black.ttf") format("truetype");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: "Paperlogy", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page-bg: #0f1416;
  --panel-bg: #172022;
  --panel-bg-deep: #12191b;
  --surface-bg: #0f1416;
  --surface-deep: #0b1112;
  --surface-muted: #1b292b;
  --surface-alt: #203033;
  --tip-bg: #101719;
  --border-dim: #24373a;
  --border-soft: #304247;
  --border: #3a5156;
  --text: #f1f6f3;
  --text-strong: #f7fbf8;
  --text-label: #e8f0ec;
  --text-body: #d5e0dc;
  --text-soft: #cad8d3;
  --text-muted: #b8c9c3;
  --text-subtle: #cbd8d2;
  --log-text: #cfefd8;
  --accent: #9fd6c2;
  --accent-strong: #f5d58c;
  --accent-on: #0f1416;
  --focus-ring: rgba(159, 214, 194, 0.15);
  --focus-ring-strong: rgba(159, 214, 194, 0.18);
  --card-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
  --image-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  --zone-header-bg: #171d21;
  --zone-header-border: #6f8292;
  --zone-header-accent: #a8c4d8;
  --zone-composer-bg: #15231f;
  --zone-composer-border: #6cc3a2;
  --zone-composer-accent: #a6dec9;
  --zone-output-bg: #181c29;
  --zone-output-border: #8fa1e4;
  --zone-output-accent: #c9d4ff;
  --zone-reference-bg: #211f18;
  --zone-reference-border: #d7b86a;
  --zone-reference-accent: #f2d58d;
  background: var(--page-bg);
  color: var(--text);
}

:root[data-theme="light"] {
  color-scheme: light;
  --page-bg: #f4f7f4;
  --panel-bg: #ffffff;
  --panel-bg-deep: #edf3ef;
  --surface-bg: #ffffff;
  --surface-deep: #f9fbf8;
  --surface-muted: #eef5f1;
  --surface-alt: #e4eee9;
  --tip-bg: #f8fbf8;
  --border-dim: #d5e0dc;
  --border-soft: #c3d2cd;
  --border: #9fb4ad;
  --text: #182123;
  --text-strong: #0f1719;
  --text-label: #1f2c2f;
  --text-body: #2d3b3e;
  --text-soft: #4f5f62;
  --text-muted: #657577;
  --text-subtle: #56676a;
  --log-text: #1f5a3f;
  --accent: #257c62;
  --accent-strong: #7a5a00;
  --accent-on: #ffffff;
  --focus-ring: rgba(37, 124, 98, 0.17);
  --focus-ring-strong: rgba(37, 124, 98, 0.22);
  --card-shadow: 0 14px 30px rgba(24, 33, 35, 0.09);
  --image-shadow: 0 10px 22px rgba(24, 33, 35, 0.11);
  --zone-header-bg: #f9fbff;
  --zone-header-border: #7a8fa6;
  --zone-header-accent: #315f88;
  --zone-composer-bg: #eefaf5;
  --zone-composer-border: #2f9b78;
  --zone-composer-accent: #166a50;
  --zone-output-bg: #f1f3ff;
  --zone-output-border: #6476c9;
  --zone-output-accent: #3148a0;
  --zone-reference-bg: #fff8e9;
  --zone-reference-border: #9c741d;
  --zone-reference-accent: #73530d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-weight: 400;
}

.shell {
  width: min(1800px, calc(100% - 20px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  border: 3px solid var(--zone-header-border);
  border-left-width: 8px;
  border-radius: 8px;
  background: var(--zone-header-bg);
  padding: 18px;
  box-shadow: var(--card-shadow);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--zone-header-accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  font-weight: 700;
}

.status {
  min-width: 164px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-bg);
  color: var(--text-soft);
  font-weight: 500;
  text-align: right;
}

.source-link,
.theme-toggle {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--accent-strong);
  padding: 9px 12px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.source-link {
  color: var(--text-body);
}

.source-link:hover,
.source-link:focus,
.theme-toggle:hover,
.theme-toggle:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}

.theme-toggle {
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.panel {
  border: 3px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  padding: 18px;
  box-shadow: var(--card-shadow);
}

.composer {
  display: grid;
  gap: 14px;
  border-color: var(--zone-composer-border);
  border-left-width: 8px;
  background: var(--zone-composer-bg);
}

.composer > .field,
.composer > .advanced,
.composer > .control-grid {
  border: 2px solid rgba(108, 195, 162, 0.38);
  border-radius: 8px;
  background: var(--panel-bg-deep);
  padding: 12px;
}

.composer .advanced summary {
  color: var(--zone-composer-accent);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--text-label);
  font-size: 13px;
  font-weight: 600;
}

.text-field {
  min-width: 0;
}

textarea,
select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-bg);
  color: var(--text-strong);
  padding: 10px 11px;
  font: inherit;
  font-weight: 500;
  outline: none;
}

textarea {
  resize: vertical;
  font-weight: 400;
  line-height: 1.45;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input[readonly][data-locked-input="true"] {
  background: var(--surface-muted);
  color: var(--text-soft);
  cursor: default;
}

input[readonly][data-locked-input="true"]::-webkit-inner-spin-button,
input[readonly][data-locked-input="true"]::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input[readonly][data-locked-input="true"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.download {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--accent-strong);
  padding: 8px 10px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

.refine-action {
  cursor: pointer;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.download[aria-disabled="true"],
.download:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.preset-row,
.script-row,
.script-request-row {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border: 2px solid rgba(108, 195, 162, 0.36);
  border-radius: 8px;
  background: var(--panel-bg-deep);
}

.script-select {
  flex: 1 1 320px;
}

.voice-field {
  min-width: 0;
}

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

.voice-preview-button {
  min-width: 98px;
  white-space: nowrap;
}

.voice-sample-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 2px solid rgba(108, 195, 162, 0.36);
  border-radius: 8px;
  background: var(--panel-bg-deep);
}

.voice-sample-panel h2 {
  color: var(--zone-composer-accent);
}

.voice-sample-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.voice-sample-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.voice-sample-control {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(72px, 1fr);
  min-height: 42px;
}

.voice-sample-button {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--accent-strong);
  padding: 8px 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  min-width: 0;
}

.voice-sample-play {
  border-radius: 8px 0 0 8px;
  text-align: left;
}

.voice-sample-select {
  margin-left: -1px;
  border-radius: 0 8px 8px 0;
  color: var(--text-body);
  font-size: 12px;
}

.voice-sample-control.is-selected .voice-sample-button {
  border-color: var(--accent);
}

.voice-sample-control.is-selected .voice-sample-select {
  background: var(--accent);
  color: var(--accent-on);
}

.script-request-topic {
  flex: 2 1 360px;
}

.script-request-notes {
  flex: 1 1 320px;
}

.script-request-submit {
  min-width: 170px;
}

.script-request-status {
  flex: 1 1 280px;
}

.compact {
  min-width: 160px;
}

.secondary {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
  padding: 9px 13px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.secondary.subtle {
  color: var(--text-subtle);
}

.preset-status {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.advanced {
  border-top: 1px solid var(--border-dim);
  padding-top: 4px;
}

.filter-picks {
  border-top: 2px solid rgba(108, 195, 162, 0.38);
  padding-top: 12px;
}

.filter-tip {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  margin-top: 12px;
  border: 2px solid rgba(108, 195, 162, 0.45);
  border-radius: 8px;
  background: var(--tip-bg);
  padding: 14px 16px;
}

.filter-tip-kicker,
.filter-tip-note,
.filter-tip p,
.filter-tip-details {
  margin: 0;
}

.filter-tip-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.filter-tip h2 {
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}

.filter-tip p {
  color: var(--text-body);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
}

.filter-tip-details {
  display: grid;
  gap: 4px;
  padding-left: 18px;
  color: var(--text-body);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
}

.filter-tip .filter-tip-note {
  color: var(--text-muted);
  font-size: 12px;
}

.advanced summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
  padding: 8px 0;
}

.slim {
  margin-top: 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--text-label);
  font-size: 13px;
  font-weight: 600;
}

.check input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.primary {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-on);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.generate-top {
  margin-top: 2px;
}

.primary:disabled {
  opacity: 0.58;
  cursor: wait;
}

.output {
  display: grid;
  gap: 12px;
  border-color: var(--zone-output-border);
  border-left-width: 8px;
  background: var(--zone-output-bg);
}

.output h2 {
  color: var(--zone-output-accent);
}

.output .downloads {
  border: 2px solid rgba(143, 161, 228, 0.36);
  border-radius: 8px;
  background: var(--panel-bg-deep);
  padding: 12px;
}

audio {
  width: 100%;
}

pre {
  min-height: 260px;
  max-height: 520px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 2px solid rgba(143, 161, 228, 0.38);
  border-radius: 8px;
  background: var(--surface-deep);
  color: var(--log-text);
  font-family: "Paperlogy", ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  line-height: 1.55;
  padding: 12px;
}

pre.reconnectable {
  cursor: pointer;
}

pre.reconnectable:hover,
pre.reconnectable:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring-strong);
  outline: none;
}

.reference-panel {
  margin-top: 24px;
  margin-bottom: 36px;
  display: grid;
  gap: 28px;
  padding: 24px;
  border-color: var(--zone-reference-border);
  border-left-width: 8px;
  background: var(--zone-reference-bg);
}

.reference-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(460px, 1fr);
  gap: 18px;
  align-items: start;
  border: 2px solid rgba(215, 184, 106, 0.36);
  border-radius: 8px;
  background: var(--panel-bg-deep);
  padding: 16px;
}

.reference-grid img {
  display: block;
  width: 100%;
  height: auto;
  border: 2px solid rgba(215, 184, 106, 0.5);
  border-radius: 8px;
  background: var(--surface-deep);
  box-shadow: var(--image-shadow);
}

.project-guide {
  display: block;
  column-count: 2;
  column-gap: 34px;
  column-rule: 1px solid var(--border-dim);
  max-width: none;
  border: 2px solid rgba(215, 184, 106, 0.36);
  border-radius: 8px;
  background: var(--panel-bg-deep);
  padding: 18px;
}

.project-guide h2 {
  column-span: all;
  margin-top: 0;
  margin-bottom: 18px;
  color: var(--zone-reference-accent);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.25;
}

.project-guide h3 {
  break-after: avoid;
  margin: 24px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-dim);
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.project-guide p,
.project-guide li {
  color: var(--text-body);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.75;
}

.project-guide p {
  margin: 0 0 16px;
}

.project-guide ul,
.project-guide ol {
  margin: 0 0 20px;
  padding-left: 20px;
}

.project-guide li {
  break-inside: avoid;
  margin-bottom: 7px;
}

.project-guide > p:first-of-type {
  column-span: all;
  max-width: 1280px;
  margin: 0 0 24px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border-soft);
}

.project-guide code {
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  background: var(--surface-bg);
  color: var(--accent-strong);
  padding: 1px 5px;
  font-family: "Paperlogy", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {

  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .voice-sample-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reference-grid {
    grid-template-columns: 1fr;
    padding-bottom: 18px;
  }
}

@media (max-width: 620px) {
  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .source-link,
  .theme-toggle {
    width: 100%;
  }

  .status {
    width: 100%;
    text-align: left;
  }

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

  .voice-select-row,
  .voice-sample-grid {
    grid-template-columns: 1fr;
  }

  .reference-panel {
    margin-top: 18px;
    margin-bottom: 26px;
    padding: 16px;
    gap: 20px;
  }

  .project-guide {
    padding: 4px 0 6px;
  }
}
