/* KMS Collection: one stylesheet. Colors are tokens on :root, with a dark set (the default look) and a light one. */
:root {
  --bg: #141417;
  --bg-card: #1d1d22;
  --bg-raised: #26262d;
  --border: #33333c;
  --text: #f1f1f4;
  --text-dim: #a2a2ae;
  --accent: #e2304a;
  --accent-text: #ffffff;
  --owned: #2fbf71;
  --warn: #f0a83a;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --radius: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f4f6; --bg-card: #ffffff; --bg-raised: #ececf0; --border: #dcdce2;
    --text: #17171b; --text-dim: #5f5f6b; --accent: #c41d36; --owned: #1f9a57; --warn: #b36b00;
    --shadow: 0 6px 24px rgba(0, 0, 0, .12);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f4f6; --bg-card: #ffffff; --bg-raised: #ececf0; --border: #dcdce2;
  --text: #17171b; --text-dim: #5f5f6b; --accent: #c41d36; --owned: #1f9a57; --warn: #b36b00;
  --shadow: 0 6px 24px rgba(0, 0, 0, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin: 20px 0 8px; }
.cc-dim { color: var(--text-dim); }
.cc-small { font-size: 13px; }
.cc-muted-box { padding: 24px 16px; text-align: center; color: var(--text-dim); }

/* Top bar and tabs */
.cc-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.cc-top h1 { flex: 1; font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-back { font-size: 26px; line-height: 1; margin-left: -8px; }
.cc-screen { padding: 12px 16px 24px; max-width: 980px; margin: 0 auto; }
.cc-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--bg-card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.cc-tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; color: var(--text-dim); text-decoration: none; font-size: 11px;
}
.cc-tabs a.on { color: var(--accent); }
.cc-tab-ic { font-size: 19px; line-height: 1.1; }

/* Controls */
.cc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-raised); cursor: pointer;
}
.cc-btn:disabled { opacity: .5; cursor: default; }
.cc-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.cc-btn.cc-small { min-height: 32px; padding: 4px 10px; }
.cc-icon-btn { background: none; border: 0; padding: 6px 8px; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text); }
.cc-input, .cc-select {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-card);
}
.cc-input:focus, .cc-select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.cc-row { display: flex; gap: 8px; align-items: center; }
.cc-row > .cc-grow { flex: 1; min-width: 0; }
.cc-row-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.cc-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.cc-chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); font-size: 13px; cursor: pointer;
}
.cc-chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.cc-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--bg-raised); font-size: 12px; margin: 2px 4px 2px 0; }
.cc-beta { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--warn); color: #1a1100; font-size: 11px; font-weight: 700; vertical-align: middle; }
.cc-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; }
.cc-switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.cc-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }

/* Progress */
.cc-progress { height: 6px; border-radius: 3px; background: var(--bg-raised); overflow: hidden; }
.cc-progress > i { display: block; height: 100%; background: var(--owned); }

/* Set list */
.cc-set { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none; color: inherit; }
.cc-set img, .cc-set .cc-ph { width: 42px; height: 58px; object-fit: cover; border-radius: 4px; background: var(--bg-raised); flex: none; }
.cc-set-main { flex: 1; min-width: 0; }
.cc-set-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-set-meta { font-size: 12px; color: var(--text-dim); margin: 2px 0 6px; }
.cc-era { position: sticky; top: 52px; z-index: 5; background: var(--bg); padding: 12px 0 4px; }

/* Card grid */
.cc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.cc-tile { position: relative; cursor: pointer; border-radius: 8px; background: none; border: 0; padding: 0; text-align: left; }
.cc-tile img, .cc-tile .cc-ph {
  width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; background: var(--bg-raised); display: block;
}
.cc-tile.missing img { filter: grayscale(1); opacity: .35; }
.cc-tile .cc-ph { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; text-align: center; font-size: 12px; color: var(--text-dim); }
.cc-tile-label { font-size: 12px; margin-top: 4px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-badge {
  position: absolute; top: 4px; right: 4px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 12px; background: var(--owned); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}

/* List rows */
.cc-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.cc-item img, .cc-item .cc-ph { width: 46px; height: 64px; object-fit: cover; border-radius: 4px; background: var(--bg-raised); flex: none; }
.cc-item-main { flex: 1; min-width: 0; }
.cc-item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-item-meta { font-size: 12px; color: var(--text-dim); }
.cc-item-right { text-align: right; font-variant-numeric: tabular-nums; }

/* Summary numbers */
.cc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cc-stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.cc-stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.cc-stat span { font-size: 12px; color: var(--text-dim); }

/* Dialogs */
.cc-modal-wrap {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.cc-modal {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  background: var(--bg-card); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 760px) { .cc-modal-wrap { align-items: center; } .cc-modal { border-radius: 16px; } }
.cc-modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 12px 10px 10px 16px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.cc-modal-head h2 { flex: 1; }
.cc-modal-body { padding: 14px 16px 18px; }

/* Card window */
.cc-card-top { display: flex; gap: 14px; align-items: flex-start; }
.cc-card-top img { width: 46%; max-width: 230px; border-radius: 10px; background: var(--bg-raised); aspect-ratio: 63 / 88; object-fit: cover; }
.cc-card-info { flex: 1; min-width: 0; font-size: 14px; }
.cc-card-info .cc-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.cc-prices { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.cc-prices th, .cc-prices td { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: right; }
.cc-prices th:first-child, .cc-prices td:first-child { text-align: left; }
.cc-qty { display: flex; align-items: center; gap: 6px; }
.cc-qty button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-raised); font-size: 18px; cursor: pointer; }
.cc-qty input { width: 52px; text-align: center; min-height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); }

/* Suggestions under a typing box */
.cc-suggest-wrap { position: relative; }
.cc-suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 120; max-height: 260px; overflow: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); margin-top: 4px;
}
.cc-suggest div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.cc-suggest div:last-child { border-bottom: 0; }
.cc-suggest div.on, .cc-suggest div:hover { background: var(--bg-raised); }

/* Rules editor */
.cc-rule { display: grid; grid-template-columns: 40% 1fr auto; gap: 6px; align-items: start; margin-bottom: 8px; }

/* Pokédex slots */
.cc-slot-no { font-size: 11px; color: var(--text-dim); }

/* Scanner */
.cc-camera { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; margin: 0 auto; }
.cc-camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-camera canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cc-camera-status { position: absolute; left: 10px; right: 10px; bottom: 10px; text-align: center; color: #fff; text-shadow: 0 1px 3px #000; font-size: 14px; }
.cc-loading { text-align: center; padding: 30px 10px; color: var(--text-dim); }

.cc-toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  z-index: 200; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.cc-toast.show { opacity: 1; transform: translate(-50%, 0); }
