/* Стили приложения. Общие компоненты и переменные — в base.css. */

/* ============ оболочка ============ */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); height: 100dvh; }
.sidebar { display: flex; flex-direction: column; padding: 18px 12px 12px; border-right: 1px solid var(--line); background: var(--sunken); min-height: 0; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: var(--r); color: var(--text-2); font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.nav-item.is-active .icon { color: var(--accent); }
.nav-sep { height: 1px; margin: 10px 8px; background: var(--line); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 5px; border-radius: var(--r); color: var(--text); }
.user:hover { background: var(--surface-2); text-decoration: none; }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 4px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13px; }
.user-text { min-width: 0; display: flex; flex-direction: column; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14px; }
.user-role { display: block; font-size: 12px; color: var(--text-3); line-height: 1.1; font-weight: 400; }
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar, .tabbar { display: none; }
.main { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; outline: none; }

.page { padding: 26px 32px 44px; max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-hint { color: var(--text-3); font-size: 13px; margin-bottom: 8px; }

/* ============ экран «День» ============ */
.day-head { display: grid; grid-template-columns: 1fr auto; gap: 12px 24px; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
/* число и подпись стоят на одной оси: число по центру двух строк подписи */
.day-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.day-num { font: 500 46px/1 var(--serif); letter-spacing: -0.02em; color: var(--text); padding-bottom: 0.06em; }
.day-sub { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.day-weekday { font: 500 22px/1.1 var(--serif); }
.day-month { color: var(--text-2); font-size: 14px; line-height: 1.2; }
.day-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.day-nav { display: flex; align-items: center; gap: 2px; }
.date-pick { position: relative; cursor: pointer; }
.date-ghost { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.date-ghost::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.progress { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 13.5px; }
.progress-bar { flex: 1; max-width: 320px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: var(--accent); transition: width 0.25s; }
.progress .progress-text { white-space: nowrap; }

.day-tabs { display: none; margin-bottom: 14px; width: 100%; }
.day-tabs .seg { flex: 1; }

.day-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.pane-side { display: flex; flex-direction: column; gap: 14px; }
.panel-schedule { padding: 12px 14px 8px; }

.overdue { margin-bottom: 14px; border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); border-left: 3px solid var(--danger); border-radius: var(--r-lg); background: var(--surface); }
.overdue summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; color: var(--danger); font-weight: 500; list-style: none; }
.overdue summary::-webkit-details-marker { display: none; }
.overdue summary .btn { margin-left: auto; color: var(--text); }
.overdue-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; padding: 0 10px 10px; }
.tray-list { display: flex; flex-direction: column; gap: 6px; min-height: 52px; padding: 6px; margin: 0 -6px 10px; border-radius: var(--r); transition: background 0.1s; }
.tray-list.is-over { background: var(--accent-soft); }
.tray-empty { padding: 12px 6px; color: var(--text-3); font-size: 13px; text-align: center; }

/* ============ доска: все колонки видны сразу, без горизонтальной прокрутки ============ */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; align-items: start; }
.col { min-width: 0; padding: 8px; border-radius: var(--r-lg); background: var(--sunken); border: 1px solid var(--line); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 3px 4px 9px; }
.col-head h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); }
.col-done .col-head h3 { color: var(--ok); }
.col-body { display: flex; flex-direction: column; gap: 6px; min-height: 40px; border-radius: var(--r); transition: background 0.1s; }
.col-body:empty::before { content: 'Пусто'; display: grid; place-items: center; height: 40px; color: var(--text-3); font-size: 13px; border: 1px dashed var(--line-strong); border-radius: var(--r); }
.col-body.is-over { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.add-card { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 6px; padding: 7px 6px; border: 0; border-radius: var(--r); background: transparent; color: var(--text-2); font-size: 13.5px; }
.add-card:hover { background: var(--surface-2); color: var(--text); }
.add-form { margin-top: 6px; }

.card {
  position: relative; display: flex; gap: 9px; align-items: flex-start; padding: 8px 10px 8px 9px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: border-color 0.1s;
}
.card:hover { border-color: var(--line-strong); }
.card.is-done .card-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.card.has-color { background: color-mix(in srgb, var(--c) 8%, var(--surface)); box-shadow: inset 3px 0 0 var(--c); padding-left: 12px; }
.card.has-color.is-done { background: var(--surface); }
.card.is-dragging { opacity: 0.35; }
.card-main { min-width: 0; flex: 1; }
.card-title { font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.check { position: relative; display: grid; place-items: center; flex: none; width: 17px; height: 17px; margin-top: 1px; padding: 0; border-radius: 4px; border: 1.5px solid var(--line-strong); background: var(--surface); color: transparent; transition: background 0.1s, border-color 0.1s; }
.check::before { content: ''; position: absolute; inset: -10px; }
.check:hover { border-color: var(--accent); color: var(--accent); }
.check.is-on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; box-shadow: var(--shadow); opacity: 0.96; border-color: var(--accent); }
.drop-line { height: 3px; margin: -2px 0; border-radius: 2px; background: var(--accent); flex: none; }
body.is-dragging-card { cursor: grabbing; user-select: none; -webkit-user-select: none; }

/* ============ сетка времени: показаны только нужные часы, расписание целиком на странице ============ */
.tg { position: relative; }
.tg-scroll { position: relative; overflow-x: auto; overflow-y: hidden; padding: 8px 0; }
.tg-scroll-full {
  max-height: max(360px, calc(100vh - 230px)); overflow-y: auto; padding: 0;
  scrollbar-width: none; -ms-overflow-style: none; overscroll-behavior: contain;
}
.tg-scroll-full::-webkit-scrollbar { display: none; }
.tg-scroll-full .tg-sticky { position: sticky; top: 0; z-index: 3; }
.tg-scroll-full .tg-body { margin-top: 8px; margin-bottom: 8px; }
.tg-sticky { background: var(--surface); }
.tg-row { display: grid; align-items: stretch; }
.tg-row > :first-child { background: var(--surface); }
.tg-head { border-bottom: 1px solid var(--line-strong); }
.tg-daylabel { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; border: 0; background: transparent; color: var(--text-2); border-left: 1px solid var(--line); }
.tg-daylabel:hover { background: var(--surface-2); }
.tg-dow { font-size: 12px; text-transform: lowercase; }
.tg-dom { display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: 4px; font-size: 16px; font-weight: 500; color: var(--text); }
.tg-daylabel.is-today .tg-dom { background: var(--accent); color: var(--on-accent); }
.tg-allday { border-bottom: 1px solid var(--line); }
.tg-gutter-label { display: grid; place-items: center; font-size: 10.5px; color: var(--text-3); text-align: center; line-height: 1.1; padding: 4px 2px; }
.tg-allcell { display: flex; flex-direction: column; gap: 3px; padding: 4px 3px; border-left: 1px solid var(--line); min-width: 0; }
.tg-chip { display: flex; align-items: center; gap: 4px; min-width: 0; height: 21px; padding: 0 6px; border: 0; border-radius: 3px; background: color-mix(in srgb, var(--c, var(--accent)) 18%, var(--surface)); color: var(--text); font-size: 12.5px; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tg-chip-task { background: var(--surface-2); color: var(--text-2); }
.tg-chip.is-done { text-decoration: line-through; opacity: 0.6; }
.tg-body { position: relative; display: grid; }
.tg-gutter { position: relative; background: var(--surface); }
.tg-hour { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11.5px; color: var(--text-3); }
.tg-col { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hh) - 1px), var(--line) calc(var(--hh) - 1px), var(--line) var(--hh)); cursor: cell; }
.tg-col.is-today { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.tg-item {
  position: absolute; display: flex; flex-direction: column; gap: 1px; padding: 3px 7px; overflow: hidden; text-align: left;
  border: 0; border-left: 3px solid var(--c, var(--accent)); border-radius: 3px;
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, var(--surface)); color: var(--text); cursor: pointer;
}
.tg-item:hover { background: color-mix(in srgb, var(--c, var(--accent)) 26%, var(--surface)); }
.tg-item.is-short { flex-direction: row; align-items: center; gap: 6px; padding-top: 0; padding-bottom: 0; }
.tg-title { font-size: 13px; font-weight: 500; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-time { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.tg-task { --c: var(--text-3); flex-direction: row; align-items: center; gap: 6px; border-left-style: dashed; background: var(--surface-2); }
.tg-task .icon { color: var(--text-3); }
.tg-task.has-color { border-left-style: solid; background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.tg-task.has-color .icon { color: var(--c); }
.tg-task.is-done { opacity: 0.55; }
.tg-task.is-done .tg-title { text-decoration: line-through; }
.tg-task .tg-time { margin-left: auto; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; margin-top: -1px; background: var(--now); z-index: 2; pointer-events: none; }
.now-line i { position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 2px; background: var(--now); }

/* ============ календарь ============ */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px 24px; flex-wrap: wrap; margin-bottom: 18px; }
.cal-title { font: 500 30px/1.1 var(--serif); letter-spacing: -0.01em; }
.cal-month { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.cal-grid-wrap { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); overflow: hidden; }
.cal-dows, .cal-cells { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 8px; font-size: 12.5px; color: var(--text-3); text-align: right; border-bottom: 1px solid var(--line-strong); background: var(--sunken); text-transform: lowercase; }
.cell { display: flex; flex-direction: column; gap: 4px; min-height: 108px; padding: 5px 5px 7px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; min-width: 0; }
.cell:nth-child(7n) { border-right: 0; }
.cell:nth-last-child(-n + 7) { border-bottom: 0; }
.cell:hover { background: var(--surface-2); }
.cell.is-out { background: var(--sunken); }
.cell.is-out .cell-num { color: var(--text-3); }
.cell.is-sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cell-num { align-self: flex-end; display: grid; place-items: center; min-width: 24px; height: 24px; border-radius: 4px; font-size: 13.5px; font-weight: 500; }
.cell.is-today .cell-num { background: var(--accent); color: var(--on-accent); }
.cell-chips { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-dots { display: none; }
.mchip { display: block; padding: 1px 5px; border-radius: 3px; font-size: 12px; line-height: 1.5; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); }
.mchip-event { background: color-mix(in srgb, var(--c) 18%, transparent); border-left: 3px solid var(--c); }
.mchip-task { color: var(--text-2); background: var(--surface-2); }
.mchip-task.has-color { color: var(--text); background: color-mix(in srgb, var(--c) 18%, transparent); border-left: 3px solid var(--c); }
.mchip.is-done { text-decoration: line-through; opacity: 0.6; }
.mmore { padding: 0 5px; font-size: 12px; color: var(--text-3); }
.mdot { width: 6px; height: 6px; border-radius: 1px; background: var(--c); }
.mdot-task { background: transparent; border: 1.5px solid var(--text-3); }
.cal-side { position: sticky; top: 0; }
.agenda { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.agenda-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 5px 8px; border: 0; border-radius: var(--r); background: transparent; text-align: left; }
button.agenda-row:hover, .agenda-open:hover { background: var(--surface-2); }
.agenda-bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--c); flex: none; }
.agenda-time { flex: none; width: 98px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.agenda-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.agenda-open { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 5px 8px; border: 0; border-radius: var(--r); background: transparent; text-align: left; }
.agenda-task { padding: 0 0 0 8px; }
.agenda-task.has-color { box-shadow: inset 3px 0 0 var(--c); border-radius: 3px; }
.agenda-task.is-done .agenda-title { text-decoration: line-through; color: var(--text-3); }
.cal-week-wrap { padding: 0; overflow: hidden; --day-min: 92px; }
.week-list { display: flex; flex-direction: column; gap: 8px; }
.week-day { padding: 10px 12px 4px; }
.week-day.is-today { border-color: var(--accent); }
.week-day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.week-day-head a { display: inline-block; color: var(--text); font-weight: 600; }
.week-day-head a::first-letter { text-transform: uppercase; }
.week-free { color: var(--text-3); font-size: 13px; }
.week-day.is-free { padding-bottom: 10px; }
.week-day.is-free .week-day-head { margin-bottom: 0; }

/* ============ проекты ============ */
.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c); color: var(--text); transition: border-color 0.1s; }
.project-card:hover { text-decoration: none; border-color: var(--line-strong); border-left-color: var(--c); }
.project-card.is-finished { opacity: 0.7; }
.pc-top { display: flex; align-items: center; justify-content: space-between; min-height: 20px; }
.pc-top .dot { display: none; }
.project-card h3 { font: 500 19px/1.2 var(--serif); }
.pc-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text-2); font-size: 14px; min-height: 2.9em; }
.project-card .progress-bar { max-width: none; flex: none; }
.project-card .progress-bar i { background: var(--c); }
.pc-foot { display: flex; justify-content: space-between; color: var(--text-2); font-size: 13px; }

.project-head { margin-bottom: 18px; }
.back { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 10px; color: var(--text-2); font-size: 14px; }
.ph-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.ph-main h1 { display: flex; align-items: center; gap: 10px; }
.ph-main .dot { background: var(--c); }
.ph-desc { max-width: 70ch; margin-top: 8px; color: var(--text-2); white-space: pre-line; }
.project-head .progress-bar i { background: var(--c); }
.project-grid { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 22px; align-items: start; }
.pane-chat { position: sticky; top: 0; display: flex; flex-direction: column; height: min(720px, calc(100dvh - 120px)); padding-bottom: 8px; }
.chat-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ============ ассистент ============ */
.main[data-view='ai'] { display: flex; flex-direction: column; }
.page-ai { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; padding-bottom: 26px; }
.page-ai .page-head { margin-bottom: 14px; }
.chat-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 14px; max-width: 920px; width: 100%; }
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.chat-tools { display: flex; align-items: center; justify-content: flex-end; }
.chat-tools .icon-btn { width: 30px; height: 30px; }
.chat-scroll { flex: 1; min-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 8px 2px; overscroll-behavior: contain; }
.chat-empty { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-2); padding: 24px 12px; }
.chat-empty strong { color: var(--text); font: 500 20px/1.2 var(--serif); }
.chat-empty p { max-width: 42ch; }
.chat-presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.chat-presets.is-disabled { opacity: 0.5; pointer-events: none; }
.preset { flex: none; height: 30px; padding: 0 11px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: 13px; white-space: nowrap; }
.preset:hover { border-color: var(--accent); color: var(--accent); }
.chat-composer { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 12px; border-radius: var(--r-lg); border: 1px solid var(--line-strong); background: var(--surface); transition: border-color 0.1s, box-shadow 0.1s; }
.chat-composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.chat-input { flex: 1; min-width: 0; max-height: 168px; padding: 7px 0; border: 0; background: transparent; resize: none; line-height: 1.45; }
.attach {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; margin-left: -8px;
  border: 0; border-radius: var(--r); background: transparent; color: var(--text-3);
}
.attach:hover { background: var(--surface-2); color: var(--text); }
.chat-files { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px; height: 28px;
  padding: 0 8px; border-radius: var(--r); background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text-2); font-size: 12.5px;
}
.file-chip.is-loading { opacity: 0.6; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x {
  display: grid; place-items: center; flex: none; width: 18px; height: 18px; margin-right: -4px;
  padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--text-3);
}
.chip-x:hover { background: var(--line); color: var(--text); }
.bubble-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.bubble-files:last-child { margin-bottom: 0; }
.chat.is-drop {
  outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: var(--r-lg);
}
.send { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border: 0; border-radius: var(--r); background: var(--accent); color: var(--on-accent); }
.send:hover { background: var(--accent-hover); }
.send.is-stop { background: var(--surface-2); color: var(--text); }

.msg { max-width: 100%; }
.msg-user { align-self: flex-end; max-width: 86%; }
.bubble { padding: 8px 12px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-ai { align-self: stretch; overflow-wrap: anywhere; padding-left: 12px; border-left: 2px solid var(--line-strong); }
.msg-error { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: var(--r); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 5px; height: 5px; border-radius: 1px; background: var(--text-3); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 9px; }
.md h3, .md h4, .md h5 { margin: 14px 0 5px; font-size: 14.5px; }
.md ul, .md ol { margin: 0 0 9px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md code { padding: 1px 5px; border-radius: 3px; background: var(--surface-2); }
.md-table { margin: 0 0 10px; overflow-x: auto; }
.md-table table { border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td { padding: 5px 10px; border: 1px solid var(--line-strong); text-align: left; vertical-align: top; }
.md-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.md hr { margin: 12px 0; border: 0; border-top: 1px solid var(--line-strong); }
.md del { color: var(--text-3); }
.md li > ul, .md li > ol { margin: 3px 0 0; }
.md pre { margin: 0 0 9px; padding: 9px 11px; border-radius: var(--r); background: var(--surface-2); overflow-x: auto; }
.md pre code { padding: 0; background: none; }
.md blockquote { margin: 0 0 9px; padding-left: 12px; border-left: 3px solid var(--line-strong); color: var(--text-2); }

.actions-card { margin-top: 10px; padding: 10px; border-radius: var(--r-lg); border: 1px solid var(--line-strong); background: var(--surface); }
.actions-card.is-applied { display: flex; align-items: center; gap: 8px; color: var(--ok); border-color: transparent; background: color-mix(in srgb, var(--ok) 12%, transparent); font-size: 14px; }
.actions-title { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-weight: 600; font-size: 13.5px; }
.actions-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.actions-list label { display: flex; align-items: flex-start; gap: 9px; padding: 6px 4px; border-radius: var(--r); cursor: pointer; }
.actions-list label:hover { background: var(--surface-2); }
.actions-list input { margin: 3px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.actions-list .icon { margin-top: 2px; color: var(--text-2); }
.actions-list .is-danger .icon, .actions-list .is-danger b { color: var(--danger); }
.act-text { min-width: 0; font-size: 14px; }
.act-meta { display: block; color: var(--text-2); font-size: 13px; }
.act-swatch { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--c); }
.actions-pending { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--text-2); font-size: 14px; }
.actions-pending.is-warn { color: var(--danger); }

/* ============ настройки: разделы слева, строки справа (как в приложении Claude) ============ */
.settings { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; align-items: start; max-width: 980px; }
.settings-nav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.snav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r); background: transparent; color: var(--text-2); font-weight: 500; text-align: left; }
.snav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.snav-item.is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.snav-item.is-active > .icon:first-child { color: var(--accent); }
.snav-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.snav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snav-blurb { display: none; color: var(--text-3); font-size: 12.5px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snav-item > .icon:last-child { display: none; color: var(--text-3); }
.snav-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.snav-logout:hover { color: var(--danger); background: var(--danger-soft); }
.settings-back { display: none; }
.settings-title { font: 500 26px/1.15 var(--serif); letter-spacing: -0.01em; }
.sgroup { margin-top: 26px; }
.settings-title + .sgroup { margin-top: 18px; }
.sgroup-title { margin-bottom: 4px; color: var(--text-3); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.sgroup-rows { border-top: 1px solid var(--line-strong); }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.srow-text { flex: 1; min-width: 0; max-width: 400px; }
.srow-title { font-weight: 500; }
.srow-hint { margin-top: 2px; color: var(--text-2); font-size: 13px; }
.srow-control { flex: none; max-width: 100%; }
.srow-control .input-group { width: 340px; max-width: 100%; }
.srow-value { color: var(--text-2); overflow-wrap: anywhere; }
.srow-stack { flex-direction: column; align-items: stretch; gap: 12px; }
.srow-stack .srow-text { max-width: none; }
.srow-stack .srow-control { flex: 1; width: 100%; }
.srow-stack .stack { max-width: 560px; }
.col-editor { display: flex; flex-direction: column; gap: 8px; }
.col-row { display: flex; align-items: center; gap: 8px; }
.col-row .input { flex: 1; min-width: 0; }
.col-actions { display: flex; flex: none; }
.col-row .icon-btn { width: 32px; height: 32px; }
.formats { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.formats-title { width: 100%; font-size: 13px; color: var(--text-2); }
.formats code { padding: 2px 7px; border-radius: 3px; background: var(--surface-2); color: var(--text-2); }
.test-result { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); }
.test-row { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.test-row .icon { margin-top: 2px; }
.test-ok .icon { color: var(--ok); }
.test-bad .icon { color: var(--danger); }
.test-warn .icon { color: var(--hi); }

/* ============ вход ============ */
.auth { display: grid; place-items: center; min-height: 100dvh; height: 100dvh; overflow-y: auto; padding: 24px 16px; }
.auth-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 22px; }
.auth-card .brand { padding: 0; font-size: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; padding: 22px; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); }
.auth-form h1 { font-size: 26px; }
.auth-form .auth-lead { margin-top: -6px; color: var(--text-2); font-size: 14px; }
.auth-switch { color: var(--text-2); text-align: center; }
.fatal { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18vh 20px 0; text-align: center; }

/* ============ планшет ============ */
@media (max-width: 1180px) {
  .day-grid { grid-template-columns: minmax(0, 1fr); }
  .pane-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
  .project-grid { grid-template-columns: minmax(0, 1fr); }
  .page-project .day-tabs { display: inline-flex; }
  .project-grid[data-pane='board'] .pane-chat,
  .project-grid[data-pane='chat'] .pane-board { display: none; }
  .pane-chat { position: static; height: calc(100dvh - 330px); min-height: 440px; }
  .cal-month { grid-template-columns: minmax(0, 1fr); }
  .cal-side { position: static; }
}

/* ============ телефон ============ */
@media (max-width: 860px) {
  :root { --tabbar: 52px; --topbar: 46px; }
  body { font-size: 14px; }
  h1 { font-size: 22px; }

  .shell { display: flex; flex-direction: column; }
  .content { flex: 1; }
  .sidebar { display: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; min-height: var(--topbar); padding: 0 6px 0 14px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line); background: var(--bg); }
  .topbar .brand { padding: 0; font-size: 18px; }
  .topbar .icon-btn { width: 38px; height: 38px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: var(--surface); }
  .tab-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-3); font-size: 10.5px; font-weight: 500; }
  .tab-item:hover { text-decoration: none; }
  .tab-item.is-active { color: var(--accent); }
  #toasts { bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); }

  .page { padding: 12px 12px calc(var(--tabbar) + 28px); }
  .page-head { margin-bottom: 12px; gap: 10px; }
  .panel { padding: 12px; }

  /* кнопка создания плавает над нижней панелью, шапка остаётся короткой */
  .fab { position: fixed; z-index: 20; right: 14px; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); height: 46px; padding: 0 16px; border-radius: 10px; box-shadow: var(--shadow); }

  .day-head { grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; padding-bottom: 10px; }
  .day-title { gap: 10px; }
  .day-num { font-size: 36px; }
  .day-weekday { font-size: 18px; }
  .day-month { font-size: 13px; }
  .day-actions { justify-content: space-between; gap: 6px; }
  .progress { font-size: 13px; gap: 10px; }
  .progress-bar { max-width: none; }

  /* колонки доски друг под другом: ничего не нужно прокручивать вбок */
  .board { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .col { padding: 6px; }
  .col-head { padding: 2px 4px 6px; }
  .col-body { gap: 5px; }
  .card { padding: 8px 9px; }
  .overdue summary { padding: 8px 10px; flex-wrap: wrap; }
  .overdue summary .btn { margin-left: 0; }
  .overdue-list { grid-template-columns: minmax(0, 1fr); padding: 0 8px 8px; }
  .pane-side { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .day-grid { gap: 10px; }
  .panel-schedule { padding: 10px 10px 6px; }

  .cal-head { margin-bottom: 12px; gap: 8px; }
  .cal-title { font-size: 22px; }
  .cal-head .day-actions { width: 100%; }
  .cal-head .segmented { flex: 1; }
  .cal-head .segmented .seg { flex: 1; }
  .cell { min-height: 46px; align-items: center; padding: 4px 2px 5px; gap: 3px; }
  .cell-chips { display: none; }
  .cell-dots { display: flex; gap: 3px; height: 8px; align-items: center; }
  .cell-num { align-self: center; }
  .cal-dow { text-align: center; padding: 6px 2px; }
  .agenda-time { width: 84px; }

  .project-list { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .project-card { padding: 12px 14px; gap: 6px; }
  .project-card h3 { font-size: 17px; }
  .pc-desc { min-height: 0; }
  .project-head { margin-bottom: 12px; }
  .ph-main { gap: 8px; margin-bottom: 8px; }
  .pane-chat { height: calc(100dvh - var(--topbar) - var(--tabbar) - 190px); min-height: 360px; }

  .page-ai { padding: 12px 0 0; }
  .page-ai .page-head { padding: 0 12px; margin-bottom: 8px; }
  .chat-panel { border-radius: 0; border-width: 1px 0 0; padding: 8px 12px; max-width: none; }
  .msg-user { max-width: 92%; }
  .chat-presets { gap: 6px; }
  .preset { height: 32px; }

  .modal { width: 100%; max-height: 92dvh; border-radius: 12px 12px 0 0; animation: sheet-in 0.2s ease-out; padding-bottom: env(safe-area-inset-bottom); }
  .modal-head { padding: 10px 8px 2px 16px; }
  .modal-body { padding: 6px 16px 16px; }
  .overlay { align-items: end; padding: 0; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }

  /* настройки: сначала список разделов, по нажатию открывается раздел */
  .settings { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .settings[data-section='none'] .settings-body { display: none; }
  .settings:not([data-section='none']) .settings-nav { display: none; }
  .page-settings:has(.settings:not([data-section='none'])) .settings-head { display: none; }
  .settings-nav { position: static; gap: 0; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
  .snav-item { padding: 13px 12px; border-radius: 0; border-bottom: 1px solid var(--line); }
  .snav-item:last-child, .snav-foot .snav-item:last-child { border-bottom: 0; }
  .snav-item.is-active { box-shadow: none; }
  .snav-blurb, .snav-item > .icon:last-child { display: block; }
  .snav-foot { margin: 0; padding: 0; border-top: 1px solid var(--line-strong); gap: 0; }
  .settings-back { display: inline-flex; margin-bottom: 6px; }
  .settings-title { font-size: 24px; }
  .srow { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 0; }
  .srow-text { max-width: none; }
  .srow-control { width: 100%; }
  .srow-control .input-group { width: 100%; }
  .srow-control .segmented { display: flex; width: 100%; }
  .srow-control .segmented .seg { flex: 1; padding: 0 6px; }
  .col-row { flex-wrap: wrap; }
  .col-row .input { flex-basis: 100%; }

  .auth { padding: 16px 12px; }
  .auth-form { padding: 18px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2:has(input[type='date']), .grid-2:has(input[type='time']) { grid-template-columns: 1fr 1fr; }
}

@media (hover: none) {
  .card:hover, .btn-ghost:hover:not(:disabled), .nav-item:hover { border-color: inherit; }
}
