:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --ring: 240 5.9% 10%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --radius: 0.5rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 6% 7%;
    --card-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --border: 240 3.7% 16.5%;
    --input: 240 3.7% 16.5%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --ring: 240 4.9% 60%;
    --destructive: 0 70% 62%;
    --destructive-foreground: 0 0% 9%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 6% 7%;
  --card-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --border: 240 3.7% 16.5%;
  --input: 240 3.7% 16.5%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --ring: 240 4.9% 60%;
  --destructive: 0 70% 62%;
  --destructive-foreground: 0 0% 9%;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --ring: 240 5.9% 10%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Author rules like `.alert { display: flex }` normally beat the browser's
   default `[hidden] { display: none }` rule, since author styles always win
   over user-agent styles regardless of specificity. This keeps `hidden`
   authoritative everywhere in this file. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }

.page { max-width: 1000px; margin: 0 auto; padding: 3rem 1.5rem 5rem; }

header.hero { margin-bottom: 1.5rem; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.75rem;
}

h1 {
  font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.5rem;
  text-wrap: balance;
  color: hsl(var(--foreground));
}

.lede { max-width: 58ch; color: hsl(var(--muted-foreground)); font-size: 0.92rem; margin: 0; }

.alert {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
}
.alert svg { flex: none; margin-top: 0.1rem; }
.alert-error {
  margin-bottom: 1.5rem;
  border-color: hsl(var(--destructive) / 0.4);
  color: hsl(var(--destructive));
  background: hsl(var(--destructive) / 0.08);
}

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 1.5rem; align-items: start; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  aside.summary { position: static !important; }
}

.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card + .card { margin-top: 1rem; }

.card-header { padding: 1.1rem 1.25rem 0; }
.card-header h2 { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.15rem; letter-spacing: -0.005em; }
.card-header p { margin: 0; font-size: 0.8rem; color: hsl(var(--muted-foreground)); }

.card-content { padding: 1rem 1.25rem 1.25rem; display: grid; gap: 1rem; }

.field { display: grid; gap: 0.45rem; }

label, .field-label, legend { font-size: 0.82rem; font-weight: 500; line-height: 1; color: hsl(var(--foreground)); }

.required::after { content: " *"; color: hsl(var(--destructive)); }

.description { font-size: 0.78rem; color: hsl(var(--muted-foreground)); margin: 0; }

input[type="text"], input[type="number"], input[type="password"], select {
  display: block;
  width: 100%;
  height: 2.25rem;
  font: inherit;
  font-size: 0.86rem;
  color: hsl(var(--foreground));
  background: transparent;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  padding: 0 0.7rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

input::placeholder { color: hsl(var(--muted-foreground)); }

input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18);
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }

.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1rem; }
@media (max-width: 480px) { .check-grid { grid-template-columns: 1fr; } }

.check-item { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; }

.checkbox {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 1rem;
  height: 1rem;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.checkbox:checked { background: hsl(var(--primary)); border-color: hsl(var(--primary)); }
.checkbox:checked::after {
  content: "";
  position: absolute;
  left: 3px; top: 0px;
  width: 4px; height: 8px;
  border: solid hsl(var(--primary-foreground));
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}
.checkbox:focus-visible { box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18); }

label.check-item span { cursor: pointer; }

.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.switch-text { display: grid; gap: 0.1rem; }
.switch-text strong { font-size: 0.85rem; font-weight: 500; }
.switch-text span { font-size: 0.78rem; color: hsl(var(--muted-foreground)); }

.switch { position: relative; width: 2.1rem; height: 1.15rem; flex: none; margin-top: 0.1rem; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; background: hsl(var(--input)); border-radius: 999px; transition: background 0.15s ease; }
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: calc(1.15rem - 4px);
  height: calc(1.15rem - 4px);
  border-radius: 50%;
  background: hsl(var(--background));
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  transition: transform 0.15s ease;
}
.switch input:checked + .track { background: hsl(var(--primary)); }
.switch input:checked + .track::after { transform: translateX(0.95rem); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18); }

details.card summary {
  list-style: none;
  cursor: pointer;
  padding: 1.05rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
details.card summary::-webkit-details-marker { display: none; }
summary .summary-title { font-size: 0.95rem; font-weight: 600; }
summary .summary-sub { font-size: 0.78rem; color: hsl(var(--muted-foreground)); font-weight: 400; margin-top: 0.1rem; }
.chevron { width: 1rem; height: 1rem; flex: none; color: hsl(var(--muted-foreground)); transition: transform 0.15s ease; }
details[open] .chevron { transform: rotate(180deg); }
details.card .card-content { border-top: 1px solid hsl(var(--border)); }

.actions { margin-top: 1.25rem; display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }

button.btn-primary {
  font: inherit;
  font-weight: 500;
  font-size: 0.86rem;
  color: hsl(var(--primary-foreground));
  background: hsl(var(--primary));
  border: none;
  border-radius: var(--radius);
  height: 2.25rem;
  padding: 0 1rem;
  cursor: pointer;
  transition: opacity 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
button.btn-primary:hover { opacity: 0.9; }
button.btn-primary:active { opacity: 0.8; }

.actions .note { font-size: 0.78rem; color: hsl(var(--muted-foreground)); }

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.spinner {
  flex: none;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status-line {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  margin: 0.6rem 0 0;
}

aside.summary { position: sticky; top: 2rem; }

.summary-list { display: grid; gap: 0.8rem; }
.summary-row { display: grid; gap: 0.2rem; }
.summary-row .k { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: hsl(var(--muted-foreground)); }
.summary-row .v { font-size: 0.85rem; }
.summary-row .v.empty { color: hsl(var(--muted-foreground)); font-style: italic; }

.summary-sites { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.summary-sites span {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}

.summary-divider { border: none; border-top: 1px solid hsl(var(--border)); margin: 0.25rem 0; }

.summary-total { display: flex; align-items: baseline; justify-content: space-between; }
.summary-total .k { font-size: 0.8rem; color: hsl(var(--muted-foreground)); }
.summary-total .v { font-size: 1.25rem; font-weight: 600; }
.summary-total .v small { font-size: 0.78rem; font-weight: 400; color: hsl(var(--muted-foreground)); }

button.btn-outline {
  width: 100%;
  font: inherit;
  font-weight: 500;
  font-size: 0.82rem;
  color: hsl(var(--foreground));
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  height: 2.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.12s ease;
}
button.btn-outline:hover { background: hsl(var(--muted)); }

.summary-footnote { font-size: 0.74rem; color: hsl(var(--muted-foreground)); text-align: center; margin: 0.6rem 0 0; }

footer.foot {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid hsl(var(--border));
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
