:root {
  --bg: #12141a;
  --bg-2: #0c0d12;
  --card: #1c1f28;
  --card-2: #232734;
  --ink: #f4efe6;
  --muted: #b5ad9f;
  --gold: #d4b36a;
  --gold-dim: #9a7d3e;
  --gold-soft: rgba(212, 179, 106, 0.14);
  --line: #2c3140;
  --ok: #8fd4a8;
  --ok-bg: rgba(143, 212, 168, 0.1);
  --warn: #e8a05a;
  --warn-bg: rgba(232, 160, 90, 0.12);
  --bad: #e07a6a;
  --bad-bg: rgba(224, 122, 106, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --tap: 44px;
  --serif: "Palatino Linotype", Palatino, "Liberation Serif", "Noto Serif", "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Liberation Sans", sans-serif;
  --mono: "Segoe UI Mono", "DejaVu Sans Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  min-height: 100vh;
  line-height: 1.45;
}
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(180deg, #0a0b0f 0%, #12141a 100%);
  border-bottom: 1px solid var(--gold-dim);
}
.app-header img.logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex: 0 0 auto;
}
.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
.brand .sub {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.header-actions { margin-left: auto; display: flex; gap: 0.4rem; }

.wrap {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 1rem 0.9rem 5.5rem;
  display: grid;
  gap: 0.9rem;
}

.panel {
  scroll-margin-top: 6.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
}
.panel p.lead {
  margin: -0.4rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.grid-2, .grid-3, .grid-5 { display: grid; gap: 0.65rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 .span-all { grid-column: 1 / -1; }
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
label.field input, label.field select, label.field textarea,
input.text, select.text, textarea.text {
  min-height: var(--tap);
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 1rem;
  width: 100%;
}
label.field textarea { min-height: 4.5rem; resize: vertical; }
label.field input:focus, label.field select:focus, label.field textarea:focus,
input.text:focus, select.text:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}
.links a, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--tap);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--gold-dim);
  background: var(--gold-soft);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover, .links a:hover { border-color: var(--gold); background: rgba(212, 179, 106, 0.22); }
.btn:disabled, .links a[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-gold {
  background: var(--gold);
  color: #16140f;
  border-color: var(--gold);
}
.btn-gold:hover { filter: brightness(1.06); }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.8rem; }

.sold-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.45rem;
  align-items: end;
  margin-bottom: 0.45rem;
}
.icon-btn {
  width: var(--tap);
  min-width: var(--tap);
  height: var(--tap);
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
}
.icon-btn:hover { border-color: var(--bad); color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.7rem; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  min-height: var(--tap);
  cursor: pointer;
  text-align: left;
}
.chip strong { display: block; color: var(--gold); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }
.chip .val { font-variant-numeric: tabular-nums; font-size: 1.05rem; font-weight: 700; }
.chip[aria-pressed="true"], .preset[aria-pressed="true"] {
  border-color: var(--gold);
  background: var(--gold-soft);
  box-shadow: inset 0 0 0 1px var(--gold);
}
.note {
  margin: 0.7rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.88rem;
}
.note.hidden, .hidden, [hidden] { display: none !important; }

.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.preset {
  min-width: 3.4rem;
  min-height: var(--tap);
  padding: 0 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.slider-row {
  display: grid;
  grid-template-columns: 1fr 6.5rem;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
  height: 1.4rem;
}
.pct-input { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

.offer-hero {
  margin: 0.9rem 0 0.35rem;
  text-align: center;
  padding: 0.9rem 0.6rem 0.7rem;
  border-radius: 14px;
  background: radial-gradient(ellipse at top, rgba(212, 179, 106, 0.16), transparent 62%), var(--bg-2);
  border: 1px solid var(--line);
}
.offer-hero .label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.offer-hero .amount {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 600;
  color: var(--gold);
  line-height: 1.05;
  margin: 0.15rem 0;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(212, 179, 106, 0.25);
}
.offer-hero .meta { color: var(--muted); font-size: 0.92rem; }
.offer-hero .meta strong { color: var(--ink); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.75rem;
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
}
.stat .k { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.stat .v { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 0.15rem; }
.stat.ok .v { color: var(--ok); }
.stat.bad .v { color: var(--bad); }

.channels { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.2rem 0 0.7rem; }
.channel {
  min-height: var(--tap);
  padding: 0 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}
.channel[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); }

details.settings {
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}
details.settings summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 600;
  min-height: var(--tap);
  display: flex;
  align-items: center;
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.5rem;
}
.fineprint { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.78rem; }

.alert {
  margin-top: 0.75rem;
  padding: 0.8rem 0.85rem;
  border-radius: 12px;
  background: var(--bad-bg);
  border: 1px solid var(--bad);
  color: var(--ink);
  font-weight: 600;
}
.alert.ok { background: var(--ok-bg); border-color: var(--ok); }

.lot-list { display: grid; gap: 0.5rem; margin-top: 0.6rem; }
.lot-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.45rem 0.6rem;
  align-items: center;
  padding: 0.7rem 0.75rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.lot-item .title { font-weight: 700; }
.lot-item .sub { color: var(--muted); font-size: 0.82rem; }
.lot-item .offer { font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.lot-totals {
  margin-top: 0.8rem;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--gold-dim);
  background: var(--gold-soft);
}
.lot-totals .big { font-family: var(--serif); font-size: 1.7rem; color: var(--gold); font-weight: 600; }
.saved-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}

.app-footer {
  padding: 1.2rem 1rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  max-width: 40rem;
  margin: 0 auto;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  background: #16140f;
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 0.7rem 1rem;
  border-radius: 999px;
  z-index: 50;
  box-shadow: var(--shadow);
  font-weight: 600;
}

@media print {
  body { background: #fff; color: #111; }
  .app-header, .btn, .btn-row, .links, .header-actions, .icon-btn, .presets,
  .slider-row, details.settings, .channels, .sold-row .icon-btn { display: none !important; }
  .panel { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .offer-hero .amount, .brand h1, .panel h2, .lot-totals .big { color: #111; text-shadow: none; }
}

@media (min-width: 880px) {
  .wrap { padding-top: 1.25rem; }
  .brand h1 { font-size: 1.35rem; }
}

.brand { min-width: 0; flex: 1; }
.header-actions { flex: 0 0 auto; }
.header-actions .btn { white-space: nowrap; }

@media (max-width: 520px) {
  .app-header { gap: 0.5rem; padding: 0.55rem 0.7rem; }
  .app-header img.logo { width: 40px; height: 40px; border-radius: 10px; }
  .brand h1 { font-size: 0.98rem; }
  .brand .sub { font-size: 0.68rem; }
  .grid-2.stack-narrow { grid-template-columns: 1fr; }
  .lot-item { grid-template-columns: 1fr auto; }
  .lot-item .offer { grid-column: 1; }
  .lot-item .icon-btn { grid-column: 2; grid-row: 1 / span 2; }
}

@media (max-width: 520px) {
  .sub-long { display: none; }
}

.settings-sub {
  margin: 0.2rem 0 0.65rem;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}
#feedback-message { min-height: 7.5rem; }
#settings-panel:target, #settings-panel.settings-focus {
  box-shadow: 0 0 0 1px var(--gold), var(--shadow);
}
@media print {
  #settings-panel, #btn-settings { display: none !important; }
}
