/* Mohr's circle practice: a lecture handout. Warm off-white paper, graphite ink, one oxblood accent for the points and
   angles a student draws, steel blue only for the turned element in the key. Answers sit in short ruled groups the way
   a solution is set out by hand. Figures in tabular numerals. */
:root {
  --bg: #f5f2ec; --paper: #fffdf9; --ink: #1f1d22; --muted: #4f4a52; --line: #dcd5ca; --line2: #8a8378;
  --accent: #8a2c37; --accent-ink: #ffffff; --accent-soft: #f3e1e1;
  --steel: #2d5a86; --mine: #6b6255; --face: #efe9df;
  --ok: #1d6a39; --ok-soft: #e1f1e6; --bad: #a3261b; --bad-soft: #fbe4e1; --warn: #6e4f00; --warn-soft: #f6ecd0;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 4px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18161a; --paper: #211e23; --ink: #ece7e1; --muted: #bdb5ad; --line: #3a353b; --line2: #7d756c;
    --accent: #f0a0a8; --accent-ink: #2a0d11; --accent-soft: #3b2226;
    --steel: #8fbbe6; --mine: #c9bfb1; --face: #2c282e;
    --ok: #82d39f; --ok-soft: #173020; --bad: #ff9b8f; --bad-soft: #3d1f1b; --warn: #efc46a; --warn-soft: #382e15;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); font-variant-numeric: tabular-nums; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 9; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.15; font-weight: 750; letter-spacing: -0.01em; }
sub { font-size: 0.75em; line-height: 0; }

/* hero */
.hero { padding: 20px 0 2px; }
.hero h1 { font-size: clamp(1.65rem, 5vw, 2.4rem); margin: 0 0 8px; }
.lede { margin: 4px 0 0; max-width: 68ch; }
.safety { margin: 10px 0 0; font-weight: 650; color: var(--warn); }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; }
.btnrow .btn { text-decoration: none; display: inline-flex; align-items: center; }

/* setup */
.setup { margin: 12px 0 10px; }
.setrow { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; max-width: 100%; }
select, input { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line2); border-radius: var(--r); }
select { min-height: 44px; padding: 6px 10px; max-width: 100%; min-width: 0; }
.btn { font: inherit; min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 6px 16px; }
.btn:hover { filter: brightness(0.96); }
.link { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 10px 4px; min-height: 44px; }
.note { margin: 8px 0; padding: 10px 12px; background: var(--warn-soft); border-radius: var(--r); overflow-wrap: anywhere; }
.note.info { background: var(--accent-soft); }

/* the sheet */
.sheet { background: var(--paper); border: 1px solid var(--line); padding: 14px 18px 16px; margin: 10px 0 18px; }
@media (max-width: 480px) { .sheet { padding: 12px 10px 14px; margin-left: -6px; margin-right: -6px; } }
/* on a phone the drawing comes before the problem text, so it reaches the first screen */
@media (max-width: 600px) { .q { display: flex; flex-direction: column; } .q > .qhead { order: -2; } .q > .figs { order: -1; } .q .see { display: none; } }
.sheet:focus { outline: none; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.code { font-family: var(--mono); letter-spacing: 0.06em; }
.lvname { font-weight: 500; color: var(--muted); font-size: 1rem; }
.score { margin: 0; color: var(--muted); }
details.rules { margin: 8px 0 4px; }
details.rules summary, details.work summary, details.recent summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
details.rules ul { margin: 4px 0 10px; padding-left: 20px; max-width: 80ch; }
details.rules li { margin: 0 0 4px; }
.qs { list-style: none; margin: 0; padding: 0; }
.q { padding: 14px 0 16px; border-top: 1px solid var(--line2); }
.q:first-child { border-top: 0; }
.qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 14px; flex-wrap: wrap; }
.qhead h3 { margin: 0 0 4px; font-size: 1.15rem; display: flex; gap: 10px; align-items: baseline; }
.qn { font-family: var(--mono); font-size: 1rem; color: var(--accent); font-weight: 800; }
.qn::after { content: "."; }
.see { font-weight: 600; padding: 10px 0; }
.scen { margin: 4px 0 8px; max-width: 76ch; }

/* the drawings */
.figs { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 4px 0 10px; }
.efig, .cfig { margin: 0; min-width: 0; max-width: 100%; }
.efig figcaption, .cfig figcaption { color: var(--muted); padding: 0 2px 4px; }
svg.elem { display: block; width: 100%; max-width: 272px; height: auto; }
svg.circ { display: block; width: 100%; height: auto; }
.cfig { width: 100%; max-width: 560px; }
svg text { font-family: var(--sans); font-size: var(--fs); fill: var(--ink); }
.esq { fill: var(--face); stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: round; }
.ghost { fill: none; stroke: var(--line2); stroke-width: 1.2; stroke-dasharray: 5 4; }
.arr line { stroke: var(--ink); stroke-width: 2; }
.arr path { fill: var(--ink); }
.cax line { stroke: var(--muted); stroke-width: 1.4; }
.cax path { fill: var(--muted); }
.eax, .eax2 { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 6 4; }
.eax2 { stroke: var(--accent); stroke-dasharray: none; stroke-width: 1.4; }
.earc { fill: none; stroke: var(--accent); stroke-width: 1.6; }
svg .eal { fill: var(--accent); font-weight: 700; }
svg .el { font-weight: 650; }
.ax { stroke: var(--muted); stroke-width: 1.2; }
.axh { fill: var(--muted); }
.brk { stroke: var(--muted); stroke-width: 1.4; fill: none; }
.mc { fill: none; stroke: var(--ink); stroke-width: 2; }
.mine { fill: none; stroke: var(--mine); stroke-width: 2; stroke-dasharray: 7 5; }
.dia { stroke: var(--ink); stroke-width: 1.4; }
.dia2 { stroke: var(--steel); stroke-width: 1.6; stroke-dasharray: 8 4; }
.arc, .arc2 { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.arc2 { stroke: var(--steel); }
.arch { fill: var(--accent); } .arc2h { fill: var(--steel); }
.pd { fill: var(--accent); } .pd2 { fill: var(--steel); } .pc, .pp { fill: var(--ink); }
svg .ml { font-weight: 700; }
svg .mla { fill: var(--accent); }
svg .mla2 { fill: var(--steel); }
.mineleg { margin: 2px 0 0; }

/* the answers */
.groups { display: grid; gap: 4px 28px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17em), 1fr)); margin: 0 0 8px; }
.grp { min-width: 0; }
.gh { margin: 6px 0 0; font-weight: 700; border-bottom: 1.5px solid var(--ink); padding-bottom: 2px; }
.arow { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; min-height: 48px; border-bottom: 1px dotted var(--line2); }
.alab { font-weight: 700; white-space: nowrap; }
.aval { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; min-width: 0; }
.un { color: var(--muted); min-width: 2.2em; }
.cw { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-width: 0; }
.cw > .cell { flex: none; }
input.cell { width: calc(var(--w) * 0.62em + 1em); max-width: 100%; min-height: 44px; padding: 6px 6px; text-align: right; font-family: var(--mono); font-size: 16px; }
input.cell.is-right { border-color: var(--ok); background: var(--ok-soft); }
input.cell.is-close { border-color: var(--warn); background: var(--warn-soft); }
input.cell.is-wrong, input.cell.is-unread { border-color: var(--bad); background: var(--bad-soft); }
input.cell.is-own { border-color: var(--warn); border-style: dashed; }
.mk { display: inline-flex; align-items: baseline; justify-content: flex-start; min-width: 2.5em; margin-right: 0.2em; flex: none; font-weight: 800; padding-left: 3px; white-space: nowrap; }
.mk-right { color: var(--ok); } .mk-close, .mk-own { color: var(--warn); } .mk-wrong, .mk-unread { color: var(--bad); }
.mn { font-size: 0.8em; font-weight: 700; margin-left: 1px; }
.kv { font-family: var(--mono); }

/* feedback */
.fbwrap { margin: 6px 0; }
.fbl { margin: 4px 0; padding: 0 0 0 2.2em; max-width: 80ch; }
.fb { margin: 4px 0; padding: 6px 10px; border-radius: var(--r); background: var(--bad-soft); max-width: 80ch; }
.fbl .fb::marker { font-weight: 700; }
.fb.right { background: var(--ok-soft); }
.fb.close { background: var(--warn-soft); }
.fb.own { background: var(--paper); border: 1px dashed var(--warn); }
.fb.empty { background: var(--paper); border: 1px solid var(--line); }
.qfoot { margin-top: 6px; }
details.work { margin-top: 6px; }
.keyfig { padding: 4px 0 6px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.kpart { min-width: 0; }
.kh { font-weight: 700; margin: 10px 0 4px; }
.kq { display: none; }
.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin: 0 0 6px; max-width: 86ch; overflow-wrap: anywhere; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--ink); }
.confirm { margin: 0; flex-basis: 100%; padding: 10px; background: var(--warn-soft); border-radius: var(--r); }
.save-hint { margin: 0; color: var(--muted); flex-basis: 100%; }

/* print and share */
.share { margin: 0 0 22px; }
.print-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.print-row label { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; flex-wrap: wrap; max-width: 100%; }
.share-out label { display: grid; gap: 4px; font-weight: 600; }
.share-out input { min-height: 44px; padding: 6px 10px; width: 100%; }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 2px 0; }
.when { display: block; color: var(--muted); }
.hint { color: var(--muted); margin: 6px 0; }

/* the text below */
.content { max-width: 74ch; padding-bottom: 24px; }
.content h2 { font-size: 1.45rem; margin: 28px 0 8px; }
.content li { margin-bottom: 4px; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-of-type { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; padding: 6px 0; }
.faq p { margin: 0 0 12px; }
.sources { color: var(--muted); overflow-wrap: anywhere; }
footer { border-top: 1px solid var(--line); padding: 16px 0 28px; color: var(--muted); }
footer p { margin: 6px 0; }
.sb-more a { white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: min(92vw, 560px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r); opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 20; }
.toast.on { opacity: 1; }
.toast.top { bottom: auto; top: 16px; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.print-root { display: none; }

/* ---------- print ---------- */
@page { margin: 12mm; }
@media print {
  body { background: #fff; color: #000; font-size: 10.5pt; }
  main, footer, .toast, .skip { display: none !important; }
  .print-root { display: block; }
  .psheet, .pkey { break-after: page; }
  .pkey:last-child, .psheet:last-child { break-after: auto; }
  table.pt { width: 100%; border-collapse: collapse; }
  .pt > thead .prun { font-size: 9.5pt; color: #222; padding-bottom: 4pt; border-bottom: 0.5pt solid #888; }
  .psafe { display: block; font-weight: 700; color: #000; }
  .ph { display: flex; justify-content: space-between; align-items: baseline; gap: 6pt 12pt; flex-wrap: wrap; margin: 4pt 0; }
  .ph h2 { font-size: 15pt; margin: 0; }
  .pmeta { margin: 0; display: flex; gap: 12pt; flex-wrap: wrap; }
  .prules { margin: 0 0 4pt; padding-left: 14pt; font-size: 9.5pt; }
  .prules li { margin: 0 0 1pt; break-inside: avoid; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li, .pk > li { margin: 0 0 8pt; padding-top: 4pt; border-top: 1.2pt solid #000; }
  .pq > li { break-inside: avoid; }
  .kmain { break-inside: avoid; }
  .pq h3, .pk h3 { font-size: 12pt; margin: 0 0 3pt; break-after: avoid; }
  .scen { margin: 0 0 4pt; max-width: none; }
  .ptop, .groups, .kpart:not(.kmain) { break-inside: avoid; }
  .figs { gap: 4pt 14pt; margin: 0 0 4pt; flex-wrap: nowrap; align-items: flex-start; }
  .efig { flex: 0 0 52mm; width: 52mm; }
  svg.elem { width: 100%; max-width: none; }
  .sketch { flex: 1 1 auto; }
  .sk { height: 52mm; border: 0.75pt solid #000; background: linear-gradient(#000, #000) center / 100% 0.5pt no-repeat, linear-gradient(#000, #000) 30% center / 0.5pt 100% no-repeat; }
  .efig figcaption, .cfig figcaption { color: #222; font-size: 9.5pt; padding: 0; }
  .cfig { max-width: none; text-align: center; }
  .cfig svg.circ { width: 70%; margin: 0 auto; }
  .cfig figcaption { text-align: left; }
  svg text, svg .eal, svg .mla { fill: #000; }
  svg .mla2 { fill: #2d5a86; }
  .esq { fill: #fff; stroke: #000; } .ghost { stroke: #555; }
  .arr line, .mc, .dia { stroke: #000; } .arr path, .pd, .pc, .pp, .arch { fill: #000; }
  .eax, .ax, .cax line, .brk { stroke: #444; } .axh, .cax path { fill: #444; }
  .eax2, .earc, .arc { stroke: #000; }
  .dia2, .arc2 { stroke: #2d5a86; } .pd2, .arc2h { fill: #2d5a86; }
  .groups { grid-template-columns: repeat(4, 1fr); gap: 2pt 12pt; margin: 0 0 4pt; }
  .gh { margin: 2pt 0 0; font-size: 10pt; border-bottom: 0.75pt solid #000; }
  .arow { min-height: 0; padding: 3pt 0; border-bottom: 0; }
  .un { color: #222; min-width: 0; }
  .pblank { display: inline-block; border-bottom: 0.75pt solid #000; height: 14pt; vertical-align: bottom; }
  .kq { display: inline; }
  .kh { margin: 3pt 0 1pt; font-size: 10.5pt; break-after: avoid; }
  .steps { font-size: 10pt; }
  .steps li { margin: 0.5pt 0; max-width: none; break-inside: avoid; }
  .pq > li:last-child, .pk > li:last-child, .kpart:last-child, .steps li:last-child { margin-bottom: 0; padding-bottom: 0; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
