:root {
  --bg: #fffaf4;
  --paper: #ffffff;
  --ink: #23201d;
  --muted: #695f55;
  --line: #eadfd3;
  --brand: #8d1e2d;
  --brand-dark: #65111d;
  --accent: #1f6f4a;
  --gold: #b7791f;
  --cream: #fbf1e4;
  --shadow: 0 24px 70px rgba(67, 41, 24, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff3df 0, transparent 34rem), var(--bg);
  line-height: 1.5;
}

a { color: inherit; }
button, input, select { font: inherit; }
button, .button, .file-label {
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
button:hover, .button:hover, .file-label:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(101,17,29,.18); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #f7bf53; outline-offset: 3px; }
.button.secondary, #clearFilters, #stopScan, #clearWishlist, #resetDemo { background: #efe2d1; color: var(--ink); }
.button.primary { background: var(--accent); }
.link-button { background: transparent; color: #fff; padding: 0; border-radius: 0; text-decoration: underline; box-shadow: none; }
.link-button:hover { box-shadow: none; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 20; background: #fff; color: var(--brand-dark); padding: .8rem 1rem; border-radius: .5rem; }
.skip-link:focus { top: 1rem; }
.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; }

.site-header { background: rgba(255,250,244,.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-strip { background: var(--brand-dark); color: #fff; display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .45rem clamp(1rem, 4vw, 3rem); font-size: .9rem; }
.nav-wrap { display: flex; align-items: center; justify-content: space-between; max-width: 1180px; margin: 0 auto; padding: 1rem clamp(1rem, 4vw, 2rem); }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand-mark { width: 3rem; height: 3rem; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #c58b35); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; letter-spacing: .05em; }
.brand strong, .brand em { display: block; }
.brand em { color: var(--muted); font-style: normal; font-size: .9rem; }
.nav { display: flex; list-style: none; margin: 0; padding: 0; gap: .35rem; }
.nav a { display: block; padding: .7rem .9rem; text-decoration: none; border-radius: 999px; font-weight: 700; color: var(--ink); }
.nav a:hover { background: var(--cream); color: var(--brand); }
.nav-toggle { display: none; }

.hero { max-width: 1180px; margin: 0 auto; padding: clamp(2.5rem, 8vw, 6rem) clamp(1rem, 4vw, 2rem); display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 2rem; align-items: center; }
.eyebrow { color: var(--brand); text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 800; margin: 0 0 .45rem; }
h1, h2, h3 { line-height: 1.1; margin: 0; }
h1 { font-size: clamp(2.35rem, 6vw, 5rem); max-width: 11ch; }
h2 { font-size: clamp(1.8rem, 3.5vw, 3rem); }
h3 { font-size: 1.1rem; }
.hero-text { font-size: 1.15rem; color: var(--muted); max-width: 48rem; }
.hero-search { display: flex; gap: .7rem; padding: .45rem; background: #fff; border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); max-width: 48rem; }
.hero-search input { flex: 1; border: 0; padding: .85rem 1rem; border-radius: 999px; min-width: 0; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.2rem; }
.hero-panel { background: linear-gradient(160deg, #fff, #fff8ef); padding: 1rem; border: 1px solid var(--line); border-radius: 2rem; box-shadow: var(--shadow); }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: 1.25rem; padding: 1.2rem; }
.stat-card.featured { min-height: 14rem; display: flex; flex-direction: column; justify-content: center; align-items: center; margin-bottom: 1rem; background: radial-gradient(circle at 50% 10%, rgba(141,30,45,.18), transparent 45%), #fff; }
.stat-number { font-size: clamp(2rem, 5vw, 4rem); font-weight: 900; color: var(--brand); display: block; }
.stat-label { color: var(--muted); font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }

.feature-band, .toolbar-section, .catalog-section, .split-section, .scanner-section, .import-section { max-width: 1180px; margin: 0 auto; padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 4vw, 2rem); }
.feature-band { display: grid; grid-template-columns: .75fr 1.25fr; gap: 2rem; align-items: start; }
.feature-cards { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.feature-cards article, .panel, .scanner-card, .manual-scan, .import-section { background: var(--paper); border: 1px solid var(--line); border-radius: 1.5rem; box-shadow: var(--shadow); padding: 1.25rem; }
.feature-cards span { font-size: 2rem; }
.feature-cards p, .section-heading p, .card-description, .helper, .site-footer p { color: var(--muted); }
.section-heading { max-width: 54rem; margin-bottom: 1.5rem; }
.section-heading.compact { display: flex; flex-direction: column; gap: .45rem; }
.filters { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters label { font-weight: 800; color: var(--muted); display: grid; gap: .35rem; min-width: 12rem; }
select, input[type="text"], input[type="search"] { border: 1px solid var(--line); background: #fff; color: var(--ink); }
select, .manual-scan input { border-radius: .8rem; padding: .8rem; }
.table-wrap { overflow: auto; background: #fff; border-radius: 1.25rem; border: 1px solid var(--line); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { padding: .9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #fbf1e4; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
td .row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
td button { padding: .55rem .75rem; font-size: .85rem; }

.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1rem; }
.ornament-card { background: #fff; border: 1px solid var(--line); border-radius: 1.5rem; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.ornament-art { min-height: 210px; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #fff 0%, #fff6eb 100%); }
.ornament-art svg { width: min(72%, 210px); height: auto; filter: drop-shadow(0 18px 25px rgba(75,45,20,.15)); }
.card-body { padding: 1.1rem; display: grid; gap: .75rem; }
.card-meta { color: var(--brand); font-weight: 900; margin: 0; font-size: .88rem; }
.card-description { margin: 0; }
.mini-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; margin: 0; }
.mini-facts div { background: #fbf1e4; border-radius: .75rem; padding: .55rem; }
.mini-facts dt { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.mini-facts dd { margin: 0; font-weight: 800; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.wish-button { background: var(--gold); }
.own-button.added, .wish-button.added { background: var(--accent); }

.split-section { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.panel-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: start; margin-bottom: 1rem; }
.collection-list { display: grid; gap: .8rem; }
.collection-item { border: 1px solid var(--line); border-radius: 1rem; padding: .9rem; background: #fffdf9; display: grid; gap: .6rem; }
.collection-item h3 { margin-right: 1rem; }
.collection-controls { display: grid; grid-template-columns: .7fr 1fr 1fr auto; gap: .5rem; align-items: end; }
.collection-controls label { display: grid; gap: .2rem; font-size: .85rem; font-weight: 800; color: var(--muted); }
.collection-controls input, .collection-controls select { border: 1px solid var(--line); border-radius: .65rem; padding: .55rem; min-width: 0; }
.collection-controls button { border-radius: .7rem; padding: .6rem .8rem; background: #6f1d1b; }
.empty-state { border: 1px dashed #c9bba8; border-radius: 1rem; padding: 1rem; background: #fffaf4; color: var(--muted); }

.scanner-layout { display: grid; grid-template-columns: .9fr 1.1fr; gap: 1rem; }
#scannerVideo { width: 100%; aspect-ratio: 16/10; background: #231f20; border-radius: 1rem; display: block; object-fit: cover; }
.scanner-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }
.manual-scan { display: grid; gap: .8rem; align-content: start; }
.manual-scan label { font-weight: 900; }
.scan-result { border-radius: 1rem; background: #fff7ec; border: 1px solid var(--line); padding: 1rem; min-height: 5rem; }
.scan-result strong { color: var(--brand); }
.import-section { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.import-actions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: flex-end; }
.file-label input { display: none; }
.site-footer { max-width: 1180px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2rem) 4rem; display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); }
.site-footer a { font-weight: 900; color: var(--brand); }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .nav { display: none; position: absolute; left: 1rem; right: 1rem; top: 7.4rem; background: #fff; border: 1px solid var(--line); border-radius: 1rem; padding: .5rem; box-shadow: var(--shadow); flex-direction: column; }
  .nav.open { display: flex; }
  .hero, .feature-band, .split-section, .scanner-layout, .import-section { grid-template-columns: 1fr; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  h1 { max-width: 14ch; }
  .hero-search { border-radius: 1.25rem; flex-direction: column; }
  .hero-search button { width: 100%; }
  .import-section { align-items: stretch; }
  .import-actions { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .top-strip { align-items: flex-start; flex-direction: column; }
  .catalog-grid, .feature-cards, .stat-grid { grid-template-columns: 1fr; }
  .panel-heading, .site-footer { flex-direction: column; }
  .collection-controls { grid-template-columns: 1fr; }
  .card-actions { grid-template-columns: 1fr; }
}
