:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1c1f24;
  --muted: #6b7280;
  --accent: #3b5bdb;
  --accent-soft: #e7ecff;
  --meeting: #7048e8;
  --meeting-soft: #efe9ff;
  --event: #1c7ed6;
  --event-soft: #e3f1ff;
  --task: #e8590c;
  --task-soft: #fff0e6;
  --ok: #2b8a3e;
  --danger: #c92a2a;
  --now: #e03131;
  --shadow: 0 8px 30px rgba(20, 24, 33, 0.12);
  --radius: 10px;
  --hour: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --surface-2: #22262e;
    --border: #2e333c;
    --text: #e8eaed;
    --muted: #9aa0aa;
    --accent: #748ffc;
    --accent-soft: #232a45;
    --meeting: #9775fa;
    --meeting-soft: #2a2340;
    --event: #4dabf7;
    --event-soft: #1b2b3d;
    --task: #ff8c42;
    --task-soft: #3a2618;
    --ok: #51cf66;
    --danger: #ff6b6b;
    --now: #ff6b6b;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Кнопки ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.icon { padding: 6px 9px; }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Верхняя панель ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; }
.week-nav { display: flex; align-items: center; gap: 4px; }
.range { margin-left: 8px; font-weight: 600; }
.actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Сетка недели ---------- */
.calendar { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-x: auto; }
.grid-head, .grid-body { min-width: 760px; }
.grid-head {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.grid-head .day-label { padding: 8px; text-align: center; color: var(--muted); }
.grid-head .day-label b { display: block; font-size: 18px; color: var(--text); }
.grid-head .day-label.today b {
  color: #fff; background: var(--accent); border-radius: 50%;
  width: 32px; height: 32px; line-height: 32px; margin: 0 auto;
}
.grid-body { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 56px 1fr; position: relative; }
.hours div { height: var(--hour); font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); position: relative; }
.day-col {
  position: relative;
  border-left: 1px solid var(--border);
  background-image: linear-gradient(var(--border) 1px, transparent 1px);
  background-size: 100% var(--hour);
  height: calc(var(--hour) * 24);
  cursor: cell;
}
.day-col.today { background-color: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--now); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }

.occ {
  position: absolute;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 12px;
  overflow: hidden;
  cursor: pointer;
  border-left: 3px solid var(--event);
  background: var(--event-soft);
  z-index: 2;
}
.occ.meeting { border-left-color: var(--meeting); background: var(--meeting-soft); }
.occ.done { opacity: 0.6; }
.occ.in_progress { box-shadow: 0 0 0 2px var(--meeting); }
.occ .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.occ .time { color: var(--muted); }
.occ:hover { filter: brightness(0.97); }

/* ---------- Боковая карточка ---------- */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 20;
}
.drawer.open { transform: none; }
.drawer-close { position: absolute; top: 12px; right: 12px; }
.drawer h2 { margin: 0 32px 4px 0; font-size: 19px; }
.drawer .sub { color: var(--muted); margin-bottom: 12px; }
.section { border-top: 1px solid var(--border); padding: 12px 0; }
.section h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.section.warn h3 { color: var(--task); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; background: var(--surface-2); cursor: pointer; }
.chip.yes::after { content: " ✅"; }
.chip.no::after { content: " ❌"; }
.chip.maybe::after { content: " 🤔"; }
.chip.pending::after { content: " ❔"; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.check-list li.current { background: var(--meeting-soft); font-weight: 600; }
.check-list li.done span { text-decoration: line-through; color: var(--muted); }
.check-list .meta { margin-left: auto; color: var(--muted); font-size: 12px; }
.inline-form { display: flex; gap: 6px; margin-top: 8px; }
.inline-form input { flex: 1; min-width: 0; }
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--surface);
}
textarea { width: 100%; resize: vertical; }
.status-pill { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 12px; background: var(--surface-2); }
.status-pill.in_progress { background: var(--meeting); color: #fff; }
.status-pill.done { background: var(--ok); color: #fff; }
.timer { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; }
.timer.over { color: var(--danger); }
.meeting-bar { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; flex-wrap: wrap; }
.summary { background: var(--surface-2); border-radius: 8px; padding: 10px; white-space: pre-wrap; }
.task-form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.task-form input[name="title"] { grid-column: 1 / -1; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Мини-панель ---------- */
.panel-fab {
  position: fixed; right: 20px; bottom: 20px;
  width: 52px; height: 52px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff; font-size: 22px;
  box-shadow: var(--shadow); cursor: pointer; z-index: 30;
}
.panel {
  position: fixed; right: 20px; bottom: 84px;
  width: min(380px, calc(100vw - 32px));
  height: min(540px, calc(100vh - 110px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  z-index: 30;
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.panel.open { opacity: 1; pointer-events: auto; transform: none; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs button { flex: 1; border: none; background: none; padding: 10px 4px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-body { flex: 1; overflow-y: auto; padding: 14px; }
.next-card { border-radius: 12px; padding: 14px; background: var(--accent-soft); }
.next-card.meeting { background: var(--meeting-soft); }
.next-card.task { background: var(--task-soft); }
.countdown { font-size: 13px; color: var(--muted); }
.countdown b { color: var(--text); font-size: 18px; }
.next-card h3 { margin: 6px 0 2px; font-size: 17px; }
.next-card .btns { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.then-list h4, .day-list h4 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.item { display: flex; gap: 8px; padding: 6px 4px; border-radius: 6px; cursor: pointer; align-items: baseline; }
.item:hover { background: var(--surface-2); }
.item .when { width: 46px; flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.item.past { opacity: 0.5; }
.item.current { background: var(--accent-soft); }
.item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--event); align-self: center; }
.item .dot.meeting { background: var(--meeting); }
.item .dot.task { background: var(--task); }
.item .dot.reminder { background: var(--ok); }
.empty { color: var(--muted); padding: 6px 4px; }

.chat { display: flex; flex-direction: column; padding: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 7px 11px; border-radius: 12px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.action-card { align-self: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; max-width: 92%; }
.action-card.undone { opacity: 0.5; text-decoration: line-through; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; min-width: 0; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples button { border: 1px dashed var(--border); background: none; border-radius: 999px; padding: 3px 10px; cursor: pointer; color: var(--muted); }

/* ---------- Уведомления ---------- */
.toasts { position: fixed; top: 64px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 40; width: min(340px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; }
.toast.reminder { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast b { display: block; }
.toast .btns { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- Диалог создания ---------- */
.dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog form { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.dialog h2 { margin: 0; font-size: 18px; }
.dialog label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; flex: 1; }
.dialog label > * { color: var(--text); font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.segmented { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.segmented button { flex: 1; border: none; background: none; padding: 5px; border-radius: 6px; cursor: pointer; }
.segmented button.active { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }
.segmented button:disabled { opacity: 0.45; cursor: default; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-error { color: var(--danger); margin: 0; }
.settings-section { display: flex; flex-direction: column; gap: 8px; }
.settings-section h3 { margin: 4px 0 0; font-size: 15px; }
.settings-section p { margin: 0; }
.muted { color: var(--muted); }
.muted.small { font-size: 12px; }

@media (max-width: 720px) {
  .topbar { padding: 8px 16px; gap: 8px; }
  .actions { margin-left: 0; width: 100%; }
  .actions .btn { flex: 1; padding: 6px 4px; }
  .range { display: none; }
  .panel { right: 16px; bottom: 80px; }
  .panel-fab { right: 16px; bottom: 16px; }
}

/* ---------- Переключатель вкладок ---------- */
.view-switch { flex: none; }
.view-switch button { padding: 5px 14px; white-space: nowrap; }
body[data-view="day"] .week-nav { display: none; }
.link { border: none; background: none; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.link:hover { text-decoration: underline; }

/* ---------- «Мой день» ---------- */
.day-view { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.day-head { display: flex; align-items: center; gap: 6px; margin: 0 auto 14px; max-width: 1280px; flex-wrap: wrap; }
.day-head h1 { margin: 0 4px; font-size: 20px; min-width: 0; }
.day-head input[type=date] { margin-left: auto; }
.day-cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; max-width: 1280px; margin: 0 auto; align-items: start; }
.day-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.day-item { border-left: 3px solid var(--event); background: var(--event-soft); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.day-item.meeting { border-left-color: var(--meeting); background: var(--meeting-soft); }
.day-item.reminder { border-left-color: var(--ok); background: var(--surface-2); }
.day-item.task { border-left-color: var(--task); background: var(--task-soft); }
.day-item.past { opacity: 0.6; }
.day-item.current { box-shadow: 0 0 0 2px var(--accent); }
.day-item.cancelled .day-item-title { text-decoration: line-through; }
.day-item-head { display: flex; align-items: flex-start; gap: 10px; }
.day-item-head .when { flex: none; width: 92px; font-variant-numeric: tabular-nums; color: var(--muted); padding-top: 1px; }
.day-item-head .what { flex: 1; min-width: 0; }
.day-item-title { font-weight: 600; overflow-wrap: anywhere; }
.todo-count { flex: none; color: var(--muted); }
.day-item-todos { margin: 6px 0 2px 102px; }
.day-now { display: flex; align-items: center; gap: 8px; color: var(--now); font-size: 12px; margin: 4px 0 10px; }
.day-now::before, .day-now::after { content: ""; height: 2px; background: var(--now); flex: 1; }
.day-now::before { flex: none; width: 10px; border-radius: 2px; }

/* ---------- Чек-лист ---------- */
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; min-height: 28px; }
.todo-title { flex: 1; min-width: 0; cursor: text; overflow-wrap: anywhere; }
.todo.done > .todo-row .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-row input[type=checkbox] { width: 16px; height: 16px; flex: none; margin: 0; accent-color: var(--accent); }
.todo-edit { flex: 1; min-width: 0; padding: 2px 6px; }
.grip { cursor: grab; color: var(--muted); opacity: 0; user-select: none; font-size: 11px; letter-spacing: -2px; padding: 0 2px; }
.todo-del, .todo-move { opacity: 0; padding: 0 6px; }
.todo-row:hover .grip, .todo-row:hover .todo-del, .todo-row:hover .todo-move,
.todo-row:focus-within .todo-del, .todo-row:focus-within .todo-move { opacity: 1; }
@media (hover: none) { .grip, .todo-del, .todo-move { opacity: 1; } }
.todo.drop > .todo-row { box-shadow: 0 -2px 0 var(--accent); }
.todo-add { width: 100%; margin-top: 4px; border-style: dashed; background: transparent; }
.todo-add-row { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.todo-add-row .todo-add { flex: 1; min-width: 0; margin-top: 0; }
.todo-repeat-ctl { display: flex; gap: 4px; align-items: center; flex: none; opacity: 0.55; }
.todo-repeat-ctl.on, .todo-repeat-ctl:hover, .todo-repeat-ctl:focus-within { opacity: 1; }
.todo-repeat-select, .todo-until { padding: 2px 4px; font-size: 13px; max-width: 150px; }
.todo-repeat { flex: none; font-size: 12px; opacity: 0.7; cursor: default; }
.todo-del-choice { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 6px 40px; }
.checklist.sub { margin: 0 0 4px 44px; }
.checklist.sub .todo-add { display: none; padding: 2px 6px; font-size: 13px; }
.todo:hover > .checklist.sub .todo-add, .todo:focus-within > .checklist.sub .todo-add, .checklist.sub .todo-add:not(:placeholder-shown) { display: block; }
@media (hover: none) { .checklist.sub .todo-add { display: block; } }

/* ---------- Заметки ---------- */
.note-new { margin-left: auto; display: flex; gap: 6px; }
.note-tools { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.note-tools input[type=search] { flex: 1; min-width: 120px; }
.segmented.small button { padding: 3px 8px; font-size: 13px; }
.note-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 4px; border-top: 1px solid var(--border); }
.note-row input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--ok); }
.note-open { flex: 1; min-width: 0; display: flex; gap: 10px; border: none; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.note-row-main { flex: 1; min-width: 0; }
.note-row-title { font-weight: 600; overflow-wrap: anywhere; }
.note-row.done .note-row-title { text-decoration: line-through; color: var(--muted); }
.note-excerpt { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-thumb { width: 72px; height: 45px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); flex: none; }
.note-head { justify-content: space-between; }
.note-head-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.note-done { display: flex; align-items: center; gap: 4px; font-size: 13px; margin-right: 6px; cursor: pointer; }
.note-title { width: 100%; font-size: 17px; font-weight: 600; border-color: transparent; background: transparent; padding: 4px 2px; }
.note-title:focus { border-color: var(--border); }
.note-meta-row { display: flex; gap: 10px; justify-content: space-between; margin: 2px 2px 8px; flex-wrap: wrap; }
.note-text { min-height: 260px; line-height: 1.5; }
.notes-card.expanded {
  position: fixed; inset: 12px; z-index: 25; overflow-y: auto; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.notes-card.expanded .note-body { flex: 1; display: flex; flex-direction: column; }
.notes-card.expanded .note-text { flex: 1; min-height: 50vh; }
.notes-card.expanded .sketch-paper { max-width: min(100%, calc((100vh - 230px) * 1.6)); }

/* ---------- Холст ---------- */
.sketch { outline: none; }
.sketch-toolbar { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 8px; align-items: center; }
.sketch-toolbar .group { display: flex; gap: 4px; align-items: center; }
.sketch-toolbar [aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); background: var(--swatch); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.size-dot { display: inline-block; width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; vertical-align: middle; }
.sketch-paper { width: 100%; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.sketch-canvas { display: block; width: 100%; aspect-ratio: 16 / 10; touch-action: none; cursor: crosshair; }

/* ---------- История правок ---------- */
.history-dialog { width: min(860px, calc(100vw - 32px)); }
.history-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; max-height: 60vh; }
.history-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.history-list button { width: 100%; text-align: left; border: none; background: none; padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; color: inherit; }
.history-list button:hover { background: var(--surface-2); }
.history-list button.active { background: var(--accent-soft); }
.history-view { overflow-y: auto; min-width: 0; }
.diff { margin: 6px 0 0; font: 13px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 8px; padding: 8px; }
.diff-add { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.diff-add::before { content: "+ "; color: var(--ok); }
.diff-del { background: color-mix(in srgb, var(--danger) 15%, transparent); text-decoration: line-through; color: var(--muted); }
.diff-del::before { content: "− "; color: var(--danger); }
.diff-same::before { content: "  "; white-space: pre; }
.diff-title { margin: 6px 0; }
.diff-title del { color: var(--danger); }
.diff-title ins { color: var(--ok); text-decoration: none; }
.history-preview { width: 100%; border-radius: 8px; border: 1px solid var(--border); background: #fff; margin-top: 6px; }

@media (max-width: 900px) {
  .day-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .day-view { padding: 12px 16px; }
  .day-head h1 { font-size: 17px; flex: 1; }
  .day-head input[type=date] { margin-left: 0; width: 100%; order: 5; }
  .day-item-head .when { width: 74px; font-size: 13px; }
  .day-item-todos { margin-left: 0; }
  .todo-add-row { flex-wrap: wrap; }
  .todo-del-choice { margin-left: 0; }
  .history-grid { grid-template-columns: minmax(0, 1fr); max-height: none; }
  .history-list { max-height: 160px; }
  .notes-card.expanded { inset: 0; border-radius: 0; }
}

/* ---------- Вход (сервер в интернете) и Telegram Mini App ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; overflow: auto; }
.login-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card form { display: flex; gap: 8px; }
.login-card input { flex: 1; min-width: 0; }
/* В Telegram своё окно и своя шапка: мини-панель с чатом не нужна, чат — это сам бот */
.in-telegram .panel-fab, .in-telegram #notify-btn { display: none; }
