:root {
  /* Warm sepia palette: cream page, parchment cards, burnt-orange accent */
  --bg: #f7f1e8; --card: #fffdf9; --text: #2b2118; --muted: #7a6a58; --line: #e6d9c8;
  --accent: #b9541a; --accent-soft: #fbe7d6; --danger: #b3321f; --ok: #2e7d4f; --warn-bg: #fdecc8;
  --header: #fff6ea; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1612; --card: #26201a; --text: #f1e8dc; --muted: #b3a08c; --line: #3d332a;
          --accent: #f0955a; --accent-soft: #3f2a18; --warn-bg: #3d2f14; --header: #221c16; }
}
* { box-sizing: border-box; }
/* Author display rules (.record, header) would otherwise beat the browser's [hidden] rule and keep them visible */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
header { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--header);
         border-bottom: 1px solid var(--line); border-top: 4px solid var(--accent); position: sticky; top: 0; z-index: 5;
         flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--accent); }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.banner { background: var(--warn-bg); padding: 8px 16px; font-size: 14px; text-align: center; }
h1 { font-size: 22px; margin: 4px 0 16px; color: var(--accent); }
h2 { font-size: 17px; margin: 20px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
        box-shadow: 0 1px 2px rgba(80, 50, 20, .06); }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
textarea { min-height: 120px; resize: vertical; }
textarea.note { min-height: 55vh; font-family: ui-monospace, Menlo, monospace; font-size: 14px; line-height: 1.55; }
button { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 9px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--muted); padding: 4px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 180px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); margin-top: 8px; }
.ok { color: var(--ok); margin-top: 8px; }
/* checkboxes keep their natural size; label.check puts one next to its text */
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; margin: 6px 0; cursor: pointer; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px; color: inherit; text-decoration: none; }
.list a:hover { background: var(--accent-soft); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.finalized { background: #e3f4ea; color: var(--ok); }
.pill.failed { background: #fbe4e1; color: var(--danger); }
.pill.admin { background: #efe3f7; color: #7d3c98; }
.pill.off { background: var(--line); color: var(--muted); }
.folder { font-weight: 600; margin-top: 12px; }
/* the module (specialty) picked in the header, shown on the dictate page */
.chip { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft);
  color: var(--accent); margin: -8px 0 14px; }
#specialty { width: auto; max-width: 200px; padding: 6px 8px; font-size: 14px; }
/* My notes: a link plus a Copy button in one row; admin lists: text, pills and buttons in one wrapping row */
.list li.noterow { display: flex; align-items: center; gap: 8px; }
.list li.noterow a { flex: 1 1 auto; min-width: 0; }
.list li.noterow button { flex: 0 0 auto; margin-right: 4px; }
.itemrow { display: flex; align-items: center; gap: 10px; padding: 10px 4px; flex-wrap: wrap; }
.itemrow .grow { flex: 1 1 200px; min-width: 0; }
.itemrow .grow .muted { overflow-wrap: anywhere; }
button.copied { color: var(--ok); border-color: var(--ok); background: #e3f4ea; }
.record { width: 140px; height: 140px; border-radius: 50%; font-size: 18px; font-weight: 700; margin: 16px auto; display: block;
  background: var(--danger); color: #fff; border: 0; }
.record.on { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 16px rgba(192,57,43,.15); } }
.timer { text-align: center; font-size: 28px; font-variant-numeric: tabular-nums; }
.steps { list-style: none; padding: 0; }
.steps li { padding: 6px 0; color: var(--muted); }
.steps li.done { color: var(--ok); }
.steps li.now { color: var(--text); font-weight: 600; }
.split { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.transcript { white-space: pre-wrap; font-size: 14px; max-height: 50vh; overflow: auto; }
.change { font-size: 14px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.change s { color: var(--danger); }
.change b { color: var(--ok); }
.warnbox { background: var(--warn-bg); padding: 8px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 8px; }
.final { white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.login { max-width: 380px; margin: 10vh auto; }
@media print { header, .banner, .actions, .noprint { display: none !important; } .card { border: 0; } }
@media (max-width: 600px) {
  header { gap: 8px; }
  nav { order: 3; flex-basis: 100%; justify-content: space-between; gap: 0; }
  nav a { padding: 6px 5px; font-size: 15px; }
  #specialty { margin-left: auto; max-width: 150px; }
  #specialty[hidden] + #logout { margin-left: auto; }
}
@media (prefers-color-scheme: dark) { .pill.admin { background: #2e1f3a; color: #c39bd3; } button.copied { background: #18301f; } }
/* recorder */
.recorder { display: flex; align-items: center; justify-content: center; gap: 20px; }
.recorder .record { margin: 16px 0; }
.record.paused { background: #d68910; }
.endbtn { width: 96px; height: 96px; border-radius: 50%; font-weight: 700; font-size: 17px; background: var(--text); color: var(--card); border: 0; }
/* coding */
h3 { font-size: 15px; margin: 18px 0 6px; }
.coderow { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.coderow.off { opacity: .55; }
.codehead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.codecheck { width: 20px; height: 20px; flex: 0 0 auto; }
.codeinput { width: 110px; flex: 0 0 auto; font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.codedesc { flex: 1 1 200px; font-weight: 600; }
.codehead > input:not(.codeinput):not(.codecheck) { flex: 1 1 200px; width: auto; }
.evidence { font-size: 14px; font-style: italic; margin: 6px 0 2px; padding-left: 10px; border-left: 3px solid var(--accent); }
.codewarn { color: var(--danger); font-size: 14px; margin-top: 4px; }
.codeextra { margin-top: 6px; }
.codeextra > div { flex: 0 1 140px; }
.small { font-size: 12px; }
.pill.conf-high { background: #e3f4ea; color: var(--ok); }
.pill.conf-medium { background: var(--accent-soft); color: var(--accent); }
.pill.conf-low { background: #fbe4e1; color: var(--danger); }
.codes-final ol { margin: 6px 0 14px; padding-left: 22px; }
.codes-final code { font-weight: 700; }
/* target CPT */
.cptpanel { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.cptrow { align-items: end; }
.cptok { background: #e3f4ea; color: var(--ok); border-radius: 8px; padding: 8px 12px; margin-top: 8px; font-weight: 600; }
.cptbad { background: #fbe4e1; color: var(--danger); border-radius: 8px; padding: 8px 12px; margin-top: 8px; }
@media (prefers-color-scheme: dark) { .cptok { background: #18301f; } .cptbad { background: #3a1c1a; } }
.linkbtn { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; font-weight: 600; cursor: pointer; }
.cptdetails { margin-top: 10px; font-size: 14px; }
.cptdetails p { margin: 4px 0; }
table.mdm { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.mdm th, table.mdm td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.evidence-cell { font-style: italic; color: var(--muted); }
ul.suggestions { padding-left: 20px; }
ul.suggestions li { margin-bottom: 8px; }
.signature { font-style: italic; margin-top: 14px; }
/* census: date row, team pills, patient rows with their actions */
.daterow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.daterow input[type="date"] { width: auto; flex: 1 1 150px; max-width: 220px; }
.daterow .arrow { padding: 9px 12px; flex: 0 0 auto; }
.daterow .tabs { margin: 0 0 0 auto; }
.teams { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.teams button { border-radius: 99px; padding: 7px 14px; }
.teams button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.teams button { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.listhead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 4px; }
a.btn { display: inline-block; border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; color: var(--text);
  background: var(--card); text-decoration: none; }
.addform { border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px 12px; margin: 8px 0; }
/* One patient = one framed row; the summary is the compact line, the body opens under it */
.crow { border: 2px solid var(--text); border-radius: 8px; margin: 8px 0; background: var(--card); overflow: hidden; }
.crow summary { display: flex; gap: 8px; align-items: center; padding: 10px 12px; cursor: pointer; list-style: none; }
.crow summary::-webkit-details-marker { display: none; }
.crow .arrow { display: inline-block; transition: transform .15s; color: var(--accent); font-size: 18px; width: 16px; }
.crow[open] .arrow { transform: rotate(90deg); }
.crow[open] summary { background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.crow .grow { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.crow .cbody { padding: 10px 12px 12px 36px; }
.crow .cbody .cactions { margin-top: 8px; }
.list li:has(> .crow) { border-bottom: 0; }
.cactions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 0 1 auto; }
/* min-width 0: a select is as wide as its longest option, which would otherwise widen the page on a phone */
.cactions select { width: auto; min-width: 0; max-width: min(280px, 100%); padding: 8px 8px; }
.cactions .othercode { width: 120px; font-family: ui-monospace, Menlo, monospace; font-weight: 600; }
.cactions .xbtn { padding: 7px 11px; font-size: 18px; line-height: 1; }
.pill.warn { background: #fdebd0; color: #b9770e; }
.pill.hand { background: var(--line); color: var(--muted); }
.pill.billed { background: #e3f4ea; color: var(--ok); }
.linkbtn.small { font-size: 13px; font-weight: 500; color: var(--muted); }
@media (max-width: 600px) {
  .cactions { flex: 1 1 100%; }
  .cactions select { flex: 1 1 100%; width: 100%; max-width: 100%; }
  .cactions .othercode { flex: 1 1 120px; }
}
@media (prefers-color-scheme: dark) { .pill.warn { background: #3a2f14; color: #f0b35a; } .pill.billed { background: #18301f; } }
