:root {
  color-scheme: light dark;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 1.5rem;
  background: #f8f6ee;
  color: #24211f;
}

main {
  display: grid;
  width: min(72rem, 100%);
  margin: 0 auto;
  gap: 1rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 5rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

h2 {
  margin: 0;
  font-size: 1rem;
}

p { line-height: 1.55; }

code {
  border-radius: 0.35rem;
  padding: 0.1rem 0.3rem;
  background: rgba(36, 33, 31, 0.08);
  font-size: 0.92em;
}

button {
  min-height: 2.5rem;
  border: 1px solid rgba(36, 33, 31, 0.18);
  border-radius: 0.75rem;
  padding: 0.55rem 0.8rem;
  background: #24211f;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: rgba(36, 33, 31, 0.08);
  color: inherit;
}

select,
input {
  min-height: 2.5rem;
  border: 1px solid rgba(36, 33, 31, 0.18);
  border-radius: 0.75rem;
  padding: 0.45rem 0.7rem;
  background: rgba(255, 255, 255, 0.7);
  color: inherit;
  font: inherit;
  font-weight: 700;
}

select { padding-right: 2rem; }

pre,
table,
.tip-card {
  border: 1px solid rgba(36, 33, 31, 0.14);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.58);
}

pre {
  min-height: 3rem;
  margin: 0;
  padding: 0.85rem;
  overflow: auto;
  white-space: pre-wrap;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

th,
td {
  border-bottom: 1px solid rgba(36, 33, 31, 0.12);
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: rgba(36, 33, 31, 0.07);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }

.eyebrow {
  margin: 0 0 0.25rem;
  color: #81796f;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.layout {
  display: grid;
  align-items: start;
  gap: 1rem;
}

.panel {
  display: grid;
  min-width: 0;
  gap: 0.75rem;
}

.panel-heading {
  display: grid;
  gap: 0.25rem;
}

.panel-heading p {
  margin: 0;
  color: #665f56;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.scan-settings {
  border: 1px solid rgba(36, 33, 31, 0.14);
  border-radius: 0.9rem;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.58);
}

.scan-settings summary {
  color: #665f56;
  font-weight: 800;
  cursor: pointer;
}

.scan-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.scan-settings-grid label {
  display: grid;
  gap: 0.3rem;
  color: #665f56;
  font-size: 0.85rem;
  font-weight: 800;
}

.preset-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #665f56;
  font-weight: 800;
}

.handler-frame {
  overflow: hidden;
  border: 1px solid rgba(36, 33, 31, 0.14);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.66);
}

.function-signature,
pre.function-signature[class*="language-"] {
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0.25rem 1rem;
  overflow: visible;
  background: rgba(36, 33, 31, 0.06);
  color: #665f56;
  font: 0.95rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.35;
  text-shadow: none;
  white-space: pre;
}

.function-signature code,
.function-signature code[class*="language-"] {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
  text-shadow: none;
}

.function-signature .token {
  background: transparent;
  text-shadow: none;
}

.editor-shell {
  min-height: 19rem;
  box-sizing: border-box;
  border: 0;
  border-top: 1px solid rgba(36, 33, 31, 0.1);
  border-bottom: 1px solid rgba(36, 33, 31, 0.1);
  padding: 0.85rem 1rem 0.85rem 2rem;
  overflow: auto;
  background: transparent;
  font: 0.95rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre-wrap;
}

.editor-shell:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22); }
.editor-shell .token { background: transparent; }

.editor-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  color: #665f56;
  font-size: 0.88rem;
}

.pill {
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  background: rgba(36, 33, 31, 0.08);
  font-weight: 700;
}

.tip-card { padding: 0.85rem; }

.tip-card p { margin: 0 0 0.45rem; }

.tip-card ul {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.55;
}

.empty {
  color: #81796f;
  font-style: italic;
}

#effects-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: none;
}

.bouncing-card {
  position: absolute;
  left: 0;
  top: 0;
  width: 92px;
  height: 128px;
  border-radius: 4.8% / 3.5%;
  filter: drop-shadow(0 0.45rem 0.8rem rgba(0, 0, 0, 0.32));
  object-fit: cover;
  will-change: transform;
}

.price-burst {
  position: fixed;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  color: #fbbf24;
  font-size: clamp(3rem, 11vw, 8rem);
  font-weight: 900;
  letter-spacing: -0.08em;
  text-shadow: 0 0.2rem 0 #7c2d12, 0 0 2rem rgba(251, 191, 36, 0.7);
  animation: price-pop 1.6s ease-out forwards;
}

.running-total {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 3;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  background: rgba(124, 45, 18, 0.76);
  color: #fbbf24;
  font-size: clamp(2.3rem, 7vw, 4.4rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  text-shadow: 0 0.12rem 0 #7c2d12, 0 0 1.2rem rgba(251, 191, 36, 0.7);
  box-shadow: 0 0.6rem 1.5rem rgba(124, 45, 18, 0.28);
}

.running-total--pulse {
  animation: total-grow 520ms ease-out;
}

.sparkle {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 1.4rem;
  animation: sparkle-pop 1.2s ease-out forwards;
}

@keyframes price-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.45); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.75); }
}

@keyframes total-grow {
  0% { transform: scale(1); }
  38% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes sparkle-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.2) rotate(180deg); }
}

@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(20rem, 0.8fr) minmax(28rem, 1.2fr); }
}

@media (prefers-color-scheme: dark) {
  body {
    background: #0f172a;
    color: #e2e8f0;
  }

  code { background: rgba(226, 232, 240, 0.1); }

  button {
    border-color: rgba(226, 232, 240, 0.18);
    background: #e2e8f0;
    color: #0f172a;
  }

  button.secondary {
    background: rgba(226, 232, 240, 0.08);
    color: inherit;
  }

  select,
  input {
    border-color: rgba(226, 232, 240, 0.18);
    background: rgba(15, 23, 42, 0.72);
  }

  pre,
  table,
  .scan-settings,
  .tip-card {
    border-color: rgba(226, 232, 240, 0.16);
    background: rgba(15, 23, 42, 0.72);
  }

  th,
  td { border-bottom-color: rgba(226, 232, 240, 0.12); }

  th { background: rgba(226, 232, 240, 0.08); }

  .panel-heading p,
  .editor-meta,
  .preset-picker,
  .scan-settings summary,
  .scan-settings-grid label { color: #cbd5e1; }

  .handler-frame {
    border-color: rgba(226, 232, 240, 0.16);
    background: rgba(15, 23, 42, 0.72);
  }

  .function-signature,
  pre.function-signature[class*="language-"] {
    background: rgba(226, 232, 240, 0.08);
    color: #cbd5e1;
  }

  .editor-shell { color: #e2e8f0; }
  .pill { background: rgba(226, 232, 240, 0.1); }
  .eyebrow, .empty { color: #94a3b8; }
}
