:root {
  --bg: #0d0b1f;
  --bg-2: #16132f;
  --card: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.1);
  --text: #ece8ff;
  --muted: #a49fc6;
  --gold: #e9c46a;
  --gold-soft: rgba(233, 196, 106, 0.14);
  --fire: #f28c5b;
  --earth: #8fbf7a;
  --air: #8ec5e8;
  --water: #9d8cf0;
  --radius: 16px;
  --display: 'Cormorant Garamond', Georgia, serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, #2b2160 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 30%, #1d2a55 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--body);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 70%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 70% 15%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 85% 60%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 50% 40%, #fff4 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 20% 90%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 88%, #fff7 50%, transparent 51%);
  background-size: 600px 600px;
  opacity: 0.7;
  z-index: -1;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: 0.01em; margin: 0; }
h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.05; }
h2 { font-size: 2rem; }
h3 { font-size: 1.35rem; }

.hero { max-width: 760px; margin: 0 auto; padding: 64px 16px 32px; text-align: center; }
.eyebrow { color: var(--gold); letter-spacing: 0.3em; text-transform: uppercase; font-size: 0.75rem; margin: 0 0 16px; }
.lede { color: var(--muted); max-width: 560px; margin: 18px auto 0; font-size: 1.05rem; }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 28px;
  backdrop-filter: blur(6px);
}

.sub { color: var(--muted); margin: 6px 0 20px; }

/* Form */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.field > span { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.field em { text-transform: none; font-style: normal; opacity: 0.7; }

input[type=text], input[type=date], input[type=time], input[type=number], select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  width: 100%;
  color-scheme: dark;
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
input:disabled { opacity: 0.4; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check select { width: auto; padding: 6px 10px; }
.check.small { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; }

.place-field { grid-column: span 1; }
.suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  list-style: none; margin: 4px 0 0; padding: 6px;
  background: #1e1a3d; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px #0008;
}
.suggestions li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.suggestions li small { color: var(--muted); display: block; }
.suggestions li:hover, .suggestions li[aria-selected=true] { background: var(--gold-soft); }
.hint { color: var(--gold); font-size: 0.85rem; margin: 2px 0 0; min-height: 1.2em; }

.manual { margin-top: 18px; color: var(--muted); }
.manual summary { cursor: pointer; font-size: 0.9rem; }

.options { display: flex; flex-wrap: wrap; gap: 22px; margin: 22px 0 18px; padding-top: 18px; border-top: 1px solid var(--line); }

.error { color: #ff9b9b; margin: 0 0 14px; }

button { font: inherit; cursor: pointer; }
.primary {
  background: linear-gradient(135deg, #f0d48a, #d9a74a);
  color: #1b1433; border: 0; border-radius: 999px;
  padding: 13px 28px; font-weight: 600; font-size: 1rem;
  box-shadow: 0 6px 24px rgba(233, 196, 106, 0.25);
}
.primary:hover { filter: brightness(1.07); }
.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px;
}
.ghost:hover { border-color: var(--gold); color: var(--gold); }

/* Results nav */
.jump {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 12px 4px; margin-bottom: 18px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.jump a { color: var(--muted); text-decoration: none; font-weight: 500; }
.jump a:hover { color: var(--gold); }
.jump .ghost { margin-left: auto; }

/* Chart */
.chart-layout { display: grid; grid-template-columns: minmax(260px, 420px) 1fr; gap: 32px; align-items: start; }
#wheel svg { width: 100%; height: auto; display: block; }
.placements { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.placements td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.placements td:first-child { font-size: 1.15rem; width: 30px; text-align: center; color: var(--gold); }
.placements .house { color: var(--muted); text-align: right; white-space: nowrap; }
.placements .rx { color: var(--fire); font-size: 0.75rem; margin-left: 4px; }
.placements tr.angle td { color: var(--gold); }

.elements { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.el { font-size: 0.8rem; color: var(--muted); }
.el .bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.el .bar i { display: block; height: 100%; border-radius: 3px; }
.el strong { color: var(--text); font-weight: 600; display: block; text-transform: capitalize; }

.reading { margin-top: 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.reading div { background: var(--gold-soft); border-radius: 12px; padding: 14px 16px; }
.reading b { font-family: var(--display); font-size: 1.15rem; color: var(--gold); display: block; margin-bottom: 4px; }
.reading p { margin: 0; font-size: 0.9rem; }

/* Week */
#week { margin-bottom: 28px; }
#week > h2 { margin-top: 8px; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.day header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.day header h3 { font-size: 1.5rem; }
.day header .date { color: var(--muted); font-size: 0.85rem; }
.day .omens { display: flex; gap: 12px; font-size: 0.8rem; color: var(--muted); margin-top: -4px; }
.day .omens span b { color: var(--gold); font-weight: 500; }
.meal {
  text-align: left; width: 100%;
  background: var(--bg-2); border: 1px solid transparent; border-radius: 12px;
  padding: 10px 12px; color: var(--text);
  border-left: 3px solid var(--accent, var(--gold));
}
.meal:hover { border-color: var(--line); border-left-color: var(--accent, var(--gold)); background: #1d193b; }
.meal small { display: block; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.68rem; color: var(--muted); }
.meal strong { display: block; font-weight: 600; margin: 2px 0; }
.meal .why { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.meal.empty { opacity: 0.6; cursor: default; }

/* Shopping */
.shop-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; flex-wrap: wrap; }
.shop-actions { display: flex; gap: 8px; }
.list { columns: 3 260px; column-gap: 32px; }
.aisle { break-inside: avoid; margin-bottom: 22px; }
.aisle h3 { font-size: 1.2rem; color: var(--gold); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; cursor: pointer; }
.item input { margin-top: 3px; flex: none; }
.item .qty { color: var(--gold); font-variant-numeric: tabular-nums; }
.item .uses { display: block; font-size: 0.75rem; color: var(--muted); }
.item.done { opacity: 0.45; }
.item.done .name { text-decoration: line-through; }

/* Recipe dialog */
dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: #17142f; color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px; box-shadow: 0 30px 80px #000a;
}
dialog::backdrop { background: rgba(5, 4, 15, 0.7); backdrop-filter: blur(3px); }
dialog .close { position: absolute; top: 14px; right: 14px; background: none; border: 0; color: var(--muted); font-size: 1.1rem; padding: 6px; }
dialog .close:hover { color: var(--gold); }
#recipe-body h2 { font-size: 2.1rem; padding-right: 30px; }
#recipe-body .meta { color: var(--muted); font-size: 0.85rem; margin: 4px 0 16px; }
#recipe-body .astro { background: var(--gold-soft); border-radius: 12px; padding: 14px 16px; margin-bottom: 20px; }
#recipe-body .astro p { margin: 0 0 6px; }
#recipe-body .astro p:last-child { margin: 0; color: var(--muted); font-size: 0.9rem; }
#recipe-body h3 { margin: 18px 0 8px; color: var(--gold); }
#recipe-body ul, #recipe-body ol { padding-left: 20px; margin: 0; }
#recipe-body li { margin: 4px 0; }
#recipe-body .swap { color: var(--earth); font-size: 0.75rem; margin-left: 6px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 0.72rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-transform: capitalize; }

footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 24px 16px 40px; }

@media (max-width: 760px) {
  .card { padding: 20px 16px; }
  .chart-layout { grid-template-columns: 1fr; }
  #wheel { max-width: 380px; margin: 0 auto; width: 100%; }
  .elements { grid-template-columns: repeat(2, 1fr); }
  .jump .ghost { margin-left: 0; }
  .hero { padding-top: 40px; }
}

@media print {
  body { background: #fff; color: #000; }
  body::before, .hero, #birth, .jump, #chart, #week, footer, .shop-actions, dialog { display: none !important; }
  #results { display: block !important; }
  .card { border: 0; padding: 0; background: none; backdrop-filter: none; }
  .aisle h3, .item .qty { color: #000; }
  .sub, .item .uses { color: #444; }
}
