:root {
  color-scheme: light dark;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-mood: #2a78d6;      /* categorical slot 1: blue */
  --series-receptive: #eb6834; /* categorical slot 2: orange */
  --good: #0ca30c;
  --critical: #d03b3b;
  --chip-positive: #e7f0fc;
  --chip-neutral: #f0efec;
  --chip-negative: #fdeee7;
  --chip-verynegative: #fbe7e7;
  /* reserved status colors */
  --ev-warning: #fab219;
  --ev-war: #d03b3b;
  --ev-both: #4a3aa7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-mood: #3987e5;
    --series-receptive: #d95926;
    --chip-positive: #16283e;
    --chip-neutral: #292926;
    --chip-negative: #3a231a;
    --chip-verynegative: #3a1c1c;
    --ev-both: #9085e9;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}

main {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

.masthead h1 { margin: 8px 0 2px; font-size: 26px; }
.tagline { margin: 0 0 16px; color: var(--ink-2); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; color: var(--ink-2); font-weight: 600; }

.charts { display: grid; gap: 14px; }
.chart { position: relative; min-height: 180px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .empty { color: var(--muted); font-size: 13px; padding: 24px 0; }

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  z-index: 5;
}
.chart-tip .tip-date { font-weight: 600; }
.chart-tip .tip-body { color: var(--ink-2); }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.error { color: var(--critical); font-size: 13px; }

input[type="date"], input[type="text"], #deviceName, #pairCode {
  width: 100%;
  max-width: 320px;
  padding: 9px 10px;
  border: 1px solid var(--baseline);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

.chip-group { margin-bottom: 8px; }
.chip-group .group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--baseline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 7px 14px;
  cursor: pointer;
  min-height: 40px;
}
.chip[aria-pressed="true"] { border-color: var(--ink); font-weight: 600; }
.chip.positive[aria-pressed="true"] { background: var(--chip-positive); }
.chip.neutral[aria-pressed="true"] { background: var(--chip-neutral); }
.chip.negative[aria-pressed="true"] { background: var(--chip-negative); }
.chip.very_negative[aria-pressed="true"] { background: var(--chip-verynegative); }
.chip.receptive[aria-pressed="true"] { background: var(--chip-neutral); }
.chip.event.warning[aria-pressed="true"] { background: rgba(250, 178, 25, 0.16); border-color: var(--ev-warning); }
.chip.event.war[aria-pressed="true"] { background: rgba(208, 59, 59, 0.14); border-color: var(--ev-war); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.chart-legend .key {
  display: inline-block;
  width: 2px;
  height: 11px;
  margin-right: 5px;
  vertical-align: -2px;
}

.e-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: baseline;
}

button.primary {
  background: var(--series-mood);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 11px 20px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
button.primary:disabled { opacity: 0.5; cursor: default; }

.encourage {
  margin-top: 12px;
  border-left: 3px solid var(--good);
  background: var(--chip-neutral);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.entries { list-style: none; margin: 0; padding: 0; }
.entries li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--grid);
  font-size: 14px;
}
.entries li:last-child { border-bottom: 0; }
.entries .e-date { font-weight: 600; white-space: nowrap; cursor: pointer; }
.entries .e-tags { flex: 1; color: var(--ink-2); }
.entries .e-del {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
}
.entries .e-del:hover { color: var(--critical); }

.pair-card { max-width: 420px; margin: 10vh auto 0; }
.pair-card h1 { margin-top: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--page);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
}
.toast button {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

@media (min-width: 640px) {
  .charts { grid-template-columns: 1fr 1fr; }
}
