/* Светлая тема — базовые токены. Тёмная переопределяет только значения ниже. */
:root {
  color-scheme: light;
  --ink: #1e2925;
  --muted: #646d68;
  --faint: #828885;
  --paper: #f5f2eb;
  --card: #fffdf9;
  --card-veil: rgba(255, 253, 249, .86);
  --card-veil-soft: rgba(255, 253, 249, .72);
  --line: #dedbd3;
  --line-soft: #ebe8e1;
  --grid-line: #e7e3dc;
  --field: #f5f2eb;
  --accent: #315e4d;
  --accent-hover: #274c3e;
  --accent-soft: #dfe9e1;
  --on-accent: #fffdf9;
  --on-accent-dim: #c8d7d0;
  --sage: #a8bba8;
  --sage-ink: #1d3e32;
  --sage-veil: rgba(168, 187, 168, .08);
  --coral: #d8866f;
  --coral-veil: rgba(216, 134, 111, .035);
  --coral-glow: rgba(216, 134, 111, .25);
  --on-coral: #2e1610;
  --yellow: #e5bf69;
  --danger: #a34e44;
  --danger-soft: #f3e1dc;
  --ring-track: #dedfd9;
  --live-dot: #62a17d;
  --shadow: 0 14px 40px rgba(40, 50, 43, .07);
  --shadow-hover: 0 8px 24px rgba(40, 50, 43, .06);
  --shadow-dialog: 0 25px 80px rgba(20, 30, 25, .25);
  --backdrop: rgba(25, 34, 30, .45);
}

/* Тёмная тема. data-theme проставляется скриптом в <head>, поэтому вспышки светлого нет. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --ink: #e6e5dd;
  --muted: #949c96;
  --faint: #6f7873;
  --paper: #111513;
  --card: #1a201d;
  --card-veil: rgba(26, 32, 29, .86);
  --card-veil-soft: rgba(26, 32, 29, .66);
  --line: #2c3531;
  --line-soft: #242c28;
  --grid-line: #222a26;
  --field: #141917;
  --accent: #7fc0a0;
  --accent-hover: #93cfb1;
  --accent-soft: rgba(127, 192, 160, .16);
  --on-accent: #0e1512;
  --on-accent-dim: rgba(14, 21, 18, .68);
  --sage: #6f9480;
  --sage-ink: #0f1a16;
  --sage-veil: rgba(111, 148, 128, .09);
  --coral: #cf7c66;
  --coral-veil: rgba(207, 124, 102, .05);
  --coral-glow: rgba(207, 124, 102, .3);
  --on-coral: #17100e;
  --yellow: #d7b263;
  --danger: #e08d80;
  --danger-soft: rgba(224, 141, 128, .16);
  --ring-track: #2c3531;
  --live-dot: #7fc0a0;
  --shadow: 0 14px 40px rgba(0, 0, 0, .35);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, .4);
  --shadow-dialog: 0 25px 80px rgba(0, 0, 0, .6);
  --backdrop: rgba(6, 10, 8, .6);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Manrope, system-ui, sans-serif; min-width: 320px; }
/* Страница под модалкой замирает. Смещение по top задаёт скрипт — так сохраняется позиция прокрутки. */
body.scroll-locked { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.app-shell { max-width: 1400px; min-height: 100vh; min-height: 100dvh; margin: auto; padding: 0 54px; }
.topbar { height: 88px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.brand { border: 0; padding: 0; background: transparent; cursor: pointer; color: var(--ink); text-decoration: none; font-family: Prata, Georgia, serif; font-size: 22px; display: flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; color: var(--on-accent); background: var(--accent); border-radius: 50% 50% 46% 54% / 55% 45% 55% 45%; font-size: 17px; }
.date-nav { display: flex; align-items: center; gap: 8px; position: relative; }
.icon-button { border: 0; background: transparent; padding: 10px; cursor: pointer; font-size: 20px; border-radius: 50%; }
.icon-button:hover { background: var(--accent-soft); color: var(--accent); }
.date-button { border: 0; background: transparent; cursor: pointer; min-width: 170px; display: flex; flex-direction: column; font-weight: 600; line-height: 1.3; border-radius: 3px; padding: 4px 6px; }
.date-button:hover { background: var(--accent-soft); }
.date-button span:last-child { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
#datePicker { position: absolute; width: 1px; height: 1px; opacity: 0; top: 50%; left: 50%; }
.local-badge { justify-self: end; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.local-badge span { width: 7px; height: 7px; background: var(--live-dot); border-radius: 50%; box-shadow: 0 0 0 4px var(--accent-soft); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 14px; }
.data-button { border: 1px solid var(--line); background: var(--card-veil-soft); color: var(--accent); padding: 8px 11px; border-radius: 2px; font-size: 10px; font-weight: 700; cursor: pointer; }
.data-button:hover { background: var(--card); }
.theme-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--card-veil-soft); color: var(--accent); cursor: pointer; font-size: 14px; line-height: 1; }
.theme-button:hover { background: var(--card); }
.theme-button .theme-glyph { display: block; }
main { padding: 58px 0 30px; }
.hero { display: flex; justify-content: space-between; align-items: end; margin-bottom: 34px; gap: 20px; }
.eyebrow { color: var(--accent); font-size: 10px; letter-spacing: .2em; font-weight: 700; margin: 0 0 12px; }
h1 { font: 400 clamp(42px, 5vw, 68px)/1.05 Prata, Georgia, serif; margin: 0; letter-spacing: -.025em; }
.day-score { display: flex; align-items: center; gap: 14px; padding-bottom: 5px; }
.day-score strong, .day-score small { display: block; }
.day-score strong { font-size: 13px; }
.day-score small { color: var(--muted); margin-top: 3px; font-size: 11px; }
.score-ring { --progress: 0deg; width: 61px; height: 61px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) var(--progress), var(--ring-track) 0); position: relative; transition: background .35s ease; }
.score-ring::after { content: ''; position: absolute; inset: 5px; background: var(--paper); border-radius: 50%; }
.score-ring span { position: relative; z-index: 1; font-size: 11px; font-weight: 700; }
.card { background: var(--card-veil); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 4px; }
.composer { padding: 9px; margin-bottom: 52px; }
.composer-main { display: flex; gap: 10px; }
.composer-main > input { flex: 1; border: 0; background: transparent; padding: 18px 20px; font-size: 16px; outline: none; min-width: 0; color: var(--ink); }
.composer-main > input::placeholder { color: var(--faint); }
.composer-main > input:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.primary-button { border: 0; background: var(--accent); color: var(--on-accent); padding: 0 24px; min-height: 52px; cursor: pointer; font-weight: 600; border-radius: 2px; }
.primary-button:hover { background: var(--accent-hover); }
.primary-button span { margin-left: 18px; }
.composer-options { display: flex; align-items: center; border-top: 1px solid var(--line-soft); margin: 0 12px; padding: 11px 8px 3px; gap: 24px; font-size: 11px; color: var(--muted); }
.field-icon { color: var(--accent); font-size: 17px; }

/* Пикеры оценки и времени: кнопка-триггер и поповер с общим оформлением. */
.picker-field { position: relative; display: inline-flex; }
.picker-trigger { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--ink); font-weight: 600; cursor: pointer; padding: 3px 6px; border-radius: 3px; white-space: nowrap; }
.picker-trigger:hover, .picker-trigger[aria-expanded='true'] { background: var(--accent-soft); color: var(--accent); }
.picker-trigger .chevron { font-size: 8px; opacity: .65; }
.picker-trigger.boxed { width: 100%; justify-content: space-between; background: var(--field); border: 1px solid var(--line); border-radius: 2px; padding: 12px; font-size: 13px; font-weight: 500; }
.picker-popover { position: absolute; top: calc(100% + 9px); left: 0; z-index: 40; width: 252px; max-width: calc(100vw - 28px); padding: 15px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow-dialog); }
.picker-popover.above { top: auto; bottom: calc(100% + 9px); }
.picker-popover:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.picker-caption { margin: 0 0 11px; color: var(--muted); font-size: 8px; letter-spacing: .16em; font-weight: 700; }
.picker-subcaption { margin: 13px 0 7px; color: var(--muted); font-size: 8px; letter-spacing: .12em; text-transform: uppercase; }
.picker-stepper { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 8px; }
.picker-stepper button { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); background: transparent; color: var(--accent); border-radius: 50%; font-size: 17px; line-height: 1; cursor: pointer; }
.picker-stepper button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.picker-stepper button:disabled { opacity: .3; cursor: not-allowed; }
.picker-value { text-align: center; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.picker-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 13px; }
.picker-chips button { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 6px 10px; border-radius: 20px; font-size: 10px; cursor: pointer; }
.picker-subcaption + .picker-chips { margin-top: 0; }
/* Сетки часов и минут: шесть колонок дают ровные ряды и попадание в значение одним кликом. */
.picker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.picker-grid button { border: 1px solid transparent; background: var(--field); color: var(--muted); padding: 6px 0; border-radius: 2px; font-size: 10px; font-variant-numeric: tabular-nums; cursor: pointer; }
.picker-chips button:hover, .picker-grid button:hover { color: var(--accent); border-color: var(--accent); }
.picker-chips button[aria-pressed='true'], .picker-grid button[aria-pressed='true'] { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 700; }
.picker-actions { display: flex; gap: 5px; margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.picker-actions button { flex: 1; border: 1px solid var(--line); background: transparent; color: var(--accent); padding: 8px 4px; border-radius: 2px; font-size: 10px; font-weight: 600; cursor: pointer; }
.picker-actions button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.picker-actions .picker-clear { color: var(--muted); }
.picker-actions .picker-clear:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.picker-actions button:disabled { opacity: .35; cursor: not-allowed; }
.picker-hint { margin: 12px 0 0; color: var(--faint); font-size: 8px; line-height: 1.5; }
.picker-done { display: none; }
.picker-backdrop { position: fixed; inset: 0; z-index: 55; display: none; background: var(--backdrop); touch-action: none; }
.composer-option { display: flex; align-items: center; gap: 8px; }
.field-block { display: grid; gap: 8px; }
.field-caption { font-size: 10px; color: var(--muted); }

/* Редактор фактических интервалов внутри диалога задачи. */
.sessions-block { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.sessions-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.sessions-total { color: var(--ink); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.session-list { display: grid; gap: 7px; }
.session-row { display: grid; grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr) 64px 32px; align-items: center; gap: 6px; }
.session-row.running .session-duration { color: var(--accent); font-weight: 700; }
.session-row .picker-trigger.boxed { padding: 9px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.session-dash { color: var(--muted); text-align: center; font-size: 11px; }
.session-duration { color: var(--muted); font-size: 10px; text-align: right; font-variant-numeric: tabular-nums; }
.sessions-empty { margin: 0; color: var(--faint); font-size: 10px; line-height: 1.5; }
.sessions-empty[hidden] { display: none; }
.add-session { width: 100%; min-height: 40px; margin-top: 9px; border-style: dashed; font-size: 11px; color: var(--muted); }
.add-session:hover { color: var(--accent); border-style: dashed; }
.sessions-error { margin: 9px 0 0; color: var(--danger); font-size: 10px; line-height: 1.5; }
.sessions-error:empty { display: none; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 285px; gap: 48px; align-items: start; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; gap: 16px; }
h2 { font: 400 28px/1.15 Prata, Georgia, serif; margin: 0; }
h2 span { display: inline-grid; place-items: center; min-width: 23px; height: 23px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 600 10px Manrope, system-ui, sans-serif; vertical-align: middle; margin-left: 5px; padding: 0 6px; }
.filter-tabs { display: flex; gap: 5px; flex: none; }
.filter-tabs button { border: 0; background: transparent; color: var(--muted); padding: 7px 10px; font-size: 10px; cursor: pointer; border-radius: 20px; white-space: nowrap; }
.filter-tabs button:hover { color: var(--accent); }
.filter-tabs button.active { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.task-list { display: grid; gap: 9px; }
.task-card { position: relative; min-height: 82px; display: grid; grid-template-columns: 36px minmax(0,1fr) auto auto; gap: 15px; align-items: center; padding: 14px 15px; background: var(--card-veil-soft); border: 1px solid var(--line); transition: background .2s ease, box-shadow .2s ease, transform .2s ease, opacity .2s ease; }
.task-card:hover { background: var(--card); box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.task-card.running { border-left: 3px solid var(--accent); }
.task-card.done { opacity: .64; }
.task-card.done h3 { text-decoration: line-through; }
.task-card.overdue:not(.done) .task-meta .meta-time { color: var(--danger); font-weight: 700; }
.status-button { width: 25px; height: 25px; border: 1px solid var(--faint); background: transparent; border-radius: 50%; cursor: pointer; display: grid; place-items: center; font-size: 12px; line-height: 1; }
.status-button:hover { border-color: var(--accent); color: var(--accent); }
.done .status-button { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.done .status-button::after { content: '✓'; }
.task-title-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.task-content h3 { font-size: 13px; margin: 0 0 7px; font-weight: 600; overflow-wrap: anywhere; }
.task-meta { color: var(--muted); font-size: 10px; display: flex; gap: 14px; flex-wrap: wrap; }
.status-pill { font-size: 8px; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 3px 7px; white-space: nowrap; }
.task-time { min-width: 68px; font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 700; text-align: right; }
.task-time small { display: block; color: var(--muted); font-weight: 400; font-size: 9px; margin-top: 2px; }
.task-actions { display: flex; align-items: center; gap: 3px; position: relative; }
.play-button, .edit-button, .delete-button, .defer-button { border: 0; background: transparent; cursor: pointer; }
.play-button { width: 35px; height: 35px; border-radius: 50%; color: var(--accent); background: var(--accent-soft); font-size: 11px; padding-left: 5px; }
.play-button:disabled { opacity: .4; cursor: not-allowed; }
.running .play-button { background: var(--accent); color: var(--on-accent); padding: 0; }
.edit-button, .delete-button, .defer-button { display: grid; place-items: center; width: 31px; height: 31px; padding: 0; color: var(--muted); border-radius: 50%; transition: color .15s ease, background .15s ease; }
.edit-button svg, .delete-button svg, .defer-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.edit-button:hover, .defer-button:hover { color: var(--accent); background: var(--accent-soft); }
.delete-button:hover { color: var(--danger); background: var(--danger-soft); }
.focus-card { display: flex; justify-content: space-between; gap: 20px; align-items: center; background: var(--accent); color: var(--on-accent); padding: 20px 22px; margin-bottom: 10px; border-radius: 3px; }
.focus-card p { margin: 0 0 5px; color: var(--on-accent-dim); font-size: 9px; letter-spacing: .13em; }
.focus-card h3 { margin: 0; font: 400 18px Prata, Georgia, serif; overflow-wrap: anywhere; }
.focus-card .focus-timer { font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; }
.focus-card button { border: 1px solid currentColor; background: transparent; color: inherit; padding: 8px 12px; cursor: pointer; border-radius: 2px; white-space: nowrap; }
.focus-card button:hover { background: color-mix(in srgb, var(--on-accent) 18%, transparent); }
.empty-state { text-align: center; padding: 45px 20px 25px; color: var(--muted); }
.empty-state.hidden { display: none; }
.empty-illustration { width: 76px; height: 76px; margin: auto; border: 1px solid var(--sage); border-radius: 48% 52% 57% 43%; display: grid; place-items: center; transform: rotate(-6deg); }
.empty-illustration span { transform: rotate(6deg); font: 28px Prata, Georgia, serif; color: var(--accent); }
.empty-state h3 { color: var(--ink); font: 18px Prata, Georgia, serif; margin: 20px 0 7px; }
.empty-state p { font-size: 11px; max-width: 330px; margin: auto; }
.summary { padding: 25px; }
.metrics { display: grid; gap: 19px; margin-top: 22px; }
.metrics div { border-bottom: 1px solid var(--grid-line); padding-bottom: 15px; }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .09em; }
.metrics strong { font: 24px Prata, Georgia, serif; margin-top: 5px; }
.summary-note { color: var(--muted); font-size: 10px; line-height: 1.6; margin: 20px 0 0; }
.timeline-section { margin-top: 56px; padding: 28px 30px 22px; }
.timeline-title { align-items: center; }
.legend { color: var(--muted); font-size: 9px; display: flex; gap: 7px; align-items: center; }
.legend span { width: 9px; height: 9px; border-radius: 2px; margin-left: 9px; }
.plan-dot { background: var(--sage); }
.actual-dot { background: var(--coral); }
.legend i { height: 14px; width: 1px; background: var(--accent); margin-left: 9px; }
.timeline-scroll { overflow-x: auto; padding: 4px 0 10px; }
.timeline { --timeline-height: 900px; --time-col: 62px; min-width: 620px; display: grid; grid-template-columns: var(--time-col) minmax(240px, 1fr) minmax(240px, 1fr); grid-template-rows: 34px auto var(--timeline-height); position: relative; }
.timeline-corner, .column-label { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; border-bottom: 1px solid var(--line); }
.timeline-corner { padding-top: 7px; }
.column-label { display: flex; align-items: flex-start; justify-content: center; gap: 8px; font-weight: 700; color: var(--ink); padding-top: 6px; }
.column-label span { width: 8px; height: 8px; border-radius: 2px; margin-top: 1px; }
.unscheduled-label { color: var(--muted); font-size: 8px; line-height: 1.35; text-align: right; padding: 15px 13px 13px 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.unscheduled-plan { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; min-height: 54px; padding: 9px; background: var(--sage-veil); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.unscheduled-plan:empty::after { content: 'Нет задач без времени'; margin: auto; color: var(--faint); font-size: 8px; font-style: italic; }
.unscheduled-chip { display: flex; align-items: center; gap: 7px; max-width: 100%; height: 34px; padding: 0 10px; background: var(--sage); color: var(--sage-ink); border-radius: 2px; font-size: 9px; }
.unscheduled-chip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unscheduled-chip small { flex: none; opacity: .7; }
.unscheduled-empty { display: grid; place-items: center; min-height: 54px; color: var(--faint); background: var(--coral-veil); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 8px; font-style: italic; text-align: center; padding: 0 8px; }
.time-labels { position: relative; color: var(--muted); font-size: 8px; border-right: 1px solid var(--line); }
.time-labels span { position: absolute; right: 13px; transform: translateY(-50%); }
/* Крайние отметки центрировались по линии и наполовину вылезали из колонки:
   верхняя наезжала на шапку «Без времени», нижняя свисала под шкалу. */
.time-labels span:first-child { transform: translateY(2px); }
.time-labels span:last-child { transform: translateY(calc(-100% - 2px)); }
.track { position: relative; min-height: var(--timeline-height); border-right: 1px solid var(--line); background-image: linear-gradient(to bottom, var(--grid-line) 0, var(--grid-line) 1px, transparent 1px); background-size: 100% var(--hour-step, calc(100% / 18)); }
.timeline-block { position: absolute; left: 7px; right: 7px; display: flex; align-items: center; gap: 8px; min-height: 30px; border-radius: 2px; padding: 0 9px; font-size: 9px; overflow: hidden; }
.timeline-block.plan { background: var(--sage); color: var(--sage-ink); }
/* Палитра задач задаётся инлайном и рассчитана на светлый фон — на тёмном её приглушаем,
   сохраняя тон и тёмный текст поверх. */
:root[data-theme='dark'] .timeline-block.plan,
:root[data-theme='dark'] .unscheduled-chip { filter: saturate(.8) brightness(.84); }
.timeline-block.plan.is-done { opacity: .55; }
.timeline-block.actual { display: block; min-height: 0; padding: 0 0 0 14px; overflow: visible; color: var(--on-coral); }
.duration-mark { position: absolute; top: 0; left: 0; display: block; width: 7px; height: 100%; min-height: 2px; background: var(--coral); border-radius: 3px; box-shadow: 0 2px 8px var(--coral-glow); }
.timeline-content { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; width: 100%; min-height: 44px; padding: 7px 10px; background: var(--coral); border-radius: 2px; overflow: hidden; }
.timeline-block.actual.live { z-index: 2; }
.timeline-block.actual.live .timeline-content { padding-right: 31px; box-shadow: 0 4px 14px var(--coral-glow); }
.timeline-block.actual.live .timeline-content::before { content: ''; position: absolute; top: 50%; right: 10px; width: 6px; height: 6px; margin-top: -3px; background: var(--on-coral); border-radius: 50%; animation: live-pulse 1.4s ease-out infinite; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--on-coral) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
.timeline-block strong, .timeline-block small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1; }
.timeline-block strong { flex: 1 1 auto; min-width: 0; font-size: 10px; }
.timeline-block small { flex: 0 1 auto; max-width: 44%; opacity: .78; font-size: 8px; }
.timeline-block.actual strong, .timeline-block.actual small { flex: none; width: 100%; max-width: 100%; }
.now-line { position: absolute; left: calc(var(--time-col) - 8px); right: 0; height: 1px; background: var(--accent); z-index: 3; pointer-events: none; }
.now-line::before { content: ''; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; position: absolute; top: -2.5px; left: 5px; }
.timeline-tip { color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 3px; font-size: 9px; }
footer { border-top: 1px solid var(--line); color: var(--muted); text-align: center; padding: 24px; font-size: 9px; letter-spacing: .06em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
dialog { border: 0; padding: 0; width: min(520px, calc(100% - 30px)); background: var(--card); color: var(--ink); box-shadow: var(--shadow-dialog); border-radius: 4px; }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
dialog { max-height: calc(100dvh - 32px); }
#editForm, #confirmForm { padding: 27px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; gap: 12px; }
.dialog-head h2 { font-size: 24px; }
.dialog-head button { border: 0; background: transparent; font-size: 25px; cursor: pointer; line-height: 1; padding: 0 4px; border-radius: 3px; }
.dialog-head button:hover { color: var(--accent); }
#editForm > label, .dialog-grid .field-block { display: grid; gap: 8px; font-size: 10px; color: var(--muted); }
#editForm input { background: var(--field); border: 1px solid var(--line); padding: 12px; color: var(--ink); outline-color: var(--accent); border-radius: 2px; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 16px; }
.dialog-actions { display: flex; justify-content: end; gap: 9px; margin-top: 25px; }
.secondary-button { border: 1px solid var(--line); background: transparent; color: inherit; padding: 0 20px; min-height: 42px; cursor: pointer; border-radius: 2px; }
.secondary-button:hover { border-color: var(--accent); color: var(--accent); }
.data-dialog { width: min(720px, calc(100% - 30px)); }
.data-dialog-content { padding: 27px; }
.data-description { color: var(--muted); font-size: 11px; line-height: 1.6; margin: -10px 0 20px; }
.json-label { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
#stateJson { display: block; width: 100%; min-height: 330px; resize: vertical; border: 1px solid var(--line); background: var(--field); color: var(--ink); padding: 14px; outline-color: var(--accent); font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; border-radius: 2px; }
.json-message { min-height: 18px; padding-top: 7px; color: var(--muted); font-size: 10px; }
.json-message.success { color: var(--accent); }
.json-message.error { color: var(--danger); }
.data-actions { flex-wrap: wrap; justify-content: space-between; }
.data-actions .file-actions { display: flex; gap: 9px; margin-right: auto; }

/* Тосты: отмена удаления и служебные сообщения. */
.toast-stack { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100% - 28px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 14px; padding: 13px 16px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--shadow-dialog); font-size: 12px; pointer-events: auto; animation: toast-in .22s ease; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast span { flex: 1; overflow-wrap: anywhere; }
.toast button { border: 0; background: var(--accent-soft); color: var(--accent); padding: 7px 12px; border-radius: 2px; font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.toast button:hover { background: var(--accent); color: var(--on-accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.shortcuts-hint { color: var(--muted); font-size: 9px; margin: 18px 0 0; text-align: center; letter-spacing: .04em; }
.shortcuts-hint kbd { font: 600 9px Manrope, system-ui, sans-serif; background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 2px 5px; margin: 0 2px; }

/* Тач-режим: поповер превращается в лист снизу экрана. Пальцем в кнопку 26 пикселей
   не попасть, поэтому в этом режиме растут все цели, а подсказки по клавишам скрываются. */
@media (pointer: coarse), (max-width: 860px) {
  .picker-backdrop:not([hidden]) { display: block; }
  .picker-popover, .picker-popover.above {
    position: fixed; top: auto; right: 0; bottom: 0; left: 0; z-index: 60;
    width: 100%; max-width: none; overflow-y: auto; overscroll-behavior: contain;
    max-height: 86vh; max-height: 86dvh;
    /* Без запасного значения в env() браузеры без поддержки отбрасывают всё правило padding. */
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
  }
  /* Полоска-ухватка: привычный признак того, что панель закрывается вниз. */
  .picker-popover::before { content: ''; display: block; width: 38px; height: 4px; margin: -8px auto 14px; background: var(--line); border-radius: 2px; }
  .picker-trigger { padding: 9px 12px; font-size: 14px; }
  .picker-trigger .chevron { font-size: 10px; }
  .picker-caption { font-size: 10px; margin-bottom: 14px; }
  .picker-subcaption { font-size: 10px; margin: 16px 0 8px; }
  .picker-stepper { grid-template-columns: 58px 1fr 58px; gap: 12px; }
  .picker-stepper button { width: 58px; height: 58px; font-size: 26px; }
  .picker-value { font-size: 24px; }
  .picker-grid { gap: 7px; }
  .picker-grid button { min-height: 50px; padding: 0; font-size: 15px; }
  .picker-chips { gap: 7px; margin-top: 16px; }
  .picker-chips button { min-height: 46px; padding: 0 16px; font-size: 13px; }
  .picker-actions { gap: 8px; margin-top: 15px; padding-top: 14px; }
  .picker-actions button { min-height: 52px; font-size: 13px; }
  .picker-hint { display: none; }
  .picker-done { display: block; width: 100%; min-height: 52px; margin-top: 12px; border: 0; border-radius: 3px; background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 700; cursor: pointer; }
}

@media (max-width: 860px) {
  .app-shell { padding: 0 22px; }
  .topbar { grid-template-columns: 1fr auto; height: 118px; }
  .date-nav { order: 3; grid-column: 1/-1; margin: 0 auto; transform: translateY(-9px); }
  .local-badge { display: none; }
  .top-actions { gap: 8px; }
  main { padding-top: 40px; }
  .workspace { grid-template-columns: 1fr; gap: 25px; }
  .summary { padding: 18px; }
  .summary .eyebrow { margin-bottom: 8px; }
  .metrics { grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
  .metrics div { border-bottom: 0; padding-bottom: 0; }
  .metrics strong { font-size: 19px; }
  .summary-note { margin-top: 14px; }
  .timeline-section { margin-top: 40px; }
  .hero { align-items: center; }
  .composer { margin-bottom: 40px; }
}
@media (max-width: 560px) {
  .app-shell { padding: 0 14px; }
  h1 { font-size: 39px; }
  .day-score > div:last-child { display: none; }
  .composer-main { display: grid; }
  .primary-button { width: 100%; }
  /* На узкой строке настроек поповер разворачивается во всю её ширину. */
  .composer-options { flex-wrap: wrap; gap: 11px 18px; position: relative; }
  .section-heading { align-items: start; gap: 15px; flex-wrap: wrap; }
  .filter-tabs { margin-top: 6px; }
  .filter-tabs button { padding: 6px 9px; }
  .task-card { grid-template-columns: 27px minmax(0,1fr) auto; gap: 10px; }
  .task-time { grid-column: 2; text-align: left; }
  .task-actions { grid-column: 3; grid-row: 1/3; flex-wrap: wrap; justify-content: end; width: 70px; }
  .edit-button, .delete-button, .defer-button { width: 29px; height: 29px; }
  .focus-card { align-items: start; flex-wrap: wrap; }
  .focus-card .focus-timer { margin-left: auto; }
  .timeline-section { padding: 22px 15px; }
  .legend { display: none; }
  .dialog-grid { grid-template-columns: 1fr; }
  .session-row { grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr) 34px; row-gap: 2px; }
  .session-duration { grid-column: 1 / -1; text-align: right; }
  .timeline { --timeline-height: 720px; --time-col: 52px; min-width: 540px; grid-template-columns: var(--time-col) 244px 244px; }
  .data-dialog-content { padding: 20px; }
  .data-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .data-actions .file-actions { display: contents; }
  .data-actions .primary-button { grid-column: 1/-1; }
  .data-actions button { min-height: 44px; padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
@media print {
  .topbar, .composer, .task-actions, .toast-stack, footer, .shortcuts-hint { display: none; }
  body { background: #fff; }
}
