/* FamilyTick — стили веб-версии. Тёмная и светлая темы через переменные. */
:root, [data-theme='dark'] {
  --bg: #1c1c1e;
  --rail: #151517;
  --side: #202022;
  --pane: #1c1c1e;
  --detail: #1f1f21;
  --card: #262628;
  --hover: #2b2b2e;
  --active: #303034;
  --line: #2f2f33;
  --line-strong: #3a3a3f;
  --text: #ececee;
  --text-2: #a5a6ad;
  --text-3: #6f7078;
  --accent: #4f7cff;
  --accent-soft: #4f7cff26;
  --danger: #e5484d;
  --ok: #2bb673;
  --warn: #f5a623;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --input: #29292c;
  color-scheme: dark;
}
[data-theme='light'] {
  --bg: #f6f6f8;
  --rail: #ececf0;
  --side: #f4f4f6;
  --pane: #ffffff;
  --detail: #fbfbfc;
  --card: #ffffff;
  --hover: #f0f0f3;
  --active: #e8ebf7;
  --line: #e7e7ea;
  --line-strong: #d9d9de;
  --text: #1d1d22;
  --text-2: #5b5d66;
  --text-3: #9a9ca5;
  --accent: #3f6cf0;
  --accent-soft: #3f6cf01f;
  --shadow: 0 12px 40px rgba(20, 20, 40, 0.16);
  --input: #f2f2f5;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.pad { padding: 12px; }
.strike { text-decoration: line-through; color: var(--text-3); }
.ic { flex: none; display: block; }

#app, .app { height: 100%; }
.app { display: flex; }

/* ---------- rail ---------- */
.rail { width: 56px; flex: none; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; gap: 4px; border-right: 1px solid var(--line); }
.rail-avatar { position: relative; margin-bottom: 10px; }
.fam-dot { position: absolute; right: -6px; bottom: -4px; font-size: 12px; }
.rail-btn { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--text-3); position: relative; transition: background .12s, color .12s; }
.rail-btn:hover { background: var(--hover); color: var(--text-2); }
.rail-btn.active { color: var(--accent); background: var(--accent-soft); }
.rail-btn.spin .ic { animation: spin 1s linear infinite; }
.rail-btn.offline { color: var(--warn); }
.rail-badge { position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%); font-size: 9px; background: var(--accent); color: #fff; border-radius: 6px; padding: 0 3px; font-variant-numeric: tabular-nums; }
@keyframes spin { to { transform: rotate(360deg); } }

.avatar { border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; flex: none; overflow: hidden; vertical-align: middle; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatars { display: flex; }
.avatars .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--pane); }
.avatars .avatar:first-child { margin-left: 0; }

/* ---------- layout ---------- */
.section-wrap { flex: 1; display: flex; min-width: 0; height: 100%; }
.sidebar { width: 252px; flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side-scroll { overflow-y: auto; padding: 12px 8px 24px; flex: 1; }
.side-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--text); position: relative; min-height: 34px; }
.side-item:hover { background: var(--hover); }
.side-item.active { background: var(--active); }
.side-item.drop-hover { outline: 2px dashed var(--accent); }
.side-lead { width: 20px; display: grid; place-items: center; color: var(--text-2); font-size: 15px; flex: none; }
.side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.side-shared { color: var(--text-3); display: inline-flex; margin-left: 4px; }
.side-more { display: none; color: var(--text-3); width: 22px; height: 22px; border-radius: 6px; place-items: center; }
.side-item:hover .side-more { display: grid; }
.side-item:hover .side-count { display: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.side-head { display: flex; align-items: center; gap: 6px; padding: 14px 10px 4px; color: var(--text-3); font-size: 12px; font-weight: 600; cursor: pointer; user-select: none; }
.side-head .icon-btn { opacity: 0; }
.side-head:hover .icon-btn { opacity: 1; }
.side-hint { color: var(--text-3); font-size: 12px; padding: 2px 10px 6px 36px; }
.side-sep { height: 1px; background: var(--line); margin: 12px 6px; }
.caret { display: inline-grid; color: var(--text-3); transition: transform .15s; width: 12px; }
.caret.closed { transform: rotate(-90deg); }
.folder-row .caret { margin-left: -4px; }
.folder-items { padding-left: 14px; }

.list-pane { flex: 1; min-width: 320px; display: flex; flex-direction: column; background: var(--pane); }
.detail-pane { width: 420px; flex: none; background: var(--detail); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px 10px; min-height: 58px; }
.pane-title { font-size: 20px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-title.as-btn { cursor: pointer; }
.title-emoji { font-size: 20px; }
.head-avatars { margin-left: 8px; }
.list-scroll { overflow-y: auto; flex: 1; padding: 0 12px 80px; }

.icon-btn { width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--text-2); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.xs { width: 22px; height: 22px; border-radius: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 34px; padding: 0 14px; border-radius: 8px; background: var(--hover); color: var(--text); font-weight: 500; white-space: nowrap; border: 1px solid var(--line); }
.btn:hover { background: var(--active); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.lg { height: 42px; padding: 0 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { color: var(--accent); font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

.input { width: 100%; height: 36px; padding: 0 12px; border-radius: 8px; background: var(--input); border: 1px solid var(--line); outline: none; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); }
.input.sm { height: 30px; font-size: 13px; }
.pane-head select.input { width: auto; }
.input.inline { width: auto; display: inline-block; font-weight: 600; font-size: 16px; }
select.input { padding-right: 6px; }
.num { width: 64px; height: 30px; padding: 0 8px; border-radius: 6px; background: var(--input); border: 1px solid var(--line); }
input[type='time'], input[type='date'] { background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }

/* ---------- quick add ---------- */
.quick-add { margin: 0 18px 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--input); border: 1px solid transparent; border-radius: 10px; padding: 0 12px; color: var(--text-3); }
.quick-add:focus-within { border-color: var(--accent); background: var(--pane); }
.quick-input { flex: 1; min-width: 200px; height: 40px; border: 0; background: none; outline: none; color: var(--text); }
.quick-chips { display: flex; gap: 6px; padding-bottom: 8px; width: 100%; padding-left: 24px; flex-wrap: wrap; }
.qchip { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 1px 8px; font-size: 12px; }

/* ---------- groups & rows ---------- */
.group { margin-bottom: 6px; }
.group-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 6px; font-weight: 600; font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.group-head.plain { cursor: default; color: var(--text-3); font-size: 12px; padding-top: 14px; }
.group-count { color: var(--text-3); font-weight: 500; font-size: 12px; }
.overdue-label { color: var(--danger); }
.done-group .group-head { color: var(--text-3); }

.task-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 8px; cursor: pointer; min-height: 40px; border-bottom: 1px solid var(--line); position: relative; }
.task-row:hover { background: var(--hover); }
.task-row.selected { background: var(--active); }
.task-row.done .task-title { color: var(--text-3); text-decoration: line-through; }
.task-row.drop-before::before { content: ''; position: absolute; left: 8px; right: 8px; top: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.task-row.note { align-items: flex-start; }
.task-row.extra { border-bottom-style: dashed; }
.task-main { flex: 1; min-width: 0; }
.task-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.task-row.note .task-title { font-weight: 600; white-space: normal; }
.task-snippet { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.task-snippet.small { color: var(--text-3); font-size: 11.5px; }
.pin { color: var(--warn); display: inline-flex; }
.note-ic { color: var(--text-2); width: 20px; display: grid; place-items: center; font-size: 16px; margin-top: 1px; }
.task-meta { display: flex; align-items: center; gap: 8px; flex: none; color: var(--text-3); font-size: 12px; max-width: 55%; overflow: hidden; }
.meta-i { display: inline-flex; align-items: center; gap: 3px; }
.tag-chip { background: var(--hover); color: var(--text-2); border-radius: 5px; padding: 0 7px; font-size: 11.5px; line-height: 19px; white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.list-chip { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.due { white-space: nowrap; color: var(--accent); font-variant-numeric: tabular-nums; }
.due.overdue { color: var(--danger); }
.due.future { color: var(--text-2); }
.done .due { color: var(--text-3); }
.done-wrap .done-by { padding: 0 12px 6px 42px; color: var(--text-3); font-size: 12px; display: flex; align-items: center; gap: 4px; margin-top: -4px; }
.trash-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 10px; }

.check { width: 18px; height: 18px; border-radius: 5px; border: 1.8px solid var(--pc, var(--text-3)); flex: none; display: grid; place-items: center; color: #fff; transition: background .12s; background: color-mix(in srgb, var(--pc, transparent) 8%, transparent); }
.check:hover { background: color-mix(in srgb, var(--pc, #888) 25%, transparent); }
.check.checked { background: var(--text-3); border-color: var(--text-3); }
.check.wont { background: transparent; color: var(--text-3); }
.check.round { border-radius: 50%; }
.check.round.checked { background: var(--pc); border-color: var(--pc); }
.check.lg { width: 22px; height: 22px; border-radius: 6px; }
.check.sm { width: 16px; height: 16px; border-radius: 4px; }
.check.square.checked { background: var(--accent); border-color: var(--accent); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 60px 20px; color: var(--text-3); }
.empty-art { width: 84px; height: 84px; border-radius: 50%; background: var(--hover); display: grid; place-items: center; color: var(--text-3); }
.empty-art.big { width: 120px; height: 120px; }
.empty-title { color: var(--text-2); font-weight: 600; font-size: 15px; }
.empty-sub { max-width: 320px; font-size: 13px; }
.empty-detail { align-items: center; justify-content: center; }

/* ---------- detail ---------- */
.detail-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); min-height: 58px; }
.sep-v { width: 1px; height: 20px; background: var(--line); }
.date-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 7px; color: var(--text-2); font-size: 13px; }
.date-btn:hover { background: var(--hover); }
.date-btn.overdue { color: var(--danger); }
.date-btn.today { color: var(--accent); }
.close-detail { display: none; }
.detail-scroll { overflow-y: auto; flex: 1; padding: 14px 18px 30px; }
.parent-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 12px; margin-bottom: 6px; }
.repeat-line { display: flex; align-items: center; margin-bottom: 4px; }
.title-input { width: 100%; border: 0; background: none; outline: none; font-size: 19px; font-weight: 650; resize: none; padding: 0; line-height: 1.35; overflow: hidden; }
.content-input { width: 100%; border: 0; background: none; outline: none; resize: none; min-height: 90px; padding: 8px 0; color: var(--text); line-height: 1.55; overflow: hidden; }
.content-view { padding: 6px 0 10px; cursor: text; min-height: 40px; }
.md p { margin: 0 0 6px; }
.md h3, .md h4, .md h5 { margin: 10px 0 6px; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; }
.md ul.md-check { list-style: none; padding-left: 2px; }
.md li.done { color: var(--text-3); text-decoration: line-through; }
.md blockquote { border-left: 3px solid var(--line-strong); margin: 6px 0; padding: 2px 10px; color: var(--text-2); }
.md code { background: var(--hover); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md hr { border: 0; border-top: 1px solid var(--line); }
.detail-block { border-top: 1px solid var(--line); padding: 10px 0; }
.block-head { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 2px 0 8px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 4px; transition: width .2s; }
.check-item, .sub-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.check-item.done .check-text { color: var(--text-3); text-decoration: line-through; }
.check-text { flex: 1; border: 0; background: none; outline: none; padding: 3px 0; }
.check-item .icon-btn { opacity: 0; }
.check-item:hover .icon-btn { opacity: 1; }
.sub-row.done .link { color: var(--text-3); text-decoration: line-through; }
.link { cursor: pointer; }
.link:hover { color: var(--accent); }
.inline-add { width: 100%; border: 0; background: none; outline: none; padding: 6px 0; color: var(--text); }
.inline-add::placeholder { color: var(--text-3); }
.props { border-top: 1px solid var(--line); padding-top: 8px; }
.prop { display: flex; align-items: center; min-height: 36px; gap: 10px; }
.prop-label { width: 120px; display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; flex: none; }
.prop-val { flex: 1; min-width: 0; }
.prop-btn { padding: 4px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; }
.prop-btn:hover { background: var(--hover); }
.prop-select { background: transparent; border: 0; padding: 4px; color: var(--text); }
.hint { display: flex; align-items: center; gap: 4px; padding: 6px 0; }
.tags-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-x { margin-left: 2px; color: var(--text-3); }
.attach-grid, .jphotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.attach { position: relative; border-radius: 8px; overflow: hidden; background: var(--hover); aspect-ratio: 1; }
.attach img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-file { display: flex; align-items: center; gap: 6px; padding: 8px; font-size: 12px; height: 100%; word-break: break-all; color: var(--text); text-decoration: none; }
.attach-x { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; display: none; }
.attach:hover .attach-x { display: grid; place-items: center; }
.comments .comment { display: flex; gap: 8px; padding: 6px 0; }
.comment-text { white-space: pre-wrap; }
.comment-input { display: flex; gap: 6px; margin-top: 6px; }
.activity { padding-top: 14px; }
.detail-foot { border-top: 1px solid var(--line); padding: 8px 12px; display: flex; align-items: center; gap: 4px; }

/* ---------- popover & menu ---------- */
.pop-back { position: fixed; inset: 0; z-index: 60; }
.popover { position: fixed; background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; overflow-y: auto; animation: pop .12s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; text-align: left; width: 100%; }
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-item .ic { color: var(--text-2); }
.menu-item.danger .ic { color: var(--danger); }
.menu-item.active { color: var(--accent); }
.menu-hint { color: var(--text-3); font-size: 12px; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.menu-title { color: var(--text-3); font-size: 11.5px; font-weight: 600; padding: 8px 10px 4px; text-transform: uppercase; letter-spacing: .03em; }
.menu-row { display: flex; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.menu-row-label { color: var(--text-3); font-size: 12px; width: 76px; }
.tag-picker { display: flex; flex-direction: column; gap: 6px; }

.datepop { display: flex; flex-direction: column; gap: 8px; padding: 6px; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 16px; background: var(--hover); color: var(--text-2); font-size: 12.5px; border: 1px solid var(--line); }
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip.add { border-style: dashed; padding: 1px 8px; }
.row-field { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.row-field.col { flex-direction: column; align-items: stretch; }
.row-title { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.row-field select { background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.repeat-extra { display: flex; flex-direction: column; gap: 6px; padding: 6px 8px; background: var(--hover); border-radius: 8px; font-size: 13px; }
.wd-pick { display: flex; gap: 4px; flex-wrap: wrap; }
.wd { width: 34px; height: 30px; border-radius: 7px; background: var(--input); border: 1px solid var(--line); font-size: 12px; }
.wd.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.check-line { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

.minical-head { display: flex; align-items: center; gap: 2px; font-weight: 600; padding: 2px 4px 6px; text-transform: capitalize; }
.minical-grid, .hcal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.minical-wd { text-align: center; font-size: 11px; color: var(--text-3); padding: 2px 0; }
.minical-day { height: 30px; border-radius: 7px; font-size: 12.5px; position: relative; }
.minical-day:hover { background: var(--hover); }
.minical-day.other { color: var(--text-3); }
.minical-day.today { color: var(--accent); font-weight: 700; }
.minical-day.sel { background: var(--accent); color: #fff; }
.minical-day.mark::after { content: ''; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.minical-day.sel.mark::after { background: #fff; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 50; display: grid; place-items: center; padding: 20px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 440px; max-width: 100%; max-height: calc(100vh - 40px); background: var(--card); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; border: 1px solid var(--line-strong); }
.modal.wide { width: 600px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 8px 16px 12px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.form { display: flex; flex-direction: column; gap: 10px; }
.field-label { color: var(--text-3); font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.name-row { display: flex; gap: 10px; align-items: center; }
.emoji-preview { width: 40px; height: 40px; border-radius: 10px; background: var(--hover); display: grid; place-items: center; font-size: 22px; flex: none; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 2px; max-height: 120px; overflow-y: auto; padding: 4px; background: var(--input); border-radius: 8px; }
.emoji { height: 34px; border-radius: 7px; font-size: 18px; }
.emoji:hover { background: var(--hover); }
.emoji.on { background: var(--accent-soft); outline: 2px solid var(--accent); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 50%; }
.swatch.on { outline: 2px solid var(--text); outline-offset: 2px; }
.share-box { background: var(--hover); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.confirm-text { margin: 10px 0; font-size: 15px; }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle-track { width: 36px; height: 21px; border-radius: 12px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(15px); }

.seg { display: inline-flex; background: var(--input); border-radius: 8px; padding: 2px; gap: 2px; border: 1px solid var(--line); }
.seg.full { display: flex; }
.seg.full .seg-btn { flex: 1; }
.seg.wrap { flex-wrap: wrap; }
.seg-btn { padding: 4px 12px; border-radius: 6px; font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 28px; }
.seg-btn.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.seg-btn:disabled { opacity: .5; }

/* ---------- kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding: 4px 18px 24px; flex: 1; align-items: flex-start; }
.kcol { width: 290px; flex: none; background: var(--side); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; max-height: 100%; border: 1px solid var(--line); }
.kcol.drop-hover { outline: 2px dashed var(--accent); }
.kcol-head { display: flex; align-items: center; gap: 6px; font-weight: 600; padding: 4px 6px 8px; }
.kcol-add { width: 100%; height: 34px; border-radius: 8px; border: 1px dashed var(--line-strong); background: transparent; padding: 0 10px; outline: none; margin-bottom: 6px; }
.kcol-add:focus { border-style: solid; border-color: var(--accent); }
.kcol-body { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.kcard .task-row { background: var(--card); border: 1px solid var(--line); flex-wrap: wrap; }
.kcard .task-meta { max-width: 100%; }
.kdone { padding: 6px; }
.add-col { align-items: center; justify-content: center; flex-direction: row; gap: 6px; height: 48px; color: var(--text-2); border-style: dashed; }

/* ---------- calendar ---------- */
.cal-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--pane); }
.month { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto repeat(6, 1fr); border-top: 1px solid var(--line); min-height: 0; }
.month-wd { padding: 6px 8px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--line); }
.month-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; overflow: hidden; display: flex; flex-direction: column; gap: 2px; min-height: 0; cursor: default; }
.month-cell:nth-child(7n + 7) { border-right: 0; }
.month-cell.other { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.month-cell.other .month-num { color: var(--text-3); }
.month-cell.weekend { background: color-mix(in srgb, var(--hover) 35%, transparent); }
.month-cell.drop-hover { background: var(--accent-soft); }
.month-num { font-size: 12.5px; padding: 1px 4px; align-self: flex-start; border-radius: 10px; }
.month-cell.today .month-num { background: var(--accent); color: #fff; font-weight: 700; }
.cal-chip { display: flex; gap: 4px; align-items: center; font-size: 12px; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--c, var(--accent)) 22%, transparent); border-left: 3px solid var(--c, var(--accent)); white-space: nowrap; overflow: hidden; cursor: pointer; min-height: 20px; }
.cal-chip.done { opacity: .5; text-decoration: line-through; }
.cal-chip.virtual { opacity: .6; border-left-style: dashed; }
.cal-chip.sel { outline: 1px solid var(--c); }
.cal-chip.cd { --c: #c58af9; }
.chip-time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.chip-title { overflow: hidden; text-overflow: ellipsis; }
.more-link { font-size: 11.5px; color: var(--text-3); padding-left: 6px; cursor: pointer; }
.cal-add { display: flex; flex-direction: column; gap: 6px; padding: 6px; }
.tgrid-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); }
.tgrid-head, .tgrid-allday { display: grid; border-bottom: 1px solid var(--line); }
.tgrid-day { padding: 6px; text-align: center; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.tgrid-day .tg-wd { color: var(--text-3); font-size: 12px; }
.tgrid-day .num { font-size: 18px; font-weight: 600; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.tgrid-day.today .num { background: var(--accent); color: #fff; }
.tgrid-allday { min-height: 34px; }
.tgrid-allday > div:first-child { display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; }
.allday-cell { border-left: 1px solid var(--line); padding: 3px; display: flex; flex-direction: column; gap: 2px; }
.tgrid-scroll { flex: 1; overflow-y: auto; }
.tgrid { display: grid; position: relative; }
.hours { position: relative; }
.hour-label { position: absolute; right: 8px; font-size: 11px; color: var(--text-3); transform: translateY(-7px); }
.tcol { position: relative; border-left: 1px solid var(--line); }
.hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.now-line { position: absolute; left: 0; right: 0; border-top: 2px solid var(--danger); z-index: 2; }
.now-line::before { content: ''; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.tevent { position: absolute; left: 3px; right: 3px; z-index: 1; }
.tevent .cal-chip { height: 100%; align-items: flex-start; padding-top: 3px; white-space: normal; }

/* ---------- matrix ---------- */
.matrix-pane { flex: 1; display: flex; flex-direction: column; background: var(--pane); min-width: 0; }
.matrix { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 12px; padding: 0 18px 18px; min-height: 0; }
.quad { background: var(--side); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--line); }
.quad.drop-hover { outline: 2px dashed var(--qc); }
.quad-head { display: flex; align-items: center; gap: 8px; color: var(--qc); font-weight: 600; padding: 2px 4px 8px; }
.quad-n { width: 22px; height: 22px; border-radius: 50%; background: var(--qc); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.quad-body { overflow-y: auto; flex: 1; }
.quad-empty { color: var(--text-3); text-align: center; padding: 40px 0; }

/* ---------- habits ---------- */
.habit-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--pane); }
.week-strip { display: grid; grid-template-columns: 1fr repeat(7, 38px); gap: 4px; padding: 0 18px 10px; align-items: center; }
.ws-day { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text-3); }
.ws-day.today { color: var(--accent); }
.ws-num { font-size: 13px; font-weight: 600; color: var(--text-2); }
.ws-day.today .ws-num { color: var(--accent); }
.habit-list { overflow-y: auto; flex: 1; padding: 0 12px 60px; }
.habit-row { display: grid; grid-template-columns: 44px 1fr repeat(7, 38px); gap: 4px; align-items: center; padding: 10px 6px; border-radius: 12px; cursor: pointer; background: var(--side); margin-bottom: 8px; border: 1px solid var(--line); }
.habit-row:hover { background: var(--hover); }
.habit-row.selected { border-color: var(--accent); }
.habit-row .habit-week { display: contents; }
.habit-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 19px; }
.habit-icon.lg { width: 48px; height: 48px; font-size: 24px; }
.habit-name { font-weight: 600; display: flex; align-items: center; gap: 4px; }
.habit-sub { color: var(--text-3); font-size: 12px; display: flex; gap: 12px; }
.hdot { width: 26px; height: 26px; border-radius: 50%; margin: 0 auto; background: var(--hover); border: 1px solid var(--line-strong); display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; }
.hdot:hover { border-color: var(--hc); }
.hdot.on { background: var(--hc); border-color: var(--hc); }
.hdot.part { background: color-mix(in srgb, var(--hc) 35%, transparent); color: var(--text); }
.hdot.off { opacity: .35; }
.habit-title { font-weight: 700; font-size: 16px; }
.motto { font-style: italic; color: var(--text-2); margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--hover); border-radius: 12px; padding: 10px 12px; }
.stat-v { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.stat-u { font-size: 12px; font-weight: 500; color: var(--text-2); }
.stat-l { font-size: 12px; color: var(--text-3); }
.today-check { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.target { margin-bottom: 10px; }
.hcal-day { height: 34px; border-radius: 50%; font-size: 12.5px; margin: 1px auto; width: 34px; position: relative; }
.hcal-day:hover { background: var(--hover); }
.hcal-day.other { color: var(--text-3); opacity: .5; }
.hcal-day.on { background: var(--hc); color: #fff; font-weight: 600; }
.hcal-day.today { outline: 1.5px solid var(--accent); }
.hcal-day.off { color: var(--text-3); }
.hcal-day.noted::after { content: ''; position: absolute; top: 3px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--warn); }
.member-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.mini-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.mini-dot.on { background: var(--hc); }
.log-row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.ring { display: block; }

/* ---------- countdown ---------- */
.cd-pane { flex: 1; display: flex; flex-direction: column; background: var(--pane); min-width: 0; }
.cd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; padding: 4px 18px 60px; overflow-y: auto; align-content: start; }
.cd-card { position: relative; border-radius: 14px; aspect-ratio: 1.45; background-size: cover; background-position: center; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 12px; cursor: pointer; overflow: hidden; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); transition: transform .15s; }
.cd-card:hover { transform: translateY(-2px); }
.cd-card.is-today { outline: 3px solid var(--warn); }
.cd-card.preview { aspect-ratio: 2.2; cursor: default; }
.cd-title { font-weight: 600; font-size: 14px; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cd-num { font-family: 'Iowan Old Style', 'Palatino', Georgia, 'Times New Roman', serif; font-size: 48px; line-height: 1.1; font-weight: 500; text-shadow: 0 2px 8px rgba(0, 0, 0, .45); font-variant-numeric: lining-nums; }
.cd-num.word { font-size: 36px; }
.cd-num.alt { font-size: 28px; }
.cd-sub { font-size: 11.5px; opacity: .85; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.cd-pin { position: absolute; top: 8px; left: 8px; opacity: .85; }
.cd-shared { position: absolute; top: 8px; right: 8px; opacity: .85; }
.photo-row { display: flex; gap: 8px; }

/* ---------- journal ---------- */
.journal-side { width: 320px; flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; }
.journal-side > .minical, .journal-side > .seg, .journal-side > .input, .journal-side > .memories { margin: 0 12px; }
.journal-list { overflow-y: auto; flex: 1; padding: 0 8px; }
.jrow { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; }
.jrow:hover { background: var(--hover); }
.jrow.selected { background: var(--active); }
.jdate { width: 38px; text-align: center; flex: none; }
.jday { font-size: 20px; font-weight: 700; line-height: 1; }
.jwd { font-size: 11px; color: var(--text-3); }
.jmain { overflow: hidden; }
.jtitle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jsnip { color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jthumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.jmood { font-size: 18px; }
.memories { background: var(--accent-soft); border-radius: 10px; padding: 8px 10px; }
.memory { display: block; text-align: left; font-size: 12.5px; color: var(--accent); padding: 2px 0; }
.journal-main { flex: 1; display: flex; flex-direction: column; background: var(--pane); min-width: 0; }
.jhead-date { display: flex; align-items: baseline; gap: 10px; color: var(--text-2); text-transform: capitalize; }
.jhead-date .big { font-size: 30px; font-weight: 700; color: var(--text); }
.journal-scroll { overflow-y: auto; flex: 1; padding: 6px 32px 60px; max-width: 860px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.moods { display: flex; align-items: center; gap: 6px; }
.mood { font-size: 22px; width: 40px; height: 40px; border-radius: 50%; filter: grayscale(1); opacity: .55; transition: all .12s; }
.mood:hover { opacity: 1; filter: none; }
.mood.on { filter: none; opacity: 1; background: var(--accent-soft); transform: scale(1.1); }
.jtitle-input { border: 0; background: none; outline: none; font-size: 24px; font-weight: 700; padding: 0; }
.jcontent { border: 0; background: none; outline: none; resize: none; min-height: 320px; line-height: 1.7; font-size: 15.5px; }
.jcontent-view { font-size: 15.5px; line-height: 1.7; }
.photo-add { aspect-ratio: 1; border: 1.5px dashed var(--line-strong); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-3); cursor: pointer; font-size: 12px; }
.photo-add:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- pomodoro ---------- */
.pomo-pane { flex: 1; display: flex; flex-direction: column; background: var(--pane); min-width: 0; }
.pomo-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding-bottom: 60px; }
.pomo-task { display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px; border-radius: 20px; background: var(--hover); color: var(--text-2); max-width: 80%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase { font-weight: 600; color: var(--text-2); }
.pomo-ring { position: relative; }
.pomo-time { position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.pomo-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pomo-stats { padding: 16px; overflow-y: auto; }
.pomo-log { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* ---------- search ---------- */
.search-box { width: 620px; max-width: 100%; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); align-self: start; margin-top: 10vh; overflow: hidden; border: 1px solid var(--line-strong); }
.search-input { display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.search-input input { flex: 1; height: 52px; border: 0; background: none; outline: none; font-size: 16px; color: var(--text); }
.search-results { max-height: 60vh; overflow-y: auto; padding: 6px; }
.search-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; width: 100%; text-align: left; }
.search-row:hover { background: var(--hover); }
.search-kind { font-size: 11px; color: var(--text-3); width: 70px; flex: none; }

/* ---------- summary & settings ---------- */
.summary-pane { flex: 1; display: flex; flex-direction: column; background: var(--pane); min-width: 0; }
.summary-pane .stats { padding: 0 6px; }
.settings-pane { flex: 1; display: flex; flex-direction: column; background: var(--pane); min-width: 0; }
.settings-scroll { overflow-y: auto; padding: 4px 18px 60px; display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; align-content: start; }
.card { background: var(--side); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.profile-row { display: flex; gap: 14px; align-items: center; }
.avatar-pick { cursor: pointer; }
.invite { display: flex; align-items: center; gap: 10px; background: var(--hover); padding: 10px 12px; border-radius: 10px; }
.code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 22px; font-weight: 700; letter-spacing: 3px; }
.members { display: flex; flex-direction: column; }
.badge { font-size: 10.5px; background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 0 6px; margin-left: 6px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 160px; }
.or { text-align: center; color: var(--text-3); font-size: 12px; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- auth ---------- */
.auth { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; overflow-y: auto; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: 380px; max-width: 100%; min-width: 0; flex: none; margin: auto 0; background: var(--card); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; }
.logo img { width: 40px; height: 40px; }
.server summary { color: var(--text-3); font-size: 12px; cursor: pointer; margin-bottom: 6px; }
.err { color: var(--danger); font-size: 13px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; }
.toast { background: #2f2f33; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; animation: pop .15s; font-size: 13.5px; }
.toast .link-btn { color: #8fb0ff; font-weight: 600; }

.mobile-tabs { display: none; }

/* ---------- адаптив ---------- */
@media (max-width: 1180px) {
  .detail-pane { width: 360px; }
  .tasks-wrap.has-detail .sidebar { display: none; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .app { flex-direction: column; }
  .rail { display: none; }
  .mobile-tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--rail); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; justify-content: space-around; }
  .mtab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--text-3); flex: 1; }
  .mtab.active { color: var(--accent); }
  .section-wrap { height: calc(100% - 62px); position: relative; }
  .sidebar { position: absolute; inset: 0; z-index: 30; width: 100%; }
  .detail-pane { position: fixed; inset: 0 0 62px 0; z-index: 35; width: 100%; border: 0; }
  .close-detail { display: inline-grid; }
  .empty-detail { display: none; }
  .list-pane { min-width: 0; }
  .task-meta { max-width: 45%; }
  .task-meta .list-chip, .task-meta .tag-chip { display: none; }
  .matrix { grid-template-columns: 1fr; grid-template-rows: none; overflow-y: auto; }
  .quad { min-height: 240px; }
  .journal-side { width: 100%; }
  .journal-main { position: fixed; inset: 0 0 62px 0; z-index: 35; }
  .journal-scroll { padding: 6px 16px 60px; }
  .habit-row { grid-template-columns: 36px 1fr repeat(7, 25px); gap: 2px; }
  .week-strip { grid-template-columns: 1fr repeat(7, 25px); gap: 2px; padding-right: 20px; }
  .hdot { width: 22px; height: 22px; }
  .habit-sub { flex-direction: column; gap: 0; }
  .mobile-tabs { overflow-x: auto; justify-content: flex-start; }
  .mtab { min-width: 54px; }
  .settings-scroll { grid-template-columns: 1fr; }
  .grid2, .toggles { grid-template-columns: 1fr; }
  .pane-head { padding: 12px 14px 8px; }
  .quick-add { margin: 0 12px 8px; }
  .cd-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); padding: 4px 12px 80px; }
  .cd-num { font-size: 38px; }
  .month-cell .cal-chip { font-size: 10px; padding: 0 3px; }
  .tgrid-day .num { font-size: 14px; }
}

@media print {
  .rail, .sidebar, .detail-pane, .quick-add, .mobile-tabs, .pane-head .icon-btn { display: none !important; }
  body { overflow: visible; background: #fff; color: #000; }
  .list-scroll { overflow: visible; }
}
