:root {
  color-scheme: light;
  --ink: #202e48;
  --muted: #54627a;
  --paper: #fff;
  --page: #f6f7fc;
  --accent: #3746a3;
  --accent-hover: #28377f;
  --border: #d5dbe8;
  --error: #a11f33;
  font-family: ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--page);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 240px; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid #9c5b00; outline-offset: 4px; }
h1, h2 { line-height: 1.2; letter-spacing: -.025em; }
h1 { margin: .3rem 0 1rem; font-size: clamp(1.8rem, 5vw, 2.6rem); }
h2 { font-size: 1.5rem; }
p { margin: 0 0 1rem; }
.skip-link { position: absolute; left: 1rem; top: -6rem; z-index: 10; padding: .8rem; background: var(--paper); }
.skip-link:focus { top: 1rem; }
.site-header { background: var(--paper); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 72rem; margin: auto; padding: 1rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); font-weight: 750; text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .8rem; background: #fff0bd; color: #765500; font-size: 1.5rem; }
nav { display: flex; align-items: center; gap: .4rem 1rem; flex-wrap: wrap; }
nav a { display: inline-flex; align-items: center; min-height: 44px; }
nav form { margin: 0; }
.page { max-width: 72rem; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.panel { padding: clamp(1.4rem, 4vw, 2.5rem); border: 1px solid var(--border); border-radius: 1.5rem; background: var(--paper); box-shadow: 0 .3rem 1.5rem #202e4806; }
.auth-panel { max-width: 32rem; margin: 2rem auto; }
.eyebrow { margin-bottom: .5rem; color: var(--accent); font-size: .8rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.intro, .muted { color: var(--muted); }
.intro { margin-bottom: 1.75rem; }
.stack-form p { margin: 0 0 1.3rem; }
.stack-form label { display: block; margin-bottom: .4rem; font-weight: 650; }
.stack-form input:not([type="hidden"]), .stack-form select, .stack-form textarea { display: block; width: 100%; min-height: 48px; border: 1px solid #8895ad; border-radius: .65rem; background: var(--paper); color: var(--ink); padding: .7rem .8rem; font: inherit; }
.stack-form input[aria-invalid="true"] { border-color: var(--error); }
.helptext { display: block; color: var(--muted); margin-top: .4rem; font-size: .9rem; }
.helptext ul { padding-left: 1.2rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: .7rem 1.2rem; border: 1px solid transparent; border-radius: .7rem; background: var(--accent); color: #fff; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--accent-hover); color: #fff; }
.button-quiet { min-height: 44px; padding: .45rem .75rem; color: var(--accent); background: #edf0fb; }
.button-quiet:hover { background: #e0e5f7; color: var(--accent-hover); }
.stack-form > .button { width: 100%; }
.secondary-link { display: block; margin-top: 1rem; padding: .5rem; text-align: center; }
.errorlist { margin: 0 0 1rem; padding: .8rem 1rem .8rem 2rem; color: var(--error); border: 1px solid #e7b8c0; border-radius: .65rem; background: #fff4f5; }
.messages { margin-bottom: 1.5rem; }
.message { padding: 1rem; border: 1px solid var(--border); border-radius: .65rem; background: var(--paper); }
.page-heading { margin-bottom: 2rem; }
.empty-state { max-width: 46rem; margin: 0 auto; text-align: center; }
.empty-state p { max-width: 34rem; margin: 0 auto 1rem; }
.empty-symbol { display: inline-grid; place-items: center; width: 4rem; height: 4rem; background: #fff0bd; color: #765500; border-radius: 1.3rem; font-size: 2.2rem; }
.site-footer { padding: 0 1.5rem 2rem; text-align: center; color: var(--muted); font-size: .85rem; }
@media (max-width: 520px) {
  .header-inner { padding: 1rem; gap: .5rem; }
  nav { width: 100%; justify-content: space-between; font-size: .9rem; gap: .25rem; }
  .page { padding: 1.5rem 1rem 3rem; }
  .auth-panel { margin: .5rem auto; }
}

/* Collection screens use ordinary links and forms, including on phones. */
.heading-actions, .form-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.heading-actions h1 { margin-bottom: 0; }
.collection-summary { display: flex; flex-wrap: wrap; gap: .75rem 2rem; padding: 1rem 1.25rem; margin-bottom: 1.5rem; border-radius: 1rem; background: #e9edfa; }
.collection-summary p { margin: 0; }
.collection-summary strong { font-size: 1.3rem; }
.browse-controls { margin-bottom: 2rem; padding: 1.25rem; }
.filter-main, .filter-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: 0 1rem; }
.filter-main { grid-template-columns: 2fr 1fr 1fr; }
summary { min-height: 44px; padding: .5rem 0; cursor: pointer; font-weight: 650; }
.filter-fields { margin-top: 1rem; }
.stack-form input[type='checkbox'] { display: inline-block; width: 1.4rem; height: 1.4rem; min-height: 0; margin: .35rem .5rem .35rem 0; vertical-align: middle; accent-color: var(--accent); }
.stack-form p:has(input[type='checkbox']) { min-height: 48px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: 1.25rem; }
.collection-card { min-width: 0; overflow: hidden; background: var(--paper); border: 1px solid var(--border); border-radius: 1rem; }
.card-art-link { display: block; padding: 1rem; background: #edf0f8; text-decoration: none; }
.card-art { display: block; width: 100%; max-width: 22rem; height: auto; aspect-ratio: 5 / 7; object-fit: contain; margin: auto; border-radius: .6rem; }
.artwork-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #e0e5f4; color: var(--muted); border: 2px dashed #adb8d5; text-align: center; gap: 1rem; padding: 1rem; }
.artwork-placeholder > span { font-size: 3rem; color: var(--accent); }
/* The frame shows a neutral mark while loading. A broken image renders its
   pseudo-elements in Chromium and Firefox (no script needed), covering the
   broken-image icon with the "unavailable" placeholder. Safari does not, so
   static/js/artwork.js adds .artwork-failed instead. Alt text stays available to
   assistive technology but is not painted. */
.artwork-frame { position: relative; overflow: hidden; background: #e0e5f4; }
.artwork-frame::before { content: "✦"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 3rem; color: #c3cbe3; }
.artwork-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; color: transparent; font-size: 0; }
.artwork-image::after { content: "Artwork unavailable"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 5.5rem 1rem 1rem; background: #e0e5f4; border: 2px dashed #adb8d5; border-radius: inherit; color: var(--muted); font-size: .85rem; }
.artwork-image::before { content: "✦"; position: absolute; z-index: 1; inset: 0 0 2rem; display: flex; align-items: center; justify-content: center; font-size: 3rem; color: var(--accent); }
.artwork-failed .artwork-image { visibility: hidden; }
.artwork-failed { border: 2px dashed #adb8d5; }
.artwork-failed::before { inset: 0 0 2rem; color: var(--accent); }
.artwork-failed::after { content: "Artwork unavailable"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 5.5rem 1rem 1rem; color: var(--muted); font-size: .85rem; }
.card-info { padding: 1rem; overflow-wrap: anywhere; }
.card-info h2 { font-size: 1.15rem; margin: 0 0 .4rem; }
.card-info p { font-size: .9rem; margin-bottom: .4rem; }
.card-info .button { width: 100%; margin-top: .75rem; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: .4rem; background: #fff0bd; color: #765500; font-size: .8rem; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 1rem; background: var(--paper); }
.collection-table { width: 100%; border-collapse: collapse; text-align: left; }
.collection-table th, .collection-table td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.collection-table th { background: #edf0f8; white-space: nowrap; }
.collection-table tr:last-child td { border-bottom: 0; }
.collection-table td:first-child a { display: inline-block; min-height: 44px; }
.pagination { margin-top: 2rem; justify-content: center; }
.search-form, .edit-panel { max-width: 46rem; }
.manual-link { margin: 1.5rem 0 2rem; }
.entry-layout { display: grid; grid-template-columns: minmax(12rem, 1fr) minmax(0, 2fr); gap: 2rem; align-items: start; }
.selected-card { max-width: 23rem; margin: 0 auto; overflow-wrap: anywhere; }
.selected-card h2 { margin-top: 1rem; }
.selected-card > .card-art { background: #edf0f8; }
.entry-facts { display: grid; grid-template-columns: minmax(6rem, 1fr) 2fr; gap: .6rem 1rem; }
.entry-facts dt { color: var(--muted); }
.entry-facts dd { margin: 0; overflow-wrap: anywhere; }
.entry-note { overflow-wrap: anywhere; }
.price-notice { padding: 1rem 0; margin: 1rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.price-notice h3 { margin-top: 0; }
.price-notice p { margin: 0; }
.price-links ul { margin: .5rem 0 1rem; padding-left: 1.2rem; }
.price-links a { display: inline-block; min-height: 44px; padding: .55rem 0; }
.price-links h3 { margin-bottom: .25rem; }
.notice { padding: 1rem; border-left: 4px solid #9c6b00; background: #fff8e0; border-radius: .3rem; }
.form-actions { justify-content: flex-start; }
.form-actions form, .form-actions form p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 650px) {
  .filter-main, .entry-layout { grid-template-columns: 1fr; }
  .selected-card { width: min(100%, 18rem); }
  .entry-layout { gap: 1.5rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 10rem), 1fr)); gap: .75rem; }
  .card-info { padding: .8rem; }
  .card-art-link { padding: .7rem; }
  .form-actions > .button, .form-actions > form, .form-actions > form .button { width: 100%; }
  .heading-actions .button { width: 100%; }
}

.price-basis { display: block; font-size: .9rem; }
.price-history, .export-controls { margin-top: 1.5rem; }
.history-series + .history-series { border-top: 1px solid #cbd5e1; margin-top: 1.5rem; padding-top: 1rem; }
.price-history figure { margin: 1rem 0; }
.price-history svg { display: block; width: 100%; max-width: 700px; }
.chart-axis { fill: none; stroke: #64748b; stroke-width: 1; }
.chart-line { fill: none; stroke: #3155a5; stroke-width: 2; }
.chart-point { fill: #3155a5; }

/* Keep long card names, translated metadata and native controls inside the page. */
.page, .panel, .filter-main > *, .filter-fields > *, .entry-layout > * { min-width: 0; }
h1, h2, h3, .brand, .notice, .message, .price-history, .collection-summary { overflow-wrap: anywhere; }
.stack-form select, .stack-form input, .stack-form textarea { max-width: 100%; }
.stack-form textarea { resize: vertical; }
.stack-form select { text-overflow: ellipsis; }
.stack-form select[aria-invalid="true"], .stack-form textarea[aria-invalid="true"] { border-color: var(--error); }
.brand { min-height: 44px; }
.brand-mark { flex-shrink: 0; }
.tap-link, .form-actions > a:not(.button), .manual-link a, .page > p > a { display: inline-flex; align-items: center; min-height: 44px; }
.secondary-link { min-height: 44px; }
.card-info h2 a { display: inline-block; padding: .3rem 0; }
.stack-form p:has(input[type='checkbox']) { display: flex; align-items: center; flex-wrap: wrap; gap: 0 .5rem; }
.stack-form p:has(input[type='checkbox']) label { display: inline-flex; align-items: center; min-height: 44px; margin: 0; cursor: pointer; }
.stack-form p:has(input[type='checkbox']) input { flex-shrink: 0; }
.table-wrap:focus-visible { outline-offset: 2px; }
.table-wrap { overscroll-behavior-x: contain; }
.table-hint { font-size: .9rem; margin-bottom: .5rem; }
.form-error-summary { margin-bottom: 1.5rem; border-color: var(--error); background: #fff4f5; color: var(--ink); }
.form-error-summary h2 { font-size: 1.2rem; margin-top: 0; }
.form-error-summary ul { margin-bottom: 0; padding-left: 1.3rem; }
.form-error-summary a { display: inline-block; padding: .35rem 0; }
@media (max-width: 650px) {
  .entry-facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: .65rem; }
  .entry-facts dt { overflow-wrap: anywhere; }
  .export-controls a { display: inline-block; min-height: 44px; padding: .4rem 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
