:root {
  --paper: #f5f0e6;
  --panel: #fffcf5;
  --ink: #1e1a16;
  --ink-2: #5d554b;
  --line: #d9d0c0;
  --accent: #8a2f1d;
  --accent-ink: #fffaf2;
  --warn-bg: #f9e4d4;
  --warn-ink: #7c2d12;
  --note-bg: #ece6d6;
  --note-ink: #4d4536;
  --ok-ink: #24613e;
  --bar: #8a2f1d;
  --display: "Fraunces", Georgia, serif;
  --body: "Instrument Sans", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171411;
    --panel: #221e1a;
    --ink: #f2ebdf;
    --ink-2: #b3a999;
    --line: #3d362e;
    --accent: #e08a68;
    --accent-ink: #1c120c;
    --warn-bg: #452418;
    --warn-ink: #f7c7ae;
    --note-bg: #2f2a23;
    --note-ink: #d6ccba;
    --ok-ink: #8bd0a6;
    --bar: #e08a68;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--body); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 24px 64px; outline: none; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(32px, 5vw, 52px); letter-spacing: -.01em; }
h2 { font-size: 26px; }
h3 { font-size: 19px; }
code { background: var(--note-bg); padding: 2px 5px; border-radius: 4px; font-size: .9em; overflow-wrap: anywhere; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.brand { font: 700 21px var(--display); color: var(--ink); text-decoration: none; }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; padding: 4px 0; border-bottom: 2px solid transparent; }
.topbar nav a.active { color: var(--ink); border-color: var(--accent); }
.sitefoot { padding: 18px 24px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 12.5px; text-align: center; }
.sitefoot a { color: inherit; }

button, .btn { font: 600 15px var(--body); padding: 9px 15px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--ink-2); }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--warn-ink); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; clip-path: inset(50%); border: 0; }
.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; font: 16px var(--body); padding: 9px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
textarea { resize: vertical; min-height: 92px; line-height: 1.4; }
.row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }

/* Home */
.hero { padding: 26px 0 30px; max-width: 760px; }
.hero p { font-size: 19px; color: var(--ink-2); margin: 14px 0 0; }
.paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.path { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 10px; transition: transform .12s, border-color .12s; }
.path:hover { transform: translateY(-2px); border-color: var(--accent); }
.path p { margin: 0; color: var(--ink-2); flex: 1; }
.path .go { color: var(--accent); font-weight: 600; }
.section-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin: 42px 0 14px; }
.list { display: grid; gap: 8px; }
.proj { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.proj a { font-weight: 600; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Project header */
.phead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.phead h1 { font-size: clamp(26px, 4vw, 38px); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 26px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-color: var(--accent); }

/* Learn and library */
.reader { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 36px; align-items: start; }
.toc { position: sticky; top: 16px; display: grid; gap: 2px; }
.toc h3 { font: 600 12px var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin: 14px 0 4px; }
.toc a { display: flex; gap: 8px; padding: 6px 9px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 15px; }
.toc a.active { background: var(--note-bg); font-weight: 600; }
.toc .tick { width: 16px; flex: none; color: var(--ok-ink); font-weight: 700; }
.article { max-width: 720px; }
.article h3 { margin: 28px 0 8px; }
.article p, .article li { font-size: 17px; }
.article table { font-size: 15px; }
.aside { color: var(--ink-2); border-left: 3px solid var(--line); padding-left: 14px; font-size: 15px !important; }
.try { background: var(--note-bg); color: var(--note-ink); padding: 14px 16px; border-radius: 8px; }
.try::before { content: "Try this: "; font-weight: 700; }
.table-wrap { overflow-x: auto; margin: 12px 0; }
table.plain { border-collapse: collapse; width: 100%; margin: 12px 0; }
table.plain th { text-align: left; font-weight: 600; font-size: 13px; color: var(--ink-2); }
table.plain th, table.plain td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.num td:not(:first-child), table.num th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.article-nav { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }

/* Card grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.grid a, .pack > * { display: block; text-decoration: none; color: inherit; }
.grid canvas, .pack canvas { width: 100%; height: auto; display: block; border-radius: 4.5%/3.2%; aspect-ratio: 750/1050; background: var(--line); }
.grid a:hover canvas { outline: 2px solid var(--accent); outline-offset: 2px; }
.flag { display: block; font-size: 12.5px; margin-top: 5px; color: var(--ink-2); }
.flag.warn { color: var(--warn-ink); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; justify-content: space-between; margin-bottom: 16px; }
.toolbar label { margin: 0; }
.empty { border: 1.5px dashed var(--line); border-radius: 12px; padding: 34px; text-align: center; color: var(--ink-2); }

/* Builder */
.builder { display: grid; grid-template-columns: minmax(280px, 400px) minmax(280px, 420px) minmax(240px, 1fr); gap: 26px; align-items: start; }
.preview-col { position: sticky; top: 16px; }
.preview-col canvas { width: 100%; height: auto; display: block; border-radius: 4.5%/3.2%; box-shadow: 0 10px 30px rgba(0,0,0,.28); }
.symbols { display: flex; flex-wrap: wrap; gap: 4px; margin: -4px 0 12px; }
.sym { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 1px solid rgba(0,0,0,.5); font: 700 12px "Cinzel", serif; color: #1a1612; }
.sym:hover { filter: brightness(1.08); border-color: #000; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.panel h3 { margin-bottom: 8px; }
.issue { padding: 10px 12px; border-radius: 8px; margin-top: 8px; font-size: 14px; }
.issue strong { display: block; }
.issue.warn { background: var(--warn-bg); color: var(--warn-ink); }
.issue.note { background: var(--note-bg); color: var(--note-ink); }
.issue a { color: inherit; font-weight: 600; }
.ok { color: var(--ok-ink); font-weight: 600; }
/* Stops match the marker in checksHTML: delta -2 sits at 27.5%, +2 at 72.5%, +4 at 95%. */
.meter { position: relative; height: 10px; border-radius: 5px; margin: 28px 0 6px; background: linear-gradient(90deg, var(--line) 0 27.5%, var(--ok-ink) 27.5% 72.5%, var(--line) 72.5% 95%, var(--accent) 95%); }
.meter i { position: absolute; top: -5px; width: 4px; height: 20px; border-radius: 2px; background: var(--ink); box-shadow: 0 0 0 2px var(--panel); transform: translateX(-2px); }
.meter-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

/* Review */
.review { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.review .wide { grid-column: 1 / -1; }
.hbar { display: grid; grid-template-columns: 90px 1fr 70px; gap: 8px; align-items: center; font-size: 14px; margin-bottom: 7px; }
.hbar .track { height: 10px; background: var(--note-bg); border-radius: 5px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.curve { display: flex; align-items: flex-end; gap: 6px; height: 140px; border-bottom: 1px solid var(--line); margin-top: 12px; }
.curve div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: 12.5px; }
.curve b { display: block; width: 70%; max-width: 34px; min-height: 1px; background: var(--bar); border-radius: 4px 4px 0 0; margin-top: 3px; }
.curve-x { display: flex; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.curve-x span { flex: 1; text-align: center; }
.pack { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.inline { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.inline input { margin: 0; }

/* Build sections */
.subnav { display: flex; gap: 6px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 2px; }
.subnav a { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.subnav a.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip { display: inline-block; width: 15px; height: 15px; border-radius: 50%; border: 1px solid rgba(0,0,0,.45); vertical-align: -2px; flex: none; }
button.link { background: none; border: 0; padding: 0; font: 600 13px var(--body); color: inherit; text-decoration: underline; }
button.link.danger { color: var(--warn-ink); }
.empty .actions { margin: 14px 0; }

table.skeleton { min-width: 860px; }
table.skeleton td { vertical-align: middle; padding: 5px 6px; }
table.skeleton input, table.skeleton select { margin: 0; padding: 6px 8px; font-size: 14px; }
table.skeleton input.mv { width: 62px; }
table.skeleton tr.group th { font: 700 16px var(--display); color: var(--ink); padding-top: 18px; }
table.skeleton tr.group .muted { font: 500 13px var(--body); margin-left: 6px; }
table.skeleton tr.done { background: var(--note-bg); }
.slot-who { display: flex; gap: 6px; align-items: center; min-width: 250px; }
.slot-card { min-width: 190px; font-size: 14px; }
.slot-card button { font-size: 13px; padding: 5px 9px; }
.slot-card .link-select { display: inline-block; width: auto; max-width: 130px; margin-left: 4px; }
.slot-card button.link { padding: 0; margin-left: 6px; }
.slot-banner { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; background: var(--note-bg); color: var(--note-ink); padding: 11px 15px; border-radius: 10px; margin-bottom: 16px; }

.arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; align-items: start; }
.arch-grid .panel { margin: 0; }
.arch-grid h4 { font: 600 13px var(--body); margin: 12px 0 4px; }
.gaps { margin: 0; padding-left: 18px; color: var(--note-ink); }
.sugg { list-style: none; padding: 0; margin: 4px 0 0; }
.sugg li { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.sugg button { padding: 4px 10px; font-size: 13px; flex: none; }
.arch-tags { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.arch-tags legend { font-weight: 600; font-size: 13.5px; padding: 0 4px; }
.arch-tag { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-weight: 500; font-size: 13px; padding: 3px 7px; border: 1px solid transparent; border-radius: 6px; }
.arch-tag input { width: auto; margin: 0; }
.arch-tag.suggested { border: 1.5px dashed var(--accent); }

.pie-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pie-notes label { margin: 0; }
.pie-notes textarea { min-height: 76px; font-size: 14.5px; }
.pie-table th:not(:first-child), .pie-cell { text-align: center; }
.pie-cell .base { color: var(--ink-2); }
.pie-cell.bent { background: var(--warn-bg); color: var(--warn-ink); }
.pie-cell.approved { color: var(--ok-ink); }

.saved-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 320px; overflow-y: auto; }
.saved-list li { border-top: 1px solid var(--line); padding: 8px 0; }
.saved-list .actions { justify-content: space-between; margin-top: 4px; }
.saved-list button { font-size: 13px; padding: 4px 10px; }
.saved-text { white-space: pre-wrap; font-size: 15px; overflow-wrap: anywhere; }
#saved-panel .actions button { font-size: 13px; padding: 6px 10px; }

/* Special card types */
[hidden] { display: none !important; }
.layout-guide { background: var(--note-bg); color: var(--note-ink); padding: 10px 13px; border-radius: 8px; margin: -4px 0 14px; font-size: 14px; }
.layout-guide p { margin: 3px 0 0; }
.layout-guide a { color: inherit; font-weight: 600; }
.face-title { margin-bottom: 10px; }
.special-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0 0 12px; min-width: 0; }
.special-box legend { font: 700 16px var(--display); padding: 0 5px; }
.ability-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 8px; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 10px; }
.ability-row label { margin: 0; }
.ability-row .ab-text { grid-column: 2; }
.ability-row .ab-pt { grid-column: 1; grid-row: 2; }
.ability-row button.link { grid-column: 3; grid-row: 1; margin-top: 22px; font-size: 12.5px; }
.face-toggle { display: flex; gap: 4px; justify-content: center; margin-bottom: 10px; }
.face-toggle button { font-size: 13.5px; padding: 5px 16px; }
.face-toggle button.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* Accounts */
.account { display: inline-flex; align-items: center; gap: 10px; }
.topbar nav { align-items: center; }
.topbar nav .signin { color: var(--ink); padding: 5px 11px; font-size: 14px; border-color: var(--line); }
.account-link { color: var(--ink) !important; font-weight: 600; }
.sync { font-size: 12.5px; color: var(--ink-2); }
.sync.error, .sync.signin { color: var(--warn-ink); font-weight: 600; }
.conflict { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; background: var(--warn-bg); color: var(--warn-ink); padding: 11px 15px; border-radius: 10px; margin-bottom: 16px; }

/* Quiz */
.quiz { max-width: 720px; margin: 0 auto; }
.quiz-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.quiz-top a { text-decoration: none; }
.quiz-track { height: 8px; background: var(--note-bg); border-radius: 4px; overflow: hidden; margin-bottom: 26px; }
.quiz-track span { display: block; height: 100%; background: var(--bar); transition: width .2s; }
.quiz-q { font-size: clamp(21px, 3vw, 27px); margin-bottom: 20px; }
.quiz-options { display: grid; gap: 10px; }
.option { justify-content: flex-start; align-items: flex-start; text-align: left; font-weight: 500; font-size: 16px; line-height: 1.4; padding: 13px 14px; gap: 12px; }
.option:disabled { cursor: default; opacity: 1; color: var(--ink-2); }
.option kbd { flex: none; width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--line); display: grid; place-items: center; font: 600 12px var(--body); color: var(--ink-2); }
.option .mark { display: block; font-size: 13px; font-weight: 600; margin-top: 3px; }
.option.right { border: 2px solid var(--ok-ink); color: var(--ink); }
.option.right .mark { color: var(--ok-ink); }
.option.wrong { border: 2px solid var(--warn-ink); background: var(--warn-bg); color: var(--warn-ink); }
.quiz-why { margin-top: 16px; padding: 13px 15px; border-radius: 8px; background: var(--note-bg); color: var(--note-ink); }

/* Print */
.print-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.print-sheet canvas { width: 100%; height: auto; display: block; aspect-ratio: 750/1050; }
@media print {
  @page { margin: 0.4in; }
  body { background: #fff; }
  .topbar, .sitefoot, .tabs, .phead, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-sheet { display: flex; flex-wrap: wrap; gap: 0; }
  .print-sheet canvas { width: 2.5in; height: 3.5in; break-inside: avoid; border-radius: 0; }
}

.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }

@media (max-width: 1100px) {
  .builder { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .builder .check-col { grid-column: 1 / -1; }
}
/* Real cards, from Scryfall. Images are shown whole and unaltered, as Scryfall's rules ask. */
.real-sec { margin-top: 12px; }
.real-sec:first-child { margin-top: 0; }
.real-sec h4 { font: 600 13px var(--body); text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); margin: 0 0 6px; }
#real-body.busy { opacity: .6; transition: opacity .2s; }
.real-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.real-grid a { display: block; border-radius: 4.5%/3.2%; }
.real-grid img { width: 100%; height: auto; display: block; aspect-ratio: 488/680; border-radius: 4.5%/3.2%; background: var(--line); }
.real-lines { margin: 0; padding-left: 18px; }
.real-lines li { margin-top: 4px; }
.real-credit { margin: 12px 0 0; }
.real-off { margin-top: 10px; }
a.real-card { text-decoration-style: dotted; text-underline-offset: 3px; }
.card-pop { position: fixed; z-index: 50; width: 250px; padding: 0; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); overflow: hidden; }
.card-pop img { width: 100%; height: auto; display: block; aspect-ratio: 488/680; background: var(--line); }
.card-pop span { display: block; font-size: 11.5px; color: var(--ink-2); padding: 4px 8px; }
td small.share { display: block; font-size: 11px; color: var(--ink-2); line-height: 1.1; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 18px; }
.compare-grid caption { text-align: left; font-weight: 600; font-size: 14px; padding-bottom: 4px; }
td.differs { background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
@media (max-width: 760px) {
  main { padding: 20px 16px 48px; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .brand { font-size: 18px; }
  .topbar { flex-wrap: wrap; }
  .topbar nav { gap: 12px; flex-wrap: wrap; }
  .topbar nav a { font-size: 14.5px; }
  .reader { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .toc { position: static; }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; order: -1; max-width: 340px; margin: 0 auto; width: 100%; }
  .review { grid-template-columns: minmax(0, 1fr); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
