:root {
  --rs-bg: #140f12;
  --rs-bg-2: #20161b;
  --rs-panel: #2a1d22;
  --rs-panel-2: #35242a;
  --rs-ink: #f6e8d0;
  --rs-muted: #c8aa91;
  --rs-faint: #937967;
  --rs-gold: #d8b36a;
  --rs-red: #8e443f;
  --rs-green: #7f8d68;
  --rs-border: rgba(216, 179, 106, 0.35);
  --rs-shadow: rgba(0, 0, 0, 0.35);
  --rs-focus: #f3d891;
  --max: 1180px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--rs-ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(216, 179, 106, 0.12), transparent 24rem),
    radial-gradient(circle at 80% 20%, rgba(142, 68, 63, 0.17), transparent 28rem),
    linear-gradient(135deg, var(--rs-bg), #0d0a0c 70%);
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1.55;
}

button, input, select {
  font: inherit;
}

button, select, input[type="search"] {
  border-radius: 0.7rem;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--rs-focus);
  outline-offset: 3px;
}

.apothecary-shell {
  width: min(var(--max), calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.apothecary-hero {
  border: 1px solid var(--rs-border);
  background:
    linear-gradient(rgba(42, 29, 34, 0.88), rgba(32, 22, 27, 0.94)),
    repeating-linear-gradient(90deg, transparent 0 4rem, rgba(216, 179, 106, 0.04) 4rem 4.1rem);
  box-shadow: 0 1rem 3rem var(--rs-shadow);
  padding: clamp(1.25rem, 3vw, 3rem);
  border-radius: 1.4rem;
  position: relative;
  overflow: hidden;
}

.apothecary-hero::after {
  content: "✦ ✧ ✦";
  position: absolute;
  right: 1.5rem;
  top: 1rem;
  color: rgba(216, 179, 106, 0.35);
  letter-spacing: 0.6rem;
}

.kicker {
  color: var(--rs-gold);
  letter-spacing: 0.24em;
  text-transform: lowercase;
  margin: 0 0 0.5rem;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  font-size: clamp(2.3rem, 8vw, 5rem);
  line-height: 0.95;
  margin-bottom: 1rem;
  text-transform: lowercase;
  text-shadow: 0 0 2rem rgba(216, 179, 106, 0.14);
}

h2 {
  font-size: clamp(1.35rem, 3vw, 2rem);
  color: var(--rs-gold);
  margin-bottom: 0.75rem;
}

h3 {
  color: var(--rs-gold);
  margin-bottom: 0.5rem;
}

.hero-copy {
  max-width: 64ch;
  color: var(--rs-muted);
  font-size: 1.05rem;
}

.notice-card,
.cabinet-panel,
.result-card,
.library-panel {
  border: 1px solid var(--rs-border);
  background: rgba(42, 29, 34, 0.9);
  border-radius: 1.15rem;
  box-shadow: 0 1rem 2rem var(--rs-shadow);
}

.notice-card {
  margin: 1rem 0;
  padding: 1.1rem 1.25rem;
}

.notice-card p { color: var(--rs-muted); margin-bottom: 0; }

.apothecary-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 1rem;
  align-items: start;
}

.cabinet-panel,
.result-card,
.library-panel {
  padding: clamp(1rem, 2vw, 1.5rem);
}

.field-block {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.field-block span,
legend {
  color: var(--rs-gold);
  font-weight: bold;
}

select,
input[type="search"] {
  width: 100%;
  color: var(--rs-ink);
  background: #160f13;
  border: 1px solid var(--rs-border);
  padding: 0.72rem 0.8rem;
}

fieldset {
  border: 1px solid rgba(216, 179, 106, 0.22);
  border-radius: 0.9rem;
  padding: 0.8rem;
}

.compact-fieldset,
.check-grid {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

label {
  color: var(--rs-muted);
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--rs-gold);
  margin-right: 0.35rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.text-button {
  color: var(--rs-gold);
  background: transparent;
  border: 1px solid transparent;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}

.text-button:hover {
  border-color: var(--rs-border);
  background: rgba(216, 179, 106, 0.08);
}

.ingredient-list {
  display: grid;
  gap: 0.55rem;
  max-height: 420px;
  overflow: auto;
  padding-right: 0.25rem;
}

.ingredient-pill {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid rgba(216, 179, 106, 0.18);
  background: rgba(22, 15, 19, 0.76);
  border-radius: 0.85rem;
}

.ingredient-pill small {
  color: var(--rs-faint);
  display: block;
}

.badge-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(216, 179, 106, 0.25);
  border-radius: 999px;
  color: var(--rs-muted);
  font-size: 0.78rem;
  padding: 0.1rem 0.45rem;
}

.badge.historical { color: #f0cc7e; }
.badge.traditional { color: #d0bd97; }
.badge.modern { color: #b9c39b; }
.badge.warning { color: #f0aaa2; border-color: rgba(240, 170, 162, 0.35); }

.brew-button {
  width: 100%;
  color: #20110f;
  background: linear-gradient(180deg, #f1d389, #c49343);
  border: 0;
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0.8rem 1.5rem rgba(0, 0, 0, 0.25);
}

.brew-button:hover { filter: brightness(1.04); }

.ritual-result {
  position: sticky;
  top: 1rem;
}

.empty-state {
  min-height: 320px;
  display: grid;
  place-content: center;
  text-align: center;
}

.sigil {
  font-size: 3rem;
  color: var(--rs-gold);
  margin-bottom: 0.25rem;
}

.result-card p,
.result-card li,
.library-card p,
.library-card li {
  color: var(--rs-muted);
}

.result-card ul,
.result-card ol {
  padding-left: 1.25rem;
}

.result-card section + section { margin-top: 1rem; }

.epithet-line {
  padding: 0.8rem;
  border-left: 3px solid var(--rs-gold);
  background: rgba(22, 15, 19, 0.62);
  border-radius: 0 0.8rem 0.8rem 0;
  margin-bottom: 0.65rem;
}

.epithet-line strong {
  color: var(--rs-ink);
}

.library-panel {
  margin-top: 1rem;
}

.library-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.library-card {
  border: 1px solid rgba(216, 179, 106, 0.2);
  background: rgba(22, 15, 19, 0.72);
  border-radius: 1rem;
  padding: 1rem;
}

.library-card h3 {
  margin-bottom: 0.25rem;
}

.library-card .meta {
  color: var(--rs-faint);
  font-size: 0.9rem;
}

.source-list {
  font-size: 0.9rem;
}

@media (max-width: 860px) {
  .apothecary-grid,
  .library-cards {
    grid-template-columns: 1fr;
  }

  .ritual-result {
    position: static;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }
}
