:root {
  --ink: #f6ead0;
  --muted: #c7b99e;
  --surface: #211b14;
  --surface-2: #2b2319;
  --surface-3: #352a1d;
  --line: #5d4a31;
  --gold: #d7ad5e;
  --gold-strong: #f0c66e;
  --black: #0e0c09;
  --danger: #e07a70;
  --radius: 18px;
  --shadow: 0 22px 60px rgba(0, 0, 0, .32);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: radial-gradient(circle at 25% 0%, #31261a 0, #16120e 40%, #0e0c09 100%) fixed; color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; min-height: 100vh; }
a { color: var(--gold-strong); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.site-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 1260px; margin: auto; padding: 14px 28px; }
.brand { display: inline-flex; gap: 12px; align-items: center; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border: 2px solid var(--gold); border-radius: 50%; font-family: Georgia, serif; font-weight: 900; color: var(--gold-strong); box-shadow: inset 0 0 0 4px #18130e; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 1.15rem; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: .73rem; text-transform: uppercase; letter-spacing: .15em; }
.site-header nav { display: flex; gap: 20px; }
.site-header nav a { color: var(--ink); text-decoration: none; font-weight: 700; }
main { min-height: calc(100vh - 170px); }
.hero { max-width: 920px; margin: 60px auto 44px; padding: 0 28px; text-align: center; }
.hero h1 { font: 700 clamp(2.25rem, 5vw, 4.7rem)/.98 Georgia, serif; letter-spacing: -.035em; margin: 12px 0 22px; }
.hero > p:last-child { max-width: 680px; margin: auto; color: var(--muted); font-size: 1.12rem; line-height: 1.7; }
.eyebrow { color: var(--gold); font-weight: 800; text-transform: uppercase; letter-spacing: .17em; font-size: .75rem; }
.catalogue-shell, .admin-shell, .form-card { max-width: 1260px; margin: auto; padding: 0 28px 60px; }
.search-panel { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(190px, .45fr) auto auto; gap: 14px; align-items: end; background: rgba(33,27,20,.9); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
label > span, .search-panel label > span { display: block; color: var(--muted); font-size: .8rem; font-weight: 750; margin: 0 0 7px; }
input, select, textarea { width: 100%; background: #15110d; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(215,173,94,.15); }
textarea { resize: vertical; }
.primary-button, .danger-button { display: inline-flex; justify-content: center; align-items: center; border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 850; text-decoration: none; cursor: pointer; }
.primary-button { background: var(--gold); color: #17110a; }
.primary-button:hover { background: var(--gold-strong); }
.danger-button { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.clear-link { padding: 12px 4px; }
.results-heading { display: flex; justify-content: space-between; align-items: center; margin: 32px 2px 18px; }
.results-heading h2 { margin: 0; font-family: Georgia, serif; }
.token-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px; }
.token-card { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; overflow: hidden; box-shadow: 0 12px 28px rgba(0,0,0,.22); transition: transform .18s ease, border-color .18s ease; }
.token-card:hover { transform: translateY(-4px); border-color: var(--gold); }
.token-card > a { color: inherit; text-decoration: none; }
.token-image-wrap { aspect-ratio: 1050 / 1498; background: #0b0907; overflow: hidden; }
.token-image-wrap img, .detail-image img { width: 100%; height: 100%; display: block; object-fit: contain; }
.image-placeholder { height: 100%; min-height: 260px; display: grid; place-items: center; color: var(--muted); background: repeating-linear-gradient(135deg,#16120e,#16120e 12px,#1d1812 12px,#1d1812 24px); }
.token-card-copy { position: relative; padding: 16px 18px 18px; min-height: 112px; }
.token-card-copy h3 { font-family: Georgia, serif; margin: 0 54px 7px 0; font-size: 1.35rem; }
.token-card-copy p { color: var(--muted); margin: 0; font-size: .86rem; line-height: 1.45; }
.stats { position: absolute; right: 16px; top: 16px; border: 1px solid var(--gold); color: var(--gold-strong); border-radius: 999px; padding: 4px 8px; font-weight: 850; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 34px; }
.empty-state { text-align: center; padding: 70px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty-state.standalone { max-width: 700px; margin: 100px auto; }
.token-detail { max-width: 1060px; margin: 56px auto 80px; padding: 0 28px; display: grid; grid-template-columns: minmax(280px, 430px) minmax(0, 1fr); gap: 56px; align-items: start; }
.detail-image { aspect-ratio: 1050/1498; overflow: hidden; border-radius: 22px; border: 1px solid var(--line); box-shadow: var(--shadow); background: #0b0907; }
.rules-card { background: rgba(33,27,20,.92); border: 1px solid var(--line); border-radius: 22px; padding: clamp(24px,4vw,42px); box-shadow: var(--shadow); }
.rules-card h1 { font: 700 clamp(2.5rem,6vw,4.8rem)/.95 Georgia, serif; margin: 10px 0; }
.type-line { color: var(--muted); font-size: 1.03rem; }
.large-stats { display: inline-block; border: 2px solid var(--gold); border-radius: 999px; padding: 6px 13px; color: var(--gold-strong); font-weight: 900; font-size: 1.25rem; }
.oracle-box, .keyword-section { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.oracle-box h2, .keyword-section h2 { font: 700 1.35rem Georgia, serif; }
.oracle-box p, .dialog-rules { white-space: pre-line; line-height: 1.7; }
.keyword-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.keyword-button { border: 1px solid var(--gold); background: transparent; color: var(--gold-strong); border-radius: 999px; padding: 9px 14px; cursor: pointer; font-weight: 800; }
.keyword-button:hover { background: var(--gold); color: #17110a; }
.hint { color: var(--muted); font-size: .85rem; }
.qr-panel { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 24px; }
.qr-panel summary { cursor: pointer; color: var(--gold-strong); font-weight: 800; }
.qr-panel img { width: 180px; max-width: 100%; display: block; margin: 18px 0; background: white; padding: 8px; }
.qr-panel code { display: block; overflow-wrap: anywhere; color: var(--muted); margin-bottom: 12px; }
.keyword-dialog { width: min(620px, calc(100vw - 32px)); color: var(--ink); background: var(--surface-2); border: 1px solid var(--gold); border-radius: 20px; padding: 34px; box-shadow: 0 25px 100px rgba(0,0,0,.7); }
.keyword-dialog::backdrop { background: rgba(3,3,2,.78); backdrop-filter: blur(3px); }
.keyword-dialog h2 { font: 700 2.2rem Georgia, serif; margin: 8px 42px 12px 0; }
.dialog-close { position: absolute; right: 14px; top: 12px; border: 0; background: transparent; color: var(--ink); font-size: 2rem; cursor: pointer; }
.dialog-summary { color: var(--gold-strong); font-weight: 750; line-height: 1.5; }
.rule-reference { color: var(--muted); font-size: .82rem; margin-top: 20px; }
footer { max-width: 1260px; margin: auto; padding: 28px; color: #8f836f; font-size: .78rem; border-top: 1px solid #31271b; }
.flash-stack { position: fixed; z-index: 20; right: 20px; top: 84px; width: min(360px, calc(100vw - 40px)); }
.flash { background: var(--surface-3); border: 1px solid var(--gold); border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow); }
.flash.error { border-color: var(--danger); }
.form-card { max-width: 980px; padding-top: 50px; }
.form-card.narrow { max-width: 520px; }
.form-card > h1, .admin-heading h1 { font: 700 2.6rem Georgia, serif; margin: 5px 0 24px; }
.form-card form:not(.danger-zone) { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 24px 0; padding: 18px; }
legend { color: var(--gold-strong); font-weight: 800; padding: 0 8px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(155px,1fr)); gap: 10px; }
.checkbox { display: flex; gap: 8px; align-items: center; }
.checkbox input { width: auto; }
.checkbox span { margin: 0; color: var(--ink); }
.form-actions, .admin-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.form-actions { justify-content: flex-start; margin-top: 20px; }
.danger-zone { margin-top: 22px; }
.admin-shell { padding-top: 50px; }
.admin-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.admin-table code { white-space: normal; overflow-wrap: anywhere; }
.text-button { border: 0; background: none; color: var(--gold-strong); padding: 15px 0; cursor: pointer; }
@media (max-width: 760px) {
  .site-header { padding-inline: 18px; }
  .site-header nav { gap: 12px; }
  .hero { margin-top: 34px; }
  .search-panel { grid-template-columns: 1fr; }
  .clear-link { text-align: center; }
  .token-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .token-card-copy { padding: 12px; min-height: 104px; }
  .token-card-copy h3 { font-size: 1.05rem; }
  .token-detail { grid-template-columns: 1fr; gap: 30px; margin-top: 24px; }
  .detail-image { width: min(100%, 420px); margin: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .admin-heading { align-items: flex-start; }
}
@media (max-width: 430px) {
  .brand small { display: none; }
  .token-grid { grid-template-columns: 1fr; }
}

/* Searchable multi-keyword picker */
.keyword-fieldset { overflow: visible; }
.keyword-picker { position: relative; }
.keyword-picker-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.keyword-picker-heading p { color: var(--muted); line-height: 1.5; margin: 0; }
.keyword-total { color: var(--gold-strong); font-size: .78rem; font-weight: 800; white-space: nowrap; }
.selected-keywords { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; min-height: 48px; padding: 10px; margin-bottom: 16px; background: #17120e; border: 1px solid var(--line); border-radius: 11px; }
.selected-keyword { display: inline-flex; align-items: center; gap: 7px; padding: 7px 8px 7px 11px; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold-strong); background: rgba(215,173,94,.08); font-weight: 800; }
.selected-keyword button { display: grid; place-items: center; width: 23px; height: 23px; padding: 0; border: 0; border-radius: 50%; background: rgba(215,173,94,.18); color: var(--ink); cursor: pointer; font-size: 1.12rem; line-height: 1; }
.selected-keyword button:hover, .selected-keyword button:focus-visible { background: var(--gold); color: #17110a; outline: none; }
.selected-keywords-empty { color: var(--muted); font-size: .88rem; padding: 2px 4px; }
.keyword-combobox { position: relative; }
.keyword-search-row { display: grid; grid-template-columns: 1fr 46px; }
.keyword-search-row input { border-radius: 10px 0 0 10px; }
.keyword-dropdown-button { border: 1px solid var(--line); border-left: 0; border-radius: 0 10px 10px 0; background: var(--surface-3); color: var(--gold-strong); cursor: pointer; font-size: 1.15rem; }
.keyword-dropdown-button:hover, .keyword-dropdown-button:focus-visible { background: var(--gold); color: #17110a; outline: none; }
.keyword-options { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 7px); max-height: 340px; overflow-y: auto; padding: 7px; background: #17120e; border: 1px solid var(--gold); border-radius: 12px; box-shadow: 0 22px 55px rgba(0,0,0,.55); }
.keyword-option { width: 100%; display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding: 11px 12px; border: 0; border-radius: 8px; text-align: left; background: transparent; color: var(--ink); cursor: pointer; }
.keyword-option:hover, .keyword-option:focus-visible { background: var(--surface-3); outline: none; }
.keyword-option span { font-weight: 800; }
.keyword-option small { color: var(--muted); white-space: nowrap; }
.keyword-options-empty { color: var(--muted); text-align: center; padding: 18px 10px; margin: 0; }
.keyword-noscript-select { min-height: 300px; }
.form-help { color: var(--muted); }

@media (max-width: 560px) {
  .keyword-picker-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .keyword-option { align-items: flex-start; flex-direction: column; gap: 3px; }
  .keyword-option small { white-space: normal; }
}

.rules-import-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 24px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.rules-import-status h2 { margin: 2px 0 6px; font: 700 1.35rem Georgia, serif; }
.rules-import-status p:last-child { margin-bottom: 0; color: var(--muted); }
@media (max-width: 700px) {
  .rules-import-status { align-items: flex-start; flex-direction: column; }
}
