/* Whoopsie Cutter: a proofreader's desk.
   Ink teal for the frame, cool paper for the page, red pen for cuts,
   amber for the playhead. */
:root {
  --ink: #0e2b2e;          /* frame, headings, waveform panel */
  --ink-2: #1c4146;
  --paper: #e9ece6;        /* page */
  --sheet: #fbfbf8;        /* cards */
  --text: #172022;
  --muted: #5d6b69;
  --rule: #d5dbd4;
  --pen: #e2382b;          /* cuts */
  --amber: #f2b134;        /* playhead, progress */
  --keep: #1f7a72;         /* kept, done */
  --radius: 6px;
  --display: Alegreya, Georgia, serif;
  --body: "Alegreya Sans", system-ui, sans-serif;
  --mono: "Courier Prime", "Courier New", monospace;
  font-family: var(--body);
  font-size: 106%; /* Alegreya Sans runs small */
  color: var(--text);
  background: var(--paper);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  /* faint ruled-paper lines */
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(14, 43, 46, .045) 31px 32px);
}
[hidden] { display: none !important; }
h1, h2 { font-family: var(--display); font-weight: 700; color: var(--ink); margin: 0 0 .35em; letter-spacing: -.005em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.08; }
h2 { font-size: 1.5rem; line-height: 1.15; }
p { margin: 0 0 1rem; line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { font-family: var(--mono); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--pen); margin: 0 0 .6rem; }
.error { color: #8f1d14; background: #fde8e5; border: 1px solid #f3b8b1; padding: .65rem .85rem; border-radius: var(--radius); margin-top: 1rem; }

/* header band */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem clamp(1rem, 4vw, 2.5rem); background: var(--ink); color: #f3efe6; margin-bottom: clamp(1.25rem, 4vw, 2.5rem); }
.brand { display: flex; align-items: center; gap: .6rem; color: #f3efe6; text-decoration: none; font-family: var(--display); font-size: 1.35rem; white-space: nowrap; }
.brand em { font-style: normal; color: var(--amber); }
.brand svg { width: 44px; height: 35px; overflow: visible; }
.brand .bars { fill: none; stroke: #f3efe6; stroke-width: 2.4; stroke-linecap: round; }
.brand .scissors { fill: none; stroke: var(--pen); stroke-width: 2.1; stroke-linecap: round; }
.who { display: flex; gap: .9rem; align-items: center; font-size: .875rem; color: #b9c9c6; }
.link { background: none; border: 0; color: #f3efe6; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; padding: .25rem 0; }

main { max-width: 880px; margin: 0 auto; padding: 0 clamp(.75rem, 3vw, 1.5rem) 6rem; }
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: clamp(1.2rem, 3.5vw, 2rem); margin-bottom: 1.1rem; box-shadow: 0 1px 0 rgba(14, 43, 46, .06); }
.narrow { max-width: 480px; margin: 6vh auto; }
.center { text-align: center; }
.back { display: inline-flex; gap: .35rem; margin: 0 0 .8rem; color: var(--ink-2); text-decoration: none; font-size: .95rem; font-weight: 700; }
.back:hover { color: var(--pen); }

/* upload */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: .45rem; padding: 2.4rem 1rem; margin-top: .5rem; border: 2px dashed #a9b8b4; border-radius: var(--radius); cursor: pointer; text-align: center; background: #f3f5f1; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--ink); background: #e6ece8; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop svg { width: 36px; height: 36px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.drop strong { font-size: 1.1rem; color: var(--ink); }
.drop:focus-within { outline: 3px solid var(--amber); outline-offset: 2px; }

/* history */
.jobs { list-style: none; margin: .5rem 0 0; padding: 0; }
.job { display: flex; align-items: center; gap: .75rem; padding: 1rem 0; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.job:first-child { border-top: 0; }
.job-main { flex: 1 1 240px; min-width: 0; }
.job-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.job .muted { font-family: var(--mono); font-size: .78rem; margin-top: .2rem; }
.job-actions { display: flex; gap: .4rem; }
.pill { display: inline-block; font-family: var(--mono); font-size: .7rem; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; padding: .15rem .45rem; border-radius: 3px; background: #fbe6c2; color: #7a4f05; margin-left: .45rem; vertical-align: 2px; }
.pill.done { background: #d5ebe7; color: var(--keep); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem 1.05rem; border-radius: var(--radius); border: 1.5px solid var(--ink); background: transparent; color: var(--ink); font: 700 .95rem var(--body); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, color .12s; }
.btn:hover { background: var(--ink); color: #f3efe6; }
.btn.primary { background: var(--pen); border-color: var(--pen); color: #fff; }
.btn.primary:hover { background: #c22a1f; border-color: #c22a1f; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.small { min-height: 36px; padding: .35rem .75rem; font-size: .85rem; }
.btn:focus-visible, .chip:focus-visible, .link:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.chip { border: 1px solid var(--rule); background: #fff; border-radius: 3px; padding: .35rem .7rem; font: 700 .8rem var(--body); cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--ink); }
.chip.danger { color: var(--pen); }

/* working */
.spinner { width: 46px; height: 46px; margin: 0 auto 1.1rem; border: 4px solid var(--rule); border-top-color: var(--pen); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; margin: 1rem 0; }
.progress .bar { height: 100%; width: 100%; background: var(--amber); transform: scaleX(0); transform-origin: left; transition: transform .25s ease-out; }
.prog { margin: 1rem 0 .5rem; }
.prog-top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.prog-label { color: var(--ink); }
.prog-pct { font-family: var(--mono); font-weight: 700; color: var(--ink); }
.prog .progress { height: 10px; margin: .55rem 0 .8rem; border-radius: 5px; }
.prog-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
.prog-steps li { display: flex; align-items: center; gap: .55rem; }
.prog-steps li::before { content: ""; flex: 0 0 14px; height: 14px; border-radius: 50%; border: 2px solid #b9c6c2; box-sizing: border-box; }
.prog-steps li.now { color: var(--ink); font-weight: 700; }
.prog-steps li.now::before { border-color: var(--amber); border-top-color: transparent; animation: spin .9s linear infinite; }
.prog-steps li.done { color: var(--keep); }
.prog-steps li.done::before { content: "✓"; border: 0; background: var(--keep); color: #fff; font-size: 10px; line-height: 14px; text-align: center; font-weight: 700; }
.sticky-action .prog-label, .sticky-action .prog-pct { color: #f3efe6; }
.sticky-action .progress { background: rgba(243, 239, 230, .18); }
.sticky-action .prog-steps { color: #a9bdb9; }
.sticky-action .prog-steps li.now { color: #f3efe6; }
.sticky-action .prog-steps li.done { color: #9fd8c9; }
.join-progress { margin-top: .5rem; }

/* review: the waveform sits on a dark "tape" panel */
.wave-wrap { position: relative; margin: 1.4rem 0 .8rem; border-radius: var(--radius); background: var(--ink); padding: 12px 0; min-height: 136px; }
.wave-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #9fb4b0; font-size: .9rem; font-family: var(--mono); }
#wave ::part(region) { border-left: 2px solid var(--pen); border-right: 2px solid var(--pen); background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, .14) 6px 8px); }
#wave ::part(kept) { border-color: rgba(243, 239, 230, .35); background-image: none; }
.transport { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.time { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 6ch; }
.zoom { margin-left: auto; display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); }
.zoom input { accent-color: var(--ink); width: 140px; }
.hint { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--muted); margin: 1rem 0 0; }
.key { flex: 0 0 18px; height: 10px; align-self: center; border-radius: 2px; }
.key-red { background: var(--pen); }
.count { font-family: var(--mono); font-size: .85rem; color: var(--muted); }

/* cut list: words being removed are struck through in red pen */
.cuts { list-style: none; margin: .4rem 0 0; padding: 0; }
.cut { display: flex; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.cut:first-child { border-top: 0; }
.cut .said { text-decoration: line-through; text-decoration-color: var(--pen); text-decoration-thickness: 2px; }
.cut.off .said, .cut .said.note { text-decoration: none; color: var(--muted); font-style: italic; }
.cut.flash { animation: flash 1.1s; }
@keyframes flash { from { background: #fdf0d4; } to { background: transparent; } }
.cut-body { flex: 1; min-width: 0; }
.cut-head { display: flex; gap: .65rem; align-items: baseline; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.num { font-family: var(--display); font-size: 1.1rem; color: var(--pen); }
.cut.off .num { color: var(--muted); }
.range { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tag { font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; padding: .1rem .4rem; border-radius: 3px; background: #e3e9e5; color: var(--ink-2); }
.said { margin: 0 0 .6rem; font-size: 1rem; line-height: 1.5; }
.cut-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

.toggle { position: relative; flex: 0 0 auto; margin-top: .2rem; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { display: block; width: 46px; height: 26px; border-radius: 13px; background: #c3ccc8; transition: background .15s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.toggle input:checked + span { background: var(--pen); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:focus-visible + span { outline: 3px solid var(--amber); outline-offset: 2px; }

.sticky-action { position: sticky; bottom: .75rem; z-index: 5; background: var(--ink); border-color: var(--ink); color: #f3efe6; }
.sticky-action strong { font-family: var(--display); font-weight: 400; font-size: 1.2rem; }
.sticky-action .muted { color: #a9bdb9; }
.action-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.result-card { background: #fff8e8; border-color: #f0d9a4; }
.result-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.result-row audio { flex: 1 1 260px; }
#result .btn.primary { background: var(--amber); border-color: var(--amber); color: var(--ink); }
#result .btn.primary:hover { background: #e09e1c; border-color: #e09e1c; }

/* upload fields */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; margin: 1.2rem 0 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; font-weight: 700; color: var(--ink); font-size: .9rem; }
.field input, .field select, .small-select { font: 400 1rem var(--body); color: var(--text); background: #fff; border: 1.5px solid #b9c6c2; border-radius: var(--radius); padding: .6rem .7rem; min-height: 44px; }
.field input:focus, .field select:focus, .small-select:focus { outline: 3px solid var(--amber); outline-offset: 1px; border-color: var(--ink); }
.small-select { min-height: 36px; padding: .3rem .5rem; font-size: .85rem; }
.keep-note { text-align: center; margin: 1.5rem 0; }

/* books */
.book-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.book-head h2 { margin-bottom: .15rem; }
.book-tools { display: flex; gap: .4rem; }
.parts { list-style: none; margin: 1rem 0 0; padding: 0; }
.part { display: flex; align-items: center; gap: .9rem; padding: .75rem 0; border-top: 1px solid var(--rule); }
.part-num { flex: 0 0 2rem; font-family: var(--display); font-weight: 700; font-size: 1.3rem; color: var(--pen); text-align: center; }
.part-main { flex: 1; min-width: 0; }
.part-title { font-weight: 700; color: var(--ink); text-decoration: none; }
.part-title:hover { color: var(--pen); text-decoration: underline; }
.part-meta { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.part-meta .pill { margin-left: .25rem; }
.part-tools { display: flex; gap: .3rem; }
.chip.icon { width: 36px; height: 36px; padding: 0; font-size: 1rem; }
.chip:disabled { opacity: .35; cursor: default; }
.join { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.join-note { margin: 0; flex: 1 1 260px; }
.joined { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; padding: 1rem; background: #fff8e8; border: 1px solid #f0d9a4; border-radius: var(--radius); }
.joined audio { flex: 1 1 260px; }
.joined .btn.primary { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.joined details { flex: 1 0 100%; }
.joined summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.chapters { margin: .5rem 0 0; padding-left: 1.4rem; line-height: 1.8; }
.chapters .range { font-family: var(--mono); color: var(--muted); margin-right: .4rem; }
.title-row { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.title-row h1 { margin-bottom: .2rem; }

/* dialog */
#dlg { width: min(460px, calc(100vw - 2rem)); padding: 0; border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet); color: var(--text); box-shadow: 0 24px 60px rgba(14, 43, 46, .35); }
#dlg::backdrop { background: rgba(14, 43, 46, .55); backdrop-filter: blur(2px); }
#dlg[open] { animation: dlg-in .18s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
#dlg form { padding: 1.5rem 1.6rem 1.3rem; }
#dlg h2 { font-size: 1.45rem; margin-bottom: .5rem; }
#dlg .field { margin-top: .6rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.4rem; }
.btn.danger { background: var(--pen); border-color: var(--pen); color: #fff; }
.btn.danger:hover { background: #c22a1f; border-color: #c22a1f; }

@media (max-width: 560px) {
  .sticky-action { position: static; }
  #who-email { display: none; }
  #result .btn { width: 100%; }
  .zoom { margin-left: 0; width: 100%; }
  .zoom input { flex: 1; }
  .action-row .btn { width: 100%; }
  .dlg-actions { flex-direction: column-reverse; }
  .dlg-actions .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
