/* 폰 우선. 색은 여기서만 정한다. */
:root {
  --bg: #f4f5f8; --surface: #fff; --surface-2: #eef0f5; --line: #dde1ea;
  --text: #1c2233; --text-2: #4b556b; --text-3: #6b7489;
  --accent: #2f5fb3; --accent-ink: #fff; --ok: #237a52; --warn: #a86400; --bad: #b3261e;
  --radius: 12px; --tab-h: 58px; --top-h: 48px;
  --G: #3f9b4a; --R: #d9502b; --W: #2f86d6; --L: #d6a700; --P: #8b56c4; --F: #b0602c; --D: #3e4a5a; --M: #7d8796; --N: #a58a1e; --C: #a3a8b3;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151d; --surface: #1b2030; --surface-2: #242a3c; --line: #2f364b;
    --text: #e7eaf2; --text-2: #b4bccd; --text-3: #8e97ab;
    --accent: #8db0f0; --accent-ink: #10172a; --ok: #6fcf9c; --warn: #f0b860; --bad: #ff8a80;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif; word-break: keep-all; overflow-wrap: anywhere; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.35rem; margin: .2rem 0 .4rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .5rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
h1 small, h2 small, h3 small { font-weight: 400; color: var(--text-3); font-size: .8rem; }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }

.top { position: sticky; top: 0; z-index: 10; height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); }
main { max-width: 760px; margin: 0 auto; padding: 12px 14px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .72rem; color: var(--text-3); gap: 2px; }
.tabs a span { font-size: 1.2rem; line-height: 1; }
.tabs a.on { color: var(--accent); font-weight: 700; }

.loading, .err { padding: 2rem 0; text-align: center; color: var(--text-2); }
.err { color: var(--bad); }
.hint { color: var(--text-3); font-size: .82rem; margin: .4rem 0; }
.note { background: var(--surface-2); border-radius: 10px; padding: .6rem .8rem; font-size: .88rem; }
.sub { color: var(--text-3); margin: 0 0 .5rem; }
.back { display: inline-block; margin-bottom: .4rem; font-size: .9rem; }
.empty { color: var(--text-3); padding: 1rem 0; list-style: none; }
.ok { color: var(--ok); } .warn { color: var(--warn); }
.up { color: var(--ok); } .down { color: var(--bad); }
.stats small { display: block; font-size: .65rem; }
em.inf { font-style: normal; font-size: .7rem; color: var(--warn); border: 1px solid currentColor; border-radius: 4px; padding: 0 .25em; }
.disclaimer { font-size: .78rem; color: var(--text-3); border-top: 1px solid var(--line); padding-top: .8rem; margin-top: 1.5rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: .82rem; }
.btn.wide { width: 100%; margin-top: .6rem; }
.row-btns { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.chip { display: inline-flex; align-items: center; gap: .25rem; min-height: 34px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font: inherit; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.ghost { border-style: dashed; }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding: .35rem 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.search { width: 100%; min-height: 44px; padding: 0 12px; font-size: 16px; }
select { min-height: 36px; padding: 0 8px; }
textarea { width: 100%; padding: 8px; font-size: 14px; }
.more-f summary { cursor: pointer; color: var(--text-2); font-size: .88rem; padding: .3rem 0; }
.frow { display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; font-size: .88rem; padding: .3rem 0; }
.ck { display: inline-flex; align-items: center; gap: .3rem; }
.count { color: var(--text-3); font-size: .82rem; margin: .4rem 0; }
.banner { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; margin-bottom: .6rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .9rem; }

/* 에너지 동그라미 */
.en { display: inline-grid; place-items: center; width: 1.25em; height: 1.25em; border-radius: 50%; font-style: normal; font-size: .72rem; font-weight: 700; color: #fff; background: var(--C); vertical-align: -.2em; margin-right: 1px; }
.en-G { background: var(--G); } .en-R { background: var(--R); } .en-W { background: var(--W); } .en-L { background: var(--L); color: #222; }
.en-P { background: var(--P); } .en-F { background: var(--F); } .en-D { background: var(--D); } .en-M { background: var(--M); } .en-N { background: var(--N); } .en-C { background: var(--C); color: #222; }
.en-0 { background: transparent; color: var(--text-3); border: 1px dashed var(--line); }

/* 카드 줄 */
.list { display: flex; flex-direction: column; gap: 6px; }
.crow-w { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.crow { flex: 1; min-width: 0; display: flex; gap: 10px; padding: 6px; color: inherit; }
.thumb { flex: 0 0 52px; }
.cimg { width: 100%; aspect-ratio: 63/88; border-radius: 6px; object-fit: cover; display: block; background: var(--surface-2); }
.ph { display: grid; place-items: center; padding: 3px; font-size: .58rem; line-height: 1.15; text-align: center; color: #fff; font-weight: 700; background: var(--C); }
.ph-G { background: var(--G); } .ph-R { background: var(--R); } .ph-W { background: var(--W); } .ph-L { background: var(--L); color: #222; } .ph-P { background: var(--P); }
.ph-F { background: var(--F); } .ph-D { background: var(--D); } .ph-M { background: var(--M); } .ph-N { background: var(--N); } .ph-C { background: var(--C); color: #222; } .ph-T { background: #6c6f7d; }
.cinfo { display: flex; flex-direction: column; min-width: 0; justify-content: center; }
.cinfo b { font-size: .95rem; }
.cinfo small { color: var(--text-3); font-size: .75rem; }
.cmeta { font-size: .8rem; color: var(--text-2); }
.cset { font-size: .72rem; color: var(--text-3); }
.side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 56px; padding: 0 8px; font-size: .8rem; color: var(--text-3); border: 0; border-left: 1px solid var(--line); background: transparent; font-family: inherit; }
button.side { cursor: pointer; color: var(--accent); font-size: 1.3rem; font-weight: 700; }
button.side small { font-size: .7rem; min-height: 1em; }
button.side.own { font-size: 1.1rem; }
.own-n { color: var(--warn); font-size: .78rem; }
.stepper { flex-direction: row; gap: 6px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 1.1rem; cursor: pointer; }
.stepper b { min-width: 1ch; text-align: center; color: var(--text); font-size: 1rem; }

/* 카드 상세 */
.dtop { display: flex; gap: 14px; align-items: flex-start; }
.big { flex: 0 0 42%; max-width: 260px; }
.big .ph { font-size: .95rem; }
.dinfo { flex: 1; min-width: 0; }
dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; margin: .3rem 0; font-size: .88rem; }
dt { color: var(--text-3); } dd { margin: 0; }
.atk { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; margin-top: .6rem; }
.atk-h { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.atk-h small { color: var(--text-3); font-size: .75rem; }
.dmg { margin-left: auto; font-weight: 700; font-size: 1.05rem; }
.tag-ab { background: var(--bad); color: #fff; border-radius: 4px; font-size: .7rem; padding: 0 .35em; }
.fx { margin: .35rem 0 0; font-size: .85rem; color: var(--text-2); white-space: pre-line; }
.fx.box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin: 1rem 0; padding: .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.own-ctl, .add-ctl { display: flex; align-items: center; gap: .4rem; }
.add-ctl select { max-width: 52vw; }
.prints { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.prints a { color: var(--text-3); font-size: .7rem; text-align: center; }
.prints a.on .cimg { outline: 3px solid var(--accent); }
ul.plain { padding-left: 1.1rem; margin: .3rem 0; }
ul.plain li { margin: .25rem 0; }
.src li { font-size: .88rem; }

/* 덱 */
.decklist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.decklist a { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; }
.dl-meta { font-size: .82rem; color: var(--text-3); white-space: nowrap; }
.dl-meta em { font-style: normal; }
.dname { width: 100%; font-size: 1.2rem; font-weight: 700; padding: .4rem .6rem; }
.size { margin: .5rem 0; color: var(--text-2); }
.size b { font-size: 1.3rem; color: var(--warn); }
.size.full b { color: var(--ok); }
.errs { color: var(--bad); font-size: .88rem; padding-left: 1.1rem; margin: .3rem 0; }
.ok-line { color: var(--ok); font-size: .9rem; }
.notes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.notes li, .n-warn.note { padding: .5rem .7rem; border-radius: 10px; font-size: .88rem; border-left: 4px solid var(--text-3); background: var(--surface); }
.n-bad { border-left-color: var(--bad) !important; } .n-warn { border-left-color: var(--warn) !important; } .n-good { border-left-color: var(--ok) !important; } .n-info { border-left-color: var(--accent) !important; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: .8rem; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; margin: .5rem 0; }
.refresh { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .3rem .6rem; font-size: .85rem; }
.refresh small { flex-basis: 100%; margin: 0; }
.kv { display: grid; grid-template-columns: 6.5em 1fr 2.5em; align-items: center; gap: .5rem; font-size: .84rem; margin: .25rem 0; }
.kv b { text-align: right; }
.bar { display: inline-block; width: 100%; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.warnbar > span { background: var(--warn); }

/* 메타 */
ol.arch { list-style: none; padding: 0; margin: .5rem 0; display: flex; flex-direction: column; gap: 6px; counter-reset: a; }
ol.arch li { counter-increment: a; }
ol.arch a { display: grid; grid-template-columns: 1.6em 1fr; gap: .1rem .4rem; padding: .65rem .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; }
ol.arch a::before { content: counter(a); grid-row: span 3; color: var(--text-3); font-weight: 700; }
ol.arch li.thin a { opacity: .6; }
.am { display: grid; grid-template-columns: 1fr 4em; align-items: center; gap: .5rem; font-size: .84rem; }
.am > span:last-child { text-align: right; }
.as { font-size: .78rem; color: var(--text-3); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: .5rem 0; }
.stats span { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .5rem; text-align: center; font-size: .75rem; color: var(--text-3); }
.stats b { display: block; font-size: 1.05rem; color: var(--text); }
.tbl { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tbl th, .tbl td { text-align: left; padding: .35rem .3rem; border-bottom: 1px solid var(--line); }
.tbl td:nth-child(2) { width: 42%; white-space: nowrap; }
.tbl td:nth-child(2) .bar { width: 55%; }
.tbl td:last-child { text-align: right; width: 3em; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); transform: translate(-50%, 20px); opacity: 0; transition: .2s; background: var(--text); color: var(--bg); padding: .55rem .9rem; border-radius: 10px; font-size: .88rem; pointer-events: none; z-index: 20; max-width: 90vw; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
