:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1d1b19;
  --muted: #6b665f;
  --line: #b9b3aa;
  --accent: #4b46b8;
  --accent-tint: rgba(75, 70, 184, 0.10);
  --transit: #c62828;
  --focus: #4b46b8;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #201f1d;
    --surface-2: #2a2826;
    --text: #f1eee9;
    --muted: #a8a299;
    --line: #5d5852;
    --accent: #9d98ff;
    --accent-tint: rgba(157, 152, 255, 0.14);
    --transit: #ff6b6b;
    --focus: #9d98ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.875rem; font-weight: normal; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem;
  padding: 0.75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.25rem; margin: 0; }
.topbar-actions { margin-left: auto; display: flex; gap: 1rem; }
.tabs { display: flex; gap: 0.25rem; }
.tabs button, .segmented button {
  border: 1px solid var(--line); background: var(--surface-2); padding: 0.4rem 0.9rem; border-radius: 0.5rem; cursor: pointer;
}
.tabs button[aria-selected="true"], .segmented button[aria-selected="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--surface);
}
button.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0.25rem; text-decoration: underline; }
button.primary {
  background: var(--accent); color: var(--surface); border: 0; border-radius: 0.5rem; padding: 0.6rem 1.2rem; cursor: pointer; font-weight: 600;
}

main { padding: 1rem; max-width: 90rem; margin: 0 auto; }

.entry { max-width: 46rem; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 0.75rem; padding: 1.25rem; }
.entry h2 { margin-top: 0; }
#birth-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
#birth-form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; }
#birth-form .wide { grid-column: 1 / -1; }
#birth-form input {
  padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--bg); font-weight: normal;
}
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; }
.form-error { grid-column: 1 / -1; color: var(--transit); margin: 0; }

.chart-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 26rem); gap: 1.5rem; align-items: start; }
@media (max-width: 60rem) { .chart-layout { grid-template-columns: minmax(0, 1fr); } }
.chart-column, .side-panel { min-width: 0; }
.chart-holder { max-width: min(100%, 85vh); margin: 0 auto; }
.transit-bar { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center; justify-content: center; margin-top: 0.75rem; }
.toggle { display: inline-flex; gap: 0.5rem; align-items: center; cursor: pointer; }
.toggle input { width: 1.2rem; height: 1.2rem; }

.chart { width: 100%; height: auto; display: block; font-family: system-ui, -apple-system, sans-serif; }
.chart .box rect { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; }
.chart .box.asc rect { fill: var(--accent-tint); }
.chart .box { cursor: pointer; }
.chart .box:hover rect, .chart .box:focus rect { stroke: var(--accent); stroke-width: 2; }
.chart .box:focus { outline: none; }
.chart .sign-name { fill: var(--muted); font-size: 9px; }
.chart .natal { fill: var(--text); font-weight: 600; }
.chart .transit { fill: var(--transit); }
.chart .asc { fill: var(--accent); font-weight: 600; }
.chart .center { fill: var(--surface); stroke: var(--line); }
.chart .center-title { fill: var(--text); font-size: 15px; font-weight: 700; }
.chart .center-line { fill: var(--muted); font-size: 11px; }
.chart .frame { fill: none; stroke: var(--text); stroke-width: 2; }

.side-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 0.75rem; padding: 1rem; }
.segmented { display: flex; gap: 0.25rem; margin-bottom: 1rem; flex-wrap: wrap; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--surface-2); vertical-align: top; }
table.data thead th { color: var(--muted); font-weight: 600; font-size: 0.875rem; }
table.data tr.current { background: var(--accent-tint); }
table.data td.nowrap { white-space: nowrap; }
.side-content { overflow-x: auto; }
@media (max-width: 30rem) {
  main { padding: 0.75rem 0.5rem; }
  .side-panel { padding: 0.75rem 0.5rem; }
  table.data th, table.data td { padding: 0.35rem 0.3rem; }
}

.upsell { margin-top: 1.5rem; }
.upsell h3 { margin-top: 0; }
.dasha-page { max-width: 40rem; margin: 0 auto; }

dialog { border: 1px solid var(--line); border-radius: 0.75rem; background: var(--surface); color: var(--text); max-width: min(32rem, 92vw); padding: 1.25rem; }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog ul { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.6rem; font-size: 1.125rem; }
dialog li.transit { color: var(--transit); }
dialog li.asc { color: var(--accent); }
dialog li .muted { display: block; font-size: 1rem; }

.footer { color: var(--muted); font-size: 0.875rem; text-align: center; padding: 2rem 1rem; }

@media print {
  .topbar-actions, .tabs, .transit-bar .toggle, .segmented, .upsell, .footer { display: none; }
  body { background: #fff; }
}

.place-search { display: flex; flex-direction: column; gap: 0.3rem; }
.place-search > label { font-weight: 600; }
.combo { position: relative; }
.place-search input {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 0.5rem; background: var(--bg); font-weight: normal;
}
#place-summary { margin: 0; min-height: 1.3em; }
#place-results {
  position: absolute; z-index: 10; top: calc(100% + 0.25rem); left: 0; right: 0; margin: 0; padding: 0.25rem; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 0.5rem; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  max-height: min(22rem, 60vh); overflow-y: auto;
}
#place-results li { padding: 0.5rem 0.6rem; border-radius: 0.375rem; cursor: pointer; display: flex; flex-direction: column; }
#place-results li[aria-selected="true"], #place-results li[role="option"]:hover { background: var(--accent-tint); }
#place-results .place-name { font-weight: 600; }
#place-results .place-where { color: var(--muted); font-size: 0.9rem; }
#place-results li.place-message { cursor: default; color: var(--muted); }
#place-details summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 0.25rem 0; }
.details-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin-top: 0.75rem; }
