/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #f5f6f9;
  --panel: #ffffff;
  --panel-2: #eef0f5;
  --line: #dde1ea;
  --line-soft: #e8eaf1;
  --ink: #1b1e2b;
  --ink-dim: #5b5f74;
  --ink-faint: #8b8ea3;
  --accent: #2f4d8c;
  --accent-dim: #6478ab;
  --accent-soft: #eef1f9;
  --violet: #5c56a0;
  --green: #1e7a4c;
  --red: #b8453b;

  --fire: #b1583a;
  --earth: #4c7a45;
  --air: #34648f;
  --water: #5c56a0;

  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .05);
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .05);

  --radius: 12px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; }

/* ---------------------------------------------------------------- shell */
.shell { max-width: 1320px; margin: 0 auto; padding: 34px 22px 90px; }

header.masthead { margin-bottom: 26px; }
header.masthead h1 {
  margin: 0;
  font-size: 34px;
  color: var(--ink);
}
header.masthead p { margin: 6px 0 0; color: var(--ink-dim); max-width: 62ch; }

.layout {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 940px) { .layout { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.panel + .panel { margin-top: 18px; }
.panel > h2 {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--sans);
  font-weight: 600;
}
aside.panel { position: sticky; top: 22px; }
@media (max-width: 940px) { aside.panel { position: static; } }

.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 5px;
}
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

.hint { margin-top: 5px; font-size: 11.5px; color: var(--ink-faint); }

/* ---------------------------------------------------------------- inputs */
input, select, button, textarea { font: inherit; color: inherit; }

input[type="text"], input[type="number"], input[type="date"],
input[type="time"], input[type="datetime-local"], select {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(47, 77, 140, .12);
}
select { appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='7'><path d='M1 1l4 4 4-4' stroke='%238b8ea3' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center; }

button {
  cursor: pointer;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 13px;
  transition: background .15s, border-color .15s, transform .08s;
}
button:hover { background: #e4e7ef; border-color: #c9cedb; }
button:active { transform: translateY(1px); }

button.primary {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  color: #fff;
  background: var(--accent);
  border: none;
}
button.primary:hover { background: #263f73; }
button.primary:disabled { opacity: .55; cursor: progress; }

button.ghost {
  background: transparent;
  border-style: dashed;
  color: var(--ink-dim);
  width: 100%;
}
button.ghost:hover { color: var(--ink); border-color: var(--accent-dim); background: transparent; }

/* ---------------------------------------------------------------- chips */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 4px 9px;
  font-size: 12.5px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-dim);
  user-select: none;
  font-variant-emoji: text;
}
.chip:hover { border-color: #c9cedb; color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-dim);
  color: var(--accent);
}
.chip[data-element="fire"][aria-pressed="true"]  { background: #f7ece7; border-color: var(--fire);  color: var(--fire); }
.chip[data-element="earth"][aria-pressed="true"] { background: #edf3ea; border-color: var(--earth); color: var(--earth); }
.chip[data-element="air"][aria-pressed="true"]   { background: #e9f0f6; border-color: var(--air);   color: var(--air); }
.chip[data-element="water"][aria-pressed="true"] { background: #eeecf6; border-color: var(--water); color: var(--water); }

/* ---------------------------------------------------------- conditions */
.cond-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cond-head h2 { margin: 0; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-family: var(--sans); font-weight: 600; }
.cond-head select { width: auto; max-width: 260px; }

.condition {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 12px 13px;
  margin-bottom: 10px;
  background: #fbfbfd;
}
.condition.negated { border-color: rgba(184, 69, 59, .35); }
.condition-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.condition-top select { flex: 1; }
.condition-body { display: flex; flex-wrap: wrap; gap: 11px; }
.condition-body .field { margin: 0; flex: 0 1 auto; min-width: 118px; }
.condition-body .field.wide { flex-basis: 100%; }

.icon-btn {
  padding: 5px 9px;
  line-height: 1;
  color: var(--ink-faint);
  background: transparent;
}
.icon-btn:hover { color: var(--red); border-color: rgba(184,69,59,.4); background: transparent; }
.icon-btn.not { font-size: 11px; letter-spacing: .08em; font-weight: 700; }
.icon-btn.not[aria-pressed="true"] { color: var(--red); border-color: rgba(184,69,59,.4); background: rgba(184,69,59,.08); }

.empty { color: var(--ink-faint); text-align: center; padding: 22px 8px; font-style: italic; }

/* ---------------------------------------------------------------- results */
.status { margin-top: 18px; color: var(--ink-dim); font-size: 13.5px; }
.status .spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 8px;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-top: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.result-head { padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.result-rank {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-dim); margin-bottom: 6px;
}
.result-date { font-family: var(--serif); font-size: 26px; line-height: 1.2; color: var(--ink); }
.result-time { font-size: 15px; color: var(--ink-dim); margin-top: 3px; }
.result-meta {
  margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px 18px;
  font-size: 12.5px; color: var(--ink-faint);
}
.result-meta b { color: var(--ink-dim); font-weight: 500; }

.result-body { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
@media (max-width: 820px) { .result-body { grid-template-columns: 1fr; } }
.wheel-wrap { padding: 14px; border-right: 1px solid var(--line-soft); background: #fbfbfd; }
@media (max-width: 820px) { .wheel-wrap { border-right: none; border-bottom: 1px solid var(--line-soft); } }
.wheel-wrap svg { width: 100%; height: auto; display: block; }

.readout { padding: 16px 20px; }
.readout h3 {
  margin: 0 0 9px; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint); font-family: var(--sans);
}
.readout h3:not(:first-child) { margin-top: 18px; }

table.placements { width: 100%; border-collapse: collapse; font-size: 13px; }
table.placements td { padding: 2.5px 0; vertical-align: baseline; }
table.placements td.glyph { width: 22px; font-size: 15px; color: var(--ink-dim); font-variant-emoji: text; }
table.placements td.name { color: var(--ink-dim); padding-right: 10px; }
table.placements td.pos { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
table.placements td.tag { text-align: right; font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.rx { color: var(--red); font-family: var(--mono); font-size: 11px; }
.dig { color: var(--green); }
.dig.bad { color: var(--red); }

ul.verdict { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
ul.verdict li { padding: 3px 0 3px 22px; position: relative; color: var(--ink-dim); }
ul.verdict li::before {
  content: "✓"; position: absolute; left: 2px; color: var(--green); font-weight: 700;
}
ul.verdict li.no::before { content: "✕"; color: var(--red); }

.factors { display: flex; flex-wrap: wrap; gap: 6px; }
.factor {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: #eeecf6; border: 1px solid rgba(92, 86, 160, .28);
  color: var(--violet);
}
.factor.warn { background: #f7ece9; border-color: rgba(184,69,59,.3); color: var(--red); }

.notice {
  margin-top: 18px; padding: 16px 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.notice h3 { margin: 0 0 8px; font-size: 16px; color: var(--accent); }
.notice p { margin: 0 0 10px; color: var(--ink-dim); }
.notice ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-dim); font-size: 13.5px; }
.notice li { margin-bottom: 5px; }
.notice code { color: var(--ink); font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); padding: 1px 4px; border-radius: 4px; }
.notice.bad { border-color: rgba(184,69,59,.35); }

.footnote { margin-top: 26px; font-size: 12px; color: var(--ink-faint); text-align: center; }
