/* Control dashboard: system font, light and dark by prefers-color-scheme, 16 px gutters, 44 px tap targets,
   bottom tab bar on the phone, left rail from 768 px, safe-area padding for the iOS home-screen app. */
:root { --bg: #ffffff; --fg: #18181b; --muted: #6b7280; --card: #f4f4f5; --line: #e4e4e7; --acc: #2563eb; --ok: #15803d; --err: #b91c1c; --late: #f59e0b; --nav: #fafafa; }
@media (prefers-color-scheme: dark) {
  :root { --bg: #18181b; --fg: #f4f4f5; --muted: #a1a1aa; --card: #27272a; --line: #3f3f46; --acc: #60a5fa; --ok: #4ade80; --err: #f87171; --nav: #1f1f23; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--acc); }
header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
header div { display: flex; gap: 8px; align-items: center; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 20px 0 6px; }
h2 .n { font-weight: 400; color: var(--muted); margin-left: 6px; }
h2.date { margin-top: 8px; }
main { padding: 8px 16px calc(72px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
#nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 2; display: flex; background: var(--nav); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav a { flex: 1; text-align: center; padding: 12px 1px; min-height: 44px; font-size: 10.5px; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
#nav a.on { color: var(--acc); font-weight: 600; }
@media (min-width: 768px) {
  #nav { top: 0; bottom: 0; right: auto; width: 160px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding-top: 16px; }
  #nav a { flex: 0 0 auto; text-align: left; padding: 12px 16px; font-size: 15px; }
  header, main { margin-left: 160px; }
  main { padding-bottom: 32px; }
}

.card { background: var(--card); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.card.late { border-left: 3px solid var(--late); }
.card.gone { opacity: .7; }
.row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.task { font-weight: 600; margin: 0; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; padding: 2px 6px; border-radius: 4px; background: var(--line); color: var(--muted); white-space: nowrap; }
.tag.personal { background: var(--acc); color: #fff; }
.meta, .muted { color: var(--muted); font-size: 13px; margin: 4px 0; }
.note { font-size: 14px; margin: 4px 0; }
.line { margin: 6px 0 0; font-size: 14px; }
.line.ok, .flash.ok { color: var(--ok); }
.line.err, .flash.err, .err { color: var(--err); }
.acts, .ask, .seg, .row2 { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row2 > * { flex: 1; min-width: 140px; }
.btn { min-height: 44px; min-width: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; font-size: 15px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary, .btn.on { background: var(--acc); color: #fff; border-color: var(--acc); }
.btn.ghost { background: transparent; color: var(--muted); }
.inp { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; flex: 1; width: 100%; }
textarea.inp.big { min-height: 88px; margin-top: 8px; }
.ask .inp { width: auto; }
pre.q, pre.log { white-space: pre-wrap; word-break: break-word; font: 14px/1.4 inherit; margin: 6px 0; }
pre.q { max-height: 8.4em; overflow: hidden; cursor: pointer; }
pre.q.open { max-height: none; }
pre.log { background: var(--card); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
details { margin: 6px 0; }
summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.chips { display: flex; gap: 8px; margin: 10px 0; }
.chips a { flex: 1; text-align: center; padding: 8px; border-radius: 10px; background: var(--card); color: var(--fg); text-decoration: none; font-size: 13px; min-height: 44px; }
.chips b { display: block; font-size: 20px; }
.habits { background: var(--card); border-radius: 10px; padding: 8px 12px; }
.hrow { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.hrow span { flex: 1; }
.hrow .inp { flex: 0 0 90px; width: 90px; }
.cal { margin: 6px 0; }
.agent { margin-top: 16px; }
.row.top { justify-content: space-between; align-items: center; }
.lnk { display: inline-block; min-height: 44px; line-height: 44px; margin: 4px 0; }
.night { font-size: 18px; margin: 16px 0; }
.money { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.money .amt { font-weight: 600; text-align: right; }
.money .meta { grid-column: 1 / -1; margin: 0; }
.cd { margin: 6px 0; }
.cd b { display: inline-block; min-width: 44px; }
.cd.late b { color: var(--err); }
.bar { display: grid; grid-template-columns: 110px 1fr 64px; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { display: block; background: var(--card); border-radius: 4px; height: 12px; }
.bar .fill { display: block; height: 12px; background: var(--acc); border-radius: 4px; }
.bar .min { text-align: right; color: var(--muted); }
table.grid, .md table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.grid td, .grid th, .md td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: top; }
.grid .c { text-align: center; }
.good { color: var(--ok); }
.bad { color: var(--err); }
.md h2 { margin-top: 24px; }
.md h3, .md h4 { font-size: 15px; margin: 14px 0 4px; }
.md ul, .md ol { padding-left: 20px; margin: 4px 0; }
.md li, .md p { margin: 3px 0; font-size: 15px; }
.md code { font-size: 13px; background: var(--card); padding: 1px 4px; border-radius: 4px; }
.hit { font-size: 14px; margin: 4px 0; padding: 6px 8px; background: var(--card); border-radius: 6px; }
.flash { position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 16px; right: 16px; z-index: 3; padding: 10px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); max-width: 600px; margin: 0 auto; }
body.login form { max-width: 320px; margin: 24vh auto; padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
body.login h1 { font-size: 32px; }
body.login input { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; }
body.login button { min-height: 44px; border: 0; border-radius: 8px; background: var(--acc); color: #fff; font: inherit; font-size: 16px; }
body.login .err:empty { display: none; }
.conv { max-height: 55vh; overflow-y: auto; background: var(--card); border-radius: 10px; padding: 8px 12px; }
.msg { margin: 8px 0; }
.msg p { margin: 2px 0; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.msg.me { border-left: 3px solid var(--acc); padding-left: 8px; }
.msg.me p { font-weight: 600; }
.msg.open { opacity: .7; }
.card.grey { opacity: .55; }
.card.running { border-left: 3px solid var(--ok); }
.acts .inp { flex: 0 0 160px; width: 160px; }
.tag.chief { background: var(--ok); color: #fff; }
details.rest { margin: 8px 0; }
