:root {
  --bg: #f7f5f2;
  --card: #ffffff;
  --text: #1f1d1a;
  --muted: #7a746c;
  --line: #ebe6df;
  --accent: #e8590c;
  --accent-soft: #fff1e8;
  --ok: #2f9e44;
  --danger: #c92a2a;
  --busy: #d9d4cc;
  --done-bg: #fff3bf;
  --done-fg: #8a6d00;
  --acc-bg: #d3f9d8;
  --acc-fg: #1b6e2c;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514; --card: #211f1d; --text: #f1ede8; --muted: #9c958c; --line: #34312d;
    --accent: #ff7a33; --accent-soft: #3a2518; --busy: #4a4641;
    --done-bg: #4a3f12; --done-fg: #ffe066; --acc-bg: #1d3b23; --acc-fg: #8ce99a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161514; --card: #211f1d; --text: #f1ede8; --muted: #9c958c; --line: #34312d;
  --accent: #ff7a33; --accent-soft: #3a2518; --busy: #4a4641;
  --done-bg: #4a3f12; --done-fg: #ffe066; --acc-bg: #1d3b23; --acc-fg: #8ce99a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
.app { max-width: 560px; margin: 0 auto; padding-top: 0; padding-bottom: calc(96px + 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)); }
a.btn { display: inline-block; text-align: center; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 6px; }
small, .sm { font-size: 13px; }
.muted { color: var(--muted); }
.danger { color: var(--danger); }
.empty { color: var(--muted); margin: 6px 0; }
.hint { color: var(--muted); font-size: 13px; text-align: center; }

.topline { display: flex; justify-content: space-between; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 0 4px; }
.brand { font-weight: 800; color: var(--accent); letter-spacing: .3px; }
.hero { padding: 12px 0 16px; }
.hero p { margin: 0 0 2px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0; }
.bar h1 { font-size: 20px; text-align: center; flex: 1; }
.bar h1:first-child { text-align: left; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); }
.card.accent { border-color: var(--accent); background: var(--accent-soft); }
.card.faded { opacity: .7; }

.row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.row + .row { border-top: 1px solid var(--line); }
.grow { flex: 1; min-width: 0; }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 84px; }
.day .row, .card > .row[style] { border-left: 4px solid var(--c); padding-left: 10px; border-top: 0; border-radius: 4px; margin: 4px 0; background: color-mix(in srgb, var(--c) 8%, transparent); }
.row.masked { --c: var(--busy) !important; color: var(--muted); font-style: italic; background: repeating-linear-gradient(45deg, transparent 0 6px, color-mix(in srgb, var(--busy) 30%, transparent) 6px 12px); }

.avatar { --c: #999; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--c) 18%, var(--card)); border: 2px solid var(--c); font-size: 18px; flex: none; }
.avatar.sm { width: 30px; height: 30px; font-size: 15px; }
.avatar.xs { width: 22px; height: 22px; font-size: 12px; border-width: 1.5px; }

.who-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.who { display: flex; gap: 8px; align-items: center; min-width: 0; }
.who div { display: flex; flex-direction: column; min-width: 0; }
.who small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.task { padding: 4px 0; }
.task + .task { border-top: 1px solid var(--line); }
.task .row { border: 0; }
.task .title { font-weight: 500; }
.task.status-accepted .title { text-decoration: line-through; color: var(--muted); }
.pill { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--line); white-space: nowrap; }
.p-done { background: var(--done-bg); color: var(--done-fg); }
.p-accepted { background: var(--acc-bg); color: var(--acc-fg); }
.checklist { list-style: none; margin: 0 0 6px 40px; padding: 0; font-size: 14px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; padding-bottom: 6px; }

.btn { border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 12px; cursor: pointer; }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn.ok { background: var(--ok); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.full { width: 100%; margin-top: 10px; }
.icon { border: 0; background: transparent; color: var(--text); font-size: 22px; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; padding: 0; }
.icon:hover { background: var(--line); }

.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.seg button { border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 14px; padding: 7px 12px; border-radius: 99px; white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.legends { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.legend { display: inline-flex; align-items: center; gap: 4px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.day.is-today { border-color: var(--accent); }
.day.is-today h3 { color: var(--accent); }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: 82%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
.col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; scroll-snap-align: start; }
.col h3 { display: flex; align-items: center; gap: 6px; }

.items { list-style: none; margin: 8px 0 0; padding: 0; }
.items li { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); }
.items li label { flex: 1; padding: 10px 0; display: flex; gap: 10px; align-items: center; }
.items li.done label { color: var(--muted); text-decoration: line-through; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
details summary { cursor: pointer; color: var(--muted); padding: 10px 0 4px; font-size: 14px; }

form.inline { display: flex; gap: 8px; }
form.inline.wrap { flex-wrap: wrap; margin-top: 10px; }
form.inline.wrap input { flex: 1 1 140px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
form.inline input { flex: 1; }
form.inline select, form.inline .btn { width: auto; }

.switch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.switch button { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; padding: 8px; border-radius: 12px; cursor: pointer; }
.switch button .avatar { grid-row: span 2; }
.switch button small { color: var(--muted); }
.switch button.on { border-color: var(--accent); background: var(--accent-soft); }

.fab { position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(80px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 28px; box-shadow: 0 6px 20px rgb(0 0 0 / .2); cursor: pointer; z-index: 5; }
nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 4; }
nav button { flex: 1; max-width: 112px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 11px; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
nav button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
nav button.on { color: var(--accent); font-weight: 600; }
nav button.on span { filter: none; opacity: 1; }

dialog { border: 0; padding: 0; border-radius: 20px 20px 0 0; width: 100%; max-width: 560px; margin: auto auto 0; background: var(--card); color: var(--text); max-height: 90vh; }
dialog::backdrop { background: rgb(0 0 0 / .4); }
.sheet-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.sheet-body label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#parsed { margin: -4px 0 0; min-height: 18px; color: var(--accent); }

#toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; z-index: 10; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Прод-версия: вход, иконки, доступность ---------- */
:root { --danger-bg: #fde8e8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --danger-bg: #4a1f1f; } }
:root[data-theme="dark"] { --danger-bg: #4a1f1f; }

:root[data-size="lg"] .app, :root[data-size="lg"] dialog { zoom: 1.2; }

.app { padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
.app:not([data-phase="ready"]) nav,
.app:not([data-phase="ready"]) .fab,
.app:not([data-phase="ready"]) #me-chip { display: none; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.center { text-align: center; }
.loading { text-align: center; color: var(--muted); padding: 40vh 0 0; }

.auth { max-width: 380px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth .logo { display: flex; justify-content: center; }
.auth h1 { text-align: center; font-size: 26px; text-wrap: balance; }
.auth .lead, .auth > .muted { text-align: center; margin: 0; }
.auth .note { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack label { font-size: 13px; color: var(--muted); }
.inline { display: flex; gap: 8px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn.google { background: var(--card); color: var(--text); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; }
.btn.danger-btn { background: var(--danger); }
.link { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; padding: 10px; align-self: center; }

nav button .ic { display: grid; place-items: center; height: 24px; }
nav button .ic svg { opacity: .75; }
nav button.on .ic svg { opacity: 1; stroke-width: 2.2; }

.avatar { font-size: 13px; font-weight: 700; color: var(--c); letter-spacing: .3px; }
.avatar.sm { font-size: 12px; }
.avatar.xs { font-size: 9px; }

/* Цели нажатия не меньше 44 px */
.items li label, .checklist li label, .toggle { min-height: 44px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.checklist li label { min-height: 40px; }
.icon.sm { width: 36px; height: 36px; font-size: 20px; color: var(--muted); }
.btn.sm { min-height: 36px; }
.toggle { margin-top: 6px; font-size: 15px; }
.card form.inline { margin-top: 10px; }
.invite-box { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.invite-box input { font-size: 13px; }
.row.ev .time { min-width: 92px; }

#toast.err { background: var(--danger); color: #fff; }
body.busy { cursor: progress; }
body.busy .btn { opacity: .7; }
