*, *::before, *::after { box-sizing: border-box; }
:root {
  --gray: #EAE9E4; --black: #000; --white: #fff;
  --red: #F46231; --red-dark: #802C14; --yellow: #FFBA02; --green: #6BA01E; --blue: #5F98DB;
  --muted: rgba(0,0,0,.6); --line: rgba(0,0,0,.1);
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--gray); color: var(--black);
  font-family: 'DM Sans', system-ui, sans-serif; font-size: 16px; line-height: 1.5;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.1; }
h2 { font-size: 1.25rem; margin-bottom: .75rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--red-dark); min-height: 1.2em; }
.center { text-align: center; }

.top { max-width: 880px; margin: 0 auto; padding: 1rem 1rem .5rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .9rem; cursor: pointer; }
.brand:hover h1 { color: var(--red-dark); }
/* Clicking the logo to go home shouldn't leave a focus ring behind; keyboard focus keeps it. */
.brand:focus:not(:focus-visible) { outline: none; }
.logo { height: 44px; width: 44px; object-fit: contain; mix-blend-mode: multiply; flex: none; }
.tag { margin: .15rem 0 0; font-size: .85rem; color: var(--muted); }
.who { font-size: .8rem; color: var(--muted); display: flex; gap: .6rem; align-items: center; }

main { max-width: 880px; margin: 0 auto; padding: 0 1rem 6rem; }
.card { background: var(--white); border-radius: 2px; padding: 1.25rem; margin-bottom: 1rem; }
.card.center { max-width: 420px; margin: 3rem auto; }
#gsi-button { display: flex; justify-content: center; margin: 1rem 0; }
.email-signin { text-align: left; border-top: 1px solid var(--line); padding-top: 1.25rem; }
.email-signin label { display: block; font-weight: 600; margin-bottom: .3rem; }
.email-signin input { font: inherit; width: 100%; min-width: 0; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 2px; }
.email-signin button.primary { width: 100%; margin-top: .75rem; background: var(--red-dark); color: white; }
.email-signin button.primary:hover { background: var(--black); }
.email-signin button:disabled { cursor: wait; opacity: .6; }
.email-signin #signin-code { letter-spacing: .35em; font-variant-numeric: tabular-nums; }
.email-signin strong { overflow-wrap: anywhere; }

.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.center { justify-content: center; }
.row.small { margin-top: .75rem; }
input[type=url], input[type=search], input[type=text], select {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 2px; background: #fff; min-width: 0;
}
input[type=url], #url-input, #ws-input, #todo-input { flex: 1 1 260px; width: auto; }
input[type=search] { width: 180px; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 2px; background: var(--gray); color: var(--black); padding: .6rem .9rem; }
button.primary { background: var(--red); color: #fff; font-weight: 600; padding: .6rem 1.3rem; }
button.primary:hover { background: var(--red-dark); }
button.link { background: none; color: var(--red-dark); padding: 0; text-decoration: underline; }
button.back { margin-bottom: .75rem; }
button:disabled { opacity: .5; cursor: default; }

.drop { margin-top: .75rem; border: 1.5px dashed var(--line); border-radius: 2px; padding: 1rem; text-align: center; color: var(--muted); font-size: .9rem; }
.drop.over { border-color: var(--red); background: #fff7f3; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: .8rem; align-items: center; padding: .8rem 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: #000; flex: none; background: var(--yellow); }
.list .icon.pdf { background: var(--red); color: #fff; } .list .icon.pptx { background: var(--blue); color: #fff; } .list .icon.docx { background: var(--green); color: #fff; }
.list .icon.gslides { background: #FBBC04; color: #000; font-size: .5rem; } .list .icon.gdoc { background: #4285F4; color: #fff; } .list .icon.gsheet { background: #34A853; color: #fff; font-size: .6rem; }
.list .info { flex: 1; min-width: 0; }
.list .drag-handle { flex: none; align-self: stretch; display: grid; place-items: center; padding: .2rem .35rem; margin-left: -.45rem; background: none; color: var(--muted); cursor: grab; touch-action: none; font-size: 1.2rem; }
.list .drag-handle:active { cursor: grabbing; }
.list li.dragging { opacity: .55; background: #fff7f3; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .play-btn { color: var(--red); font-size: 1.2rem; }
.list .meta { font-size: .8rem; color: var(--muted); }
.list .meta .ready { color: var(--green); } .list .meta .busy { color: #AD7901; }
/* a failure explains itself in a couple of lines — never a wall of text in the library */
.list .meta .caveat { color: #8a5a00; }
.fidelity-notes { font-size: .85rem; color: #8a5a00; margin: .2rem 0 .6rem; }
.fidelity-notes summary { cursor: pointer; }
.fidelity-notes ul { margin: .3rem 0 0; padding-left: 1.2rem; color: var(--muted); }
.fidelity-notes li { margin: .2rem 0; }
.list .meta .failed { color: var(--red-dark); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list li.ready { cursor: pointer; } .list li.ready:hover .title { color: var(--red-dark); }
.list li.ready:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.list .del { background: none; color: var(--muted); font-size: 1.1rem; padding: .3rem .5rem; }

.player #p-title { font-size: 1.4rem; cursor: text; }
.player #p-title:hover::after { content: ' ✎'; color: var(--muted); font-size: 1rem; }
#scrub { width: 100%; margin-top: 1rem; accent-color: var(--red); }
.times { font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--muted); }
.controls { display: flex; justify-content: center; align-items: center; gap: .9rem; margin: .75rem 0; }
.controls button { font-size: 1.1rem; width: 52px; height: 44px; padding: 0; }
.controls button.big { width: 72px; height: 72px; border-radius: 50%; font-size: 1.7rem; background: var(--red); color: #fff; }
.controls button.big:hover { background: var(--red-dark); }
.check { display: inline-flex; gap: .35rem; align-items: center; }

.parts { margin: 0; padding-left: 1.4rem; }
.parts li { padding: .5rem 0; border-top: 1px solid var(--line); cursor: pointer; }
.parts li:first-child { border-top: 0; }
.parts li.current { font-weight: 700; color: var(--red-dark); background: #fff7f3; border-left: 4px solid var(--red); padding-left: .6rem; margin-left: -1rem; }
.parts .dur { float: right; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.parts .txt { display: none; font-weight: 400; color: var(--muted); font-size: .9rem; margin-top: .3rem; white-space: pre-wrap; }
.show-text .parts .txt { display: block; }

footer { text-align: center; padding: 1rem; }
@media (max-width: 600px) {
  .top { padding-top: .75rem; } h1 { font-size: 1.35rem; } .tag { display: none; }
  .card { padding: 1rem; } input[type=search] { width: 130px; }
  .controls { gap: .5rem; } .controls button { width: 46px; }
}

.thread { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; max-height: 50vh; overflow-y: auto; padding-right: .6rem; }
.thread:empty { display: none; }
.note { padding: .6rem .8rem; border-radius: 2px; max-width: 92%; white-space: pre-wrap; font-size: .95rem; }
.note.question { background: var(--gray); align-self: flex-end; }
.note.answer { background: #fff7f3; border-left: 3px solid var(--red); align-self: flex-start; }
.note .play { background: none; padding: 0 0 0 .4rem; color: var(--red-dark); font-size: .9rem; }
.note time { display: block; font-size: .7rem; color: var(--muted); margin-top: .2rem; }
#ask-input { flex: 1 1 200px; font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 2px; }
#mic.listening { background: var(--red); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.list .meta .notes { color: var(--muted); }
.note.note { background: #fffbe8; border-left: 3px solid var(--yellow); align-self: flex-start; }
.note .pos { display: inline-block; font-size: .72rem; color: var(--red-dark); background: none; padding: 0; margin-right: .5rem; text-decoration: underline; }
.note .rm { float: right; background: none; padding: 0 0 0 .5rem; color: var(--muted); }
.speeds { display: flex; justify-content: center; gap: .4rem; margin: .25rem 0 .5rem; }
.speeds button { padding: .4rem .7rem; font-size: .85rem; font-variant-numeric: tabular-nums; }
.speeds button.on { background: var(--black); color: #fff; }
#live-btn.on { background: var(--red-dark); color: #fff; animation: pulse 1.4s infinite; }

/* Compact combined Q&A cards */
.qa { border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: 2px; padding: .5rem .7rem; font-size: .92rem; }
.qa.plain { border-left-color: var(--yellow); }
.qa-head { display: flex; gap: .6rem; align-items: baseline; font-size: .72rem; color: var(--muted); margin-bottom: .15rem; }
.qa-head .rm { margin-left: auto; margin-right: .35rem; background: none; padding: 0 .35rem; color: var(--muted); }
.qa-head .by { font-weight: 600; color: var(--red-dark); }
.qa .q { font-weight: 600; }
.qa .a { color: #222; margin-top: .2rem; }
.qa .play { font: inherit; font-size: .8rem; font-weight: 600; padding: .15rem .5rem; margin-left: .4rem; background: var(--gray); color: var(--red-dark); vertical-align: baseline; }
.qa .play.on, #note-stop { background: var(--red-dark); color: #fff; }
.qa time { font-size: inherit; color: inherit; margin: 0; }
/* Rows that aren't parts: display:block (not list-item) so they don't eat a part number. */
.parts li.total { display: block; font-weight: 700; border-top: 2px solid var(--black); cursor: default; margin-left: -1.4rem; padding-left: 1.4rem; }
/* topic source headers in the Parts list */
.parts li.src-head { display: block; font-family: 'DM Serif Display', Georgia, serif; font-size: 1.05rem; border-top: 2px solid var(--line); cursor: default; margin-left: -1.4rem; padding: .7rem 0 .3rem 1.4rem; }
.parts li.src-head:first-child { border-top: 0; padding-top: .2rem; }
.parts li.src-head.pending { color: var(--muted); font-style: italic; }
.parts .src-tools { float: right; display: inline-flex; gap: .25rem; margin-left: .6rem; }
.parts .src-tools button { font: inherit; font-size: .8rem; line-height: 1; padding: .25rem .5rem; background: var(--gray); }
.parts .src-tools button:disabled { opacity: .3; }
.parts .src-tools button[data-remove]:hover, .parts .src-tools button[data-remove-yes] { background: var(--red); color: #fff; }
.parts .src-tools .confirm { font-family: 'DM Sans', system-ui, sans-serif; font-size: .85rem; display: inline-flex; gap: .4rem; align-items: center; }
.parts li.add-part { display: block; border-top: 0; margin-left: -1.4rem; padding: .9rem 0 .2rem 1.4rem; cursor: default; }
.parts li.parts-msg { display: block; border-top: 0; margin-left: -1.4rem; padding: .2rem 0 .2rem 1.4rem; cursor: default; color: var(--red-dark); font-size: .9rem; }
.parts li.add-part { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; align-items: baseline; }
.parts li.add-part button { font-weight: 600; }
.parts li.add-part #copy-text-btn { margin-left: auto; font-weight: 500; }
/* add-sources picker */
.addsrc-list { list-style: none; margin: .3rem 0 .9rem; padding: 0; max-height: 35vh; overflow-y: auto; }
.addsrc-list li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.addsrc-list li:last-child { border-bottom: 0; }
/* left-aligned rows: checkbox pinned at the start, title flowing beside it. A long
   unbreakable title must wrap and clamp — otherwise it widens the list, pushes every
   title out of view sideways and leaves a column of blank rows. */
.addsrc-list { overflow-x: hidden; text-align: left; }
/* Plain two-column grid: checkbox | title. (A flex + -webkit-box line-clamp combo made the
   title compute to 0px wide in Chromium — the titles vanished and the rows went blank.) */
.addsrc-list .check { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: .55rem; width: 100%; }
.addsrc-list .check input { margin: .25rem 0 0; }
.addsrc-list .check span { display: block; min-width: 0; overflow-wrap: anywhere; line-height: 1.4; max-height: 2.8em; overflow: hidden; }
/* adding something new from inside the picker */
.addsrc-new { margin: .9rem 0 0; }
.addsrc-new input[type=text] { flex: 1 1 auto; width: auto; }
.addsrc-new > button { flex: none; }
#addsrc-paste textarea { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 2px; margin: .5rem 0; resize: vertical; }
#addsrc-new-status { margin: .6rem 0 0; font-weight: 600; color: var(--red-dark); }
#addsrc-new-status:empty { display: none; }
dialog.copy-dlg.over { outline: 2px dashed var(--red); outline-offset: -6px; }
.addsrc-or { margin: 1rem 0 0; padding-top: .8rem; border-top: 1px solid var(--line); }
.ask .noise { flex: none; display: flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.ask .noise button { padding: .2rem .6rem; line-height: 1; }
/* web search results */
.ws-results { list-style: none; margin: .5rem 0 0; padding: 0; }
.ws-results:empty { display: none; }
.ws-results li { display: flex; align-items: center; gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.ws-results li:last-child { border-bottom: 0; }
.ws-results .ws-info { flex: 1; min-width: 0; }
.ws-results a { font-weight: 600; }
.ws-results button { flex: none; white-space: nowrap; }
.lib-tools { gap: .6rem; align-items: center; }
/* todos */
.todos { list-style: none; margin: .6rem 0 0; padding: 0; }
.todos li { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.todos li:last-child { border-bottom: 0; }
.todos li .check { flex: 1; display: flex; gap: .5rem; align-items: baseline; }
.todos li.done span { text-decoration: line-through; color: var(--muted); }
.todos .del { background: none; color: var(--muted); padding: 0 .4rem; }
#summary-row button { font-size: .85rem; padding: .3rem .8rem; }
#mic-pick { max-width: 200px; font-size: .85rem; }
details.paste { margin-top: .75rem; }
details.paste summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details.paste textarea { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 2px; margin: .5rem 0; resize: vertical; }
/* Add card: four ways in, one look — plain matching rows split by simple divider lines */
.add h2 { margin-bottom: .35rem; }
.add .add-row { margin: 0; padding: .85rem 0; flex-wrap: nowrap; border-bottom: 1px solid var(--line); }
.add .add-row input { flex: 1 1 auto; width: auto; }
.add .add-row > button { flex: none; min-width: 108px; padding: .6rem .9rem; text-align: center; }
.add .drop {
  margin: 0; padding: .85rem 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  text-align: left; font-size: .9rem; color: var(--muted);
}
.add .drop.over { background: #fff7f3; border-bottom-color: var(--red); }
.add details.paste { margin: 0; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.add details.paste summary { padding: 0; }
.add #web-search { border-bottom: 0; }
.add .ws-results { margin: 0; }
.add #add-status { margin: .6rem 0 0; min-height: 1.2em; }
@media (max-width: 480px) { .add .add-row > button { min-width: 84px; } }
/* copy dialog — shown when the link can't be put on the clipboard silently */
dialog.copy-dlg { border: 0; border-radius: 2px; padding: 1.25rem; max-width: 480px; width: calc(100% - 2rem); font: inherit; }
dialog.copy-dlg::backdrop { background: rgba(0, 0, 0, .35); }
dialog.copy-dlg p { margin: 0 0 .6rem; font-weight: 600; }
dialog.copy-dlg input { width: 100%; font: inherit; font-size: .9rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 2px; margin-bottom: .9rem; }

/* Evidence stays readable next to the answer, including on narrow screens. */
.evidence-status { border-left: 3px solid var(--red); padding: .65rem .85rem; background: #faf7f2; font-size: .85rem; }
.answer-controls { margin-top: .75rem; }
.answer-controls label { font-weight: 600; font-size: .85rem; }
.answer-evidence { margin-top: .75rem; border-top: 1px solid var(--line); padding-top: .5rem; font-size: .85rem; }
.answer-evidence summary { cursor: pointer; color: #1A4975; }
.answer-evidence figure { margin: .75rem 0; }
.answer-evidence figcaption { font-weight: 600; }
.answer-evidence blockquote { margin: .35rem 0; padding: .5rem .75rem; border-left: 2px solid var(--blue); white-space: pre-wrap; overflow-wrap: anywhere; }
.evidence-warning { color: var(--red-dark); }
.qa .a { white-space: pre-wrap; }
#ask-btn { background: var(--red); color: #000; }
