/* One stylesheet. One card style, one primary button per view. Phone (390 px) and desktop (1440 px) are both first-class:
   44 px tap targets, AA contrast, labels wrap instead of clipping, nothing scrolls sideways. Brand colors: /brand/theme.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--page); overflow-wrap: anywhere; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.25; }
h2 { font-size: 1.15rem; line-height: 1.3; }
h3 { font-size: 1rem; line-height: 1.35; }
a { color: var(--brand); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden, [hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.top { background: #fff; border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-top: 8px; padding-bottom: 8px; }
.logo { display: inline-flex; align-items: center; min-height: 44px; }
.logo img { height: 28px; width: auto; display: block; }
.top .spacer { flex: 1 1 auto; }
.whoami { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; min-height: 44px; font-weight: 600; }
.whoami .place { min-width: 0; }
.chip.role { background: var(--brand-soft); color: var(--brand-ink); }
@media (max-width: 767px) { .whoami { order: 5; flex-basis: 100%; min-height: 0; } .nav { order: 6; } }
.nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600; }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }
.nav .sep { flex-basis: 100%; height: 0; }
.nav .label { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 4px 8px 12px; color: var(--muted); font-size: .875rem; font-weight: 600; }
main.wrap { padding-top: 20px; padding-bottom: 48px; display: grid; gap: 16px; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.head > div { min-width: 0; flex: 1 1 240px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.grid3 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: repeat(3, 1fr); } }

.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card > .head h2 { flex: 1 1 auto; }
.card.flat { box-shadow: none; }
.notice { border-left: 4px solid var(--brand); }
.notice.warn { border-left-color: #b45309; }
.notice.good { border-left-color: #15803d; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 8px 16px; border-radius: 8px; border: 1px solid #6b7280; background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; }
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-danger { border-color: #b91c1c; color: #991b1b; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--brand); padding-left: 8px; padding-right: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; }

label { font-weight: 600; display: block; }
.field { display: grid; gap: 4px; min-width: 0; }
.hint { color: var(--muted); font-size: .875rem; font-weight: 400; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=month], input[type=url], input[type=tel], input[type=file], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #6b7280; border-radius: 8px; font: inherit; color: var(--ink); background: #fff; }
textarea { min-height: 96px; resize: vertical; }
.choice { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-weight: 500; cursor: pointer; }
.choice input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.choices { display: grid; gap: 8px; }
@media (min-width: 768px) { .choices.wide { grid-template-columns: 1fr 1fr; } }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 4px; }

.chip { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 600; background: #e5e7eb; color: #1f2937; white-space: normal; }
.chip.good, .chip.hard { background: #dcfce7; color: #14532d; }
.chip.bad { background: #fee2e2; color: #7f1d1d; }
.chip.warn, .chip.soft { background: #fef3c7; color: #713f12; }
.chip.dark { background: #1f2937; color: #fff; }
.chip.info { background: #dbeafe; color: #1e3a8a; }
.chip.assumed { background: #fff; border: 1px dashed #6b7280; }

.flash { background: #dcfce7; color: #14532d; border: 1px solid #86efac; border-radius: 8px; padding: 10px 14px; font-weight: 600; }
.formerror { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; border-radius: 8px; padding: 10px 14px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: .875rem; color: var(--muted); border-top: 0; }
.tablewrap { overflow-x: auto; }
@media (max-width: 767px) {
  table.stacked thead { display: none; }
  table.stacked tr { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
  table.stacked td { border: 0; padding: 2px 0; }
  table.stacked td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .875rem; font-weight: 600; }
}

.linkbox { display: grid; gap: 8px; }
.linkbox input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875rem; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; color: var(--ink); }
dialog::backdrop { background: rgba(17, 24, 39, .55); }
dialog form, dialog .stack { display: grid; gap: 12px; }
.center { max-width: 460px; margin: 6vh auto 0; }
.foot { color: var(--muted); font-size: .875rem; text-align: center; padding: 24px 16px; }

progress { background: #fef3c7; color: #713f12; }
.chip.rule { background: #1f2937; color: #fff; }
.chip.proven { background: #dbeafe; color: #1e3a8a; }
.chip.code { background: #fff; border: 1px solid #6b7280; }

.flash { background: #dcfce7; color: #14532d; border: 1px solid #86efac; border-radius: 8px; padding: 10px 14px; font-weight: 600; }
.formerror { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; border-radius: 8px; padding: 10px 14px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: .875rem; color: var(--muted); border-top: 0; }
.tablewrap { overflow-x: auto; }
@media (max-width: 767px) {
  table.stacked thead { display: none; }
  table.stacked tr { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
  table.stacked td { border: 0; padding: 2px 0; }
  table.stacked td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .875rem; font-weight: 600; }
}

.linkbox { display: grid; gap: 8px; }
.linkbox input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875rem; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; color: var(--ink); }
dialog::backdrop { background: rgba(17, 24, 39, .55); }
dialog form, dialog .stack { display: grid; gap: 12px; }
.center { max-width: 460px; margin: 6vh auto 0; }
.foot { color: var(--muted); font-size: .875rem; text-align: center; padding: 24px 16px; }

/* The machine check: who set a result, the proof that opens in place, the Run Check card. */
.chip.machine { background: #e0e7ff; color: #312e81; }
.setby { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 4px 0; }
.differs { border-left: 4px solid #b45309; padding-left: 8px; }
details.proof > summary { cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; color: var(--brand); font-weight: 600; }
.proof-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.proof-list a { overflow-wrap: anywhere; }
ul.sum { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
progress { width: 100%; height: 12px; accent-color: var(--brand); }

.warnline { background: #fef3c7; color: #713f12; border-radius: 8px; padding: 8px 12px; font-weight: 600; }

/* Sign in and setup */
.narrow { max-width: 480px; width: 100%; margin: 4vh auto 0; }
.pw { display: flex; gap: 8px; }
.pw input { flex: 1 1 auto; min-width: 0; width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #6b7280; border-radius: 8px; font: inherit; }
.eye { flex: none; padding: 8px; }
.eye .slash { display: none; }
.eye[aria-pressed="true"] .slash { display: inline; }
.qr img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9375rem; background: var(--page); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; color: var(--brand); font-weight: 600; }

/* One way to show cost, locks, working and failed */
.cost { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 700; background: #111827; color: #fff; }
.state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.state::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #6b7280; flex: none; }
.state.working::before { background: #b45309; animation: pulse 1.2s ease-in-out infinite; }
.state.done::before { background: #15803d; }
.state.failed::before { background: #b91c1c; }
.state.locked::before { background: #111827; border-radius: 2px; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .state.working::before { animation: none; } }

/* How a number was known */
.known { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.known .k { display: inline-flex; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.known .hard { background: #dcfce7; color: #14532d; }
.known .soft { background: #fef3c7; color: #713f12; }
.known .assumed { background: #fff; color: #374151; border: 1px dashed #6b7280; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.25rem; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.tile { background: var(--page); border-radius: 10px; padding: 12px; display: grid; gap: 4px; min-width: 0; }
.tile .num { font-size: 1.6rem; }

/* Rows that open show a chevron */
a.rowlink { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
a.rowlink:first-child { border-top: 0; }
a.rowlink > .grow, .grow { flex: 1 1 auto; min-width: 0; }
a.rowlink::after { content: "›"; font-size: 1.5rem; line-height: 1; color: var(--muted); flex: none; }
.list { display: grid; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--muted); font-size: .875rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.toolbar .field { flex: 1 1 160px; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; z-index: 2; }
input[type=password], input[type=time], input[type=search] { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #6b7280; border-radius: 8px; font: inherit; color: var(--ink); background: #fff; }
input[type=checkbox].pick { width: 24px; height: 24px; accent-color: var(--brand); }
label.pickbox { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.why { color: var(--ink); }
.rankno { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3ch; display: inline-block; }
.lead { border-top: 1px solid var(--line); padding: 10px 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; }
.lead:first-child { border-top: 0; }
.lead .body { min-width: 0; display: grid; gap: 4px; }
.lead .title { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.lead .title a { font-weight: 700; color: var(--ink); }
.dmcard { display: grid; gap: 12px; }
.dmcard textarea { min-height: 150px; }
.banner { background: #1f2937; color: #fff; border-radius: 10px; padding: 12px 14px; font-weight: 600; }
.undo { position: sticky; bottom: 12px; background: #111827; color: #fff; border-radius: 10px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; z-index: 3; }
.undo .btn { background: #fff; }
.funnel { display: grid; gap: 8px; }
.funnel .step { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 10px 12px; background: var(--page); border-radius: 10px; }
.funnel .step .top { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; justify-content: space-between; background: transparent; border: 0; }
.funnel .def { color: var(--muted); font-size: .875rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 2px 10px; border-radius: 999px; background: #e5e7eb; font-size: .875rem; font-weight: 600; }
.tag.locked { background: #111827; color: #fff; }
.tag button { border: 0; background: transparent; font: inherit; cursor: pointer; min-width: 28px; min-height: 28px; color: inherit; }

