:root {
  font-family: Inter, "Segoe UI", sans-serif;
  color: #23362f;
  background: #f4f6f3;
  font-synthesis: none;
  font-size: 14px;
  --green: #23674a;
  --border: #dde4dd;
  --muted: #728077;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
header {
  max-width: 1360px;
  margin: auto;
  padding: 30px 40px 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}
.mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--green);
  color: white;
  border-radius: 12px;
  font-weight: 750;
  font-size: 19px;
  letter-spacing: -1px;
}
h1 {
  font-size: 18px;
  letter-spacing: 2px;
  margin: 0 0 5px;
}
.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.local {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--green);
  background: #e7eee7;
  padding: 9px 12px;
  border-radius: 30px;
}
main {
  max-width: 1360px;
  margin: auto;
  padding: 0 40px;
}
nav {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
button,
a.button {
  font: inherit;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid #cfdacf;
  border-radius: 7px;
  background: #fff;
  color: #365142;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
button:hover,
a.button:hover {
  background: #eef4ee;
}
button:disabled,
.disabled {
  opacity: 0.42;
  cursor: default;
  pointer-events: none;
}
button.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
button.primary:hover {
  background: #174e37;
}
.tab {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 18px 24px;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}
.tab.selected {
  color: var(--green);
  border-bottom-color: var(--green);
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 1.7px;
  color: var(--muted);
  font-weight: 700;
}
h2 {
  font-size: 23px;
  font-weight: 600;
  margin: 8px 0 0;
  letter-spacing: -0.5px;
}
.tag {
  font-size: 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 9px;
  color: #65806b;
  letter-spacing: 0.5px;
}
.settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px;
}
.wide {
  grid-column: 1/-1;
}
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #41564a;
}
input,
select,
textarea {
  display: block;
  width: 100%;
  border: 1px solid #dbe2db;
  border-radius: 6px;
  background: #fbfcfa;
  color: #283a2e;
  font: inherit;
  padding: 11px 12px;
  margin-top: 7px;
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px #23674a12;
}
textarea {
  resize: vertical;
  line-height: 1.7;
}
#script {
  min-height: 260px;
}
::placeholder {
  color: #99a299;
  font-size: 13px;
}
.muted,
.hint {
  color: var(--muted);
  font-weight: 400;
}
.hint {
  font-size: 11px;
  line-height: 1.7;
}
.credentials {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 13px;
  margin: 20px 0;
  font-size: 12px;
}
.credentials summary {
  cursor: pointer;
  color: #516653;
}
.credentials summary span {
  float: right;
  color: var(--green);
}
.credentials p {
  color: var(--muted);
  line-height: 1.6;
}
.credentials button {
  margin-top: 10px;
}
.credentials ul {
  padding: 0;
  list-style: none;
}
.credentials li {
  border-top: 1px solid var(--border);
  padding: 8px 0;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.credentials li button {
  margin: 0 0 0 auto;
  padding: 6px;
  font-size: 9px;
}
.script-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
}
.script-label span {
  font-size: 11px;
  color: var(--muted);
}
.editor > .primary {
  margin-top: 8px;
  width: 100%;
}
.actions {
  display: flex;
  gap: 8px;
  margin: 22px 0 10px;
  flex-wrap: wrap;
}
.actions .primary {
  flex: 1;
}
.progress-line {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 25px;
}
.progress-line span {
  color: var(--muted);
}
progress {
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0 20px;
  background: #eef1ec;
}
progress::-webkit-progress-bar {
  background: #eef1ec;
}
progress::-webkit-progress-value {
  background: #3a8055;
}
progress::-moz-progress-bar {
  background: #3a8055;
}
#chunks {
  max-height: 600px;
  overflow: auto;
  min-height: 280px;
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 300px;
  color: var(--muted);
  padding: 20px;
}
.empty > span {
  font-size: 52px;
  color: #a7b7a8;
}
.empty h3 {
  font-size: 15px;
  color: #637467;
  font-weight: 500;
  margin: 8px;
}
.empty p {
  font-size: 12px;
  line-height: 1.7;
  max-width: 260px;
}
.chunk {
  border-top: 1px solid #edf0ea;
  padding: 16px 0;
}
.chunk-main {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chunk-number {
  font-variant-numeric: tabular-nums;
  color: #8b978c;
  font-size: 12px;
}
.chunk-status {
  font-size: 10px;
  letter-spacing: 0.5px;
  font-weight: 650;
}
.chunk-status.DONE {
  color: #2b7847;
}
.chunk-status.GENERATING {
  color: #b17b1d;
}
.chunk-status.FAILED {
  color: #b2493c;
}
.chunk-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}
.chunk-actions button,
.chunk-actions a {
  padding: 6px 8px;
  font-size: 9px;
}
.chunk audio {
  width: 100%;
  height: 34px;
  margin-top: 10px;
}
.chunk details {
  color: var(--muted);
  font-size: 10px;
  margin: 8px 0 0 37px;
}
.chunk details p {
  line-height: 1.6;
}
.download-bar {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}
.download-bar a {
  font-size: 10px;
}
footer {
  display: flex;
  justify-content: space-between;
  padding: 25px 0;
  color: #8a978b;
  font-size: 9px;
  letter-spacing: 1px;
}
footer span {
  letter-spacing: 0;
}
#message,
.error {
  border: 1px solid #e5d4ba;
  background: #fff9ec;
  color: #775928;
  border-radius: 7px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
}
#message {
  margin-bottom: 20px;
}
.error {
  overflow-wrap: anywhere;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: 2px solid #23674a;
  outline-offset: 3px;
}
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  header {
    padding: 24px;
  }
  main {
    padding: 0 24px;
  }
  .local {
    display: none;
  }
  footer {
    gap: 15px;
    line-height: 1.8;
  }
}
@media (max-width: 480px) {
  header,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }
  .panel {
    padding: 20px;
  }
  .download-bar,
  footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .settings {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: auto;
  }
  h1 {
    font-size: 15px;
  }
  .chunk-main {
    gap: 8px;
  }
}

.subnav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
}
.subnav .selected {
  background: #e2eee5;
  color: #23674a;
  border-color: #93b39e;
}
.subnav .hint {
  margin-left: auto;
}
.advanced,
.preview-controls {
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px;
}
.advanced summary,
.preview-controls summary {
  cursor: pointer;
  color: #4d6656;
  font-size: 12px;
  font-weight: 600;
}
.advanced .settings {
  margin-top: 16px;
}
.preview-controls label {
  margin-top: 14px;
}
.preview-controls audio {
  width: 100%;
  margin-top: 12px;
}
.badge {
  margin: 4px 0;
  background: #edf6ed;
  color: #23674a;
}
.compact-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.compact-actions button {
  font-size: 9px;
  padding: 8px;
}
.history-row {
  border-top: 1px solid var(--border);
  padding: 18px 0;
}
.history-row p {
  margin: 8px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.history-meta {
  font-size: 11px;
  color: var(--muted);
}
.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.history-actions button,
.history-actions a {
  font-size: 9px;
  padding: 8px 10px;
}
#history-view {
  margin-bottom: 22px;
}
.results-only {
  grid-template-columns: 1fr;
}
.results-only .editor {
  display: none;
}
.results-only #chunks {
  max-height: none;
}
.chunk-snippet {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #637568;
  font-size: 12px;
  line-height: 1.6;
  margin: 10px 0;
}
.text-preview pre,
.boundary pre,
#compiled-instruction {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 350px;
  overflow: auto;
  font:
    12px/1.7 "Segoe UI",
    sans-serif;
  background: #f5f7f3;
  padding: 12px;
  border-radius: 5px;
  color: #2c4034;
}
.chunk details {
  margin: 10px 0;
}
.chunk details summary {
  cursor: pointer;
}
.segment {
  padding: 10px;
  border-top: 1px solid var(--border);
}
.boundary {
  border-top: 1px dashed #d0d9cd;
  padding-top: 10px;
}
.boundary-label {
  letter-spacing: 0.7px;
  font-size: 10px;
  color: #6f7f70;
}
.forced {
  color: #946024;
  font-size: 11px;
}
.chunk-count {
  font-size: 10px;
  color: var(--muted);
}
dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(760px, calc(100% - 30px));
  max-height: 90vh;
  padding: 24px;
  color: #23362f;
}
dialog::backdrop {
  background: #162a2359;
}
dialog details {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin: 16px 0;
}
dialog summary {
  cursor: pointer;
  margin-bottom: 12px;
}
dialog button {
  margin-top: 8px;
}
.scroll-list {
  max-height: 380px;
  overflow: auto;
  margin: 16px 0;
}
.credential-row,
.candidate-row {
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.candidate-row label {
  display: flex;
  align-items: center;
  gap: 10px;
}
.candidate-row input {
  width: auto;
  margin: 0;
}
.credential-row p {
  margin: 7px 0;
  line-height: 1.5;
}
.credential-row .active {
  color: #23674a;
  font-weight: 600;
}
.candidate-row small {
  display: block;
  margin: 6px 0;
  color: var(--muted);
}
.danger {
  color: #9d473b;
}
#preview-status {
  display: block;
  margin: 10px 0;
}
#analysis-status {
  display: block;
  margin: 10px 0;
  font-size: 12px;
}
.queue #back-history {
  margin-bottom: 10px;
}
#preview-text {
  min-height: 110px;
}
@media (max-width: 600px) {
  .subnav {
    flex-wrap: wrap;
  }
  .subnav .hint {
    width: 100%;
    margin: 0;
  }
  .chunk-main {
    flex-wrap: wrap;
  }
  .chunk-actions {
    margin-left: 0;
  }
  dialog {
    padding: 18px;
  }
}
/* Desktop production workspace: content scrolls within each panel. */
header {
  max-width: none;
  padding: 16px 24px;
  height: 80px;
}
main {
  max-width: none;
  padding: 0 24px;
  height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
nav {
  margin-bottom: 10px;
  flex-shrink: 0;
}
.tab {
  padding: 12px 22px;
}
.subnav {
  margin-bottom: 12px;
  flex-shrink: 0;
}
.workspace {
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
}
.panel {
  min-width: 0;
  padding: 18px;
  border-radius: 10px;
}
.workspace > .panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.section-head {
  margin-bottom: 14px;
  gap: 10px;
  flex-shrink: 0;
}
h2 {
  font-size: 18px;
  letter-spacing: -0.3px;
  margin-top: 5px;
}
.script-label {
  margin-top: 0;
}
#script {
  flex: 1;
  min-height: 100px;
  resize: none;
  overflow: auto;
  margin-top: 10px;
}
.editor > .hint {
  margin: 10px 0 4px;
}
.editor > .primary {
  flex-shrink: 0;
}
.queue > * {
  flex-shrink: 0;
}
.queue > .hint {
  margin: 6px 0;
}
.actions {
  margin: 8px 0;
  gap: 6px;
}
.actions button {
  padding: 10px;
}
.progress-line {
  margin-top: 10px;
}
progress {
  margin: 8px 0 12px;
}
#chunks {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.empty {
  min-height: 220px;
}
.chunk {
  padding: 12px 4px 12px 0;
}
.chunk-main {
  gap: 8px;
  flex-wrap: wrap;
}
.chunk-actions {
  gap: 5px;
}
.chunk-snippet {
  margin: 8px 0;
}
.download-bar {
  margin-top: 10px;
  padding-top: 12px;
  flex-wrap: wrap;
  gap: 6px;
}
.settings-scroll {
  overflow: auto;
  min-height: 0;
  padding: 2px 3px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.settings {
  gap: 10px;
}
.settings > * {
  min-width: 0;
}
.settings input,
.settings select {
  padding: 9px 8px;
  margin-top: 5px;
  font-size: 12px;
}
.settings-panel .section-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.settings-panel .settings > .gemini-setting:has(#voice) {
  grid-column: 1/-1;
}
#open-voices {
  width: 100%;
  justify-content: space-between;
  margin-top: 5px;
  padding: 10px;
  font-size: 13px;
  letter-spacing: 0;
}
.advanced,
.preview-controls {
  margin: 12px 0;
  padding: 11px;
}
.compact-actions {
  gap: 4px;
}
.compact-actions button {
  padding: 7px;
  font-size: 9px;
  letter-spacing: 0;
}
.badge {
  width: 100%;
}
footer {
  padding: 12px 0;
  flex-shrink: 0;
}
#message {
  margin: 0 0 10px;
  padding: 8px 12px;
  max-height: 70px;
  overflow: auto;
  flex-shrink: 0;
}
#history-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-bottom: 0;
}
.results-only {
  grid-template-columns: 1fr;
}
.results-only .editor,
.results-only .settings-panel {
  display: none;
}
#voice-dialog {
  width: min(780px, calc(100% - 32px));
  max-height: min(850px, 90dvh);
  padding: 22px;
  overflow: hidden;
}
#voice-dialog[open] {
  display: flex;
  flex-direction: column;
}
#voice-dialog .section-head {
  margin-bottom: 0;
  align-items: flex-start;
}
#voice-dialog .section-head .hint {
  margin-bottom: 0;
}
#close-voices {
  margin-top: 0;
}
.voice-note {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
#voice-list {
  overflow: auto;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 2px;
}
.voice-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 138px;
  align-items: center;
  gap: 16px;
  padding: 14px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.voice-row.selected {
  border-color: var(--green);
  background: #f3f8f3;
  box-shadow: inset 3px 0 var(--green);
}
.voice-row button {
  margin: 0;
  padding: 9px 8px;
  letter-spacing: 0;
}
.voice-copy h3 {
  display: inline;
  margin: 0;
  font-size: 15px;
}
.voice-descriptor {
  color: #617366;
  font-size: 11px;
  margin-left: 10px;
}
.voice-copy p {
  margin: 6px 0 0;
  color: #65756b;
  font-size: 12px;
  line-height: 1.5;
}
.voice-player {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 12px;
  font-size: 12px;
  flex-shrink: 0;
}
.voice-player audio {
  width: 100%;
  height: 36px;
  margin-top: 8px;
}
#voice-dialog > .hint {
  flex-shrink: 0;
}
@media (max-width: 1100px) {
  main {
    height: auto;
    min-height: calc(100dvh - 80px);
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .workspace > .editor,
  .workspace > .queue {
    height: 650px;
  }
  .settings-panel {
    grid-column: 1/-1;
  }
  .settings-scroll {
    overflow: visible;
  }
  .settings-panel .settings {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .settings-panel .settings > .gemini-setting:has(#voice) {
    grid-column: auto;
  }
  .results-only {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  header {
    padding: 16px;
  }
  main {
    padding: 0 16px;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 16px;
  }
  .settings-panel .settings {
    grid-template-columns: 1fr 1fr;
  }
  .voice-row {
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 10px;
  }
  .voice-row > button:last-child {
    grid-column: 2;
    justify-self: start;
  }
  #voice-dialog {
    padding: 16px;
  }
  .subnav .hint {
    display: none;
  }
}
/* Keep the toolbar in one desktop row and reserve space for actual text. */
@media (min-width: 1101px) {
  main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  main > nav {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 12px;
    border-bottom: 0;
  }
  .subnav {
    grid-column: 2;
    grid-row: 1;
    margin-left: 20px;
  }
  #message {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .workspace,
  #history-view {
    grid-column: 1 / -1;
    grid-row: 3;
  }
  footer {
    grid-column: 1 / -1;
    grid-row: 4;
  }
  .settings-panel .settings > .gemini-setting:has(#voice) {
    grid-column: auto;
  }
}
.chunk-snippet {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.api-section {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 8px;
}
.api-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
}
.api-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.api-actions .badge {
  width: auto;
  flex: 1;
  margin: 0;
}
.api-actions button {
  padding: 9px 8px;
  letter-spacing: 0;
}
#message button {
  margin-left: 12px;
  padding: 6px 10px;
}
#base-add-api {
  display: block;
}
.voice-row.preview-playing {
  background: #ecf5ee;
  border-color: #6a9b7a;
}
.voice-row.preview-loading {
  background: #f6f8f5;
  border-color: #96aa99;
}
.voice-row.preview-failed .base-preview-button {
  color: #9a4938;
}
.base-preview-button {
  min-height: 36px;
}
.preview-loading .base-preview-button::before {
  content: "";
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  border: 2px solid #b4cabb;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: preview-spin 0.8s linear infinite;
}
@keyframes preview-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .preview-loading .base-preview-button::before {
    animation: none;
  }
}
.chunk-actions {
  flex-wrap: wrap;
}
.chunk-generate {
  font-size: 9px;
}
.settings-panel > .settings-scroll {
  flex: 1;
}
.settings-panel > .api-section {
  flex-shrink: 0;
}
.api-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}
.api-heading h3 {
  margin: 0;
}
#api-tutorial {
  border: 0;
  padding: 4px 0;
  font-size: 10px;
  letter-spacing: 0;
  font-weight: 500;
}
#api-tutorial-dialog {
  width: min(540px, calc(100% - 32px));
  font-size: 13px;
  line-height: 1.7;
}
.tutorial-steps {
  padding-left: 22px;
}
.tutorial-steps li {
  padding: 3px 0;
}
#public-api-notice {
  margin: 6px 0 0;
  line-height: 1.5;
  font-size: 10px;
}
