:root { --fg:#1d1f23; --muted:#6b7280; --line:#e5e7eb; --bg:#fafafa; --accent:#2457c5; --hi:#0f7b3f; --mid:#9a6b00; --lo:#9ca3af; }
@media (prefers-color-scheme: dark) { :root { --fg:#e6e6e6; --muted:#9aa0a6; --line:#2d3036; --bg:#15171a; --accent:#7aa2ff; --hi:#4ade80; --mid:#facc15; --lo:#6b7280; } }
* { box-sizing: border-box; }
body { margin:0; font:14px/1.45 system-ui, -apple-system, Segoe UI, sans-serif; color:var(--fg); background:var(--bg); }
header { display:flex; gap:24px; align-items:baseline; padding:12px 24px; border-bottom:1px solid var(--line); }
.brand { font-weight:700; font-size:16px; color:var(--fg); text-decoration:none; }
nav a { margin-right:16px; }
.meta { margin-left:14px; color:var(--muted); font-size:12px; }

/* hover card image popover */
#cardpop { position:fixed; z-index:50; display:none; pointer-events:none; }
#cardpop img { width:240px; display:block; border-radius:12px; box-shadow:0 10px 30px rgba(0,0,0,0.55); }

/* card page header image */
.cardhead { display:flex; gap:22px; align-items:flex-start; flex-wrap:wrap; }
.cardimg { width:240px; border-radius:12px; box-shadow:0 6px 20px rgba(0,0,0,0.35); }
.cardhead > div { flex:1; min-width:280px; }

/* header card search + typeahead */
.cardsearch { position:relative; margin-left:auto; }
.cardsearch input { width:190px; padding:5px 9px; border:1px solid var(--line); border-radius:6px;
                    background:transparent; color:inherit; font-size:13px; }
.cardsearch input:focus { outline:none; border-color:var(--accent); }
.suggest-box { position:absolute; top:calc(100% + 3px); left:0; right:0; z-index:30;
               background:var(--bg); border:1px solid var(--line); border-radius:6px; overflow:hidden;
               box-shadow:0 6px 20px rgba(0,0,0,0.25); }
.suggest-box:empty { display:none; }
.suggest-box a { display:flex; justify-content:space-between; gap:10px; padding:5px 9px; color:var(--fg); font-size:13px; }
.suggest-box a:hover { background:rgba(127,127,127,0.14); text-decoration:none; }
main { padding:20px 24px; max-width:1400px; }
a { color:var(--accent); text-decoration:none; } a:hover { text-decoration:underline; }
a.card { color:inherit; border-bottom:1px dotted var(--muted); }
h1 { font-size:20px; margin:0 0 4px; } h2 { font-size:16px; margin:24px 0 8px; } h3 { font-size:14px; margin:18px 0 6px; }
h4 { font-size:13px; margin:16px 0 5px; color:var(--muted); }
.sub { color:var(--muted); font-size:12px; }
.note { padding:8px 12px; border-left:3px solid var(--mid); }
.error { color:#c0392b; }
.from { font-weight:600; }
table { border-collapse:collapse; }
td, th { padding:3px 10px 3px 0; text-align:left; vertical-align:top; border-bottom:1px solid var(--line); }
th { font-weight:600; color:var(--muted); font-size:12px; }
td.n, th.n { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
.hi { color:var(--hi); font-weight:600; } .mid { color:var(--mid); font-weight:600; } .lo { color:var(--lo); }
.query { display:grid; grid-template-columns:minmax(260px, 340px) 1fr; gap:28px; align-items:start; }
@media (max-width: 900px) { .query { grid-template-columns:1fr; } }
form label { display:block; color:var(--muted); font-size:12px; margin-bottom:6px; }
textarea { width:100%; font:12px/1.4 ui-monospace, Menlo, monospace; padding:8px; border:1px solid var(--line); border-radius:6px; background:transparent; color:inherit; }
button { margin-top:8px; padding:6px 16px; border:0; border-radius:6px; background:var(--accent); color:#fff; font-weight:600; cursor:pointer; }
.htmx-indicator { display:none; color:var(--muted); } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display:inline; }
.cols { display:grid; grid-template-columns:repeat(auto-fit, minmax(280px, 1fr)); gap:24px; }
.builds { display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:12px; }
.build { border:1px solid var(--line); border-radius:8px; padding:10px 12px; }
.bh { margin-bottom:6px; }
.swaps { list-style:none; margin:0; padding:0; font-size:13px; }
.swaps li.plus::marker, .swaps li.minus::marker { content:none; }
.swaps .plus { color:var(--hi); } .swaps .minus { color:#d9534f; }
.swaps .plus a.card, .swaps .minus a.card { color:var(--fg); }
td { white-space:nowrap; } td.wrap { white-space:normal; }
.oracle { max-width:46em; white-space:pre-wrap; margin:6px 0 10px; }
.hint { color:var(--muted); font-size:12px; max-width:46em; margin:2px 0 10px; }
td.mana { font-variant-numeric:tabular-nums; white-space:nowrap; color:var(--muted); }
.deckcards { display:flex; flex-wrap:wrap; gap:4px 16px; margin:4px 0 0; }
.deckcards .dc { white-space:nowrap; font-variant-numeric:tabular-nums; }

/* panels: box each result section so the page reads as cards, not a wall */
.panel { border:1px solid var(--line); border-radius:10px; padding:12px 16px; margin:0 0 14px;
         background:rgba(127,127,127,0.045); }
.panel > h2:first-child, .panel > h3:first-child { margin-top:0; }
.panels-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(260px, 1fr)); gap:14px; margin-bottom:14px; }
.panels-grid .panel { margin:0; }
.summary { margin:0 0 12px; }
.summary .warn { color:var(--mid); }

/* grouped decklist (Your deck) */
.deck-groups { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:8px 20px; }
.dg .dc { padding:1px 0; font-variant-numeric:tabular-nums; }
.dg-h { font:600 11px/1.5 system-ui, sans-serif; text-transform:uppercase; letter-spacing:.04em; color:var(--muted);
        border-bottom:1px solid var(--line); padding-bottom:2px; margin:0 0 3px; display:flex; justify-content:space-between; }
.dg-h.side-h { margin-top:12px; }

/* inline share / similarity bars */
.bar { display:inline-flex; align-items:center; gap:7px; }
.bar .track { width:70px; height:7px; border-radius:4px; background:var(--line); overflow:hidden; display:inline-block; }
.bar .fill { display:block; height:100%; border-radius:4px; }
.fill.hi { background:var(--hi); } .fill.mid { background:var(--mid); } .fill.lo { background:var(--lo); } .fill.acc { background:var(--accent); }
.bar .lbl { font-variant-numeric:tabular-nums; min-width:30px; text-align:right; color:var(--muted); font-size:12px; }

/* mana pips */
.pip { display:inline-block; min-width:16px; height:16px; line-height:16px; padding:0 3px; border-radius:9px; text-align:center;
       font:700 11px/16px ui-monospace, Menlo, monospace; color:#1b1b1b; background:#c7c7c7; margin-left:1px; vertical-align:middle; }
.pip-W { background:#f6f1e0; } .pip-U { background:#a5d6f0; } .pip-B { background:#b3abc4; } .pip-R { background:#f0a48e; } .pip-G { background:#9ed7ac; }

/* metagame chart (server-rendered SVG) */
.chart { max-width:100%; height:auto; margin:4px 0 16px; }
.chart .abar { fill:var(--accent); }
.chart .albl { fill:var(--fg); font:12px system-ui, sans-serif; }
.chart .aval { fill:var(--muted); font:12px system-ui, sans-serif; }
.chart a:hover .abar { fill:var(--hi); }
.chart a:hover .albl { text-decoration:underline; }
