/* hse app web. Стиль приложения без Liquid Glass: матовые поверхности, один акцент Вышки.
   Сетка 4px, радиусы из Tokens.swift (8/12/16/20), системный шрифт. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --r-xs: 8px; --r-sm: 12px; --r-md: 16px; --r-lg: 20px;

  --bg: #000;
  --surface: #1c1c1e;
  --raised: #2c2c2e;
  --step: rgba(255, 255, 255, 0.06);
  --step-hover: rgba(255, 255, 255, 0.1);
  --hairline: rgba(255, 255, 255, 0.1);
  --text: #fff;
  --text-2: #aeaeb2;
  --muted: #8e8e93;
  --accent: #0047bb;
  --accent-hover: #0a56d6;
  --accent-text: #6ea4ff;
  --on-accent: #fff;
  --danger: #ff6961;
  --danger-fill: #d70015;
  --ok: #30d158;
  --warn: #ff9f0a;
  --overlay: rgba(0, 0, 0, 0.6);

  --c-blue: #0a84ff; --c-indigo: #5e5ce6; --c-teal: #40c8e0; --c-green: #30d158; --c-orange: #ff9f0a;
  --c-red: #ff453a; --c-pink: #ff375f; --c-purple: #bf5af2; --c-gray: #8e8e93;
}

:root[data-theme="light"] {
  --bg: #f2f2f7;
  --surface: #fff;
  --raised: #f2f2f7;
  --step: rgba(0, 0, 0, 0.05);
  --step-hover: rgba(0, 0, 0, 0.09);
  --hairline: rgba(0, 0, 0, 0.1);
  --text: #111;
  --text-2: #55555a;
  --muted: #6c6c70;
  --accent-text: #0047bb;
  --danger: #c4120a;
  --danger-fill: #d70015;
  --ok: #1f8f3a;
  --overlay: rgba(0, 0, 0, 0.35);

  --c-blue: #007aff; --c-indigo: #5856d6; --c-teal: #1f9cb3; --c-green: #28a745; --c-orange: #e08600;
  --c-red: #e5352b; --c-pink: #e0244a; --c-purple: #a041d1; --c-gray: #8e8e93;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
html[data-theme="light"] { color-scheme: light; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.45 var(--font); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.noscript { padding: 24px; }

/* Поверхности */
.card { background: var(--surface); border-radius: var(--r-lg); }
:root[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }

/* Кнопки */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border: 0; border-radius: var(--r-sm); background: var(--step); color: var(--text); font-weight: 500;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease), opacity 150ms var(--ease);
}
.button:hover { background: var(--step-hover); }
.button:active { transform: scale(0.98); }
.button:disabled { opacity: 0.45; cursor: default; transform: none; }
.button-primary { background: var(--accent); color: var(--on-accent); }
.button-primary:hover { background: var(--accent-hover); }
.button-danger { background: var(--danger-fill); color: #fff; }
.button-danger:hover { background: #e8222f; }
.button-quiet { background: transparent; color: var(--danger); }
.button-quiet:hover { background: var(--step); }
.button-small { min-height: 32px; padding: 0 12px; font-size: 14px; }
.button-wide { width: 100%; }
.icon-button {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--text-2); transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.icon-button:hover { background: var(--step); color: var(--text); }

/* Поля */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field-label { font-size: 13px; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--muted); }
.field-input {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--hairline); border-radius: var(--r-sm);
  background: var(--raised); color: var(--text); transition: border-color 150ms var(--ease);
}
:root[data-theme="light"] .field-input { background: var(--bg); }
.field-input:focus-visible { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 1px var(--accent-text); }
.field-input[readonly], .field-input:disabled { opacity: 0.6; }
.field-input-compact { width: auto; }
.field-textarea { padding: 12px; min-height: 96px; resize: vertical; line-height: 1.45; }
.field-select { min-width: 156px; width: auto; padding-right: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-field { display: flex; align-items: center; gap: 12px; min-height: 32px; }
.check-field input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.form-error { color: var(--danger); font-size: 14px; }
.form-note { color: var(--text-2); font-size: 14px; background: var(--step); padding: 12px; border-radius: var(--r-sm); }
.counter { font-family: var(--mono); font-variant-numeric: tabular-nums; justify-self: end; }
.spacer { flex: 1; }

/* Переключатель */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--step); border-radius: var(--r-sm); }
.segment {
  min-height: 32px; padding: 0 16px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-weight: 500;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.segment[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); }
:root[data-theme="light"] .segment[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

/* Оболочка */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 24px; padding: 24px 12px 16px;
  border-right: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.brand-mark { border-radius: 7px; display: block; }
.brand-name { font-size: 17px; font-weight: 600; }
.brand-tag { font: 500 12px/1 var(--mono); color: var(--muted); padding: 3px 6px; border: 1px solid var(--hairline); border-radius: 6px; }
.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); color: var(--text-2);
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.nav-item:hover { background: var(--step); color: var(--text); }
.nav-item.is-active { background: var(--step); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
:root[data-theme="light"] .nav-item.is-active { box-shadow: none; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.sync { display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 12px; color: var(--muted); min-height: 24px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-dot.is-ok { background: var(--ok); }
.sync-dot.is-bad { background: var(--danger); }
.lock-button {
  display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2); text-align: left;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.lock-button:hover { background: var(--step); color: var(--text); }

.main { padding: 32px 32px 48px; max-width: 1280px; width: 100%; margin: 0 auto; outline: none; }
.view { display: grid; gap: 20px; align-content: start; animation: rise 300ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.view-head h1 { font-size: 28px; line-height: 1.15; font-weight: 600; }
.view-lead { color: var(--text-2); max-width: 60ch; margin-top: -8px; }
.empty { color: var(--muted); text-align: center; padding: 48px 16px; }

/* Планер */
.planner-title { display: grid; gap: 4px; }
.planner-title h1 { text-transform: none; }
.planner-title h1::first-letter { text-transform: uppercase; }
.planner-sub { color: var(--muted); font-size: 13px; }
.planner-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nav-buttons { display: flex; align-items: center; gap: 4px; }
.day-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-pill {
  display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; border: 0; border-radius: var(--r-sm); background: transparent;
  transition: background-color 150ms var(--ease);
}
.day-pill:hover { background: var(--step); }
.day-pill.is-selected { background: var(--surface); box-shadow: inset 0 0 0 1px var(--hairline); }
.day-pill-name { font-size: 12px; color: var(--muted); }
.day-pill-num { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.day-pill.is-today .day-pill-num { color: var(--accent-text); }
.day-pill-dot { width: 4px; height: 4px; border-radius: 50%; background: transparent; }
.day-pill-dot.is-on { background: var(--muted); }

.timeline { overflow: hidden; display: flex; flex-direction: column; }
.tl-head, .tl-allday, .tl-grid { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr)); }
.tl-head { border-bottom: 1px solid var(--hairline); }
.tl-corner { width: 56px; }
.tl-day {
  display: flex; align-items: baseline; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 4px; border: 0;
  background: transparent; color: var(--text-2); border-left: 1px solid var(--hairline); transition: background-color 150ms var(--ease);
}
.tl-day:hover { background: var(--step); }
.tl-day-num { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text); }
.tl-day.is-today .tl-day-num { color: var(--accent-text); }
.tl-allday { border-bottom: 1px solid var(--hairline); }
.tl-allday-label { font-size: 11px; line-height: 1.2; color: var(--muted); padding: 10px 8px 0 0; text-align: right; width: 56px; white-space: nowrap; }
.tl-allday-cell { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 4px; padding: 6px 4px; border-left: 1px solid var(--hairline); min-height: 36px; }
.tl-scroll { overflow-y: auto; max-height: calc(100dvh - 300px); min-height: 360px; position: relative; }
.tl-grid { position: relative; }
.hours { position: relative; }
.hour-label { position: absolute; right: 8px; transform: translateY(-50%); font: 400 11px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.hours .hour-label:first-child { transform: translateY(2px); }
.timeline-col { position: relative; border-left: 1px solid var(--hairline); cursor: cell; }
.hour-line { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--hairline); pointer-events: auto; }
.hour-line::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 56px; }
.now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--danger); pointer-events: none; z-index: 3; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

.event {
  --c: var(--c-gray);
  position: absolute; display: grid; align-content: start; gap: 2px; padding: 4px 8px; overflow: hidden; text-align: left;
  border: 0; border-left: 3px solid var(--c); border-radius: 8px;
  background: color-mix(in srgb, var(--c) 24%, var(--surface)); color: var(--text); z-index: 2; cursor: pointer;
  transition: background-color 150ms var(--ease);
}
.event:hover { background: color-mix(in srgb, var(--c) 34%, var(--surface)); }
.event.is-compact { padding: 2px 6px; }
.event-title { font-size: 13px; font-weight: 500; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.event-time { font: 400 11px/1.2 var(--mono); color: var(--text-2); font-variant-numeric: tabular-nums; }
.chip {
  --c: var(--c-gray);
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-height: 24px; padding: 0 8px; border: 0; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 24%, var(--surface)); color: var(--text); font-size: 12px;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.chip { cursor: pointer; }
.chip-task { background: color-mix(in srgb, var(--c-red) 18%, var(--surface)); color: var(--text); }
.chip-task svg { color: var(--c-red); flex: none; }
.event-blue, .chip-blue, .swatch-blue { --c: var(--c-blue); }
.event-indigo, .chip-indigo, .swatch-indigo { --c: var(--c-indigo); }
.event-teal, .chip-teal, .swatch-teal { --c: var(--c-teal); }
.event-green, .chip-green, .swatch-green { --c: var(--c-green); }
.event-orange, .chip-orange, .swatch-orange { --c: var(--c-orange); }
.event-red, .chip-red, .swatch-red { --c: var(--c-red); }
.event-pink, .chip-pink, .swatch-pink { --c: var(--c-pink); }
.event-purple, .chip-purple, .swatch-purple { --c: var(--c-purple); }
.event-gray, .chip-gray, .swatch-gray, .swatch-auto { --c: var(--c-gray); }

/* Задачи */
.quick-add { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-add .field-input:first-child { flex: 1 1 240px; width: auto; }
.task-groups { display: grid; gap: 24px; }
.task-group { display: grid; gap: 8px; }
.group-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); padding: 0 4px; }
.group-title.is-danger { color: var(--danger); }
.group-count { font: 400 12px/1 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.task-list { overflow: hidden; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 0 16px 0 12px; min-height: 56px; }
.task-row + .task-row { border-top: 1px solid var(--hairline); }
.check {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border: 1.5px solid var(--muted); border-radius: 50%;
  background: transparent; color: var(--on-accent); padding: 0;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.check:hover { border-color: var(--text); }
.check.is-done { background: var(--accent); border-color: var(--accent); }
.is-important .check:not(.is-done) { border-color: var(--danger); }
.task-main { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 10px 0; border: 0; background: transparent; text-align: left; }
.task-title { overflow-wrap: anywhere; }
.is-done .task-title { color: var(--muted); text-decoration: line-through; }
.task-meta { font-size: 13px; color: var(--muted); }
.task-meta.is-overdue { color: var(--danger); }
.task-flag { color: var(--danger); display: grid; }

/* Память */
.memory-grid { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 16px; align-items: start; }
.memory-list { padding: 8px; display: grid; gap: 2px; }
.memory-item {
  position: relative; display: grid; gap: 2px; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--r-sm); background: transparent; text-align: left;
  transition: background-color 150ms var(--ease);
}
.memory-item:hover { background: var(--step); }
.memory-item.is-selected { background: var(--step); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.memory-item-title { font-weight: 500; padding-right: 20px; }
.memory-item-text { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory-pin { position: absolute; right: 12px; top: 12px; color: var(--muted); display: grid; }
.memory-editor { padding: 20px; display: grid; gap: 16px; }
.editor-actions { display: flex; justify-content: flex-start; }

/* Настройки */
.settings { max-width: 720px; }
.settings-group { display: grid; gap: 8px; }
.rows { overflow: hidden; }
.row { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 8px 16px; }
.row + .row { border-top: 1px solid var(--hairline); }
.row-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.row-label { font-weight: 500; }
.row-hint { font-size: 13px; color: var(--muted); }
.row-value { color: var(--text-2); font-size: 14px; text-align: right; overflow-wrap: anywhere; }
.note { display: flex; gap: 16px; padding: 20px; color: var(--text-2); }
.note h2 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.note p { font-size: 14px; max-width: 62ch; }
.note-icon { color: var(--accent-text); flex: none; }

/* Диалог */
.dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.dialog-narrow { width: min(420px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--overlay); }
.dialog[open] { animation: rise 220ms var(--ease) both; display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0 20px; }
.dialog-head h2 { font-size: 17px; font-weight: 600; }
.dialog-body { padding: 16px 20px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 0 20px 20px; }
.dialog-text { color: var(--text-2); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; padding: 0; border: 2px solid transparent; border-radius: 50%; background: var(--c); display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px var(--surface); font: 600 12px/1 var(--font); color: #fff;
  transition: border-color 150ms var(--ease);
}
.swatch-auto { background: transparent; box-shadow: none; border: 1.5px dashed var(--muted); color: var(--muted); }
.swatch[aria-checked="true"] { border-color: var(--text); }
.swatch-auto[aria-checked="true"] { border: 1.5px solid var(--text); color: var(--text); }

/* Вход */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: center; gap: 64px; max-width: 1120px; margin: 0 auto; padding: 48px 32px; }
.login-intro { display: grid; gap: 24px; max-width: 520px; }
.brand-large { padding: 0; }
.brand-large .brand-name { font-size: 20px; }
.login-intro h1 { font-size: 40px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; }
.login-lead { color: var(--text-2); font-size: 17px; line-height: 1.5; }
.login-facts { display: grid; gap: 16px; margin-top: 8px; }
.login-fact { display: flex; gap: 12px; }
.login-fact-icon { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-xs); background: var(--step); color: var(--text-2); }
.login-fact div { display: grid; gap: 2px; }
.login-fact strong { font-weight: 500; }
.login-fact span { color: var(--muted); font-size: 14px; }
.login-card { padding: 32px; display: grid; gap: 20px; }
.login-card h1, .login-card h2 { font-size: 22px; font-weight: 600; }
.login-help { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: calc(100vw - 32px);
  padding: 12px 16px; border-radius: var(--r-sm); background: var(--raised); color: var(--text); font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Телефон и планшет */
@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-bottom: 72px; }
  .sidebar {
    position: fixed; inset: auto 0 0 0; top: auto; height: auto; z-index: 10; flex-direction: row; align-items: center; gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-right: 0; border-top: 1px solid var(--hairline);
  }
  .brand, .sync, .lock-button span { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; flex: 1; }
  .nav-item { flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 0 4px; font-size: 11px; }
  .side-foot { margin: 0; }
  .lock-button { justify-content: center; padding: 0 12px; min-height: 52px; }
  .main { padding: 20px 16px 32px; }
  .view-head h1 { font-size: 24px; }
  .memory-grid { grid-template-columns: minmax(0, 1fr); }
  .tl-scroll { max-height: calc(100dvh - 340px); }
  .timeline.is-week { overflow-x: auto; }
  .timeline.is-week > * { min-width: 760px; }
  .timeline.is-week .tl-scroll { overflow-x: visible; }
  .login { grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 32px 16px; align-content: center; }
  .login-intro h1 { font-size: 30px; }
  .login-card { padding: 24px; }
  .field-row { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .toast { bottom: 88px; }
}

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