@font-face { font-family: 'Lite Manrope'; src: url('../resources/fonts/manrope-lite.woff2') format('woff2'); font-weight: 400 800; font-display: block; }

:root {
  --ink: #eef0f3;
  --mark: #f25c4b;
  --ground: #121417;
  --pri-4: #ff5a4e;   /* Todoist sends 4 for its p1 (urgent) */
  --pri-3: #ffa31a;
  --pri-2: #4c9dff;
  --pri-1: color-mix(in srgb, var(--ink) 22%, transparent);

  --u: 1vmin;
  --pad: calc(var(--u) * 4.2);
  --space: calc(var(--u) * 2.1);
  --body: calc(var(--u) * 3.5);
  --small: calc(var(--u) * 2.45);
  --big: calc(var(--u) * 18);
  --line: calc(var(--u) * 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--ground); }
body { color: var(--ink); font: 500 var(--body)/1.24 'Lite Manrope', 'Segoe UI', system-ui, sans-serif; -webkit-font-smoothing: antialiased; user-select: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* ---- frame: summary column | task rows ---- */
.tl-root { position: relative; display: flex; width: 100%; height: 100%; padding: var(--pad) calc(var(--pad) * 1.1); gap: calc(var(--space) * 2.6); overflow: hidden; }
.tl-head { flex: 0 0 auto; width: calc(var(--u) * 50); min-width: 0; display: flex; flex-direction: column; }
.tl-day { font-size: var(--small); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.62; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-num { display: flex; align-items: baseline; gap: calc(var(--space) * 0.7); margin-top: calc(var(--space) * 0.5); }
.tl-num b { font-size: var(--big); font-weight: 800; line-height: 0.92; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; color: var(--mark); }
.tl-num span { font-size: calc(var(--body) * 1.05); font-weight: 700; opacity: 0.75; }
.tl-late { font-size: var(--body); font-weight: 600; opacity: 0.55; margin-top: calc(var(--space) * 0.5); white-space: nowrap; }
.tl-late.is-on { color: var(--pri-4); opacity: 1; }
.tl-sync {
  margin-top: auto; align-self: flex-start; display: inline-flex; align-items: center; gap: calc(var(--space) * 0.55);
  padding: calc(var(--space) * 0.35) calc(var(--space) * 0.7) calc(var(--space) * 0.35) calc(var(--space) * 0.5); margin-left: calc(var(--space) * -0.5);
  border: 0; border-radius: calc(var(--u) * 1.6); background: transparent; font-size: var(--small); font-weight: 600; opacity: 0.5; cursor: pointer; white-space: nowrap; max-width: 100%;
}
.tl-sync span:last-child { overflow: hidden; text-overflow: ellipsis; }
.tl-sync:active { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.tl-sync-dot { flex: 0 0 auto; width: calc(var(--u) * 1.3); height: calc(var(--u) * 1.3); border-radius: 50%; background: #3ecf8e; }
.tl-root.is-stale .tl-sync { opacity: 1; color: var(--mark); }
.tl-root.is-stale .tl-sync-dot { background: var(--mark); }

/* ---- rows: read-only, a priority bar instead of a checkbox ---- */
.tl-rows {
  list-style: none; margin: 0; padding: 0; flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--u) * 74), 1fr)); grid-auto-rows: min-content;
  column-gap: calc(var(--space) * 2.6); align-content: start; transition: opacity 0.4s;
}
.tl-sec { grid-column: 1 / -1; font-size: var(--small); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.45; padding: calc(var(--space) * 0.5) 0 calc(var(--space) * 0.15); }
.tl-sec-over { color: var(--pri-4); opacity: 0.85; }
.tl-row { display: flex; align-items: stretch; gap: calc(var(--space) * 0.95); padding: calc(var(--space) * 0.5) 0; min-width: 0; }
.tl-bar { flex: 0 0 auto; width: calc(var(--u) * 0.85); border-radius: calc(var(--u) * 0.5); background: var(--pri-1); }
.tl-p4 .tl-bar { background: var(--pri-4); }
.tl-p3 .tl-bar { background: var(--pri-3); }
.tl-p2 .tl-bar { background: var(--pri-2); }
.tl-words { display: flex; flex-direction: column; justify-content: center; gap: calc(var(--space) * 0.12); min-width: 0; }
.tl-title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tl-info { display: flex; gap: calc(var(--space) * 0.75); font-size: var(--small); opacity: 0.6; white-space: nowrap; overflow: hidden; }
.tl-when { font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-row.is-late .tl-when { color: var(--pri-4); opacity: 1; }
.tl-row.is-late .tl-info { opacity: 0.85; }
.tl-proj { overflow: hidden; text-overflow: ellipsis; }
.tl-proj::before { content: '#\00a0'; opacity: 0.55; }
.tl-more, .tl-clear { grid-column: 1 / -1; font-size: var(--small); font-weight: 600; opacity: 0.5; padding-top: calc(var(--space) * 0.5); }
.tl-clear { font-size: calc(var(--body) * 1.15); opacity: 0.8; padding-top: calc(var(--space) * 1.2); }
.is-off { display: none !important; }

/* nothing left today: the zero is calm, not alarming */
.tl-root[data-state="clear"] .tl-num b { color: #3ecf8e; }
.tl-clear { color: #3ecf8e; }

/* last good list while Todoist can't be reached: greyed, with "as of" in the sync line */
.tl-root.is-stale .tl-rows { opacity: 0.42; filter: grayscale(1); }
.tl-root.is-stale .tl-num b { color: var(--ink); opacity: 0.55; }

/* ---- messages (setup, token, unreachable) ---- */
.tl-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 80%;
  display: flex; flex-direction: column; gap: 0.45em; text-align: center; padding: calc(var(--pad) * 0.75) var(--pad);
  border-radius: calc(var(--u) * 2.2); background: color-mix(in srgb, var(--ground) 86%, var(--ink)); border-left: calc(var(--u) * 0.8) solid var(--mark);
}
.tl-card { max-width: min(84%, calc(var(--u) * 120)); }
.tl-card b { font-weight: 800; font-size: calc(var(--body) * 1.35); }
.tl-card span { font-size: calc(var(--body) * 0.95); line-height: 1.4; opacity: 0.85; }

/* ---- per slot shape ---- */
/* Small horizontal (840x344) and small vertical (696x416): short column, one list column */
@media (max-height: 499px) {
  :root { --u: 5px; }
  .tl-head { width: calc(var(--u) * 38); }
  .tl-num b { font-size: calc(var(--big) * 0.78); }
  .tl-rows { grid-template-columns: 1fr; }
  .tl-title { -webkit-line-clamp: 1; white-space: nowrap; display: block; text-overflow: ellipsis; }
}
@media (max-height: 499px) and (max-aspect-ratio: 2/1) {
  :root { --u: 4.4px; }
  .tl-head { width: calc(var(--u) * 33); }
  .tl-day { white-space: normal; }
}
/* Medium horizontal (840x696): the summary as a band across the top */
@media (max-aspect-ratio: 2/1) and (min-aspect-ratio: 1/1) and (min-height: 500px) {
  .tl-root { flex-direction: column; gap: calc(var(--space) * 1.2); }
  .tl-head { width: auto; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; column-gap: calc(var(--space) * 1.8); align-items: end; }
  .tl-day { grid-column: 1 / 4; }
  .tl-num { grid-row: 2; margin-top: 0; }
  .tl-num b { font-size: calc(var(--big) * 0.62); }
  .tl-late { grid-row: 2; grid-column: 2; margin: 0 0 calc(var(--space) * 0.35); }
  .tl-sync { grid-row: 2; grid-column: 3; margin: 0 0 calc(var(--space) * 0.15); }
  .tl-rows { grid-template-columns: 1fr; border-top: var(--line) solid color-mix(in srgb, var(--ink) 12%, transparent); padding-top: calc(var(--space) * 0.4); }
}
/* Vertical (696x840, 696x1688, 696x2536): band on top, rows below */
@media (max-aspect-ratio: 1/1) {
  .tl-root { flex-direction: column; gap: calc(var(--space) * 1.4); }
  .tl-head { width: auto; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: calc(var(--space) * 1.6); }
  .tl-day { grid-column: 1 / 3; }
  .tl-num { grid-row: 2 / 4; margin-top: calc(var(--space) * 0.3); }
  .tl-num b { font-size: calc(var(--big) * 0.85); }
  .tl-late { grid-column: 2; grid-row: 2; align-self: end; margin: 0; }
  .tl-sync { grid-column: 2; grid-row: 3; align-self: start; margin-top: calc(var(--space) * 0.2); }
  .tl-rows { grid-template-columns: 1fr; border-top: var(--line) solid color-mix(in srgb, var(--ink) 12%, transparent); padding-top: calc(var(--space) * 0.5); }
}
@media (max-aspect-ratio: 1/2) {
  :root { --body: calc(var(--u) * 3.9); --small: calc(var(--u) * 2.7); }
  .tl-row { padding: calc(var(--space) * 0.65) 0; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
