:root {
  color-scheme: dark;
  --page: #181818;
  --card: #202020;
  --raised: #2b2b2b;
  --edge: #383838;
  --text: #eee;
  --muted: #b4b4b4;
  --gold: #dab57c;
  --mint: #96dec9;
  --focus: #a9f0dd;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-height: 100%; margin: 0; background: transparent; }
body { color: var(--text); font: 14px/1.4 system-ui, "Segoe UI", sans-serif; }
body[data-view="caption"] { height: 100%; min-height: 0; overflow: hidden; }
.caption { position: fixed; inset: 0; overflow: hidden; background: transparent; }
.caption canvas { display: block; width: 100%; height: 100%; pointer-events: none; }

body[data-view="settings"], body[data-view="docs"] { background: var(--page); }
.settings { width: min(100%, 900px); margin-inline: auto; padding: 11px 14px; }
.settings-header, .settings-footer { display: flex; align-items: center; gap: 10px; }
.settings-header { margin-bottom: 9px; }
.settings-footer { margin-top: 9px; }
h1, h2, fieldset { margin: 0; }
.settings h1 { color: var(--gold); font-size: 19px; font-weight: 700; }
.settings h2 { font-size: 14px; font-weight: 650; }
.status { margin-inline-start: auto; }
.status, #feedback { min-width: 0; min-height: 1.4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
#feedback { flex: 1; text-align: center; }
.settings-grid { display: grid; grid-template-columns: minmax(235px, 1fr) minmax(0, 1.65fr); gap: 9px; }
.card { min-width: 0; padding: 9px 11px; background: var(--card); border: 1px solid var(--edge); border-radius: 9px; }
.card h2 { margin-bottom: 6px; }
fieldset { min-width: 0; padding: 0; border: 0; }
legend { padding: 0; color: var(--muted); font-size: 12px; }
.languages { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; background: var(--raised); padding: 3px; margin-top: 3px; border-radius: 6px; }
.languages label { position: relative; min-width: 0; cursor: pointer; }
.languages input, .setting-switch input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.languages span { display: grid; min-height: 25px; place-items: center; border-radius: 4px; white-space: nowrap; }
.languages input:checked + span { background: #29453d; color: var(--focus); }
.languages label:hover span { filter: brightness(1.12); }
.languages input:focus-visible + span, .setting-switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 1px; }
.setting-row, .font-row { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.setting-row { margin-top: 7px; justify-content: space-between; }
.setting-row select { min-width: 0; max-width: 67%; }
.font-row { margin-bottom: 5px; }
.font-row > input { flex: 1; min-width: 0; }
.font-row > span { flex: none; }

button, select, input:not([type="radio"], [type="range"], [type="checkbox"], [type="color"]) {
  min-height: 27px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--raised);
  color: inherit;
  font: inherit;
}
button { white-space: nowrap; cursor: pointer; }
button:hover { filter: brightness(1.14); }
button[data-action="hide"] { min-width: 28px; font-size: 17px; line-height: 1; }
button.primary { background: var(--gold); color: #211a11; font-weight: 650; }
:is(button, select, input):focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
:is(button, select, input):disabled { opacity: .65; cursor: default; }
input::placeholder { color: #a3a3a3; }

.setting-switch { position: relative; cursor: pointer; }
.switch-track { display: flex; align-items: center; width: 35px; height: 19px; padding: 2px; border-radius: 12px; background: #4a4a4a; }
.switch-track::before { content: ""; width: 15px; height: 15px; border-radius: 50%; background: #ddd; }
.setting-switch input:checked + .switch-track { justify-content: flex-end; background: #3e7465; }
.setting-switch input:checked + .switch-track::before { background: #bcebdc; }
.setting-switch input:disabled + .switch-track { opacity: .6; }

.sliders { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 15px; }
.sliders label { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-width: 0; white-space: nowrap; font-size: 12px; }
.sliders output { width: 6ch; text-align: right; color: var(--mint); font-variant-numeric: tabular-nums; }
.sliders input { grid-column: 1 / -1; width: 100%; min-width: 0; margin: 1px 0 0; height: 17px; accent-color: var(--mint); cursor: pointer; }
.colors { display: flex; gap: 16px; margin-top: 5px; }
.colors label { display: flex; min-height: 23px; align-items: center; gap: 6px; font-size: 12px; }
.colors input { width: 27px; height: 20px; padding: 1px 2px; border: 1px solid var(--edge); border-radius: 4px; background: var(--raised); cursor: pointer; }
.docs { max-width: 760px; margin-inline: auto; padding: 22px; }
.docs section { margin-top: 13px; }
.docs pre { margin-bottom: 0; overflow: auto; }
.docs code, .docs a { color: var(--mint); }
.docs a:hover { color: var(--gold); }

@media (max-width: 670px) {
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 390px) {
  .settings { padding-inline: 8px; }
  .sliders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-footer { gap: 5px; }
}
