/* PMT web app styles, taken from the prototype (prototype/ui.template.html). Fonts are
   self-hosted: see fonts.css, made by web/tools/fetch_fonts.py. */
/* Layout: app shell — sticky top bar, period-grouped side nav, one working pane; nav becomes a scroller on phones */
:root {
  --bg: #F4F6F3; --surface: #FFFFFF; --surface-2: #ECF0EB; --line: #D7DDD5; --ink: #17201B; --muted: #57645D;
  --accent: #1D6B56; --accent-ink: #FFFFFF; --accent-soft: #DCEDE5;
  --cash: #8C5410; --cash-soft: #F7E8D3; --swap: #2A5B9C; --swap-soft: #E1EAF7;
  --star: #A86A00; --warn: #965400; --warn-soft: #FFF0D6; --bad: #B0281F; --bad-soft: #FBE4E1;
  --f-display: "Bricolage Grotesque", "Space Grotesk", system-ui, sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #101412; --surface: #171C19; --surface-2: #1F2622; --line: #2D3631; --ink: #E3EAE6; --muted: #98A59E;
  --accent: #5BC09F; --accent-ink: #0B1C16; --accent-soft: #1B3A30;
  --cash: #E3A85E; --cash-soft: #3A2A15; --swap: #8DB5EB; --swap-soft: #1B2A3E;
  --star: #F5C04A; --warn: #F1B65C; --warn-soft: #382A12; --bad: #F28A80; --bad-soft: #3C1D1A; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #101412; --surface: #171C19; --surface-2: #1F2622; --line: #2D3631; --ink: #E3EAE6; --muted: #98A59E;
  --accent: #5BC09F; --accent-ink: #0B1C16; --accent-soft: #1B3A30;
  --cash: #E3A85E; --cash-soft: #3A2A15; --swap: #8DB5EB; --swap-soft: #1B2A3E;
  --star: #F5C04A; --warn: #F1B65C; --warn-soft: #382A12; --bad: #F28A80; --bad-soft: #3C1D1A; color-scheme: dark; }

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; line-height: 1.15; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; font-family: var(--f-body); font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono, code { font-family: var(--f-mono); font-size: 0.86em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.eyebrow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

/* prototype ribbon + top bar */
.proto { background: var(--ink); color: var(--bg); font-size: 0.8rem; padding-block: 6px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.proto b { font-weight: 600; }
.proto button { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--f-display); font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.brand svg { color: var(--accent); }
.tradename { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.tradename strong { font-weight: 600; }
.who { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 0.86rem; }
.howto { font-size: 0.86rem; font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap; }
.howto:hover { text-decoration: underline; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 0.75rem; }

.rep { display: inline-flex; align-items: center; gap: 2px; font-size: 0.78rem; font-weight: 600; color: var(--star); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rep.new { color: var(--muted); font-weight: 500; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 500;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.cash { background: var(--cash-soft); color: var(--cash); border-color: transparent; }
.chip.swap { background: var(--swap-soft); color: var(--swap); border-color: transparent; }
.chip.bargain { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

/* shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 0; min-height: 70vh; }
.shell.solo { grid-template-columns: minmax(0, 1fr); }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; padding-block: 14px 22px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.foot a { color: inherit; }
.tradecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tradecard { gap: 10px; }
.tradecard h3 { font-size: 1.1rem; }
.tradecard .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.dates { display: grid; grid-template-columns: max-content max-content; gap: 3px 14px; margin: 0; font-size: 0.86rem; }
.dates dt { color: var(--muted); white-space: nowrap; }
.dates dd { margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.terms { max-width: 720px; display: flex; flex-direction: column; gap: 18px; }
.terms ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.side { border-right: 1px solid var(--line); padding: 18px 12px 18px max(12px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 16px; }
.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navgroup .eyebrow { padding: 0 10px 4px; display: flex; justify-content: space-between; gap: 6px; }
.navgroup .eyebrow span:last-child { text-transform: none; letter-spacing: 0; font-weight: 500; }
.side a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--surface-2); }
.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.side a .count { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
main { padding-block: 24px 64px; padding-left: 28px; padding-right: max(16px, env(safe-area-inset-right, 0px)); min-width: 0; display: flex; flex-direction: column; gap: 20px; max-width: 1180px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; overflow-x: auto; gap: 8px; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
  .navgroup { flex-direction: row; gap: 2px; }
  .navgroup .eyebrow { display: none; }
  .side a { white-space: nowrap; }
  main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-top: 18px; }
  .who .label { display: none; }
}

/* page parts */
.pagehead { display: flex; flex-direction: column; gap: 6px; }
.pagehead .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lede { color: var(--muted); max-width: 70ch; text-wrap: pretty; }
.lede.wide { max-width: none; }
.guide-host { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.lede .line { display: block; text-wrap: balance; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel.flat { background: transparent; border-style: dashed; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.cols-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .cols-2-1 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.note { padding: 10px 12px; border-radius: 6px; background: var(--surface-2); color: var(--ink); font-size: 0.88rem; display: flex; gap: 8px; align-items: flex-start; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.ok { background: var(--accent-soft); color: var(--accent); }
.note.cash { background: var(--cash-soft); color: var(--cash); }
.note > b:first-child { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; width: 100%; }

/* form */
label.field, .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span:first-child { font-weight: 600; font-size: 0.88rem; }
.field .hint { color: var(--muted); font-size: 0.8rem; }
.field .err { color: var(--bad); font-size: 0.8rem; }
input[type=text], input[type=url], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-width: 0; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.choice { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.choice input { margin-top: 3px; accent-color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.cardopt { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; background: var(--surface); }
.cardopt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.cardopt input { position: absolute; opacity: 0; pointer-events: none; }
.cardopt strong { font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 14px; cursor: pointer; font-weight: 500; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { padding: 3px 9px; font-size: 0.82rem; }
.btn.ghost { border-color: transparent; background: none; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.iconbtn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 4px; font-size: 1rem; line-height: 1; }
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tr.dim td { opacity: 0.55; }
.code { font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.title { font-weight: 600; }

/* puzzle card */
.pz { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start; }
.thumb { position: relative; width: 64px; height: 64px; flex: none; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); overflow: hidden; font-size: 0.78rem; }
.thumb.sm { width: 44px; height: 44px; }
.thumb.xs { width: 32px; height: 32px; border-radius: 4px; }
a.thumb:hover { border-color: var(--accent); }
.thumb .more { position: absolute; right: 2px; bottom: 2px; background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 0.68rem; font-weight: 600; padding: 0 4px; border-radius: 4px; }
.pz.sm { grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: center; }
td .pz.sm { grid-template-columns: 44px minmax(150px, 1fr); }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.items li { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start; }
.items li + li { border-top: 1px solid var(--line); padding-top: 12px; }
.item-form { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin: 0; min-inline-size: 0; display: flex; flex-direction: column; gap: 10px; }
#entry-form .seg { flex-wrap: wrap; max-width: 100%; }
#entry-form .seg button { padding: 6px 10px; }
.item-form legend { font-weight: 600; padding: 0 4px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; font-size: 0.86rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pblink { font-family: var(--f-mono); font-size: 0.78rem; color: var(--accent); overflow-wrap: anywhere; }
a.pblink:hover { text-decoration: underline; }

/* overview */
.timeline { display: grid; grid-template-columns: 8fr 7fr 7fr 4fr 4fr; gap: 3px; }
.timeline div { padding: 10px 10px 8px; background: var(--surface-2); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.timeline div:first-child { border-radius: 6px 0 0 6px; } .timeline div:last-child { border-radius: 0 6px 6px 0; }
.timeline div.now { background: var(--accent-soft); color: var(--accent); }
.timeline strong { font-size: 0.86rem; }
.timeline span { font-size: 0.76rem; color: var(--muted); }
@media (max-width: 640px) { .timeline { grid-template-columns: 1fr 1fr; } .timeline div { border-radius: 6px !important; } }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.checklist li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.tick { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tick.done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tick.todo { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--f-display); font-size: 1.5rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: 0.8rem; color: var(--muted); }

/* wishlist */
.wl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wl li { display: grid; grid-template-columns: 22px 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.wl li.dragging { opacity: 0.4; }
.wl li.over { border-color: var(--accent); }
.handle { cursor: grab; color: var(--muted); user-select: none; text-align: center; font-size: 1.1rem; }
.rank { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.rank b { font-family: var(--f-display); font-size: 1.15rem; }
.rank span { font-size: 0.7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.wl .bidcell { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.wl select { width: auto; }
@media (max-width: 640px) { .wl li { grid-template-columns: 22px 36px minmax(0, 1fr); } .wl .bidcell { grid-column: 2 / -1; justify-content: flex-start; } }

/* matrix */
.matrix th.colh { white-space: normal; min-width: 92px; max-width: 120px; text-transform: none; letter-spacing: 0; font-size: 0.78rem; vertical-align: bottom; color: var(--ink); }
.matrix th.colh .code { display: block; }
.matrix th .thumb { margin-bottom: 4px; }
.matrix th.rowh { background: var(--surface); text-transform: none; letter-spacing: 0; font-size: 0.86rem; color: var(--ink); white-space: normal; min-width: 200px; position: sticky; left: 0; z-index: 1; border-right: 1px solid var(--line); }
.matrix td { text-align: center; vertical-align: middle; }
.matrix td input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.matrix tr.empty th.rowh { box-shadow: inset 3px 0 0 var(--warn); }
.matrix td.on { background: var(--accent-soft); }
.matrix td.on.over { background: var(--warn-soft); box-shadow: inset 0 0 0 2px var(--warn); }
.note .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* results */
.loop { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.loop:last-child { border-bottom: 0; }
.mv { display: inline-flex; gap: 6px; align-items: center; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); font-size: 0.82rem; }
.mv.cash { background: var(--cash-soft); color: var(--cash); }
.arrow { color: var(--muted); }
.big { font-family: var(--f-display); font-size: 2rem; font-variant-numeric: tabular-nums; line-height: 1; }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.dl button { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); cursor: pointer; }
.dl button:hover { border-color: var(--accent); }
.dl button strong { font-family: var(--f-mono); font-size: 0.82rem; font-weight: 600; }
.dl button span { font-size: 0.8rem; color: var(--muted); }
.outcome { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.outcome li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.outcome li:last-child { border-bottom: 0; }

/* progress */
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width 0.4s ease; }
.stage { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; }

/* modal + toast */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 10px; border: 1px solid var(--line); width: min(760px, 100%); max-height: 85vh; display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.modal pre { margin: 0; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: 6px; font-family: var(--f-mono); font-size: 0.78rem; flex: 1; min-height: 120px; white-space: pre; }
.toasts { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 0.88rem; max-width: 360px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.2); }

/* sign-in */
.signin { max-width: 460px; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 18px; }
.discord { background: #5865F2; color: #fff; border: 0; border-radius: 6px; padding: 11px 16px; font-weight: 600; cursor: pointer; display: flex; justify-content: center; gap: 8px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: flex; gap: 10px; align-items: center; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
