:root {
  color-scheme: light;
  --bg: #f5eee4;
  --panel: rgba(255, 253, 247, .86);
  --ink: #28181d;
  --muted: #6f6264;
  --line: rgba(45, 23, 28, .14);
  --accent: #4b1626;
  --accent-2: #ba862d;
  --soft: #fff7e9;
  --shadow: 0 24px 60px rgba(27, 10, 18, .15);
  --radius: 28px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: Aptos, "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(139, 35, 59, .13), transparent 26rem),
    radial-gradient(circle at 92% 20%, rgba(186, 134, 45, .16), transparent 22rem),
    linear-gradient(135deg, #f5eee4, #fffaf1 48%, #efe2d0);
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-header {
  width: min(1180px, calc(100% - 28px));
  margin: 24px auto 16px;
  padding: 24px;
  border-radius: 32px;
  background: var(--panel);
  border: 1px solid rgba(77, 22, 38, .12);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: 12px;
  font-weight: 950;
}

h1, h2, h3 { margin: 0; }
h1 {
  font-size: clamp(34px, 5.6vw, 68px);
  line-height: .92;
  letter-spacing: -.065em;
  color: var(--accent);
}
h2 { font-size: clamp(22px, 3vw, 34px); letter-spacing: -.035em; color: var(--ink); }
h3 { font-size: 20px; letter-spacing: -.025em; line-height: 1.08; }
.lede { max-width: 68ch; color: var(--muted); line-height: 1.48; margin: 12px 0 0; }

.mode-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.tab {
  border: 1px solid rgba(75, 22, 38, .16);
  background: rgba(255,255,255,.58);
  color: var(--accent);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
}
.tab.active, .tab:hover { background: var(--accent); color: #ffffff; }
.link-tab { display: inline-flex; align-items: center; }
.icon-tab {
  width: 44px;
  height: 42px;
  justify-content: center;
  padding: 0;
}
.icon-tab svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layout {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 18px;
  align-items: start;
}
.layout.mode-add,
.layout.mode-scan {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}
.panel {
  background: var(--panel);
  border: 1px solid rgba(77, 22, 38, .12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(10px);
}
.hidden { display: none !important; }

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}
.stats-chip, .small-button, .ghost-button {
  border: 1px solid rgba(75, 22, 38, .16);
  border-radius: 999px;
  background: rgba(255,255,255,.64);
  padding: 9px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.small-button { color: var(--accent); text-decoration: none; }
.small-button:not(.disabled) { cursor: pointer; }
.small-button.disabled { pointer-events: none; opacity: .45; }
.ghost-button { cursor: pointer; color: var(--accent); }
.stats-box {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  border-radius: 8px;
  margin: -4px 0 14px;
  padding: 10px;
  color: var(--accent);
  background: rgba(255,255,255,.72);
}
.stats-box span {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(75, 22, 38, .12);
  border-radius: 8px;
  background: rgba(255,255,255,.62);
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
}
.stats-box strong {
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.filter-panel {
  border: 1px solid rgba(75, 22, 38, .12);
  border-radius: 14px;
  background: rgba(255,255,255,.42);
  margin-bottom: 14px;
  overflow: hidden;
}
.filter-panel summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  padding: 12px 14px;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.filter-panel[open] summary {
  border-bottom: 1px solid rgba(75, 22, 38, .10);
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}
.price-filter { min-width: 0; }
.price-range-controls {
  display: grid;
  gap: 4px;
}
input[type="range"] {
  padding: 0;
  height: 42px;
  accent-color: var(--accent);
  background: transparent;
  border: 0;
}
label span, .search-box span, .type-filter span {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  font-weight: 950;
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(45, 23, 28, .16);
  background: rgba(255,255,255,.72);
  color: var(--ink);
  border-radius: 16px;
  padding: 12px 13px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px rgba(186,134,45,.13); }

.results { display: grid; gap: 12px; }
.result-card {
  border: 1px solid rgba(45, 23, 28, .12);
  border-radius: 22px;
  background: rgba(255,255,255,.58);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  cursor: pointer;
}
.result-card:focus-visible {
  outline: 3px solid rgba(186,134,45,.42);
  outline-offset: 3px;
}
.result-kicker { margin: 0 0 6px; color: var(--accent-2); text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 950; }
.result-meta { margin: 7px 0 0; color: var(--muted); line-height: 1.35; font-weight: 650; }
.note-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.note-chip {
  border: 1px solid rgba(75, 22, 38, .12);
  background: var(--soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 780;
}
.result-actions { display: flex; flex-direction: column; gap: 8px; }
.result-actions button, .result-actions .buy-button, .primary-button, .danger-button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(75,22,38,.18);
}
.danger-button {
  background: #9f2736;
  box-shadow: 0 8px 18px rgba(159,39,54,.18);
}
.profile-button {
  border: 1px solid var(--accent-2);
  border-radius: 999px;
  background: #fff8e7;
  color: var(--accent);
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
}
.profile-button:hover { transform: translateY(-1px); }
.result-actions button:disabled,
.result-actions .buy-button.disabled {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
}
.result-actions .buy-button {
  background: rgba(186,134,45,.18);
  color: var(--accent);
  box-shadow: none;
  display: grid;
  place-items: center;
  min-width: 46px;
  min-height: 42px;
  text-decoration: none;
  font-size: 20px;
  line-height: 1;
}
.result-actions .buy-button:not(.disabled):hover { transform: translateY(-1px); }
.rating-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(54px, 1fr));
  gap: 6px;
}
.result-actions .rating-button {
  background: rgba(255,255,255,.78);
  color: var(--accent);
  border: 1px solid rgba(75, 22, 38, .16);
  box-shadow: none;
  min-width: 0;
  padding-inline: 10px;
}
.result-actions .rating-button.active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #ffffff;
}
.result-actions button:hover, .primary-button:hover, .danger-button:hover { transform: translateY(-1px); }
.result-actions button:disabled:hover,
.result-actions .buy-button.disabled:hover { transform: none; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.status-line { color: var(--muted); margin: 0; font-weight: 700; }
.status-line.good { color: #237044; }
.status-line.bad { color: #a83240; }

.hint { color: var(--muted); line-height: 1.5; margin-top: 0; }
.scan-box {
  display: grid;
  gap: 12px;
  border: 1px dashed rgba(75,22,38,.2);
  border-radius: 22px;
  background: rgba(255,255,255,.48);
  padding: 16px;
  margin-top: 12px;
}
.scan-json {
  white-space: pre-wrap;
  border-radius: 18px;
  background: #28181d;
  color: #fff7e9;
  padding: 14px;
  overflow: auto;
  max-height: 420px;
}
.import-results {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.58);
  border: 1px solid rgba(75,22,38,.12);
  padding: 14px;
}
.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-weight: 850;
}
.import-summary strong { color: var(--accent); }
.import-results h3 { font-size: 15px; letter-spacing: 0; }
.import-results ul { margin: 0; padding-left: 18px; color: var(--ink); }
.import-results li { margin: 4px 0; line-height: 1.35; }
.import-results li span, .import-results p { color: var(--muted); }
.import-results p { margin: 0; line-height: 1.45; }

@media (max-width: 980px) {
  .app-header { grid-template-columns: 1fr; align-items: start; }
  .mode-tabs { justify-content: flex-start; }
  .layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app-header, .layout { width: min(100% - 20px, 1180px); }
  .app-header, .panel { padding: 14px; border-radius: 22px; }
  .search-row, .filter-grid, .form-grid { grid-template-columns: 1fr; }
  .result-card { grid-template-columns: 1fr; }
  .result-actions { flex-direction: row; flex-wrap: wrap; }
}
