/* Accounts, the card library, 我的卡组 and 用户管理. Loaded after style.css, whose colours, buttons and icons it reuses. */
.ic-user { --i: url(vendor/lucide/user.svg); }

/* ---------- Site navigation (every page, including the table's header) ---------- */
.site-nav { display: flex; align-items: center; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; color: rgba(255,255,255,.85); text-decoration: none; font-weight: 700; white-space: nowrap; }
.nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-link.on { background: var(--yellow); color: #1d2a5a; }
.user-menu { position: relative; margin-left: 6px; }
.user-btn { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); white-space: nowrap; }
.role-tag { font-size: 11px; font-weight: 800; background: var(--yellow); color: #1d2a5a; border-radius: 99px; padding: 0 6px; }
.user-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; display: flex; flex-direction: column; min-width: 140px; background: var(--panel); border-radius: 12px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.user-pop button { border: none; background: transparent; text-align: left; color: var(--ink); }
.user-pop button:hover { background: #ece8dc; }
header nav .site-nav { margin-right: 6px; }
.start-nav { justify-content: flex-end; margin-bottom: 4px; }
@media (max-width: 900px) { .nav-link span { display: none; } }

/* ---------- Scrolling pages ---------- */
body.page { height: auto; min-height: 100vh; overflow: auto; }
body.page > header { position: sticky; top: 0; z-index: 10; background: rgba(13, 27, 62, .92); backdrop-filter: blur(6px); }
a.brand { text-decoration: none; }
.page-main { width: min(1440px, 100% - 32px); margin: 0 auto; padding: 18px 0 40px; }
.page-title { color: #fff; margin-bottom: 16px; }
.page-title h1 { margin: 0 0 4px; font-size: 30px; color: var(--yellow); text-shadow: 2px 2px 0 var(--navy); }
.page-title p { margin: 0; color: rgba(255,255,255,.8); line-height: 1.5; max-width: 900px; }
a.button { display: inline-flex; align-items: center; gap: 6px; font: inherit; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 6px 12px; color: var(--ink); text-decoration: none; }
a.button.primary { background: var(--yellow); border-color: var(--yellow-dark); font-weight: 800; color: #1d2a5a; }
.ed-bar a.textlink, .f-head button.textlink { color: var(--blue); }
.load-error { background: #fdecea; color: #8a1f1f; border-radius: 12px; padding: 12px 16px; }
.status { font-weight: 800; }
.status.ok { color: var(--good); }
.status.no { color: #c0392b; }
.panel-box { background: var(--panel); border-radius: 16px; padding: 16px; }

/* ---------- Forms and dialogs ---------- */
.acct-form { display: flex; flex-direction: column; gap: 12px; }
.acct-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 14px; color: #3c4a43; }
.acct-form input, .lib-filters input, .lib-filters select, .ed-bar input, .ed-bar select, .deck-toolbar select, table.users select {
  font: inherit; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); min-width: 0; }
.acct-form input:focus, .lib-filters input:focus, .ed-bar input:focus { outline: 2px solid var(--blue); outline-offset: 0; }
.form-error { color: #c0392b; min-height: 1.2em; margin: 0; font-size: 14px; }
.hint { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.acct-overlay { z-index: 60; }
.acct-dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- Login ---------- */
.login-page { display: flex; }
.login-wrap { width: min(440px, 100% - 32px); margin: auto; padding: 40px 0; display: flex; flex-direction: column; gap: 18px; }
.login-hero { text-align: center; color: #fff; }
.login-hero h1 { margin: 0; line-height: 0; }
.login-hero .set-logo { height: 84px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.45)); }
.login-hero p { margin: 10px 0 0; color: rgba(255,255,255,.8); line-height: 1.5; }
.login-card { background: var(--panel); border-radius: 18px; padding: 18px 20px 20px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { flex: 1; font-weight: 800; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
#auth-submit { padding: 10px; font-size: 16px; }
.login-page .legal { color: rgba(255,255,255,.45); }

/* ---------- Card library ---------- */
.library { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; align-items: start; }
.lib-filters { position: sticky; top: calc(var(--header-h) + 12px); max-height: calc(100vh - var(--header-h) - 24px); overflow-y: auto;
  background: var(--panel); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.f-head { display: flex; justify-content: space-between; align-items: baseline; }
.f-head b { font-family: "Baloo 2", sans-serif; font-size: 18px; color: var(--navy); }
.f-row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: #3c4a43; border: none; padding: 0; margin: 0; min-width: 0; }
.f-row legend { padding: 0; margin-bottom: 4px; }
.f-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg label, .checks label, .type-pick label { cursor: pointer; }
.seg input, .checks input, .type-pick input { position: absolute; opacity: 0; pointer-events: none; }
.seg span, .checks span { display: inline-block; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font-weight: 700; font-size: 13px; }
.seg input:checked + span, .checks input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg input:focus-visible + span, .checks input:focus-visible + span, .type-pick input:focus-visible ~ span { outline: 2px solid var(--blue); }
.checks { display: flex; flex-wrap: wrap; gap: 4px; }
.type-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 4px; }
.type-pick label { display: flex; align-items: center; gap: 4px; padding: 3px 6px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.type-pick label:has(input:checked) { background: #1d2a5a; color: #fff; border-color: #1d2a5a; }
.lib-results { min-width: 0; }
.lib-count { color: rgba(255,255,255,.8); margin: 0 0 10px; font-size: 14px; }
.panel-box .lib-count { color: var(--muted); }
.lib-empty { color: rgba(255,255,255,.75); padding: 20px 0; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.lib-card { background: var(--panel); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 3px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.lib-card.in-deck { box-shadow: 0 0 0 3px var(--yellow), 0 4px 12px rgba(0,0,0,.3); }
.lib-img { position: relative; padding: 0; border: none; background: none; border-radius: 7px; overflow: hidden; display: block; }
.lib-vers { position: absolute; right: 5px; bottom: 5px; padding: 1px 7px; border-radius: 99px; background: rgba(13, 27, 62, .85); color: #fff; font-size: 11px; font-weight: 800; }
.lib-img img { width: 100%; aspect-ratio: .716; object-fit: cover; display: block; transition: transform .15s; }
.lib-img:hover img { transform: scale(1.03); }
.lib-name { font-weight: 800; color: var(--navy); line-height: 1.25; margin-top: 3px; }
.lib-sub { display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); }
.lib-sub .ei { width: 15px; height: 15px; }
.lib-sub .ei i { width: 9px; height: 9px; }
.lib-sub span:last-child { margin-left: 2px; }
.lib-meta { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.lib-meta > span:first-child { margin-right: auto; }
.legal-badge { font-size: 10px; font-weight: 800; padding: 0 5px; border-radius: 99px; line-height: 16px; }
.legal-badge.ok { background: #dff3e5; color: #1f6b3a; }
.legal-badge.no { background: #f3e1e1; color: #8a2b2b; }
.lib-ctl { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.lib-ctl button, .ed-ctl button { width: 30px; height: 28px; padding: 0; font-weight: 800; font-size: 16px; line-height: 1; }
.lib-ctl button[data-act="add"]:not(:disabled) { background: var(--yellow); border-color: var(--yellow-dark); }
.lib-n { font-weight: 800; color: var(--muted); }
.lib-n.on { color: var(--navy); font-size: 17px; }
/* Cards whose rules are not implemented yet: browsable and savable, not playable. */
.impl-badge { font-size: 10px; font-weight: 800; padding: 0 5px; border-radius: 99px; line-height: 16px; background: #ece9f5; color: #4c3f7a; }
.impl-badge.machine { background: #fff0d1; color: #825006; }
.impl-badge.reviewed { background: #dff3e5; color: #1f6b3a; }
.lib-more { display: block; margin: 16px auto 0; min-width: 220px; }
.cd-ok { color: #1f6b3a; font-weight: 700; }
.cd-warn { color: #8a5a10; font-weight: 700; }
.ed-row .impl-badge { margin-left: 4px; }

/* ---------- Card detail ---------- */
.card-detail { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: 18px; align-items: start; }
.cd-img { width: 100%; border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.cd-body h2 { margin: 0 32px 4px 0; }
.cd-sub { margin: 0 0 10px; color: var(--muted); }
.cd-sub b { color: var(--ink); }
.cd-skill { border-top: 1px solid var(--line); padding: 8px 0; }
.cd-skill-head { display: flex; align-items: center; gap: 8px; }
.cd-skill-head .cost { display: inline-flex; gap: 2px; }
.cd-skill-head .dmg { margin-left: auto; font-weight: 800; font-size: 18px; }
.cd-skill p, .cd-text, .cd-rule { margin: 6px 0 0; line-height: 1.6; font-size: 14px; }
.ability-tag { background: #c0392b; color: #fff; font-size: 12px; font-weight: 800; border-radius: 6px; padding: 1px 6px; }
.cd-rule { color: var(--muted); font-size: 13px; }
.cd-facts { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr; gap: 4px 8px; align-items: center; border-top: 1px solid var(--line); padding-top: 8px; margin: 0; font-size: 14px; }
.cd-facts dt { color: var(--muted); font-weight: 700; }
.cd-facts dd { margin: 0; display: flex; gap: 2px; align-items: center; }
.cd-print { color: var(--muted); font-size: 13px; margin: 8px 0 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.no-cost { color: var(--muted); }
/* The card's printings, under its card view. */
.cd-versions { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 10px; }
.cd-versions h3 { margin: 0 0 10px; font-size: 16px; color: var(--navy); }
.cd-vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.cd-ver { display: flex; flex-direction: column; gap: 2px; padding: 5px; border-radius: 10px; border: 2px solid transparent; font-size: 12px; }
.cd-ver.sel { border-color: var(--navy); background: #fff; }
.cd-ver.in-deck { box-shadow: 0 0 0 3px var(--yellow); }
.cd-ver-set { font-weight: 800; color: var(--navy); line-height: 1.25; margin-top: 3px; }
.cd-ver-meta { color: var(--muted); line-height: 1.35; }
@media (max-width: 700px) { .card-detail { grid-template-columns: 1fr; } .cd-img { max-width: 260px; } }

/* ---------- 我的卡组 ---------- */
.deck-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; color: #fff; }
.from-preset { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.deck-toolbar select { max-width: 360px; }
.my-decks { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.my-deck { display: flex; flex-direction: column; background: var(--panel); border-radius: 18px; overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.my-deck .deck-art { height: 130px; }
.my-deck .fan { position: absolute; inset: 0; z-index: 1; }
.my-deck .fan img { position: absolute; left: 50%; bottom: -26px; height: 84%; border-radius: 7px; box-shadow: 0 6px 14px rgba(0,0,0,.4); transform-origin: 50% 100%; }
.my-deck .fan img:nth-child(1) { transform: translateX(-50%) translateX(-58%) rotate(-11deg); }
.my-deck .fan img:nth-child(2) { transform: translateX(-50%) translateY(-6px); z-index: 2; }
.my-deck .fan img:nth-child(3) { transform: translateX(-50%) translateX(58%) rotate(11deg); }
.md-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.md-body h3 { margin: 0; color: var(--navy); font-size: 20px; }
.md-meta, .md-date, .md-issue { margin: 0; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.md-meta b { color: var(--ink); }
.md-issue { color: #8a2b2b; }
.md-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--line); }

/* ---------- Deck builder ---------- */
.ed-bar { position: sticky; top: var(--header-h); z-index: 5; display: flex; flex-wrap: wrap; align-items: end; gap: 12px; background: var(--panel); border-radius: 16px; padding: 10px 14px; margin-bottom: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.ed-bar label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 700; color: var(--muted); }
.ed-bar #ed-back { align-self: center; }
.ed-name input { width: min(320px, 60vw); font-weight: 800; }
.ed-count { align-self: center; font-size: 15px; color: var(--muted); }
.ed-count b { font-size: 24px; color: #c0392b; }
.ed-count b.full { color: var(--good); }
.ed-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; align-self: center; }
.ed-msg { font-size: 13px; color: var(--muted); }
.ed-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.library.builder { grid-template-columns: 230px minmax(0, 1fr); }
.library.builder .lib-filters { top: calc(var(--header-h) + 92px); max-height: calc(100vh - var(--header-h) - 104px); }
.library.builder .lib-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.ed-deck { position: sticky; top: calc(var(--header-h) + 92px); max-height: calc(100vh - var(--header-h) - 104px); overflow-y: auto; background: var(--panel); border-radius: 16px; padding: 12px 14px; }
.ed-check p { margin: 0 0 6px; display: flex; gap: 6px; align-items: center; }
.ed-issues { margin: 0 0 8px; padding-left: 18px; font-size: 13px; color: #8a2b2b; line-height: 1.5; }
.ed-strategy { margin: 4px 0 8px; }
.ed-strategy summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.ed-strategy summary small { margin-left: 4px; font-weight: 400; color: var(--muted); }
.ed-strategy textarea { display: block; width: 100%; margin-top: 6px; box-sizing: border-box; resize: vertical; font: inherit; font-size: 13px; line-height: 1.5; }
.ed-group h3 { margin: 10px 0 4px; font-size: 16px; color: var(--navy); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.ed-group h3 small { color: var(--muted); font-size: 14px; }
.ed-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.ed-thumb { padding: 0; border: none; background: none; flex: none; }
.ed-thumb img { width: 34px; border-radius: 3px; display: block; }
.ed-card { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; }
.ed-card > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.ed-card b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-card small { font-size: 11px; color: var(--muted); }
.ed-card em { color: #c0392b; font-style: normal; }
.ed-ctl { display: flex; align-items: center; gap: 6px; flex: none; }
.ed-ctl b { min-width: 18px; text-align: center; }
.ed-none { margin: 4px 0; color: var(--muted); font-size: 13px; }
@media (max-width: 1100px) { .ed-body { grid-template-columns: 1fr; } .ed-deck { position: static; max-height: none; } }
@media (max-width: 760px) {
  .library, .library.builder { grid-template-columns: 1fr; }
  .lib-filters, .library.builder .lib-filters { position: static; max-height: none; }
  .ed-bar { position: static; }
}

/* ---------- 用户管理 ---------- */
.table-wrap { overflow-x: auto; }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.users th { color: var(--muted); font-size: 13px; }
table.users td.ops { display: flex; gap: 6px; }

/* ---------- The table's deck chooser: 我的卡组 ---------- */
.deck-group a { margin-left: auto; color: var(--yellow); font-size: 14px; font-weight: 700; }
.deck-new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 180px; border: 2px dashed rgba(255,255,255,.35);
  border-radius: 18px; color: rgba(255,255,255,.85); text-decoration: none; font-weight: 800; text-align: center; padding: 16px; }
.deck-new:hover { border-color: var(--yellow); color: var(--yellow); }
.deck-new .ic { width: 28px; height: 28px; }
.deck-new small { font-weight: 400; color: rgba(255,255,255,.6); }

/* ---------- 对局记录 ---------- */
table.users a.btn { display: inline-block; border-radius: 10px; border: 1px solid var(--yellow-dark); background: var(--yellow); padding: 4px 12px;
  font-weight: 800; color: #1d2a5a; text-decoration: none; }
.lib-count label { margin-left: 12px; white-space: nowrap; }
.tag-debug { background: #fde8e8; color: #b71c1c; border-radius: 99px; padding: 1px 7px; font-weight: 800; }
