  :root {
    --bg: #f7f6f2; --panel: #ffffff; --ink: #24222b; --muted: #6b6875; --line: #e3e0d8;
    --accent: #3b5bdb; --accent-ink: #ffffff; --warn: #b4441c; --ok: #2f7d4f;
  }
  @media (prefers-color-scheme: dark) {
    :root { --bg: #16151b; --panel: #1f1e26; --ink: #ecebf2; --muted: #a09dab; --line: #33313d;
            --accent: #7c95ff; --accent-ink: #0d0c12; --warn: #ff9a6b; --ok: #6fd39a; }
  }
  * { box-sizing: border-box; }
  body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
  main { max-width: 980px; margin: 0 auto; padding: 40px 16px 80px; }
  .brand { display: flex; align-items: center; gap: 10px; margin: 0 0 12px -8px; }
  .brand img { display: block; }
  .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .25em; text-transform: uppercase; color: var(--accent); line-height: 1; margin-bottom: 4px; }
  h1 { font-size: 30px; font-weight: 800; margin: 0; letter-spacing: -0.02em; line-height: 1.05; }
  .lede { color: var(--muted); margin: 0 0 28px; }
  .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
  label.h { display: block; font-weight: 600; margin-bottom: 6px; }
  .hint { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
  input[type=url], input[type=search], textarea, select, input[type=number] {
    width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
    border-radius: 8px; padding: 10px 12px;
  }
  textarea { min-height: 90px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
  .row { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
  @media (max-width: 640px) { .row { grid-template-columns: 1fr; } }
  .drop { border: 1.5px dashed var(--line); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; }
  .drop.has { border-color: var(--ok); color: var(--ok); }
  button { font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 11px 18px; cursor: pointer;
           background: var(--accent); color: var(--accent-ink); }
  button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
  button:disabled { opacity: .55; cursor: progress; }
  .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
  .err { color: var(--warn); margin-top: 12px; }
  .stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 4px 0 16px; }
  .stat b { display: block; font-size: 26px; line-height: 1.1; }
  .stat span { color: var(--muted); font-size: 14px; }
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
  .card { position: relative; }
  .card img { width: 100%; aspect-ratio: 63/88; object-fit: cover; border-radius: 6px; display: block; background: var(--line); }
  .card.owned img { opacity: .35; }
  .card .meta { font-size: 13px; margin-top: 6px; }
  .card .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .card .qty { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
  .card .qty input { width: 56px; padding: 4px 6px; }
  .badge { position: absolute; top: 6px; right: 6px; background: var(--warn); color: #fff; font-weight: 700; font-size: 13px;
           border-radius: 999px; padding: 2px 8px; }
  .badge.ok { background: var(--ok); }
  .opts { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
  .opts > div { min-width: 140px; }
  .hidden { display: none !important; }
  details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
  footer { color: var(--muted); font-size: 13px; margin-top: 40px; }
  a { color: var(--accent); }

/* Site navigation */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.topbar .brand { margin-bottom: 0; }
.brand-link { color: inherit; text-decoration: none; }
nav.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
nav.tabs a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; padding: 7px 14px; border-radius: 999px; }
nav.tabs a:hover { color: var(--ink); }
nav.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

/* Account control */
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#account:empty { display: none; }
.acct { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; }
.signin { display: inline-block; font-weight: 600; font-size: 14px; color: var(--ink); text-decoration: none;
          border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 14px; }
.signin:hover { border-color: var(--accent); }
.use-saved { margin-top: 8px; }
.pub-loader { display: flex; gap: 8px; margin-top: 8px; }
.pub-loader input { flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pub-loader button { padding: 8px 14px; font-size: 14px; }

/* Username in the top bar */
.acct-name { color: var(--ink); font-weight: 600; text-decoration: none; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-name:hover { color: var(--accent); }

/* Required-username dialog */
body.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(15, 14, 20, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 100%; max-width: 440px; }
.modal h2 { margin: 0 0 6px; font-size: 22px; }
.modal input:not([type=radio]):not([type=checkbox]) { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.modal-actions { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; }
.acct a.linkish { text-decoration: none; }
.count-badge { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px; }

/* Request tray on shared collections */
.req-add { margin-left: auto; margin-right: 6px; padding: 2px 8px !important; font-size: 12px !important; border-radius: 6px !important; background: transparent !important; color: var(--accent) !important; border: 1px solid var(--line) !important; }
.req-add:hover { border-color: var(--accent) !important; }
.tray { position: sticky; bottom: 12px; z-index: 20; margin-top: 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
        background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 16px; }
.tray b { font-size: 15px; }
.modal textarea { width: 100%; min-height: 80px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.modal .radio-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; margin: 6px 0 10px; }

/* Notifications panel */
.push-panel { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.push-panel p { margin: 4px 0 0; }
.push-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.push-btns button { padding: 8px 14px; font-size: 14px; }
.push-msg { color: var(--ink) !important; }

/* DeckSwapp wordmark and five-tab nav */
h1 .swapp { color: var(--accent); }
nav.tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { white-space: nowrap; }
@media (max-width: 560px) {
  /* One line on phones: tabs share the full width, "Deck proxies" becomes "Deck". */
  .topbar-right { width: 100%; }
  nav.tabs { width: 100%; gap: 2px; padding: 3px; }
  nav.tabs a { flex: 1 1 auto; text-align: center; padding: 6px 4px; font-size: 13px; }
  nav.tabs .tab-long { display: none; }
  nav.tabs .count-badge { min-width: 15px; margin-left: 2px; padding: 0 3px; font-size: 10px; line-height: 15px; }
}
@media (max-width: 350px) {
  nav.tabs a { font-size: 12px; padding: 6px 2px; }
}

/* Small segmented switch (deck link / paste, loan tabs) */
.seg { display: inline-flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 12px; }
.seg button { background: transparent; color: var(--muted); padding: 6px 14px; font-size: 14px; border-radius: 999px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Loan / borrow lines under cards in the collection */
.loan-line { font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loan-line a { text-decoration: none; }
.loan-line.out { color: var(--warn); }
.loan-line.in { color: var(--ok); }

/* Wish toggle on card images */
.wish-btn { position: absolute; top: 6px; left: 6px; width: 30px; height: 30px; padding: 0; border-radius: 999px; font-size: 16px; line-height: 30px;
            background: rgba(255, 255, 255, .92); color: #b4441c; border: 1px solid rgba(0, 0, 0, .12); }
.wish-btn[aria-pressed="false"] { color: #6b6875; }
.wish-btn:hover { transform: scale(1.06); }

/* Nickname shown next to a username */
.nick { font-weight: 600; }
.nick + .uname { color: var(--muted); font-weight: 400; }
input.text { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
input[type=date] { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
