/* Layout: desktop first. What needs me (2/3) on the left; Today above the app tiles on the right (1/3).
   Under 860px everything stacks in that order. System fonts only: the server CSP admits no font host. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --fg: #15191f;
  --muted: #545e6c;
  --line: #dce1e7;
  --accent: #2550b8;
  --warn: #8a4b00;   --warn-bg: #fff1dd;
  --unk: #4a5566;    --unk-bg: #e9edf2;
  --ok: #1b6e40;     --ok-bg: #e2f3e8;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --fg: #e7eaef; --muted: #a3acb9; --line: #29303a;
    --accent: #93b0ff; --warn: #f2b45a; --warn-bg: #2b2112; --unk: #b3bccb; --unk-bg: #222830;
    --ok: #6fd39b; --ok-bg: #13261a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --fg: #e7eaef; --muted: #a3acb9; --line: #29303a;
  --accent: #93b0ff; --warn: #f2b45a; --warn-bg: #2b2112; --unk: #b3bccb; --unk-bg: #222830;
  --ok: #6fd39b; --ok-bg: #13261a; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--font);
  padding-block: max(20px, env(safe-area-inset-top, 0px)) max(32px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body > * { max-width: 1180px; margin-inline: auto; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { font-size: 1.6rem; font-weight: 750; letter-spacing: -.01em; line-height: 1.2; }
.date { color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status { color: var(--muted); font-size: .875rem; text-align: right; }
.status.warn { color: var(--warn); }
.btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--fg);
  font-size: 1.15rem; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { cursor: progress; opacity: .6; }
.btn:disabled i { animation: spin 1s linear 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Grid */
.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 20px; align-items: start; }
/* A long problem list must not push the launcher off screen, so on desktop the list owns the left
   column and Today and the tiles share the right. */
.needs { grid-row: span 2; }
.apps { min-width: 0; }
.shortcuts { margin-top: 20px; }
.grid > .needs[hidden] + .today[hidden] + .apps { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid { grid-template-columns: minmax(0, 1fr); } .needs { grid-row: auto; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; min-width: 0; }
h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
h3 { font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.count { font-size: .8rem; font-weight: 700; padding: 1px 9px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* What needs me */
.prob { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.prob:first-child { border-top: 0; padding-top: 0; }
.prob .ico { font-size: 1.25rem; line-height: 1.3; }
.prob.attention .ico { color: var(--warn); }
.prob.stale .ico { color: var(--warn); }
.prob.unknown .ico { color: var(--unk); }
.prob .title { font-weight: 650; overflow-wrap: anywhere; }
.prob .why { color: var(--muted); overflow-wrap: anywhere; }
.prob .todo { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; margin-top: 4px; overflow-wrap: anywhere; }
.prob .todo .act { grid-column: 2; }
.act {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--accent); border-radius: var(--r); background: var(--surface); color: var(--accent);
  font: inherit; font-weight: 600; font-size: .9rem; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.act:hover { background: var(--accent); color: var(--surface); }
.copybox { grid-column: 1 / -1; width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); color: var(--fg); font: .85rem var(--mono); }
.prob .meta { grid-row: 1; grid-column: 3; font-size: .8rem; color: var(--muted); text-align: right; white-space: nowrap; }
.prob > div { grid-column: 2; min-width: 0; }
@media (max-width: 520px) {
  .prob .meta { grid-column: 2; grid-row: auto; text-align: left; }
  .prob .todo { grid-template-columns: minmax(0, 1fr); }
  .prob .todo .act { grid-column: 1; justify-self: start; }
}

.clear { display: flex; align-items: center; gap: 14px; padding: 6px 0 4px; }
.clear i { font-size: 2.2rem; color: var(--ok); }
.clear strong { display: block; font-size: 1.15rem; }

details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; color: var(--muted); font-size: .9rem; min-height: 44px; display: flex; align-items: center; gap: 6px; }
summary::marker { content: ""; }
summary::before { content: "\25B8"; transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }
.oklist li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 2px 10px; padding: 6px 0; font-size: .9rem; }
.oklist i { color: var(--ok); margin-top: .2em; }
.oklist .why { grid-column: 2; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.sources { margin-top: 14px; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.sources .stale { color: var(--warn); }

.skel { height: 14px; border-radius: 6px; background: var(--line); margin: 10px 0; }
.skel.w60 { width: 60%; } .skel.w40 { width: 40%; }

/* Today */
.today section + section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.today .head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.today .head a { font-size: .85rem; white-space: nowrap; display: inline-flex; align-items: center; min-height: 44px; }
.ev, .mail { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; padding: 5px 0; }
.ev .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; }
.mail { grid-template-columns: minmax(0, 1fr); gap: 0; }
.mail .from { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.mail .subj { overflow-wrap: anywhere; }
.big { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.note { margin-top: 10px; font-size: .8rem; color: var(--muted); }
.note.warn { color: var(--warn); }

/* Apps */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.tile {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--fg); text-decoration: none; font-weight: 600;
}
.tile i { font-size: 1.35rem; color: var(--accent); }
.tile:hover { border-color: var(--accent); }

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