:root {
  --bg: #f4f6f8; --card: #ffffff; --text: #141a20; --muted: #5d6873; --line: #dde3e8;
  --accent: #0e8f84; --accent-text: #ffffff; --danger: #c23b3b; --warn: #b7791f; --ok: #2f855a;
  --chip: #e8eef2; --code: #eef2f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #101418; --card: #1a2027; --text: #e7ecf0; --muted: #94a1ad; --line: #2a333c;
    --accent: #2bb3a5; --accent-text: #06201d; --danger: #f07070; --warn: #e3b04b; --ok: #5cc28c; --chip: #252e37; --code: #141a20; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; padding-bottom: calc(64px + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }
body.signed-out { padding-bottom: 0; }
body.signed-out #top, body.signed-out #nav { display: none; }

#top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
#top h1 { margin: 0; font-size: 20px; letter-spacing: .5px; }
#mac { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
#mac::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
#mac.ok::before { background: var(--ok); }
#mac.stale::before { background: var(--warn); }

main { padding: 12px 16px 24px; max-width: 680px; margin: 0 auto; }
h2 { font-size: 15px; margin: 18px 4px 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.title { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.muted { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.working { color: var(--accent); }
.chip.blocked, .chip.urgent { color: var(--danger); }
.chip.idle, .chip.done { color: var(--ok); }
.msg { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; margin: 10px 0 0; }
.msg.clamped { max-height: 14.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
pre.screen { background: var(--code); border-radius: 8px; padding: 10px; font-size: 12px; overflow-x: auto; white-space: pre; margin: 10px 0 0; }
.more { background: none; border: 0; color: var(--accent); padding: 6px 0 0; font-size: 14px; }
.reply { margin-top: 12px; display: flex; gap: 8px; align-items: flex-end; }
textarea { flex: 1; min-width: 0; resize: none; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); max-height: 40vh; }
button { font: inherit; cursor: pointer; }
.btn { border: 0; border-radius: 12px; padding: 10px 16px; background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 15px; }
.btn.secondary { background: var(--chip); color: var(--text); }
.btn.danger { background: none; color: var(--danger); padding: 8px 10px; }
.btn.danger.armed { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; }
.status { font-size: 13px; margin-top: 8px; }
.status.failed { color: var(--danger); }
.status.done { color: var(--ok); }
.reminder .when { font-size: 14px; font-weight: 600; color: var(--accent); }
.reminder .text { margin-top: 4px; font-size: 15px; overflow-wrap: anywhere; white-space: pre-wrap; }

#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 2; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; font-size: 12px; color: var(--muted); text-decoration: none; }
#nav a span { font-size: 20px; line-height: 1.2; }
#nav a.active { color: var(--accent); font-weight: 600; }

.splash, .signin { min-height: 80dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; }
.signin h1 { margin: 6px 0 0; font-size: 28px; }
.signin p { color: var(--muted); max-width: 320px; margin: 0; line-height: 1.45; }
.signin .btn { max-width: 320px; }
.error { color: var(--danger); font-size: 14px; max-width: 320px; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 3; margin: 0 auto; max-width: 420px;
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; font-size: 14px; text-align: center; }
