/* Journal — dark panels floating on a warm gradient.
   Laptop-first, still honest at 390px. System fonts only: the character comes
   from scale, tracking and colour, not from a typeface. */

:root {
  --bg: #2a2a2c;

  --panel: #1a1a1c;
  --panel-2: #212124;
  --line: #34343a;

  --text: #ececef;
  --muted: #a0a0a8;

  /* One accent, two weights: the deep purple for fills you look at, the
     lifted one (same 264deg hue) for text and hairlines that must be read. */
  --purple: #3c107d;
  --purple-lift: #8532ff;
  --done: #c2500a;   /* progress, target met */
  --error: #f08e88;

  --radius: 14px;
  --radius-sm: 8px;
  --gap: 0.85rem;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", Menlo,
          Consolas, "Liberation Mono", monospace;
}

/* Dark in both schemes — this design doesn't invert. */

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

a { color: var(--purple-lift); }

:focus-visible {
  outline: 2px solid var(--purple-lift);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.eyebrow,
.panel-head label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* ---------- deck: two columns on a laptop, one on a phone ---------- */

.deck {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

@media (min-width: 60rem) {
  .deck {
    grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
    align-items: start;
  }
  .panel-day    { grid-column: 1; }
  .panel-metrics{ grid-column: 1; }
  .panel-note   { grid-column: 2; grid-row: 1 / span 2; }
  .pagefoot     { grid-column: 1 / -1; }

  .deck-single { grid-template-columns: minmax(0, 44rem); justify-content: center; }
  .deck-single > * { grid-column: 1 !important; grid-row: auto !important; }
}

/* ---------- day header ---------- */

.panel-day {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dayline { flex: 1; min-width: 0; position: relative; }

.stamp {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.live { color: var(--purple-lift); }

.chip {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}

.chip:hover { border-color: var(--purple-lift); color: var(--purple-lift); }
.chip-off { opacity: 0.25; }
.chip-off:hover { border-color: var(--line); color: var(--text); }
.chip-wide { white-space: nowrap; }

/* ---------- date picker ---------- */


.daypick {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  border-radius: var(--radius-sm);
}

.dayname {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.daypick .stamp {
  display: block;
  margin-top: 0.1rem;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.daypick:hover .stamp { text-decoration-color: var(--purple-lift); }
.daypick[aria-expanded="true"] .stamp { text-decoration-color: var(--purple-lift); }

/* The panel hangs below the header, above everything else on the page. */
.picker-slot:empty { display: none; }

.picker {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.6rem);
  left: 0;
  width: min(18rem, calc(100vw - 2rem));
  padding: 0.7rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
}

.picker-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.picker-title {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: var(--text);
}

.picker-step,
.picker-back {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1;
}

.picker-step:hover:not(:disabled),
.picker-back:hover { border-color: var(--purple-lift); color: var(--purple-lift); }

.picker-step:disabled { opacity: 0.25; cursor: default; }

.picker-grid { display: grid; gap: 0.25rem; }
.picker-months { grid-template-columns: repeat(3, 1fr); }
.picker-days { grid-template-columns: repeat(7, 1fr); }

.picker-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.picker-dow span {
  text-align: center;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.cell {
  display: grid;
  place-items: center;
  min-height: 2rem;
  padding: 0.2rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  text-decoration: none;
}

.picker-months .cell { min-height: 2.25rem; }

a.cell:hover,
button.cell:hover { border-color: var(--purple-lift); color: var(--purple-lift); }

.cell-blank { background: none; border: 0; }

.cell-off {
  opacity: 0.22;
  cursor: default;
  background: none;
}

/* A dot marks a day you actually logged — the grid is otherwise identical cells. */
.cell-has { position: relative; }

.cell-has::after {
  content: "";
  position: absolute;
  bottom: 3px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--purple-lift);
}

.cell-now {
  border-color: var(--purple-lift);
  color: var(--purple-lift);
}

.cell-now.cell-has::after { background: var(--purple-lift); }

/* ---------- metric rows ---------- */

.panel-metrics { display: grid; gap: 0.4rem; min-width: 0; }

.row {
  position: relative;
  min-width: 0;
  padding: 0.5rem 0.75rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid transparent;
}

.row:focus-within { border-color: var(--purple-lift); }

.row > label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.readout {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  min-width: 0;
}

.readout input {
  min-width: 0;
  width: 0;
  flex: 1 1 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  padding: 0;
}

.readout input:focus { outline: none; }
.readout input::placeholder { color: var(--line); }

/* Spinners shrink the target and nobody nudges a step count by 1. */
.readout input::-webkit-outer-spin-button,
.readout input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.readout input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.unit { color: var(--muted); font-size: 0.9rem; }

.goal {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.goal::before { content: "/ "; opacity: 0.5; }

/* The track: server renders --fill, the input listener keeps it live. */
.track {
  height: 4px;
  margin-top: 0.4rem;
  border-radius: 2px;
  background: #141215;
  overflow: hidden;
}

.track i {
  display: block;
  height: 100%;
  width: var(--fill, 0%);
  border-radius: 2px;
  background: var(--purple);
  transition: width 240ms ease, background-color 240ms ease;
}

.row-met .track i { background: var(--done); }
.row-met .goal { color: var(--done); }

/* ---------- note ---------- */

.panel-note { display: flex; flex-direction: column; }

textarea {
  width: 100%;
  flex: 1;
  min-height: 14rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.7;
  resize: vertical;
}

textarea::placeholder { color: var(--muted); opacity: 0.6; }
textarea:focus { outline: none; border-color: var(--purple-lift); }

/* ---------- chart ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 6.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}

.bar {
  flex: 1;
  min-width: 0;
  height: var(--h, 0%);
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--purple-lift);
}

/* Hit the target and the bar takes the completion colour, same as the track. */
.bar-met { background: var(--done); }

.bar:hover { background: #a566ff; }
.bar-met:hover { background: #e06514; }

/* A day with nothing logged is a gap, not a zero — a hairline on the floor. */
.bar-empty {
  height: 2px;
  background: var(--line);
}

/* ---------- trends ---------- */

.windows { display: flex; gap: 0.3rem; flex: none; }

.chip-on {
  border-color: var(--purple-lift);
  color: var(--purple-lift);
}

.trend { display: grid; gap: 0.55rem; }

.trend-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

/* Emphasis tracks certainty: only a tested finding gets the accent. */
.verdict {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.verdict-clearly { color: var(--purple-lift); font-weight: 600; }

.arrow-up,
.arrow-down {
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 0.15rem;
  border-left: 0.28rem solid transparent;
  border-right: 0.28rem solid transparent;
}

.arrow-up { border-bottom: 0.36rem solid currentColor; }
.arrow-down { border-top: 0.36rem solid currentColor; }

.trend-figures {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
}

.trend-mean {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.trend-label,
.trend-coverage {
  font-size: 0.72rem;
  color: var(--muted);
}

.trend-coverage { margin-left: auto; text-align: right; }

.trend-pct {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.trend-empty {
  margin: 0;
  padding: 1rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* The bars and the average line share one box so they stay in register. */
.chart-trend { position: relative; padding: 0.5rem 0.6rem; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
}

.chart-line {
  position: absolute;
  inset: 0.5rem 0.6rem;
  width: calc(100% - 1.2rem);
  height: calc(100% - 1rem);
  overflow: visible;
  pointer-events: none;
}

.chart-line polyline {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.85;
}

/* ---------- status ---------- */

.status-slot { font-size: 0.72rem; }

.row .status-slot {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  max-width: 55%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status { letter-spacing: 0.04em; }
.status-ok { color: var(--purple-lift); }
.status-error { color: var(--error); }

.status-fade { animation: settle 2.4s ease forwards; }

@keyframes settle {
  0%   { opacity: 0; transform: translateY(-2px); }
  12%  { opacity: 1; transform: none; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- entry list ---------- */

.entry { display: grid; gap: 0.4rem; }

.entry-date {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

.entry-date:hover { color: var(--purple-lift); }

.dow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
  margin-right: 0.4rem;
}

.entry-metrics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.entry-metrics b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.entry-note {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Long notes collapse. The note renders in full but is clamped to a few
   lines until opened — <details> handles the state with no script. */
.entry-more { position: relative; }

.entry-more .entry-note {
  max-height: 6.4em;   /* ~4 lines at line-height 1.6 */
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
}

.entry-more[open] .entry-note {
  max-height: none;
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}

/* summary comes after the note in source order so the clamp applies cleanly;
   flip it back visually. */
.entry-more { display: flex; flex-direction: column-reverse; align-items: flex-start; }

.entry-more summary {
  margin-top: 0.35rem;
  list-style: none;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--purple-lift);
}

.entry-more summary::-webkit-details-marker { display: none; }
.entry-more summary:hover { text-decoration: underline; }

.entry-more .more-shut { display: none; }
.entry-more[open] .more-open { display: none; }
.entry-more[open] .more-shut { display: inline; }

.panel-empty { display: grid; gap: 0.8rem; justify-items: start; }
.panel-empty p { margin: 0; color: var(--muted); }

.more { margin: 0.4rem 0 0; font-size: 0.85rem; }

/* ---------- login ---------- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.panel-login { width: min(22rem, 100%); padding: 1.6rem; }

.panel-login h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.panel-login .eyebrow { display: block; margin-bottom: 1.4rem; }

.panel-login label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.panel-login input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.panel-login input:focus { outline: none; border-color: var(--purple-lift); }
.panel-login .status-error { margin: 0.7rem 0 0; font-size: 0.8rem; }

button { font: inherit; cursor: pointer; }

.panel-login button {
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--purple);
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.panel-login button:hover { background: #4d1a9e; }

/* ---------- footer ---------- */

.pagefoot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.3rem;
  font-size: 0.8rem;
}

.pagefoot a { color: var(--muted); }
.pagefoot a:hover { color: var(--purple-lift); }

.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
}

.linkish:hover { color: var(--purple-lift); }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  /* The badge still needs to appear and clear — just without the movement. */
  .status-fade { animation: hold 2.4s step-end forwards !important; }
  @keyframes hold { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}
