/* ─────────────────────────────────────────────────────────────────────────
   MyOwnPod · Apple HIG
   Токены — по design-system «Apple»: SF Pro (системный стек), нейтрали
   #f5f5f7 / #1d1d1f, синий действий #0071e3, радиусы ярусами 8/10/16/18,
   сдержанная глубина (hairline вместо теней). Тёмная тема — автоматически.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light dark;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --border-strong: #86868b;
  --hairline: rgba(60, 60, 67, 0.18);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-ink: #0066cc;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --success: #34c759;
  --success-ink: #1f7d36;
  --warn: #ff9500;
  --warn-ink: #8f5b00;
  --danger: #ff3b30;
  --danger-ink: #d70015;
  --danger-soft: rgba(255, 59, 48, 0.12);
  --warn-soft: rgba(255, 149, 0, 0.16);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', sans-serif;
  --fs-large: 30px;
  --fs-h3: 17px;
  --fs-body: 16px;
  --fs-small: 14px;
  --fs-micro: 12px;

  --r-sm: 8px;
  --r: 10px;
  --r-lg: 16px;
  --r-xl: 18px;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.14);
  --focus-ring: 0 0 0 4px rgba(0, 113, 227, 0.32);
  --motion: 220ms cubic-bezier(0.25, 0.1, 0.25, 1);

  --topbar-h: 52px;
  --sidebar-w: 238px;
  --bar-bg: rgba(245, 245, 247, 0.8);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --fg: #f5f5f7;
    --muted: rgba(235, 235, 245, 0.62);
    --border: rgba(84, 84, 88, 0.65);
    --border-strong: rgba(142, 142, 147, 0.9);
    --hairline: rgba(84, 84, 88, 0.5);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.32);

    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-ink: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.22);
    --success: #30d158;
    --success-ink: #30d158;
    --warn: #ffd60a;
    --warn-ink: #ffd60a;
    --danger: #ff453a;
    --danger-ink: #ff6961;
    --danger-soft: rgba(255, 69, 58, 0.22);
    --warn-soft: rgba(255, 214, 10, 0.18);

    --shadow-1: none;
    --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.55);
    --focus-ring: 0 0 0 4px rgba(10, 132, 255, 0.45);
    --bar-bg: rgba(18, 18, 20, 0.78);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.45;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#app-view, #login-view { position: relative; z-index: 1; }

img, svg, video { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; letter-spacing: inherit; cursor: pointer; color: inherit; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

/* Типографика: SF Pro, крупный заголовок экрана в духе iOS */
h2, .h2 { font-size: var(--fs-large); font-weight: 700; letter-spacing: -0.022em; line-height: 1.1; margin: 0; }
h3, .h3 { font-size: var(--fs-h3); font-weight: 600; letter-spacing: -0.011em; line-height: 1.25; margin: 0; }
.muted { color: var(--muted); font-size: var(--fs-small); }
.num { font-family: var(--font); font-variant-numeric: tabular-nums; font-size: 0.95em; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.88em; background: var(--fill); border-radius: 5px; padding: 1px 5px; }

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 60;
  background: var(--surface); border-radius: var(--r);
  padding: 8px 14px; transition: top var(--motion);
}
.skip-link:focus-visible { top: 12px; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

/* ── Верхняя панель: полупрозрачная, как навбар iOS ── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space, 20px);
  height: var(--topbar-h);
  padding: 0 22px;
  background: var(--bar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 500; }

.search { position: relative; flex: 1; max-width: 420px; margin-left: 8px; }
.search-icon {
  position: absolute; left: 10px; top: 50%; translate: 0 -50%;
  width: 14px; height: 14px; opacity: 0.45;
  background: currentColor; mask: var(--ic-search) center / contain no-repeat;
}
.search-input {
  padding: 7px 12px 7px 30px;
  background: var(--fill); border: none; border-radius: var(--r-sm);
  font-size: var(--fs-small);
}
.search-input:focus-visible { background: var(--surface); box-shadow: var(--focus-ring); }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.user-chip { font-size: 13px; font-weight: 600; padding: 6px 4px; white-space: nowrap; }
.user-chip .muted { display: block; font-size: 11px; font-weight: 500; }

/* ── Кнопки: заполненная / тонированная / серая / текстовая ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; min-height: 36px;
  border-radius: var(--r-sm); border: none;
  font-size: var(--fs-small); font-weight: 600; letter-spacing: -0.01em;
  background: transparent;
  transition: background var(--motion), color var(--motion), transform 120ms ease;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--fill); color: var(--accent-ink); }
.btn-secondary:hover { background: var(--fill-2); }
.btn-plain { color: var(--accent-ink); padding-inline: 10px; }
.btn-plain:hover { opacity: 0.75; }
.btn-ghost { background: transparent; color: var(--muted); padding-inline: 10px; }
.btn-ghost:hover { color: var(--fg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-ink); }
.btn-sm { padding: 5px 12px; min-height: 30px; font-size: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: none; border-radius: var(--r-sm); background: transparent; color: var(--muted);
  transition: background var(--motion), color var(--motion);
}
.icon-btn:hover { background: var(--fill); color: var(--fg); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.is-accent { color: var(--accent-ink); }

/* ── Фильтры-капсулы (iOS-чипы) ── */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; min-height: 32px;
  border-radius: 999px; border: none;
  background: var(--fill);
  font-size: 13px; font-weight: 500; color: var(--fg);
  transition: background var(--motion), color var(--motion), transform 120ms ease;
}
.chip:hover { background: var(--fill-2); }
.chip:active { transform: scale(0.97); }
.chip.is-on { background: var(--accent); color: #fff; }
.chip .chip-count { font-variant-numeric: tabular-nums; font-size: 11px; opacity: 0.7; }
.chip-demo {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-ink);
}
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--fill); color: var(--muted);
}
.badge-src-tg { background: var(--accent-soft); color: var(--accent-ink); }
.badge-kind-exam { background: var(--danger-soft); color: var(--danger-ink); }
.badge-kind-deadline { background: var(--warn-soft); color: var(--warn-ink); }
.badge-kind-lesson { background: var(--accent-soft); color: var(--accent-ink); }
.badge-role { color: var(--fg); }

/* ── Каркас ── */
.layout { display: flex; min-height: calc(100dvh - var(--topbar-h)); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  padding: 14px 12px 20px;
  display: flex; flex-direction: column; gap: 22px;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; min-height: 40px;
  border-radius: var(--r); border: none; background: transparent;
  font-size: var(--fs-small); font-weight: 500; color: var(--fg);
  text-align: left; transition: background var(--motion);
}
.nav-item:hover { background: var(--fill); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-ic { display: inline-grid; place-items: center; width: 20px; height: 20px; }
.nav-ic svg { width: 18px; height: 18px; }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--accent); color: #fff;
  border-radius: 999px; padding: 1px 7px;
}
.side-title { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin: 0 12px 6px; }
.side-courses-list { display: flex; flex-direction: column; gap: 1px; }
.side-course {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 12px; border: 0; background: none; border-radius: var(--r-sm);
  font-size: 13px; color: var(--fg); text-align: left;
}
.side-course:hover { background: var(--fill); }
.course-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--cc, var(--border)); }
.side-empty { font-size: 12.5px; color: var(--muted); padding: 4px 12px; }

.main { flex: 1; min-width: 0; padding: 26px 32px 96px; }
.view { max-width: 1080px; margin: 0 auto; animation: view-in var(--motion); }
.view[hidden] { display: none; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.view-actions { display: flex; gap: 8px; }
.block-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 26px 0 12px; }

/* ── Календарь ── */
.cal-controls { display: flex; align-items: center; gap: 6px; }
.cal-month { font-size: 15px; font-weight: 600; min-width: 176px; text-align: center; letter-spacing: -0.01em; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; margin-top: 4px; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--surface); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-1);
}
.cal-dow {
  padding: 8px 6px; text-align: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--hairline); background: var(--surface-2);
}
.cal-cell {
  min-height: 96px; padding: 6px 6px 8px;
  border-right: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
  background: var(--surface); text-align: left;
  display: flex; flex-direction: column; gap: 4px;
  transition: background var(--motion);
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:not(.is-head):hover { background: var(--surface-2); }
.cal-cell.is-other { background: var(--surface-2); }
.cal-cell.is-other .cal-day-num { color: var(--border-strong); opacity: 0.6; }
.cal-cell.is-selected { background: var(--accent-soft); }
.cal-cell.is-today .cal-day-num { background: var(--accent); color: #fff; }
.cal-day-num {
  align-self: flex-start;
  font-size: 13px; font-weight: 500; color: var(--fg);
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-variant-numeric: tabular-nums;
}
.cal-cell.is-weekend .cal-day-num { color: var(--muted); }
.cal-chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-chip {
  font-size: 12px; line-height: 1.3; padding: 2px 7px; border-radius: 6px;
  background: color-mix(in srgb, var(--cc) 16%, var(--surface));
  border: none; text-align: left; width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-chip:hover { filter: brightness(0.96); }
.cal-chip .num { font-weight: 600; margin-right: 4px; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 4px; }

.day-panel {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: 16px;
  position: sticky; top: calc(var(--topbar-h) + 16px);
}
.day-panel .day-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.day-list { display: flex; flex-direction: column; }
.day-event { padding: 10px 0; border-bottom: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 3px; }
.day-event:last-of-type { border-bottom: 0; }
.day-event .de-top { display: flex; align-items: center; gap: 8px; }
.day-event .de-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day-event .de-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.day-event .de-course { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.day-event .de-note { font-size: 13px; color: var(--muted); margin: 0; }
.day-event .de-link { font-size: 13px; color: var(--accent-ink); background: none; border: 0; padding: 0; font-weight: 500; }
.day-event .de-link:hover { text-decoration: underline; }
.day-event .de-actions { display: flex; gap: 2px; }
.day-material { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: baseline; padding: 5px 0; }
.day-material button { background: none; border: 0; padding: 0; color: var(--accent-ink); font-size: 13px; font-weight: 500; }
.day-material button:hover { text-decoration: underline; }

.suggest-block { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 14px 18px; margin: 0 0 16px; }
.suggest-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.suggest-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.suggest-item .si-when { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); }
.suggest-item .si-actions { margin-left: auto; display: flex; gap: 6px; }

/* ── Материалы ── */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.toolbar-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mat-search { display: none; }
.select { width: auto; min-width: 140px; }

.mat-feed { display: flex; flex-direction: column; gap: 12px; }
.mat-card {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: 16px 18px;
  display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px 14px;
}
.mat-ic {
  width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center; color: var(--muted); background: var(--fill);
}
.mat-ic svg { width: 18px; height: 18px; }
.mat-body { min-width: 0; }
.mat-title { font-weight: 600; font-size: 16px; letter-spacing: -0.012em; margin: 0 0 2px; overflow-wrap: anywhere; }
a.mat-title { text-decoration: none; color: var(--accent-ink); }
a.mat-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.mat-text { margin: 0 0 8px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.mat-text.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mat-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.mat-meta .course-tag { display: inline-flex; align-items: center; gap: 6px; }
.mat-actions { display: flex; gap: 2px; margin-left: auto; }
.mat-preview { margin-top: 10px; }
.mat-preview img { border-radius: 12px; max-height: 340px; width: auto; cursor: zoom-in; }
.mat-preview video { border-radius: 12px; max-height: 380px; }
.mat-preview audio { width: 100%; }
.mat-file-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--fill); border-radius: var(--r); font-size: 13.5px;
}
.feed-more { text-align: center; margin-top: 16px; }

/* ── Хранилище ── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1.5px dashed var(--border); border-radius: var(--r-lg);
  padding: 26px; margin-bottom: 16px; cursor: pointer; text-align: center;
  background: var(--surface);
  transition: border-color var(--motion), background var(--motion);
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { width: 26px; height: 26px; color: var(--muted); background: currentColor; mask: var(--ic-upload) center / contain no-repeat; }
.dz-text { font-weight: 500; font-size: 15px; }
.dz-hint { font-size: 12.5px; }
.upload-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.bar { flex: 1; height: 6px; background: var(--fill); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width var(--motion); }

.files-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto auto; gap: 12px;
  align-items: center; padding: 10px 14px;
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1);
}
.file-ic { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); background: var(--fill); }
.file-ic svg { width: 18px; height: 18px; }
.file-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.file-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.file-actions { display: flex; gap: 2px; }

/* ── Загрузки ── */
.dl-form { display: flex; gap: 8px; align-items: end; margin-bottom: 14px; flex-wrap: wrap; }
.dl-form .field { flex: 1; min-width: 260px; margin: 0; }
.note { border-radius: var(--r); padding: 12px 16px; font-size: 13.5px; margin-bottom: 14px; }
.note-warn { background: var(--warn-soft); color: var(--warn-ink); }
.dl-list { display: flex; flex-direction: column; gap: 8px; }
.dl-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px;
  padding: 12px 16px; background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); align-items: center;
}
.dl-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.dl-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.dl-status-queued { color: var(--muted); }
.dl-status-downloading { color: var(--accent-ink); font-weight: 600; }
.dl-status-done { color: var(--success-ink); font-weight: 600; }
.dl-status-error { color: var(--danger-ink); font-weight: 600; }
.dl-progress { height: 5px; background: var(--fill); border-radius: 999px; overflow: hidden; grid-column: 1 / -1; }
.dl-error { font-size: 12.5px; color: var(--danger-ink); grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; }

/* ── Курсы и семья ── */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 6px; }
.course-card {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px;
}
.course-card .cc-head { display: flex; align-items: center; gap: 10px; }
.course-card .cc-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--cc); flex-shrink: 0; }
.course-card h3 { font-size: 16px; }
.course-card .cc-meta { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.course-card .cc-meta .num { font-size: 11.5px; }
.course-card .cc-actions { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.users-list { display: flex; flex-direction: column; gap: 8px; }
.user-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1);
  padding: 10px 16px;
}
.user-row .ur-name { font-weight: 600; font-size: 14px; }
.user-row .ur-login { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.user-row .ur-actions { margin-left: auto; display: flex; gap: 4px; }

/* ── Формы и модалки ── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label, .field-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-grow { flex: 2 !important; }
.input {
  width: 100%; padding: 10px 12px; min-height: 40px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--fg);
  font: inherit; font-size: 15px; letter-spacing: -0.01em;
  transition: border-color var(--motion), box-shadow var(--motion);
}
.input:hover { border-color: var(--border-strong); }
.input:focus-visible { border-color: var(--accent); box-shadow: var(--focus-ring); }
.input:user-invalid { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 64px; line-height: 1.45; }
select.input { appearance: auto; }
.hint { font-size: 12px; color: var(--muted); }
.form-error { color: var(--danger-ink); font-size: 13px; margin: 0 0 12px; }

.modal {
  border: none; border-radius: var(--r-xl); padding: 22px 24px;
  box-shadow: var(--shadow-2); width: min(540px, 94vw);
  background: var(--surface); color: var(--fg);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.4); }
.modal-sm { width: min(400px, 92vw); }
.modal h3 { font-size: 19px; letter-spacing: -0.015em; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.confirm-text { color: var(--muted); font-size: 14px; }
.swatch-row { display: flex; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; padding: 0;
  background: var(--cc); transition: transform var(--motion);
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-on { border-color: var(--fg); }

/* ── Состояния ── */
.empty { text-align: center; padding: 52px 24px; color: var(--muted); }
.empty .empty-ic {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%;
  background: var(--fill); position: relative;
}
.empty .empty-ic::after {
  content: ''; position: absolute; inset: 16px;
  background: var(--muted); mask: var(--ic-empty) center / contain no-repeat;
}
.empty h3 { color: var(--fg); font-size: 17px; margin-bottom: 6px; }
.empty p { font-size: 14px; margin: 0 auto 18px; max-width: 46ch; }

.skeleton-card {
  height: 88px; border-radius: var(--r-lg); background: var(--fill);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.55; } }

#toasts { position: fixed; bottom: 20px; left: 50%; translate: -50% 0; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(28, 28, 30, 0.92); color: #f5f5f7;
  backdrop-filter: blur(16px);
  border-radius: 999px; padding: 11px 20px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-2);
  max-width: min(480px, 92vw);
  animation: toast-in var(--motion);
}
.toast.t-error { background: var(--danger); color: #fff; }
.toast.t-success { background: var(--success-ink); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* ── Вход ── */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(380px, 100%); background: var(--surface);
  border-radius: 22px; box-shadow: var(--shadow-2); padding: 36px 28px 26px;
}
.login-card h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 22px 0 18px; text-align: center; }
.login-card .brand-big { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.login-hint { font-size: 12.5px; color: var(--muted); text-align: center; margin: 18px 0 0; }

/* ── Нижняя панель iPhone ── */
.tabbar { display: none; }

/* ── Адаптив: iPad ── */
@media (max-width: 1279px) and (min-width: 768px) {
  :root { --sidebar-w: 208px; }
  .main { padding: 22px 24px 96px; }
  .topbar { padding: 0 18px; }
}
@media (max-width: 1279px) {
  /* панель дня под календарём — весь iPad-диапазон 768–1279;
     два столбца остаются только на десктопе ≥1280 */
  .cal-layout { grid-template-columns: 1fr; }
  .day-panel { position: static; }
}

/* ── Адаптив: iPhone ── */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--bar-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--hairline);
    padding: 5px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .tab-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: none; border: 0; border-radius: 10px; padding: 5px 2px;
    font-size: 10px; font-weight: 600; color: var(--muted);
  }
  .tab-item.is-active { color: var(--accent); }
  .tab-item .nav-ic svg { width: 22px; height: 22px; }
  .main { padding: 18px 16px 130px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .brand-sub { display: none; }
  .user-chip .muted { display: none; }
  #quick-add { padding: 8px 13px; }
  .search { display: none; }
  .mat-search { display: block; }
  .view-head h2 { font-size: 26px; }
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-chips { display: none; }
  .cal-dot-row { display: flex; flex-wrap: wrap; gap: 3px; }
  .cal-dot-row i { width: 7px; height: 7px; border-radius: 50%; background: var(--cc); }
  .field-row { flex-direction: column; gap: 0; }
  .file-row { grid-template-columns: 38px minmax(0, 1fr); }
  .file-row .file-meta { grid-column: 2; }
  .file-row .file-actions { grid-column: 2; }
  .dl-form { flex-direction: column; align-items: stretch; }
}
.cal-dot-row { display: none; }
@media (max-width: 767px) { .cal-dot-row { display: flex; } }

/* ── Крупные тач-цели на сенсорных экранах (≥44px по HIG) ── */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .btn { min-height: 44px; }
  .input { min-height: 44px; font-size: 16px; }
  .chip { min-height: 44px; padding: 8px 16px; }
  .day-material button { padding: 6px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Офлайн-баннер (PWA) ── */
.offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  padding: 8px 16px;
  text-align: center;
  font-size: 13px;
  color: #f5f5f7;
  background: #6e6e73;
}
@media (prefers-color-scheme: dark) {
  .offline-banner { color: #f5f5f7; background: #48484a; }
}

/* ── Журнал изменений ── */
.audit-list { display: flex; flex-direction: column; gap: 6px; }
.audit-row {
  display: flex; gap: 12px; align-items: baseline;
  padding: 7px 12px;
  border-bottom: 0.5px solid var(--separator, rgba(0,0,0,0.08));
  font-size: 13px;
}
.audit-row .audit-details { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }

/* ── Push-колокольчик ── */
.icon-btn.is-on { color: #0071e3; }
