/* ---- palette (see dataviz skill reference palette) ---- */
:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.page-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.page-sub {
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 10px 0 0;
  font-size: 0.95rem;
}

.icon-btn {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { color: var(--text-primary); }
#theme-icon-dark { display: none; }
:root[data-theme="dark"] #theme-icon-light { display: none; }
:root[data-theme="dark"] #theme-icon-dark { display: block; }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-top: 16px;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 10px 0 0;
}

.panel-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.date-input {
  font-size: 1rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: inherit;
}

#stats-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 28px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.grid-wrap {
  position: relative;
  overflow-x: auto;
}

#weeks-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--page-plane);
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 6px 9px;
  border-radius: 6px;
  max-width: 220px;
  z-index: 20;
  transform: translate(-50%, -100%);
}
.fade-settings {
  margin-top: 14px;
  border-top: 1px solid var(--gridline);
  padding-top: 10px;
}

.fade-settings summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  list-style: revert;
}
.fade-settings summary:hover { color: var(--text-primary); }

.fade-settings-body {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.field-label-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.field-label-inline input {
  font-size: 0.9rem;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: inherit;
  width: 100px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 7px 0;
}
.text-btn:hover { color: var(--text-primary); }

.event-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.event-form input[type="text"] {
  flex: 1 1 160px;
}

.event-form input[type="number"] {
  flex: 0 0 110px;
}

.event-form input {
  font-size: 0.9rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: inherit;
}

.event-form button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--series-1);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.event-form button:hover { opacity: 0.9; }

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  padding: 6px 2px;
  border-bottom: 1px solid var(--gridline);
}
.event-row:last-child { border-bottom: none; }

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: none;
}
.swatch.ritual { border-radius: 50%; }

.event-row .event-name { font-weight: 600; flex: 1 1 auto; }
.event-row .event-meta { color: var(--text-muted); font-size: 0.82rem; }

.remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
}
.remove-btn:hover { color: var(--series-8); }

@media (max-width: 480px) {
  .page { padding: 20px 14px 48px; }
  #stats-panel { gap: 14px 20px; }
  .stat { min-width: 80px; }
}
