:root {
  color-scheme: light dark;
  --bg: #f4f5fb;
  --fg: #1b1c2b;
  --muted: #62647a;
  --line: #dfe1ee;
  --panel: #ffffff;
  --panel-2: #f0f1fa;
  --accent: #4f46e5;
  --accent-fg: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --error: #dc2626;
  --wave: #a9b4dc;
  --wave-progress: #4f46e5;
  --selection: rgba(22, 163, 74, 0.22);
  --silence: rgba(120, 120, 150, 0.16);
  --cut: rgba(220, 38, 38, 0.28);
  --shadow: 0 1px 2px rgba(30, 30, 80, 0.06), 0 8px 24px -10px rgba(60, 60, 140, 0.18);
  --shadow-lg: 0 2px 6px rgba(30, 30, 80, 0.08), 0 24px 56px -12px rgba(60, 60, 140, 0.35);
  --glass: rgba(255, 255, 255, 0.72);
  /* the brand gradient: buttons, the active bits, the progress */
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #2563eb 100%);
  --grad-hover: linear-gradient(135deg, #5b52f0 0%, #8b4af0 55%, #3b73f0 100%);
  --radius: 12px;
}
/* The theme is the device's (light or dark) unless one was chosen: theme.js sets
   data-theme on <html>. The dark colours are written twice, for those two ways in
   (custom properties, because editor.js reads some of them for the waveform). */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e16;
  --fg: #e9eaf4;
  --muted: #9a9cb4;
  --line: #2b2d42;
  --panel: #171826;
  --panel-2: #1e2033;
  --accent: #8b8bff;
  --accent-fg: #ffffff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --error: #ff7b7b;
  --wave: #454f7c;
  --wave-progress: #8b8bff;
  --selection: rgba(74, 222, 128, 0.2);
  --silence: rgba(160, 160, 190, 0.13);
  --cut: rgba(255, 123, 123, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 24px 56px -12px rgba(0, 0, 0, 0.8);
  --glass: rgba(23, 24, 38, 0.72);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0d0e16;
    --fg: #e9eaf4;
    --muted: #9a9cb4;
    --line: #2b2d42;
    --panel: #171826;
    --panel-2: #1e2033;
    --accent: #8b8bff;
    --accent-fg: #ffffff;
    --ok: #4ade80;
    --warn: #fbbf24;
    --error: #ff7b7b;
    --wave: #454f7c;
    --wave-progress: #8b8bff;
    --selection: rgba(74, 222, 128, 0.2);
    --silence: rgba(160, 160, 190, 0.13);
    --cut: rgba(255, 123, 123, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 24px 56px -12px rgba(0, 0, 0, 0.8);
    --glass: rgba(23, 24, 38, 0.72);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--fg);
  /* a soft glow of the brand colours in two corners, fixed behind everything */
  background-color: var(--bg);
  background-image:
    radial-gradient(52rem 34rem at 8% -8%, color-mix(in srgb, #4f46e5 16%, transparent), transparent 70%),
    radial-gradient(46rem 30rem at 100% 0%, color-mix(in srgb, #2563eb 13%, transparent), transparent 70%);
  background-attachment: fixed;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 2rem;
  padding: 0.7rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 18%, transparent), 0 6px 20px -14px rgba(60, 60, 140, 0.4);
}
header .brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--fg); text-decoration: none; }
header .brand-name { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
header .brand img { border-radius: 6px; }
header .tools { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
header #logout[hidden] { display: none; }
/* Settings and Log out: icons. Log out asks first: one click opens "Log out?", the next logs out. */
header .icon { box-shadow: none; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem; border: 1px solid transparent;
  border-radius: 8px; background: none; font: inherit; color: var(--muted); cursor: pointer; text-decoration: none; transition: background 0.15s, color 0.15s; }
header .icon svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
header .icon:hover, header .icon.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
header .icon .ask { display: none; }
header .icon.asking { color: var(--error); border-color: var(--error); padding: 0.3rem 0.6rem; }
header .icon.asking .ask { display: inline; }
header button.link { background: none; box-shadow: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
header button.link:hover { color: var(--fg); text-decoration: underline; }
/* The church: most people have one for good, so it is quiet text. With several (or to add one)
   it is a select that looks like text until hovered. */
header select, header .church-name { font: inherit; font-size: 0.9rem; color: var(--muted); }
header .church-name { max-width: 14rem; padding: 0.25rem 0.4rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header .church-name[hidden] { display: none; }
header select { appearance: none; max-width: 14rem; padding: 0.25rem 1.3rem 0.25rem 0.4rem; cursor: pointer;
  border: 1px solid transparent; border-radius: 6px; background: transparent no-repeat right 0.4rem center / 0.6rem
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
header select:hover, header select:focus-visible { color: var(--fg); border-color: var(--line); }
header select[hidden] { display: none; }
header select option { color: initial; }
header .brand img { height: 28px; width: auto; max-width: 9rem; object-fit: contain; }
.logo-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.logo-row img { height: 40px; max-width: 12rem; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: #fff; }

footer { padding: 0 1.5rem 1.5rem; text-align: center; font-size: 0.85rem; }
footer a { color: var(--muted); text-decoration: none; padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); transition: color 0.15s, border-color 0.15s; }
footer a:hover { color: var(--accent); border-color: var(--accent); }
main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 1.5rem 4rem; }

h1 { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.02em; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em; margin: 1.6rem 0 0.6rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--error); }
.warn { color: var(--warn); }
.ok { color: var(--ok); }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.88em; }
.crumbs { color: var(--muted); margin-bottom: 0.4rem; }
.crumbs a { color: var(--muted); }

button, .button {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(30, 30, 80, 0.05);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.15s;
}
button:hover:not(:disabled), .button:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
button:active:not(:disabled), .button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: default; }
button.danger { background: linear-gradient(135deg, #dc2626, #be185d); border-color: transparent; color: #fff; font-weight: 600; }
button.danger:hover:not(:disabled) { background: linear-gradient(135deg, #ef4444, #db2777); box-shadow: 0 6px 16px -6px rgba(220, 38, 38, 0.6); }
button.primary { background: var(--grad); border-color: transparent; color: var(--accent-fg); font-weight: 600; box-shadow: 0 4px 14px -4px rgba(79, 70, 229, 0.55); }
button.primary:hover:not(:disabled) { background: var(--grad-hover); box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.7); transform: translateY(-1px); }
input[type=text], input[type=number] {
  font: inherit;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--panel);
  color: var(--fg);
}
.panel select {
  font: inherit;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--panel);
  color: var(--fg);
}
input[type=text]:focus, input[type=number]:focus, .panel select:focus, .search:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input.date { width: 9.5em; font-variant-numeric: tabular-nums; }
input.time { width: 8.5em; font-family: ui-monospace, Menlo, Consolas, monospace; }
input.invalid { border-color: var(--error); }

table.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.list td, table.list th { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); }
table.list tr:last-child > td { border-bottom: 0; }
table.list tr.row { transition: background 0.15s; }
table.list tr.row:hover { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); cursor: pointer; }
.badge {
  display: inline-block;
  padding: 0.08rem 0.6rem 0.08rem 0.5rem;
  margin-right: 0.3rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  background: color-mix(in srgb, currentColor 11%, transparent);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.badge::before { content: ""; display: inline-block; width: 0.42rem; height: 0.42rem; margin-right: 0.35rem; border-radius: 50%; background: currentColor; vertical-align: 0.05em; }
.badge.on { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.busy { color: var(--accent); }
.badge.busy::before { animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; margin: 0.8rem 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.6rem 0; }
.toolbar .sep { width: 1px; height: 1.6rem; background: var(--line); margin: 0 0.3rem; }
.toolbar .zoom { display: inline-flex; align-items: center; gap: 0.4rem; }
.toolbar .clock { margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; }
#minimap { margin-bottom: 0.3rem; }
/* A finger drag on the waveform selects; scrolling the page still works up and down. */
#waveform { border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(180deg, var(--panel-2), var(--bg)); touch-action: pan-y; }
#minimap { touch-action: pan-y; }
.controls { display: grid; gap: 0.6rem; margin: 0.6rem 0; }
/* Wide screens: the sermon and the cuts side by side. */
@media (min-width: 1000px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .controls .group.wide { grid-column: 1 / -1; }
}
.group { border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.9rem; background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.group > strong { font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.group .toolbar { margin: 0.4rem 0; }
.cut, .section { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; padding: 0.3rem 0; border-top: 1px solid var(--line); }
.cut.selected, .section.selected { box-shadow: inset 3px 0 0 var(--accent); padding-left: 0.6rem; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.cut.outside .muted { color: var(--warn); }
.cut-warn { flex-basis: 100%; margin: 0; padding: 0.3rem 0.6rem; color: var(--warn); font-size: 0.88rem;
  border-left: 3px solid var(--warn); border-radius: 4px; background: color-mix(in srgb, var(--warn) 11%, transparent); }
.cut-warn[hidden] { display: none; }
input.span-label { width: 12em; }
.group .length { margin: 0.4rem 0 0; }
.keys, .touch-hint { color: var(--muted); font-size: 0.85em; }
.touch-hint { display: none; }
.keys kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 0.3em; font-family: inherit; }
.keys-table { border-collapse: collapse; margin: 0 0 0.6rem; }
.keys-table th { text-align: left; font-weight: normal; white-space: nowrap; padding: 0.25rem 1rem 0.25rem 0; vertical-align: top; }
.keys-table td { padding: 0.25rem 0; }
.keys-table kbd, .dialog p kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 0.35em; font-family: inherit; background: var(--panel-2); }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.4rem 2rem; }
.options label { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.options label span.name { min-width: 11em; }
.options input[type=number] { width: 6.5em; }
.options input[type=text] { width: 14em; }
details summary { cursor: pointer; color: var(--muted); margin: 0.6rem 0 0.3rem; }
.notice { color: var(--warn); margin: 0.4rem 0; padding: 0.4rem 0.7rem; border-left: 3px solid var(--warn); border-radius: 4px; background: color-mix(in srgb, var(--warn) 11%, transparent); }

progress { width: 100%; height: 0.6rem; accent-color: var(--accent); appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--line); }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--grad); border-radius: 999px; transition: width 0.2s; }
progress::-moz-progress-bar { background: var(--grad); border-radius: 999px; }
.steps { list-style: none; padding: 0; margin: 0.4rem 0; }
.steps li::before { content: "✓ "; color: var(--ok); }
.steps li.current::before { content: "● "; color: var(--accent); }
.steps li.failed::before { content: "✗ "; color: var(--error); }
pre.log { max-height: 14rem; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.5rem; margin: 0.5rem 0; font-size: 0.85em; }
.outputs { display: grid; gap: 0.5rem; }
.outputs .out { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.outputs audio { height: 2rem; }

.drop { border: 2px dashed color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--radius); padding: 1.5rem; text-align: center; color: var(--muted);
  background: linear-gradient(135deg, color-mix(in srgb, #4f46e5 7%, transparent), color-mix(in srgb, #2563eb 5%, transparent)); transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.drop.over { border-color: var(--accent); color: var(--fg); background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
/* Newly imported recordings, above the years. */
.recent { margin: 0 0 0.8rem; }
.recent .arrived { margin: 0 0.6rem; font-size: 0.9em; white-space: nowrap; }
/* The recordings page: search, years, labels. */
.searchbar { margin: 0 0 1rem; }
.search { width: 100%; box-sizing: border-box; font: inherit; padding: 0.7rem 1rem 0.7rem 2.6rem; border: 1px solid var(--line); border-radius: 999px; color: var(--fg); box-shadow: var(--shadow);
  background: var(--panel) no-repeat 1rem center / 1.1rem url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8ca8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); }
.results { margin: 0 0 0.4rem; }
.year { margin: 0 0 0.8rem; }
button.year-head { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.7rem 0.2rem 0.5rem; border: 0; border-radius: 0; box-shadow: none;
  background: none; font: inherit; font-size: 1.1rem; font-weight: 600; color: var(--fg); cursor: pointer; text-align: left; }
button.year-head .tw { color: var(--muted); width: 1rem; }
button.year-head .muted { font-weight: 400; font-size: 0.9rem; }
.chips { display: inline; }
.chip { display: inline-flex; align-items: center; gap: 0.2rem; margin: 0 0.25rem 0.15rem 0; padding: 0.05rem 0.6rem; border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: 999px; background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); box-shadow: none; transition: background 0.15s, border-color 0.15s; font: inherit; font-size: 0.82rem; line-height: 1.5; cursor: pointer; }
button.chip:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }
.chip.own { cursor: default; color: var(--fg); }
.chip .x { border: 0; background: none; box-shadow: none; padding: 0 0.1rem; font: inherit; color: var(--muted); cursor: pointer; }
.chip .x:hover { color: var(--error); }
.labels { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0; margin: 0.4rem 0; }
.label-input { font: inherit; font-size: 0.85rem; padding: 0.15rem 0.6rem; width: 9rem; border: 1px dashed var(--line); border-radius: 999px; background: none; color: var(--fg); }
.label-input:focus { border-style: solid; }
.label-add-box { position: relative; display: inline-flex; align-items: center; gap: 0.3rem; }
.label-add { border-radius: 999px; padding: 0.1rem 0.7rem; font-size: 1rem; line-height: 1.2; }
.suggest { position: absolute; top: 100%; left: 0; z-index: 5; margin: 0.2rem 0 0; padding: 0.2rem 0; min-width: 9rem; max-height: 14rem; overflow: auto;
  list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); }
.suggest li { padding: 0.35rem 0.8rem; cursor: pointer; font-size: 0.9rem; }
.label-add[hidden] { display: none; }
.suggest li:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
tr.row.target { animation: target 2.5s ease-out; }
@keyframes target { from { background: var(--selection); } to { background: transparent; } }
/* On the folder list: one line above the list, out of the way of listening. */
.upload { margin: 0 0 1rem; }
.upload .drop { padding: 0.6rem 0.8rem; text-align: left; }
.upload .drop strong { color: var(--fg); }
.upload .drop button.link { font-size: inherit; padding: 0; }
.upload .panel { margin-top: 0.5rem; }

.tags label { display: grid; grid-template-columns: 6em minmax(12em, 28em); align-items: center; gap: 0.2rem 0.8rem; padding: 0.3rem 0; }
.tags label .muted { grid-column: 2; font-size: 0.9em; }
.tags input[type=text], .tags select { width: 100%; }
.processing-defaults label { grid-template-columns: 11em auto; }
.processing-defaults label > span:last-child { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.4rem; }
.processing-defaults label .muted { grid-column: auto; }
.processing-defaults input, .processing-defaults input[type=text] { width: 7.5em; }
.processing-defaults select { width: auto; min-width: 7.5em; }
.options .tag input[type=text] { width: 14em; }
button.link { border: 0; background: none; box-shadow: none; color: var(--accent); font-size: 0.9rem; padding: 0 0.3rem; cursor: pointer; }

.dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--fg); padding: 0; width: min(32rem, calc(100vw - 2rem)); box-shadow: var(--shadow-lg); }
.dialog[open] { animation: pop 0.18s ease-out; }
.dialog::backdrop { background: rgba(13, 14, 30, 0.5); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dialog-body { padding: 1.2rem 1.4rem; }
.dialog-body h2 { margin: 0 0 0.6rem; font-size: 1.15rem; }
.dialog-body p { margin: 0.5rem 0; }
.dialog-body ul { margin: 0.4rem 0 0.6rem; padding-left: 1.3rem; }
.dialog-body input[type=text] { width: 100%; box-sizing: border-box; margin-top: 0.3rem; }
.settings-dialog { width: min(54rem, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); overflow: auto; }
.settings-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1.4rem; background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.settings-head h1 { margin: 0; font-size: 1.35rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.settings-head .close { min-width: 40px; min-height: 40px; font-size: 1.1rem; border: 0; box-shadow: none; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; }
.settings-head .close:hover { color: var(--fg); background: var(--bg); }
.settings { padding: 0.2rem 1.4rem 1.4rem; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.1rem; }

main.narrow { max-width: 44rem; }
main.narrow > h1, main.narrow > .panel:first-of-type { margin-top: 1rem; }
.code-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.code-form input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.1rem; letter-spacing: 0.06em; width: 16em; text-transform: uppercase; }
.files { list-style: none; padding: 0; margin: 0.8rem 0; display: grid; gap: 0.6rem; }
.files li { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 0.6rem 0.8rem; }
.files li p { margin: 0.2rem 0; }
.share-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.3rem; letter-spacing: 0.06em;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; cursor: copy; }
.share-link { word-break: break-all; user-select: all; }
.share-form { display: grid; grid-template-columns: 11em minmax(10em, 22em); align-items: center; gap: 0.5rem 0.8rem; }
.share-form .wide { grid-column: 1 / -1; }

/* Touch screens and phones: no keyboard, fingers instead of a mouse. */
@media (pointer: coarse), (max-width: 640px) {
  .keys { display: none; }
  .touch-hint { display: block; }
}
@media (pointer: coarse) {
  #waveform ::part(region-handle) { width: 18px !important; }
  button, .button { padding: 0.5rem 0.9rem; }
}

/* Phones. */
@media (max-width: 640px) {
  /* One row, big enough for a thumb: the logo, the church, the icons. */
  header { padding: 0.4rem 0.8rem; gap: 0.5rem; flex-wrap: nowrap; }
  header .brand img { height: 34px; max-width: 7rem; }
  header .brand-name { display: none; }
  header select, header .church-name { flex: 1; min-width: 0; max-width: none; font-size: 1.05rem; padding: 0.6rem 1.6rem 0.6rem 0.4rem; }
  header .church-name { padding-right: 0.4rem; }
  header .tools { gap: 0.2rem; }
  header .icon { min-width: 44px; min-height: 44px; justify-content: center; padding: 0; }
  header .icon svg { width: 24px; height: 24px; }
  header .icon.asking { padding: 0 0.7rem; }
  .settings-dialog { width: 100vw; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; border-radius: 0; }
  main { padding: 1rem 1rem 3rem; }
  .panel { padding: 0.8rem; }
  .group { padding: 0.5rem 0.6rem; }
  .toolbar .sep { display: none; }
  /* A section or cut: its name, from and to side by side, then the buttons. */
  .cut, .section { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.4rem; }
  .cut > strong, .section > strong, .cut > .muted, .section > .muted, .cut > .cut-warn, .section > input.span-label, .cut > input.span-label { grid-column: 1 / -1; }
  input.span-label { width: 100%; }
  .cut label, .section label { display: flex; align-items: center; gap: 0.3rem; }
  .cut input.time, .section input.time { width: auto; flex: 1; min-width: 0; }
  .options { grid-template-columns: 1fr; }
  .options label span.name { min-width: 0; flex: 1; }
  .options input[type=text], .options .tag input[type=text] { width: auto; flex: 1.4; min-width: 0; }
  .tags label { grid-template-columns: 1fr; }
  .tags label .muted { grid-column: 1; }
  .share-form { grid-template-columns: 1fr; }
  .share-form input[type=text], .share-form input[type=number] { width: 100%; }
  .code-form input { width: 100%; }
  .toolbar .clock { margin-left: 0; }
  table.list td, table.list th { padding: 0.5rem 0.3rem; }
}

/* the folder list: a sermon opens its details in place */
button.twisty { border: 0; background: none; box-shadow: none; padding: 0.2rem 0.5rem 0.2rem 0; color: var(--muted); font-size: 1rem; cursor: pointer; }
button.sermon-name { border: 0; background: none; box-shadow: none; padding: 0; font: inherit; font-weight: 600; color: var(--fg); cursor: pointer; text-align: left; }
button.sermon-name:hover { color: var(--accent); background: none; }
table.list tr.detail-row td { background: var(--panel-2); border-bottom: 1px solid var(--line); padding: 0.6rem 0.8rem 0.8rem 1.6rem; }
.detail .facts { margin: 0 0 0.6rem; color: var(--muted); }
.detail .player { width: 100%; max-width: 32rem; display: block; margin: 0.2rem 0 0.8rem; }
.detail .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0; }
.detail .making:empty { display: none; }
.dl { border: 2px solid var(--ok); box-shadow: none; background: var(--line); color: var(--fg); }
.dl.on { background: var(--ok); color: var(--bg); }
button.dl:disabled:not(.busy) { opacity: 0.6; }
button.dl.busy { opacity: 1; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { background: var(--line); } 50% { background: color-mix(in srgb, var(--ok) 55%, var(--line)); } }
@media (prefers-reduced-motion: reduce) { button.dl.busy { animation: none; background: color-mix(in srgb, var(--ok) 35%, var(--line)); } }
@media (max-width: 640px) {
  table.list tr.detail-row td { padding: 0.6rem 0.5rem; }
}

/* the edit page: Input file, Edit, Options, Output */
section.step > h2 { font-size: 1.2rem; margin: 1.8rem 0 0.5rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--line); }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.3rem 1.2rem; margin: 0 0 0.6rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
details.metadata { margin: 0.4rem 0 0.8rem; }
details.metadata dl.facts { margin-top: 0.5rem; font-size: 0.9em; }
.group .fade { display: inline-flex; align-items: center; gap: 0.4rem; margin-right: 1rem; }
.group .fade input { width: 5.5em; }

/* mono ↔ stereo switch */
.channels { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.channels > .name { min-width: 11em; }
label.switch { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; position: relative; }
label.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
label.switch .track { width: 2.6rem; height: 1.4rem; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s; }
label.switch .track::after { content: ''; position: absolute; top: 0.15rem; left: 0.15rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,0.3); transition: transform 0.15s; }
label.switch input:checked + .track { background: var(--grad); }
label.switch input:checked + .track::after { transform: translateX(1.2rem); }
label.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
/* the order in the markup is Mono, input, track, Stereo: the side that is on is bold */
label.switch .side { color: var(--muted); }
label.switch:has(input:not(:checked)) .side.off, label.switch:has(input:checked) .side.on { color: var(--fg); font-weight: 600; }

/* the formats: one per line, the names and the states in columns */
.pills { display: grid; grid-template-columns: max-content max-content; align-items: center; gap: 0.4rem 1rem; margin-bottom: 0.6rem; }
.pill { display: contents; }
.pill button.pick { border: 2px solid var(--line); box-shadow: none; border-radius: 999px; padding: 0.3rem 0.9rem; font-weight: 600; text-align: left; min-width: 7.5rem; background: none; }
.pill.exists button.pick { border-color: var(--ok); }
.pill.chosen button.pick { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); }
.pill .box { font-weight: normal; }
.pill .state { font-size: 0.85em; color: var(--muted); }
.pill .state.will { color: var(--warn); font-weight: 600; }
.pill .state.delete { color: var(--error); font-weight: 600; }
@media (max-width: 640px) {
  .channels > .name { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* delete and the trash */
.button.delete, button.delete { color: var(--error); }
button.delete:hover:not(:disabled) { border-color: var(--error); background: color-mix(in srgb, var(--error) 8%, var(--panel)); }
.trash-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.5rem; padding: 0.45rem 0; border-top: 1px solid var(--line); }
.trash-item:first-child { border-top: 0; }
.trash-actions { margin-left: auto; display: inline-flex; gap: 0.4rem; }

/* what Play plays, and the pause fields */
.mode { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--panel); }
.mode button.seg { border: 0; border-radius: 0; box-shadow: none; background: none; }
.mode button.seg + button.seg { border-left: 1px solid var(--line); }
.mode button.seg[aria-pressed=true] { background: var(--grad); color: #fff; font-weight: 600; }
label.pause { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); }
input.pause { width: 4.5em; }
@media (max-width: 640px) {
  label.pause { grid-column: 1 / -1; }
}

/* processing: groups of settings, each with its hint */
.processing { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1.2rem 2.5rem; }
.pgroup > strong { display: block; margin-bottom: 0.4rem; }
.pgroup label { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.pgroup label > .name { min-width: 11em; }
.pgroup input[type=number] { width: 6.5em; }
.pgroup input[type=text] { width: 9em; }
.pgroup select { min-width: 9em; font: inherit; padding: 0.3rem 0.5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); }
.pgroup .range { display: inline-flex; align-items: center; gap: 0.6rem; }
.pgroup input[type=range] { width: 10rem; accent-color: var(--accent); }
.pgroup .hint { margin: 0.3rem 0 0; font-size: 0.88rem; }
.pgroup audio.player { display: block; width: 100%; max-width: 24rem; margin: 0.4rem 0; }
@media (max-width: 640px) {
  .pgroup label > .name { min-width: 0; flex: 1; }
}

/* the input file: one line that opens to the facts, with the download beside it */
.input-line { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.6rem 1.2rem; }
.input-line > details { flex: 1 1 20rem; min-width: 0; }
.input-line > details > summary { margin: 0.4rem 0; color: var(--fg); overflow-wrap: anywhere; }
.input-line > details[open] > summary { margin-bottom: 0.8rem; }

/* the bar under the edit page: saved or not, what Save does, Revert and Save; it sticks to the bottom of the window */
.save-bar { position: sticky; bottom: 0.6rem; z-index: 9; margin: 1.5rem 0 0; display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.4rem 1rem; padding: 0.6rem 0.9rem; border: 1px solid var(--line); border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: blur(10px); box-shadow: var(--shadow-lg); }
.save-state .unsaved { color: var(--warn); }
.save-what { flex: 1 1 14rem; min-width: 0; color: var(--muted); font-size: 0.92em; }
.save-what p { margin: 0.15rem 0; }
.save-actions { display: flex; gap: 0.5rem; margin-left: auto; }
@media (max-width: 640px) {
  /* a phone: small text above, the buttons on their own row, flush with the bottom of the screen */
  .save-bar { bottom: 0; gap: 0.15rem 0.6rem; padding: 0.4rem 0.7rem 0.5rem; border-radius: 12px 12px 0 0; font-size: 0.85rem; }
  .save-what { flex-basis: 100%; font-size: 1em; }
  .save-actions { gap: 0.4rem; }
  .save-actions button { padding: 0.4rem 0.75rem; }
  .save-actions .wide-only { display: none; } /* undo and redo: the arrows only */
}
