:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d1c1a;
  --muted: #6b6862;
  --line: #dcd8d0;
  --accent: #2f5d8a;
  --accent-text: #ffffff;
  --danger: #a3332b;
  --code-bg: #f2f0ea;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #1f1e1c;
    --text: #e9e6df;
    --muted: #a19d94;
    --line: #3a3834;
    --accent: #7fa8d1;
    --accent-text: #10141a;
    --danger: #e0786f;
    --code-bg: #262522;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, sans-serif;
}

[hidden] { display: none !important; }

.bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.bar h1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

.bar button { white-space: nowrap; }

/* With a library chosen, the bar is headed by it, noesis a small line above. */
.bar h1:has(#library:not([hidden])) .brand {
  font-size: .75rem;
  font-weight: 500;
  color: var(--muted);
}

main { max-width: 56rem; margin: 0 auto; padding: 1rem; }

h2 { font-size: 1rem; margin: 0; overflow-wrap: anywhere; }

button, .button, select, input, textarea {
  font: inherit;
  color: inherit;
}

button, .button {
  display: inline-block;
  padding: .35rem .8rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

button.quiet, .button.quiet {
  background: transparent;
  color: var(--accent);
}

button:disabled {
  opacity: .5;
  cursor: default;
}

button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

select, input:not([type=checkbox]), textarea {
  padding: .35rem .5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  min-width: 0;
}

label { display: block; }
label input:not([type=checkbox]), label textarea { display: block; width: 100%; margin-top: .2rem; }
label.check { display: inline-flex; align-items: center; gap: .4rem; }
label select { display: block; width: 100%; margin-top: .2rem; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; margin: 0; }
#copy-speakers { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .4rem; }
#voices-list { display: grid; gap: .5rem; }
.voice { display: grid; gap: .4rem; }
.voice legend { font-weight: 600; overflow-wrap: anywhere; padding: 0 .2rem; }

.toolbar, .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }

#file-draft { width: 100%; font-family: ui-monospace, monospace; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .8rem;
  margin-bottom: 1rem;
}

.panel > * + * { margin-top: .7rem; }
.panel .actions { margin-bottom: 0; }

.heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.heading > span { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }

pre {
  margin: 0;
  padding: .7rem;
  background: var(--code-bg);
  border-radius: 6px;
  overflow: auto;
  max-height: 60vh;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 13px/1.45 ui-monospace, monospace;
}

#output-text:empty { display: none; }

.files, #output-changes { list-style: none; margin: 0; padding: 0; }
#output-changes { font: 13px/1.45 ui-monospace, monospace; color: var(--muted); }

.list-head { display: flex; align-items: center; gap: .75rem; }
.list-head input[type=search] { flex: 1; }

.hint { color: var(--muted); font-size: .9rem; margin: .4rem 0; }

.files li { border-bottom: 1px solid var(--line); }
#settings-files:not(:empty) { border-top: 1px solid var(--line); }
.group { border-bottom: 1px solid var(--line); }
.group summary { cursor: pointer; color: var(--muted); padding: .4rem 0; }
.group .files { margin-left: 1rem; }
.group .files li:last-child { border-bottom: 0; }
#files:not(:empty) { margin-top: .75rem; border-top: 1px solid var(--line); }

button.file {
  display: block;
  width: 100%;
  text-align: left;
  padding: .45rem .2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 14px/1.4 ui-monospace, monospace;
  overflow-wrap: anywhere;
}

button.file:hover, button.file:focus-visible { background: var(--code-bg); }

#library {
  max-width: 100%;
  margin-left: -.3rem;
  padding: .1rem .3rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

#library:hover, #library:focus-visible, #library[aria-expanded="true"] { background: var(--code-bg); }

/* A caret that turns over while the list of libraries is open. */
.chevron {
  display: inline-block;
  width: .45rem;
  height: .45rem;
  margin: 0 .2rem .2rem .45rem;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform .15s;
}

#library[aria-expanded="true"] .chevron { margin-bottom: 0; transform: rotate(-135deg); }

.libraries { list-style: none; margin: 0; padding: 0; }
.libraries li + li { border-top: 1px solid var(--line); }

button.library {
  display: grid;
  gap: .1rem;
  width: 100%;
  text-align: left;
  padding: .5rem .4rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
}

button.library:hover, button.library:focus-visible { background: var(--code-bg); }
button.library[aria-current="true"] { box-shadow: inset 3px 0 0 var(--accent); }
.library-name { font-weight: 600; overflow-wrap: anywhere; }
button.library code { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.library-about { font-size: .85rem; color: var(--muted); }

#message {
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

code { font-family: ui-monospace, monospace; }
