:root {
  color-scheme: light;
  font: 100%/1.5 "Source Sans 3", system-ui, sans-serif;
  color: #172e2b;
  background: #f3f5f1;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
.masthead {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .95rem clamp(1.25rem, 5vw, 5rem);
  border-bottom: 1px solid #cbd4cb;
  font: 600 1.22rem/1.2 Georgia, serif;
}
.masthead img { border-radius: .5rem; }
main { width: min(100% - 2rem, 30rem); margin: clamp(1.8rem, 8vh, 6rem) auto; }
#signin, #shell {
  padding: clamp(1.45rem, 5vw, 2.75rem);
  background: #fffefa;
  border: 1px solid #cbd4cb;
  border-radius: 1rem;
  box-shadow: 0 .8rem 2.4rem #172e2b0c;
}
.card-back {
  height: 5.25rem;
  width: 3.8rem;
  margin: 0 0 1.6rem .5rem;
  display: grid;
  place-items: center;
  transform: rotate(7deg);
  border-radius: .36rem;
  color: #e4c990;
  background: repeating-radial-gradient(ellipse at center, #254841 0 5px, #547268 6px, #254841 7px);
  outline: 1px solid #b8aa80;
  outline-offset: -4px;
  box-shadow: -.34rem .25rem 0 #d6dfd6, -.39rem .29rem 0 #9eaea3;
}
.card-back span { font: 2.8rem/1 Georgia, serif; }
h1 { font: 500 clamp(2.3rem, 7vw, 3.2rem)/1.1 "Baskervville", Georgia, serif; letter-spacing: -.04em; margin: 0 0 1.7rem; }
form { display: grid; }
label, dt { font-weight: 600; font-size: .9375rem; }
input, button { font: inherit; }
input { min-width: 0; margin: .35rem 0 1rem; padding: .65rem .8rem; border: 1px solid #97a79e; border-radius: .4rem; background: white; color: inherit; }
button { cursor: pointer; min-height: 2.8rem; }
.primary { margin-top: .65rem; padding: .65rem 1.2rem; color: #fff; background: #23483f; border: 0; border-radius: .4rem; font-weight: 600; }
.primary:hover { background: #17372f; }
.secondary { padding: .65rem 1.2rem; color: #23483f; background: transparent; border: 1px solid #23483f; border-radius: .4rem; font-weight: 600; }
h2 { font: 600 1.15rem/1.3 Georgia, serif; margin: 1rem 0 .9rem; }
#password-form { margin-bottom: 2rem; padding-top: 1rem; border-top: 1px solid #cbd4cb; }
#password-status { margin: .75rem 0 0; color: #23483f; }
#password-status.error { color: #8d3424; }
#password-status:empty { display: none; }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 3px solid #a66420; outline-offset: 3px; }
nav { display: flex; gap: .2rem; border-bottom: 1px solid #cbd4cb; margin: -.5rem 0 2rem; }
nav button { flex: 1; padding: .35rem; color: inherit; background: transparent; border: 0; border-bottom: 3px solid transparent; }
nav [aria-current] { border-color: #23483f; font-weight: 650; }
#shell section { min-height: 12rem; }
dd { margin: .15rem 0 1rem; overflow-wrap: anywhere; }
#message { color: #8d3424; }
#message:empty { display: none; }

#capture { width: 100%; min-height: 3.4rem; margin: 0; }
#scan-status, #recent-status, #card-printing { color: #455c52; }
#scan-status:empty, #recent-status:empty { display: none; }
#review { margin-top: 1.5rem; }
#card-art { display: block; width: min(100%, 17rem); margin: 0 auto .5rem; border-radius: .8rem; }
#card-name { margin-bottom: .25rem; font-size: 1.6rem; }
#card-printing { margin: 0 0 1rem; }
#scan-controls { display: grid; gap: .4rem; min-width: 0; padding: 0; border: 0; margin: 0; }
#scan-controls label { margin-top: .5rem; }
#scan-controls select, .stepper button, .stepper input {
  min-height: 2.8rem; margin: 0; padding: .5rem .7rem; border: 1px solid #97a79e;
  background: white; border-radius: .4rem; color: inherit; font: inherit;
}
.stepper { display: grid; grid-template-columns: 3rem minmax(4rem, 1fr) 3rem; gap: .4rem; }
.stepper input { text-align: center; }
#card-price { font-weight: 600; margin: .7rem 0 0; }
#recent-title { border-top: 1px solid #cbd4cb; padding-top: 1.5rem; margin-top: 2rem; }
#recent { list-style: none; padding: 0; margin: 0; }
#recent a, .printing-list button {
  display: flex; gap: .7rem; align-items: center; text-align: left; overflow-wrap: anywhere;
  padding: .65rem 0; border: 0; border-bottom: 1px solid #dbe1db; width: 100%; color: inherit; background: transparent;
}
#printings-panel { display: grid; }
#printing-filter { margin-bottom: .3rem; }
.printing-count { margin: 0 0 .3rem; color: #455c52; font-size: .87rem; }
.printing-list { max-height: 20rem; overflow-y: auto; padding: .2rem; }
.printing-list button:hover { background: #f3f5f1; }
#recent img, .printing-list img { width: 2.8rem; border-radius: .2rem; }
#recent span span, .printing-list span span { display: block; color: #455c52; font-size: .87rem; }
.scan-modes { display: flex; padding: .2rem; margin: 0 0 1rem; background: #e8ede5; border-radius: .55rem; }
.scan-modes button { flex: 1; border: 0; border-radius: .4rem; background: transparent; color: #23483f; }
.scan-modes [aria-pressed="true"] { background: #23483f; color: white; font-weight: 600; }
#batch-controls { margin: 0; padding: 0; min-width: 0; border: 0; }
#spread-photo, #start-camera { width: 100%; }
.viewfinder { position: relative; aspect-ratio: 4 / 5; overflow: hidden; border-radius: .6rem; background: #172e2b; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; }
#stack-guide { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 75%;
  aspect-ratio: 63 / 88; border: 2px solid white; border-radius: .6rem; box-shadow: 0 0 0 100vmax #0006; }
.stack-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-top: .6rem; }
.stack-actions button, .stack-actions input { margin: 0; }
.auto-hint { margin: .45rem 0 0; color: #455c52; font-size: .87rem; }
#capture-frame { flex: 1; min-height: 3.3rem; }
#review-queue { display: grid; gap: .9rem; list-style: none; padding: 0; }
.queue-row { min-width: 0; padding: .9rem; border: 1px solid #cbd4cb; border-radius: .6rem; }
.queue-row.has-error { border-color: #993d2d; }
.queue-overview { display: flex; align-items: center; gap: .7rem; overflow-wrap: anywhere; }
.queue-overview small, .queue-price { display: block; color: #455c52; }
.queue-art:empty, .queue-error:empty, #camera-status:empty, #batch-status:empty { display: none; }
.queue-art img, .queue-art canvas { display: block; width: 3.8rem; max-height: 6rem; object-fit: contain; border-radius: .25rem; }
.queue-flags { display: flex; gap: .35rem; flex-wrap: wrap; }
.queue-flags span { color: #553915; background: #f4e7c9; padding: .12rem .45rem; border-radius: .3rem;
  margin-top: .5rem; font-size: .85rem; }
.queue-error { color: #8d3424; }
.queue-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin: .75rem 0; }
.queue-quantity { grid-column: 1 / -1; font-size: .9375rem; font-weight: 600; }
.queue-choices select, .queue-row input[type="search"] { display: block; width: 100%; min-width: 0; }
.queue-choices select { font: inherit; color: inherit; background: white; border-radius: .4rem; min-height: 2.75rem; }
.queue-search, .queue-picker { margin-top: .75rem; }
.queue-search input { margin-bottom: .4rem; }
.queue-row .secondary { padding: .45rem .65rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

a { color: #23483f; text-underline-offset: .18em; }
#recent a, .card-tile { text-decoration: none; }
main.collection-open { width: min(100% - 1rem, 70rem); margin: 1.2rem auto; }
.collection-open #shell { padding: clamp(.85rem, 3vw, 2.5rem); }
.value-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 2rem;
  background: #23483f; color: #fffefa; border-radius: .65rem; padding: 1rem 1.25rem; }
.value-bar strong { display: block; font: 500 clamp(2rem, 5vw, 3rem)/1.15 Georgia, serif; overflow-wrap: anywhere; }
.value-bar p { margin: .1rem 0; }
.refresh-line { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; font-size: .9rem; }
.refresh-line button { color: inherit; border-color: #b4c7bd; min-height: 2.4rem; padding: .3rem .7rem; }
.refresh-line small { display: block; }
#collection-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: 1.25rem 0; }
.search-name { grid-column: 1 / -1; }
/* Phones: search, then [Filters] [Sort by], then the four filters when opened. */
#filters-toggle { grid-row: 2; grid-column: 1; align-self: end; min-height: 2.75rem; margin: 0; }
#filters-toggle[aria-expanded="true"] { background: #23483f; color: white; }
.sort-by { grid-row: 2; grid-column: 2; }
#more-filters { grid-column: 1 / -1; display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
#more-filters.open { display: grid; }
#collection-filters input, #collection select { display: block; width: 100%; min-width: 0; margin: .25rem 0 0;
  padding: .5rem; min-height: 2.75rem; font: inherit; color: inherit; background: white; border: 1px solid #97a79e; border-radius: .4rem; }
#card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem .7rem; }
.card-tile { min-width: 0; display: flex; flex-direction: column; color: inherit; overflow-wrap: anywhere; }
.card-tile:hover strong, #recent a:hover strong { text-decoration: underline; }
.tile-art { position: relative; aspect-ratio: 63 / 88; background: #e8ede5; border-radius: .5rem; overflow: hidden; margin-bottom: .4rem; }
.tile-art img { width: 100%; height: 100%; object-fit: contain; }
.tile-art span { position: absolute; bottom: .35rem; font-size: .8rem; font-weight: bold; padding: .12rem .45rem; border-radius: .3rem; }
.qty-badge { right: .35rem; color: white; background: #172e2b; }
.finish-badge { left: .35rem; color: #332507; background: #efdcaa; }
.card-tile small, #match-count, .date-axis { color: #455c52; }
#load-more { display: block; margin: 1.5rem auto 0; }
#collection-message { color: #8d3424; }
#collection-message:empty, #match-count:empty { display: none; }
#collection-back { display: inline-block; padding: .6rem 0; }
.detail-overview { display: grid; gap: 1.2rem; margin: 1rem 0 1.8rem; }
.detail-overview img { width: min(100%, 17rem); border-radius: .65rem; justify-self: center; }
.detail-overview h1 { margin: 0; overflow-wrap: anywhere; }
.finish-prices { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.finish-prices dd { margin: 0; }
.chart-ranges, .copy-actions, .chart-legend { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chart-ranges button { padding: .25rem .8rem; }
.chart-ranges [aria-pressed="true"] { background: #23483f; color: white; }
#collection figure { margin: .8rem 0 1.5rem; padding: .8rem 1rem; max-width: 42rem; border: 1px solid #cbd4cb; border-radius: .5rem; }
#collection svg { display: block; width: 100%; border-bottom: 1px solid #cbd4cb; }
.date-axis { display: flex; justify-content: space-between; font-size: .8rem; }
.chart-legend { margin-top: .5rem; gap: 1rem; }
.chart-legend span::before { content: ""; display: inline-block; width: .9rem; margin-right: .3rem; border-top: 3px solid; vertical-align: middle; }
.series-nonfoil { color: #285a45; } .series-foil { color: #8c501c; } .series-etched { color: #725288; }
.copy-editor fieldset { min-width: 0; margin: .5rem 0; padding: .9rem; border: 1px solid #cbd4cb; border-radius: .5rem; display: grid; gap: .4rem; }
.copy-editor legend { font-weight: 600; padding: 0 .4rem; }
.copy-actions { margin-top: .5rem; }
.copy-actions button { margin: 0; }
@media (min-width: 40rem) {
  #card-grid { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 1.4rem 1rem; }
  #collection-filters { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  /* Wider screens show every filter inline; the toggle isn't needed. */
  #filters-toggle { display: none; }
  #more-filters, #more-filters.open { display: contents; }
  .sort-by { grid-row: auto; grid-column: auto; }
  .detail-overview { grid-template-columns: minmax(10rem, 16rem) 1fr; align-items: center; }
  .copy-editor { max-width: 42rem; }
  .refresh-line { margin-left: auto; }
}
