:root {
  --bg: #faf8f4;
  --card: #ffffff;
  --text: #2a2733;
  --muted: #6f6a7d;
  --accent: #6d4fc4;
  --accent-text: #ffffff;
  --border: #e3ded3;
  --table-stripe: #f4f1ea;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151d;
    --card: #201d29;
    --text: #eae7f2;
    --muted: #9c96ac;
    --accent: #9b83e8;
    --accent-text: #17151d;
    --border: #363146;
    --table-stripe: #262230;
  }
}

/* Explicit theme toggle (e.g. the Artifacts viewer) wins over the OS preference. */
:root[data-theme="dark"] {
  --bg: #17151d;
  --card: #201d29;
  --text: #eae7f2;
  --muted: #9c96ac;
  --accent: #9b83e8;
  --accent-text: #17151d;
  --border: #363146;
  --table-stripe: #262230;
}

:root[data-theme="light"] {
  --bg: #faf8f4;
  --card: #ffffff;
  --text: #2a2733;
  --muted: #6f6a7d;
  --accent: #6d4fc4;
  --accent-text: #ffffff;
  --border: #e3ded3;
  --table-stripe: #f4f1ea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

header { text-align: center; margin-bottom: 1.5rem; }
h1 { margin: 0 0 0.25rem; font-size: 2rem; letter-spacing: 0.02em; }
.subtitle { color: var(--muted); margin: 0; }

form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid.three { grid-template-columns: 1fr 1fr 1.4fr; }
@media (max-width: 640px) { .grid, .grid.three { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.95rem; }
.forecast-field span { display: flex; align-items: center; gap: 0.4rem; }

input, select, button {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

details { border: 1px dashed var(--border); border-radius: 8px; padding: 0.6rem 0.9rem; }
summary { cursor: pointer; color: var(--muted); }
details .grid { margin-top: 0.8rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0 0; }

button[type="submit"] {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 0.7rem 1rem;
  font-size: 1.05rem;
  cursor: pointer;
  border-radius: 8px;
}
button[type="submit"]:hover { filter: brightness(1.08); }
button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }

#status {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
}
#status.error { border-color: #c0392b; color: #c0392b; }

figure#wheel {
  margin: 1.5rem 0 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
figure#wheel svg { display: block; margin: 0 auto; max-width: 620px; }

article#report {
  margin-top: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  overflow-x: auto;
}

#report h1 { font-size: 1.6rem; text-align: left; }
#report h2 {
  margin-top: 2rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.3rem;
}
#report h3 { margin-top: 1.4rem; font-size: 1.1rem; }

#report table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8rem 0;
  font-size: 0.95rem;
}
#report th, #report td {
  text-align: left;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
#report tbody tr:nth-child(odd) { background: var(--table-stripe); }

#report ul { padding-left: 1.2rem; }
#report li { margin: 0.45rem 0; }
#report hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
#report em { color: var(--muted); }
#report a { color: var(--accent); text-underline-offset: 2px; }

footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding-bottom: 2rem; }

/* Rectification: event rows */
.event-row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1.4fr) minmax(0, 1fr) 2rem;
  gap: 0.5rem;
  margin-top: 0.6rem;
  align-items: center;
}
.event-row .ev-remove {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  height: 2.2rem;
}
.event-row .ev-remove:hover { color: #e66; border-color: #e66; }
button.secondary {
  margin-top: 0.6rem;
  border: 1px dashed var(--border);
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
}
@media (max-width: 560px) {
  .event-row { grid-template-columns: 7rem minmax(0, 1fr) 2rem; }
  .event-row .ev-note { display: none; }
}

/* Two-layer report: collapsed astro base */
details.astro-base {
  margin: 1.2rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1rem;
}
details.astro-base > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
details.astro-base[open] > summary { margin-bottom: 0.6rem; }

/* Personal calendar download link */
a.ics-link {
  display: block;
  margin-bottom: 1rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
a.ics-link:hover { filter: brightness(1.1); }

/* Astro-chronometer */
#chrono {
  margin-top: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
#chrono h2 { margin: 0.2rem 0 0.4rem; }
#chrono-wheel { margin: 0.8rem 0; }
#chrono-wheel svg { display: block; margin: 0 auto; max-width: 640px; }
#chrono-status { list-style: none; padding: 0; margin: 0.6rem 0; }
.chrono-item { padding: 0.35rem 0.6rem; border-radius: 8px; margin: 0.25rem 0; }
.chrono-item.tone-good { background: rgba(63, 157, 99, 0.12); }
.chrono-item.tone-hard { background: rgba(179, 86, 77, 0.12); }
.chrono-item.tone-calm { background: var(--table-stripe); }
.chrono-controls { margin-top: 0.8rem; }
#chrono-slider { width: 100%; accent-color: var(--accent); }
.chrono-row { display: flex; justify-content: space-between; align-items: center; margin-top: 0.4rem; color: var(--muted); }
