:root {
  --bg: #0B0B0A;
  --text: #ECEAE4;
  --muted: #8E8C86;
  --line: #262521;
  --line-soft: #1C1B18;
  --tick-off: #2B2A26;
  --accent: #FF6A1A;
  --personal: #5FB3A6;
  --ui: "Geist", -apple-system, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--ui);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

ul { list-style: none; }

.label {
  font-family: var(--ui);
  font-size: 10px;
  line-height: 14px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

#app { position: fixed; inset: 0; }

.layer {
  position: absolute;
  top: 0;
  bottom: 0;
  transition: opacity 2s ease;
}
.layer.off { opacity: 0; pointer-events: none; }

/* ───────────── Day ───────────── */

.day {
  /* keep clear of the notch: the panel surface sits inside the safe area, #000 outside */
  left: env(safe-area-inset-left, 0px);
  right: env(safe-area-inset-right, 0px);
  display: flex;
  padding: 18px 0 max(18px, env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0 18px;
}
.col + .col { border-left: 1px solid var(--line); }
.col-left  { flex: 0 0 268px; }
.col-mid   { flex: 1 1 auto; }
.col-right { flex: 0 0 232px; }

.row-labels {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.pinned {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  flex: none;
}

/* left */
.clock {
  margin-top: 10px;
  font: 300 76px/1 var(--mono);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.colon { color: var(--accent); transition: opacity 0.45s ease-in-out; }
.colon.dim { opacity: 0.35; }

.sub {
  margin-top: 8px;
  font: 11px/16px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-top: 8px;
  row-gap: 1px;
  text-align: center;
}
.cal-wd { font: 500 9px/16px var(--ui); color: var(--muted); letter-spacing: 0.08em; }
.cal-d  { font: 11px/18px var(--mono); font-variant-numeric: tabular-nums; }
.cal-d span { display: inline-block; min-width: 22px; border-radius: 3px; }
.cal-d.past { color: var(--muted); }
.cal-d.due span {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  -webkit-text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.cal-d.today span { background: var(--accent); color: var(--bg); }

/* middle */
#un-label.live { color: var(--accent); }
.un-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 4px;
}
.un-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 22px;
  line-height: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.un-count {
  flex: none;
  font: 400 22px/28px var(--mono);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.meta {
  margin-top: 2px;
  font: 11px/16px var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl { margin-top: 14px; min-height: 0; overflow: hidden; }
.tl-now {
  display: flex;
  align-items: center;
  height: 20px;
}
.tl-now-label { font: 500 10px/14px var(--ui); letter-spacing: 0.14em; color: var(--accent); }
.tl-now-line { flex: 1 1 auto; height: 1px; background: var(--accent); margin: 0 10px; }
.tl-done { font: 10px/14px var(--mono); color: var(--muted); white-space: nowrap; }

.tl-row {
  display: flex;
  align-items: center;
  height: 38px;
  border-bottom: 1px solid var(--line-soft);
}
.tl-time {
  flex: 0 0 40px;
  font: 12px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}
.dot { flex: none; width: 6px; height: 6px; margin: 0 10px 0 4px; background: var(--text); }
.dot.due { background: var(--accent); }
.dot.personal { background: var(--personal); }
.tl-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-kind {
  flex: none;
  margin-left: 10px;
  font: 500 9px/1 var(--ui);
  letter-spacing: 0.12em;
  color: var(--muted);
}
.tl-row.live .tl-time { color: var(--accent); }
.tl-more { margin-top: 6px; font: 10px/14px var(--mono); color: var(--muted); }
.tl-more:empty { display: none; }

/* timer */
.ticks { display: flex; gap: 2px; height: 10px; }
.tick { flex: 1 1 0; background: var(--tick-off); }
.tick.on { background: var(--accent); }
.ticks.flash { animation: flash 0.6s steps(1, end) 5; }
@keyframes flash { 50% { opacity: 0.15; } }

.timer-row {
  display: flex;
  align-items: center;
  margin-top: 10px;
  height: 44px;
}
.tm-time {
  margin-left: 12px;
  font: 400 22px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tm-reset {
  margin-left: auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.tm-reset:active { color: var(--text); }
.tm-go {
  flex: none;
  height: 44px;
  min-width: 96px;
  padding: 0 20px;
  margin-left: 6px;
  border-radius: 22px;
  background: var(--accent);
  color: var(--bg);
  font: 600 12px/1 var(--ui);
  letter-spacing: 0.1em;
}
.tm-go:active { opacity: 0.8; }

/* right */
.w-now {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.w-temp {
  font: 300 52px/1 var(--mono);
  letter-spacing: -0.04em;
  white-space: nowrap;
}
.w-desc { text-align: right; min-width: 0; }
.w-cond { font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-hl { margin-top: 2px; font: 11px/16px var(--mono); color: var(--muted); white-space: nowrap; }

.w-hours {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 14px;
  text-align: center;
}
.w-h-hr { font: 10px/14px var(--mono); color: var(--muted); }
.w-h-ic { display: block; width: 18px; height: 18px; margin: 6px auto; color: var(--text); }
.w-h-t  { font: 12px/16px var(--mono); }

.w-rain { margin-top: 10px; font: 10px/14px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-rain:empty { display: none; }

.td-list { margin-top: 2px; }
.td {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
.td-box {
  flex: none;
  width: 14px;
  height: 14px;
  margin-right: 12px;
  border: 1.5px solid var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.td-box svg { display: none; }
.td-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.td.done .td-box { background: var(--accent); border-color: var(--accent); }
.td.done .td-box svg { display: block; }
.td.done .td-title { color: var(--muted); text-decoration: line-through; }
.td-empty { font-size: 12px; color: var(--muted); line-height: 44px; }

/* ───────────── Night ───────────── */

.night {
  left: 0;
  right: 0;
  z-index: 2;
  background: #000;
  color: #7D7B76;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px calc(40px + env(safe-area-inset-right, 0px)) max(28px, env(safe-area-inset-bottom, 0px)) calc(40px + env(safe-area-inset-left, 0px));
}
.night .label { color: #7D7B76; }
.n-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; white-space: nowrap; }
.n-val { font: 11px/14px var(--mono); }
.n-clock {
  align-self: center;
  font: 200 200px/1 var(--mono);
  letter-spacing: -0.04em;
  color: #6B6964;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: transform 3s ease-in-out;
}
.n-colon { color: #7A3412; }

/* ───────────── Misc ───────────── */

.stale {
  position: fixed;
  z-index: 3;
  right: calc(6px + env(safe-area-inset-right, 0px));
  bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.6;
}
.stale[hidden] { display: none; }

#rotate {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: #000;
}
@media (orientation: portrait) {
  #app { display: none; }
  #rotate { display: flex; }
}
