:root {
  color-scheme: light dark;
  --page: #f3f5f7;
  --card: #ffffff;
  --text: #17202a;
  --muted: #5d6b7a;
  --line: #d5dce3;
  --accent: #0f6b6b;
  --accent-soft: #dff0ef;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --warn: #8a5a00;
  --pill-todo: #e6ebf0;
  --pill-todo-text: #3d4a57;
  --pill-work: #dbeafe;
  --pill-work-text: #1d4f91;
  --pill-held: #fdecc8;
  --pill-held-text: #7a4e00;
  --pill-done: #d9f2e2;
  --pill-done-text: #17643a;
  --shadow: 0 1px 2px rgb(0 0 0 / 7%);
  --nav-height: 58px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #11171d;
    --card: #1b232b;
    --text: #e8edf2;
    --muted: #9aa8b5;
    --line: #33404c;
    --accent: #58bdb9;
    --accent-soft: #1d3a3a;
    --on-accent: #0b1a1a;
    --danger: #f2998f;
    --warn: #e4b75f;
    --pill-todo: #2c3640;
    --pill-todo-text: #c4cfd9;
    --pill-work: #1e3552;
    --pill-work-text: #a8cdf7;
    --pill-held: #43351a;
    --pill-held-text: #edc77c;
    --pill-done: #1a3d2a;
    --pill-done-text: #99e0b5;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--page); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: anywhere; }
main { width: 100%; }
h1, h2, p, dl, dd, ol { margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { opacity: 0.6; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.big-icon { display: block; width: 44px; height: 44px; margin-bottom: 12px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* --- Login ---------------------------------------------------------------------------------- */
.login-card { max-width: 420px; margin: 0 auto; padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom)); }
@media (min-width: 480px) {
  .login-card { margin-top: 48px; padding: 32px 28px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
}
.brand { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; color: var(--accent); }
.login-card h1 { margin: 8px 0 8px; font-size: 26px; line-height: 1.2; }
.intro { margin-bottom: 20px; color: var(--muted); }
.step { margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--accent); }
.field-block { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
input { display: block; width: 100%; min-height: 50px; padding: 12px 14px; font: inherit; font-size: 16px; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.input-row { position: relative; }
.input-row input { padding-right: 76px; }
.reveal { position: absolute; top: 0; right: 0; height: 50px; min-width: 70px; font-size: 14px; color: var(--accent); }
.code-input { text-align: center; font-size: 26px; font-weight: 600; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.primary { display: block; width: 100%; min-height: 52px; padding: 14px; font-weight: 600; text-align: center; text-decoration: none; color: var(--on-accent); background: var(--accent); border-radius: 12px; }
.secondary { display: block; width: 100%; min-height: 48px; padding: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 12px; }
.link-button { margin: 10px 0 8px; }
.error { margin-bottom: 12px; font-size: 14px; color: var(--danger); }
.steps { margin: 0 0 20px; padding-left: 22px; }
.steps > li { margin-bottom: 14px; padding-left: 2px; }
.stores { margin-top: 4px; font-size: 14px; color: var(--muted); }
.stores a { display: inline-block; padding: 4px 2px; font-weight: 600; }
.secret { display: block; margin: 8px 0; font-size: 12px; text-align: center; color: var(--muted); }
.other-ways summary { padding: 8px 0; font-size: 14px; color: var(--muted); cursor: pointer; }
.qr { display: block; width: 200px; height: 200px; margin: 8px auto; padding: 8px; background: #ffffff; border-radius: 8px; }

/* --- The menus ------------------------------------------------------------------------------ */
body.wide main { max-width: 720px; margin: 0 auto; padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px); }
.head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 4px; min-height: 52px; padding: env(safe-area-inset-top) 8px 0 16px; background: var(--page); border-bottom: 1px solid var(--line); }
.head-title { flex: 1; font-size: 18px; font-weight: 700; }
.head .back { display: none; margin-left: -8px; }
.head.has-back .back { display: flex; }
.icon-button { align-items: center; justify-content: center; width: 44px; height: 44px; }
.plain { min-height: 44px; padding: 0 10px; font-size: 14px; color: var(--muted); }
.menu-content { padding: 12px 16px 0; }
.tabs { position: fixed; right: 0; bottom: 0; left: 0; z-index: 2; display: flex; padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav-height); font-size: 12px; color: var(--muted); }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }
.chips { display: flex; gap: 8px; margin-bottom: 10px; }
.chip { flex: 1; min-height: 40px; padding: 8px 6px; font-size: 14px; font-weight: 500; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 20px; }
.chip[aria-selected="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.search { min-height: 44px; margin-bottom: 12px; padding: 10px 14px; }
.card { display: block; width: 100%; margin-bottom: 8px; padding: 14px; text-align: left; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); }
.row { min-height: 60px; }
.row:active, .event summary:active { background: var(--accent-soft); }
.row-title { display: block; font-weight: 600; line-height: 1.3; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.row-sub { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; font-size: 12px; font-weight: 600; border-radius: 10px; }
.status-todo { color: var(--pill-todo-text); background: var(--pill-todo); }
.status-in_progress { color: var(--pill-work-text); background: var(--pill-work); }
.status-blocked { color: var(--pill-held-text); background: var(--pill-held); }
.status-done { color: var(--pill-done-text); background: var(--pill-done); }
.due.late { font-weight: 600; color: var(--danger); }
.due.soon { font-weight: 600; color: var(--warn); }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.skeleton { height: 72px; margin-bottom: 8px; background: var(--card); border-radius: 12px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.group { margin-top: 20px; }
.group h2 { margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.menu-content > .group:first-child { margin-top: 4px; }
.task-title { font-size: 21px; line-height: 1.25; }
.facts { margin-top: 12px; }
.fact { display: flex; gap: 12px; padding: 7px 0; font-size: 15px; border-bottom: 1px solid var(--line); }
.fact:last-child { border-bottom: 0; }
.fact dt { flex: 0 0 38%; color: var(--muted); }
.fact dd { flex: 1; }
.text { white-space: pre-wrap; }
.note { margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.file { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.file-name { flex: 1; color: var(--text); font-size: 15px; }
.file-size { flex: none; font-size: 13px; }
.entry .pill { margin-bottom: 4px; }
.entry-head { margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.entry-head b { color: var(--text); }
.event { padding: 0; }
.event summary { display: flex; gap: 12px; min-height: 60px; padding: 12px 14px; list-style: none; cursor: pointer; border-radius: 12px; }
.event summary::-webkit-details-marker { display: none; }
.event-time { flex: 0 0 62px; display: flex; flex-direction: column; font-size: 14px; color: var(--muted); }
.event-time b { color: var(--accent); font-size: 15px; }
.event-main { flex: 1; }
.event .facts { margin: 0; padding: 0 14px 8px; border-top: 1px solid var(--line); }
.event > .text { padding: 0 14px 14px; font-size: 15px; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.person-main { flex: 1; min-width: 0; }
.avatar { flex: none; display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; font-size: 14px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 50%; }
.tab { position: relative; }
.badge { flex: none; min-width: 22px; padding: 1px 6px; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; color: #ffffff; background: var(--danger); border-radius: 11px; }
.tab-badge { position: absolute; top: 5px; left: calc(50% + 6px); }
.chat-row { min-height: 66px; }
.chat-top { display: flex; align-items: baseline; gap: 8px; }
.chat-top .row-title { flex: 1; min-width: 0; }
.chat-time { flex: none; font-size: 12px; color: var(--muted); }
.chat-last { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-heading { margin: 16px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.chat-messages { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.chat-message { align-self: flex-start; max-width: 84%; padding: 8px 12px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.chat-message.mine { align-self: flex-end; background: var(--accent-soft); }
.chat-name { margin-bottom: 2px; font-size: 13px; font-weight: 700; color: var(--accent); }
.chat-quote { margin-bottom: 4px; padding-left: 8px; font-size: 13px; color: var(--muted); border-left: 2px solid var(--line); }
.chat-meta { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 2px; font-size: 12px; color: var(--muted); }
.chat-remove { min-height: 28px; font-size: 12px; color: var(--muted); text-decoration: underline; }
.chat-deleted { font-style: italic; color: var(--muted); }
.chat-system { align-self: center; font-size: 12px; text-align: center; color: var(--muted); }
.chat-file { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; text-align: left; color: var(--accent); }
.chat-earlier { margin-bottom: 12px; }
.chat-compose { position: sticky; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); z-index: 1; display: flex; align-items: flex-end; gap: 8px; margin: 0 -16px; padding: 8px 12px; background: var(--page); border-top: 1px solid var(--line); }
.chat-compose textarea { flex: 1; min-width: 0; min-height: 44px; margin: 0; padding: 10px 14px; resize: none; border-radius: 22px; }
.chat-send { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--on-accent); background: var(--accent); border-radius: 50%; }
.post { padding: 14px; }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-text { margin-top: 10px; }
.feed-picture { min-height: 60px; margin-top: 10px; }
.feed-picture img, .feed-picture video { display: block; width: 100%; max-height: 480px; object-fit: contain; background: var(--page); border-radius: 10px; }
.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.reaction { min-width: 52px; min-height: 40px; padding: 4px 10px; font-size: 14px; background: var(--page); border: 1px solid transparent; border-radius: 20px; }
.reaction[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.feed-comments { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.comment { margin-bottom: 12px; font-size: 15px; }
.comment.reply { margin-left: 18px; padding-left: 10px; border-left: 2px solid var(--line); }
.tab { min-width: 0; font-size: 11px; }
.month-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; text-align: center; }
.month-switch .chip { flex: 0 0 56px; font-size: 22px; line-height: 1; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.warn b { color: var(--danger); }
.attendance-day { display: flex; gap: 12px; }
.attendance-date { flex: 0 0 52px; display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.attendance-date b { font-size: 20px; color: var(--text); }
.attendance-head { margin-top: 0; }
.attendance-ok { color: var(--pill-done-text); background: var(--pill-done); }
.attendance-warn { color: var(--pill-held-text); background: var(--pill-held); }
.attendance-bad { color: #ffffff; background: var(--danger); }
.attendance-info { color: var(--pill-work-text); background: var(--pill-work); }
.attendance-off { color: var(--pill-todo-text); background: var(--pill-todo); }
.chat-attach { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--muted); }
.chat-picture { display: block; min-width: 120px; min-height: 80px; max-width: 100%; padding: 0; color: var(--muted); }
.chat-picture img { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; }
.previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.previews:empty { display: none; }
.preview { position: relative; aspect-ratio: 1; }
.preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.preview-remove { position: absolute; top: 2px; right: 2px; width: 40px; height: 40px; font-size: 22px; line-height: 1; color: #ffffff; background: rgb(0 0 0 / 55%); border-radius: 50%; }
.post-note { margin: 10px 0 12px; }
.money-warning { margin-bottom: 12px; padding: 12px 14px; font-weight: 600; color: var(--pill-held-text); background: var(--pill-held); border-left: 4px solid var(--warn); border-radius: 10px; }
.expense-line { display: flex; align-items: center; gap: 10px; }
.expense-form-line { display: grid; gap: 8px; }
.expense-form-line .plain { justify-self: end; }
.expense-total { margin: 10px 0 16px; font-size: 18px; font-weight: 700; }
.decide textarea { margin-bottom: 10px; }
.decide .two { gap: 10px; }
.decide .primary { min-height: 48px; padding: 12px; }
.avatar .icon { width: 22px; height: 22px; }
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px); z-index: 2; display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; color: var(--on-accent); background: var(--accent); border-radius: 50%; box-shadow: 0 2px 8px rgb(0 0 0 / 28%); }
.fab .icon { width: 26px; height: 26px; }
textarea, select { display: block; width: 100%; min-height: 50px; padding: 12px 14px; font: inherit; font-size: 16px; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
textarea { resize: vertical; margin-bottom: 12px; }
.check { flex: none; width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--accent); }
.invite { display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 0; font-size: 15px; font-weight: 400; }
.invite-list { max-height: 260px; overflow-y: auto; padding: 0 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.field-label { margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.status-choice { display: grid; grid-template-columns: 1fr 1fr; }
.chip[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.danger { color: var(--danger); background: transparent; border: 1px solid var(--line); }
.event-actions { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.event-actions .chips { margin-bottom: 0; }
.event-actions .two { gap: 10px; }
.round { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--accent); background: var(--accent-soft); border-radius: 50%; }
.menu-content:has(.fab) { padding-bottom: 76px; }
.tab span { white-space: nowrap; }
@media (max-width: 360px) { .tab { font-size: 10px; } }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.head .bell { position: relative; display: flex; }
.bell .badge { position: absolute; top: 4px; right: 0; }
.notice.unread { border-left: 3px solid var(--accent); }
.notice.unread .row-title { font-weight: 700; }
.chat-name { display: flex; align-items: center; gap: 6px; }
.chat-name .avatar { width: 22px; height: 22px; font-size: 10px; }
