/* ============================================================
   Хроника — дизайн-система
   Тёмная «чернильная» тема по умолчанию, светлая «бумага» — опция.
   ============================================================ */

:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #0b0d0f;
  --bg-glow-a: rgba(224, 164, 88, 0.09);
  --bg-glow-b: rgba(111, 179, 168, 0.07);
  --surface: #12161a;
  --surface-2: #171c21;
  --surface-3: #1d232a;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #ece8e1;
  --text-2: #b9b6ae;
  --muted: #7f858c;
  --accent: #e0a458;
  --accent-soft: rgba(224, 164, 88, 0.14);
  --accent-line: rgba(224, 164, 88, 0.35);
  --sage: #74b6a9;
  --sage-soft: rgba(116, 182, 169, 0.13);
  --work: #7f9cf5;
  --work-soft: rgba(127, 156, 245, 0.13);
  --danger: #e2786a;
  --danger-soft: rgba(226, 120, 106, 0.14);
  --ok: #79b98f;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 12px 32px -12px rgba(0, 0, 0, 0.65);
  --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-full: 999px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f5f2ec;
  --bg-glow-a: rgba(180, 118, 42, 0.08);
  --bg-glow-b: rgba(58, 128, 116, 0.06);
  --surface: #fffdf8;
  --surface-2: #f8f4ec;
  --surface-3: #efe9df;
  --line: rgba(30, 26, 20, 0.09);
  --line-strong: rgba(30, 26, 20, 0.18);
  --text: #1d1a15;
  --text-2: #46413a;
  --muted: #7b756c;
  --accent: #a9661d;
  --accent-soft: rgba(169, 102, 29, 0.1);
  --accent-line: rgba(169, 102, 29, 0.3);
  --sage: #35776b;
  --sage-soft: rgba(53, 119, 107, 0.1);
  --work: #3f5bcc;
  --work-soft: rgba(63, 91, 204, 0.09);
  --danger: #b8433a;
  --danger-soft: rgba(184, 67, 58, 0.1);
  --ok: #3f8159;
  --shadow-1: 0 1px 2px rgba(60, 45, 25, 0.08);
  --shadow-2: 0 14px 34px -16px rgba(60, 45, 25, 0.28);
  --shadow-3: 0 26px 60px -24px rgba(60, 45, 25, 0.34);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 560px at 82% -8%, var(--bg-glow-a), transparent 62%),
    radial-gradient(900px 520px at -12% 108%, var(--bg-glow-b), transparent 60%);
  pointer-events: none;
}

::selection { background: var(--accent-soft); color: var(--text); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.012em; }

a { color: inherit; text-decoration: none; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: 0; background: none; }

.ico { width: 16px; height: 16px; flex: 0 0 auto; }

:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- layout */
.app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}

.view {
  width: 100%;
  max-width: 860px;
  min-width: 0;
  margin: 0 auto;
  padding: calc(18px + var(--safe-t)) 18px calc(96px + var(--safe-b));
  animation: view-in 0.34s var(--ease) both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 980px) {
  .app { grid-template-columns: 264px minmax(0, 1fr); }
  .view { padding: 40px 44px 80px; max-width: 900px; }
}

/* ------------------------------------------------------- рабочий стол (≥1240) */
.rail { display: none; }

@media (min-width: 1240px) {
  .plan-section { display: none; }
}

@media (min-width: 1240px) {
  .app { grid-template-columns: 248px minmax(0, 1fr) 296px; }
  .view { max-width: 880px; padding: 36px 34px 72px; }
  .rail {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100dvh;
    overflow-y: auto;
    padding: 34px 20px 40px 6px;
    display: grid;
    gap: 12px;
    align-content: start;
  }
  .rail[hidden] { display: none; }
}

.rail-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow-1); }
.rail-card .card-title { font-size: 11px; }
.rail-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; padding: 3px 0; color: var(--text-2); }
.rail-row .rail-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: 0 0 auto; margin-top: 6px; }
.rail-row.overdue .rail-dot { background: var(--danger); }
.rail-row .rail-days { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.rail-num { display: flex; gap: 14px; align-items: baseline; }
.rail-num b { font-family: var(--font-display); font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.rail-num span { font-size: 11px; color: var(--muted); }
.rail-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rail-links a { font-size: 11.5px; color: var(--accent); }

/* -------------------------------------------------------------- sidebar */
.sidebar { display: none; }

@media (min-width: 980px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 30px 20px;
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100dvh;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 40%);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, var(--accent), #b8763a);
  color: #1a1206;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), var(--shadow-1);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 0.01em;
}

.brand-sub {
  display: block;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1px;
}

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 14.5px;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active .ico { color: var(--accent); }
.nav-item .ico { width: 18px; height: 18px; opacity: 0.9; }

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 6px; }

.streak-pill {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.streak-pill b { color: var(--text); font-weight: 600; }

/* -------------------------------------------------------------- tabbar */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + var(--safe-b));
  z-index: 40;
  display: grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 6px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: var(--shadow-2);
}

@media (min-width: 980px) { .tabbar { display: none; } }

.tab {
  display: grid;
  place-items: center;
  gap: 2px;
  width: 56px;
  padding: 7px 0 6px;
  border-radius: 16px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.01em;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
  white-space: nowrap;
}

.tab .ico { width: 21px; height: 21px; }
.tab.active { color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- header */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head > div:first-child { flex: 1 1 260px; min-width: 0; }

.kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
  font-weight: 500;
}

.display {
  font-family: var(--font-display);
  font-size: clamp(30px, 7.4vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.display em { font-style: italic; color: var(--accent); }

.head-sub { color: var(--text-2); font-size: 14.5px; margin-top: 8px; max-width: 60ch; }

.head-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ---------------------------------------------------------------- button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.14s var(--ease), background 0.18s var(--ease), border-color 0.18s;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active { transform: scale(0.975); }
.btn .ico { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(160deg, var(--accent), #c2813f);
  color: #201505;
  border-color: transparent;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 6px 18px -8px rgba(224, 164, 88, 0.6);
}

.btn-primary:hover { filter: brightness(1.05); background: linear-gradient(160deg, var(--accent), #c2813f); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: var(--r-xs); }

.btn-icon { width: 40px; padding: 0; }

.btn-danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }

.btn:disabled { opacity: 0.45; pointer-events: none; }

/* ------------------------------------------------------------------ card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}

.card + .card { margin-top: 14px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 12px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* --------------------------------------------------------------- composer */
.composer {
  background: linear-gradient(170deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow-1);
  transition: border-color 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.composer:focus-within { border-color: var(--accent-line); box-shadow: var(--shadow-2), 0 0 0 3px var(--accent-soft); }

.composer textarea {
  width: 100%;
  min-height: 52px;
  max-height: 40vh;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16.5px;
  line-height: 1.5;
  padding: 6px 2px;
}

.composer textarea::placeholder { color: var(--muted); }

.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; flex-wrap: wrap; row-gap: 8px; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  border: 1px solid var(--line);
}

.seg-btn {
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s var(--ease);
}

.seg-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.55; }
.seg-btn[data-on="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg-btn[data-on="true"][data-kind="work"] { color: var(--work); }
.seg-btn[data-on="true"][data-kind="personal"] { color: var(--accent); }

.composer-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

@media (max-width: 520px) {
  .composer-actions { gap: 6px; }
  .composer-actions .btn-sm { padding: 0 8px; font-size: 12.5px; height: 30px; }
  .composer-bar .seg-btn { padding: 5px 8px; font-size: 11.5px; }
  .composer-bar .seg-btn .dot { display: none; }
}

.hint { font-size: 11.5px; color: var(--muted); }

@media (max-width: 700px) { #composer-hint { display: none; } }

kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  color: var(--text-2);
}

/* --------------------------------------------------------------- metrics */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 14px 12px;
  display: grid;
  gap: 4px;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.metric:hover { border-color: var(--line-strong); }
.metric-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.metric-value { font-family: var(--font-display); font-size: 25px; line-height: 1.1; letter-spacing: -0.01em; }
.metric-value small { font-family: var(--font-ui); font-size: 12px; color: var(--muted); letter-spacing: 0; }
.metric-bar { height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 5px; }
.metric-bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.5s var(--ease); }
.metric.sage .metric-bar > i { background: var(--sage); }
.metric.work .metric-bar > i { background: var(--work); }

/* ----------------------------------------------------------------- scale */
.scale { display: flex; gap: 4px; align-items: center; flex: 1; }

.scale-row {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
}

.scale-row + .scale-row { border-top: 1px solid var(--line); }

.scale-label {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scale-label b { color: var(--accent); font-family: var(--font-mono); font-size: 12px; margin-left: 4px; }

.scale-dot {
  flex: 1;
  height: 24px;
  border-radius: 7px;
  background: var(--surface-3);
  border: 1px solid transparent;
  transition: all 0.16s var(--ease);
  position: relative;
  min-width: 0;
}

.scale-dot[data-fill="true"] { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 34%, var(--surface-3)), color-mix(in srgb, var(--accent) 20%, var(--surface-3))); }
.scale-dot[data-on="true"] {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 85%, white), var(--accent));
  border-color: transparent;
  box-shadow: 0 0 0 3px var(--accent-soft), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.scale-dot:hover { border-color: var(--line-strong); }
.scale-dot[data-on="true"]:hover { filter: brightness(1.06); }

.scale-num { display: flex; justify-content: space-between; margin-top: 7px; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }

/* --------------------------------------------------------------- entries */
.entries { display: grid; gap: 2px; }

.entry {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  padding: 11px 6px 11px 0;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.entry:last-child { border-bottom: 0; }
.entry::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.5;
}

.entry.work::before { background: var(--work); }
.entry-time { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); padding-top: 3px; letter-spacing: 0.02em; }
.entry-text { font-size: 15.5px; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; padding-right: 26px; }
.entry-text p { margin: 0; }

.entry-text a.wikilink { color: var(--sage); background: var(--sage-soft); padding: 0 4px; border-radius: 5px; }
.entry-text a.wikilink:hover { background: color-mix(in srgb, var(--sage) 24%, transparent); }
.entry-text a.tag { font-size: 13px; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: var(--r-full); }
.entry-text img.embed { margin-top: 6px; max-width: 100%; border-radius: var(--r-sm); border: 1px solid var(--line); }

.entry.editable { cursor: pointer; border-radius: 10px; }
.entry.editable:hover { background: var(--surface-2); }
.entry.editable:active { background: var(--surface-3); }

.entry-edit {
  position: absolute;
  right: 0;
  top: 7px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s var(--ease), background 0.15s, color 0.15s;
}

.entry-edit .ico { width: 14px; height: 14px; }
.entry.editable:hover .entry-edit,
.entry-edit:focus-visible { opacity: 1; }
.entry-edit:hover { background: var(--surface-3); color: var(--accent); }

@media (hover: none) {
  .entry-edit { opacity: 0.5; }
}

.edit-area {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 12px 13px;
  font-size: 15.5px;
  line-height: 1.5;
  font-family: var(--font-ui);
  outline: 0;
  transition: border-color 0.18s;
}

.edit-area:focus { border-color: var(--accent-line); }

.toast { display: inline-flex; align-items: center; gap: 10px; }
.toast > span { white-space: nowrap; }
.toast-btn {
  font-size: 12.5px;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 99px;
  padding: 3px 10px;
  white-space: nowrap;
}

.entry-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--work);
  background: var(--work-soft);
  padding: 2px 7px;
  border-radius: var(--r-full);
  margin-right: 7px;
  vertical-align: 1px;
  font-weight: 600;
}

/* ------------------------------------------------------------------ tasks */
.tasks { display: grid; gap: 2px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 9px 4px;
  border-radius: var(--r-xs);
  font-size: 15px;
  transition: background 0.16s var(--ease);
  cursor: pointer;
}

.task:hover { background: var(--surface-2); }

.task .box {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin-top: 2px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  transition: all 0.18s var(--ease);
  color: transparent;
}

.task .box svg { width: 12px; height: 12px; }
.task.done .box { background: var(--sage); border-color: var(--sage); color: #08110e; }
.task.done .label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--muted); }
.task .label { overflow-wrap: anywhere; }
.task .due { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-left: auto; white-space: nowrap; padding-top: 3px; }

/* ---------------------------------------------------------------- day feed */
.feed { display: grid; gap: 10px; }

.day-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 15px 17px;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s;
}

.day-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }

.day-card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.day-date { font-family: var(--font-display); font-size: 18px; letter-spacing: -0.01em; }
.day-weekday { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.day-tags { margin-left: auto; display: flex; gap: 5px; align-items: center; }

.pill {
  font-size: 11px;
  padding: 2.5px 8px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pill.work { background: var(--work-soft); color: var(--work); }
.pill.mood { background: var(--accent-soft); color: var(--accent); }
.pill.ghost { color: var(--muted); background: transparent; border: 1px dashed var(--line-strong); }

.day-preview { color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.day-summary { color: var(--text); font-size: 14px; font-style: italic; font-family: var(--font-display); margin-bottom: 4px; }

.day-group-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
  font-weight: 600;
}

/* -------------------------------------------------------------------- chat */
.chat-wrap { display: flex; flex-direction: column; height: calc(100dvh - 250px - var(--safe-b)); min-height: 340px; }
@media (min-width: 980px) { .chat-wrap { height: calc(100dvh - 250px); } }

.chat-scroll { flex: 1; overflow-y: auto; padding: 4px 2px 18px; scroll-behavior: smooth; display: flex; flex-direction: column; gap: 14px; }

.msg { max-width: 92%; animation: msg-in 0.3s var(--ease) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; width: 100%; max-width: 100%; }

.msg-bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 15.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.msg.user .msg-bubble { background: var(--accent-soft); border: 1px solid var(--accent-line); border-bottom-right-radius: 7px; }
.msg.assistant .msg-bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 7px; }
.msg.assistant .msg-bubble p:first-child { margin-top: 0; }
.msg.assistant .msg-bubble p:last-child { margin-bottom: 0; }
.msg.assistant .msg-bubble h1, .msg.assistant .msg-bubble h2, .msg.assistant .msg-bubble h3 { font-size: 15px; margin: 14px 0 6px; color: var(--accent); }
.msg.assistant .msg-bubble ul, .msg.assistant .msg-bubble ol { margin: 6px 0; padding-left: 20px; }
.msg.assistant .msg-bubble li { margin: 3px 0; }
.msg.assistant .msg-bubble code { font-family: var(--font-mono); font-size: 13px; background: var(--surface-3); padding: 1.5px 5px; border-radius: 5px; }

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.sources { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }

.source {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-2);
  transition: all 0.16s;
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.source:hover { color: var(--accent); border-color: var(--accent-line); }
.source .ico { width: 11px; height: 11px; }

.chat-input-wrap { border-top: 1px solid var(--line); padding-top: 12px; }

.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 8px 8px 8px 14px;
  transition: border-color 0.2s;
}

.chat-input:focus-within { border-color: var(--accent-line); }
.chat-input textarea {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  max-height: 140px;
  min-height: 26px;
  padding: 5px 0;
  font-size: 15.5px;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #201505;
  transition: transform 0.15s var(--ease), opacity 0.2s;
  flex: 0 0 auto;
}

.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.4; }
.send-btn .ico { width: 17px; height: 17px; }

.suggestions { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }

.chip {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-2);
  transition: all 0.16s var(--ease);
  text-align: left;
}

.chip:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* ------------------------------------------------------------------ stats */
.spark-wrap { position: relative; }
.spark { width: 100%; height: 150px; display: block; overflow: visible; }
.spark .grid-line { stroke: var(--line); stroke-width: 1; }
.spark .area { opacity: 0.16; }
.spark .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .dot { stroke: var(--surface); stroke-width: 2; }
.spark-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.spark-legend span { display: inline-flex; align-items: center; gap: 6px; }
.spark-legend i { width: 9px; height: 3px; border-radius: 2px; display: inline-block; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 96px; }
.bars > div { flex: 1; background: var(--sage-soft); border-radius: 4px 4px 2px 2px; position: relative; min-height: 3px; transition: height 0.5s var(--ease); }
.bars > div > span { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--muted); font-family: var(--font-mono); }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .stat-grid { gap: 12px; } }

.big-stat { display: grid; gap: 3px; padding: 15px 14px; }
.big-stat .num { font-family: var(--font-display); font-size: clamp(20px, 5.6vw, 32px); line-height: 1.05; letter-spacing: -0.02em; }
.big-stat .num small { font-size: 12px; color: var(--muted); font-family: var(--font-ui); letter-spacing: 0; }
.big-stat .cap { font-size: 11.5px; color: var(--muted); line-height: 1.3; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-cloud .tag-pill { font-size: 13px; padding: 4px 11px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.tag-cloud .tag-pill b { color: var(--accent); font-weight: 500; margin-left: 5px; font-size: 11px; }

/* ------------------------------------------------------------------ note */
.prose { font-size: 16px; line-height: 1.68; color: var(--text); }
.prose h1, .prose h2, .prose h3 { font-family: var(--font-display); letter-spacing: -0.015em; margin: 1.5em 0 0.5em; line-height: 1.22; }
.prose h1 { font-size: 26px; }
.prose h2 { font-size: 21px; }
.prose h3 { font-size: 17px; }
.prose p { margin: 0.7em 0; }
.prose ul, .prose ol { margin: 0.7em 0; padding-left: 22px; }
.prose li { margin: 0.28em 0; }
.prose a { color: var(--accent); border-bottom: 1px solid var(--accent-line); }
.prose a.wikilink { color: var(--sage); border-bottom-color: transparent; background: var(--sage-soft); padding: 0 4px; border-radius: 5px; }
.prose a.wikilink:hover { background: color-mix(in srgb, var(--sage) 25%, transparent); }
.prose span.wikilink.missing { color: var(--muted); border-bottom: 1px dashed var(--line-strong); }
.prose .tag { font-size: 13px; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: var(--r-full); white-space: nowrap; }
.prose mark { background: color-mix(in srgb, var(--accent) 26%, transparent); color: var(--text); padding: 0 3px; border-radius: 4px; }
.prose code { font-family: var(--font-mono); font-size: 13.5px; background: var(--surface-3); padding: 2px 6px; border-radius: 5px; }
.prose pre { background: var(--surface-2); border: 1px solid var(--line); padding: 14px; border-radius: var(--r-sm); overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: 13px; }
.prose blockquote { margin: 1em 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--accent-line); color: var(--text-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.prose img.embed { max-width: 100%; border-radius: var(--r-md); border: 1px solid var(--line); }

.prose .callout {
  margin: 14px 0;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  padding: 11px 14px;
}

.prose .callout-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.prose .callout-icon { font-size: 14px; }
.prose .callout-body { margin-top: 6px; color: var(--text-2); font-size: 15px; }
.prose .callout-body p { margin: 4px 0; }
.prose .callout-tip { border-left-color: var(--sage); }
.prose .callout-cash { border-left-color: var(--ok); }
.prose .callout-warning, .prose .callout-danger { border-left-color: var(--danger); }

.prose .ifield { display: flex; gap: 10px; padding: 3px 0; font-size: 14.5px; }
.prose .ifield-key { color: var(--muted); min-width: 110px; }
.prose .ifield-val { color: var(--text); }

.prose .obsidian-block {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  margin: 12px 0;
  background: var(--surface-2);
}

.prose .obsidian-block .ob-ico { color: var(--accent); }
.prose .obsidian-block .ob-note { margin-left: auto; font-size: 11px; opacity: 0.7; }

.prose li.task { list-style: none; display: flex; gap: 9px; align-items: flex-start; margin-left: -22px; }
.prose input.task-box { margin-top: 5px; accent-color: var(--sage); width: 16px; height: 16px; }

.note-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }

/* --------------------------------------------------------------- settings */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.field .desc { font-size: 12.5px; color: var(--muted); }

.input, .select {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  outline: 0;
  transition: border-color 0.18s;
  font-size: 15px;
}

.input:focus, .select:focus { border-color: var(--accent-line); }
.input.mono { font-family: var(--font-mono); font-size: 13.5px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > .input { flex: 1; }

.divider { height: 1px; background: var(--line); margin: 20px 0; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status-dot.off { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.copy-row { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); overflow-x: auto; }

.steps { counter-reset: step; display: grid; gap: 10px; }
.step { display: grid; grid-template-columns: 24px 1fr; gap: 10px; font-size: 14px; color: var(--text-2); }
.step::before {
  counter-increment: step;
  content: counter(step);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
}

/* ------------------------------------------------------------------ misc */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.serif { font-family: var(--font-display); }
.mono { font-family: var(--font-mono); }
.center { text-align: center; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 26px; }
.mb { margin-bottom: 14px; }
.stack { display: grid; gap: 10px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.empty {
  text-align: center;
  padding: 34px 20px;
  color: var(--muted);
  font-size: 14px;
  display: grid;
  gap: 8px;
  place-items: center;
}

.empty .ico { width: 26px; height: 26px; opacity: 0.5; }
.empty b { color: var(--text-2); font-weight: 600; display: block; font-size: 15px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-b));
  transform: translate(-50%, 14px);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--r-full);
  font-size: 13.5px;
  box-shadow: var(--shadow-3);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease);
  z-index: 90;
  max-width: 90vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.err { border-color: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------------ gate */
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 30px 26px;
  box-shadow: var(--shadow-3);
  display: grid;
  gap: 14px;
  animation: view-in 0.5s var(--ease) both;
}

.gate-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(150deg, var(--accent), #b8763a);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 27px;
  color: #1a1206;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.gate h1 { font-family: var(--font-display); font-size: 26px; letter-spacing: -0.02em; }
.gate p { color: var(--muted); font-size: 14px; margin: 0; }

/* --------------------------------------------------------- link suggest */
.link-pop {
  position: static;
  margin: 4px 0 6px;
  z-index: 30;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}

.composer { position: relative; }

.link-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 13px;
  font-size: 14.5px;
  text-align: left;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  transition: background 0.12s;
}

.link-item:last-child { border-bottom: 0; }
.link-item:hover, .link-item.active { background: var(--accent-soft); }
.link-item .li-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-item .li-meta { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.link-item .ico { color: var(--muted); }
.link-item.active .ico { color: var(--accent); }

/* ------------------------------------------------------------- link list */
.link-list { padding: 4px 6px; }

.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--r-xs);
  border-bottom: 1px solid var(--line);
  transition: background 0.14s var(--ease);
}

.link-row:last-child { border-bottom: 0; }
.link-row:hover { background: var(--surface-2); }
.link-row-name { font-size: 15px; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }

.prose span.wikilink.missing { cursor: pointer; }
.prose span.wikilink.missing:hover { color: var(--text); border-bottom-color: var(--accent); }

/* -------------------------------------------------------------- calendar */
.cal-card { padding: 18px 16px 14px; }

.cal-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.cal-month { font-family: var(--font-display); font-size: 20px; letter-spacing: -0.01em; }

.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 6px; }
.cal-week span { text-align: center; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.cal-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.14s var(--ease);
  min-width: 0;
}

.cal-cell:hover { border-color: var(--line-strong); }
.cal-cell:active { transform: scale(0.95); }
.cal-cell.blank { background: transparent; pointer-events: none; }
.cal-cell.has { background: var(--surface-3); }
.cal-cell.today { border-color: var(--accent-line); }
.cal-cell.sel { background: var(--accent-soft); border-color: var(--accent); }

.cal-num { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); line-height: 1; }
.cal-cell.today .cal-num { color: var(--accent); font-weight: 700; }
.cal-cell.sel .cal-num { color: var(--text); }

.cal-marks { display: flex; gap: 3px; align-items: center; height: 9px; }
.m-entry { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; }
.m-entry.work { background: var(--work); }
.m-tasks {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
  background: var(--surface);
  border-radius: 40px;
  padding: 0 4px;
  line-height: 12px;
  display: inline-block;
}

.cal-legend { display: flex; gap: 14px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }

/* --------------------------------------------------------- chat actions */
.act-list { display: grid; gap: 6px; margin-top: 8px; }

.act {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  min-width: 0;
}

.act-ok { border-color: color-mix(in srgb, var(--sage) 34%, var(--line)); }
.act-err { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.act-ico { color: var(--sage); display: grid; place-items: center; flex: 0 0 auto; }
.act-err .act-ico { color: var(--danger); }
.act-body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; gap: 1px; }
.act-body b { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-body span { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-day { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); flex: 0 0 auto; }

.act-undo {
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 99px;
  padding: 3px 8px;
  flex: 0 0 auto;
  transition: background 0.15s;
  white-space: nowrap;
}

.act-undo:hover { background: var(--accent-soft); }
.act-undo.done { color: var(--muted); border-color: var(--line); pointer-events: none; }

/* --------------------------------------------------------- быстрая запись */
body.focus-mode .tabbar,
body.focus-mode .sidebar { display: none; }

body.focus-mode .view { padding-bottom: 32px; }

.quick { max-width: 560px; margin: 0 auto; display: grid; gap: 18px; }
@media (min-width: 980px) { .quick { margin-top: 8vh; } }

.quick-head .display { margin-bottom: 0; }

.quick-form { display: grid; gap: 12px; }

.quick-form textarea {
  width: 100%;
  min-height: 140px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 16px 18px;
  font-size: 18px;
  line-height: 1.5;
  font-family: var(--font-ui);
  outline: 0;
  box-shadow: var(--shadow-1);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.quick-form textarea:focus {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-2), 0 0 0 3px var(--accent-soft);
}

/* ----------------------------------------------------------- quick chips */
.quick-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }

.qchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-2);
  transition: color 0.16s var(--ease), border-color 0.16s, background 0.16s;
}

.qchip:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.qchip.work { color: var(--work); border-color: color-mix(in srgb, var(--work) 32%, var(--line)); background: var(--work-soft); }
.qchip .qdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.75; }
.qchip:disabled { opacity: 0.5; }

.metric.editable { cursor: pointer; }
.metric.editable:hover { border-color: var(--line-strong); }
.metric.editable .metric-label b { color: var(--muted); font-weight: 400; opacity: 0.55; font-size: 10px; }
.metric.editable:hover .metric-label b { color: var(--accent); opacity: 1; }
.metric[data-metric="price"] .metric-bar { display: none; }

@media (max-width: 619px) {
  .metric[data-metric="price"] { grid-column: 1 / -1; }
}

.debt-move {
  margin-left: 6px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.debt-move:hover { color: var(--accent); border-color: var(--accent-line); }

.report-box {
  max-height: 46vh;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 14px;
  color: var(--text-2);
}

.day-weather { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.day-weather .ico { width: 14px; height: 14px; color: var(--accent); }

.memory-card .card-head { margin-bottom: 10px; }
.memory-item + .memory-item { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.memory-title { font-size: 13px; color: var(--accent); }
.memory-summary { font-size: 13.5px; font-style: italic; color: var(--text-2); margin-top: 4px; }
.memory-entries { font-size: 13px; color: var(--text-2); margin-top: 5px; display: grid; gap: 3px; }

.entity-day + .entity-day { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.entity-date { font-size: 12.5px; color: var(--muted); font-family: var(--font-mono); display: inline-block; margin-bottom: 6px; }

/* ---------------------------------------------------------------- sheets */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 60;
  opacity: 0;
  transition: opacity 0.24s var(--ease);
}

.sheet-backdrop.show { opacity: 1; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: min(560px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(24px + var(--safe-b));
  z-index: 70;
  transition: transform 0.34s var(--ease);
  box-shadow: var(--shadow-3);
}

.sheet.show { transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; transform: translate(-50%, -46%) scale(0.98); border-radius: 24px; border-bottom: 1px solid var(--line); max-height: 84vh; }
  .sheet.show { transform: translate(-50%, -50%) scale(1); }
}

.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 16px; }
.sheet h2 { font-family: var(--font-display); font-size: 21px; margin-bottom: 4px; }
.sheet-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

/* ------------------------------------------------------------- nav drawer */
@media (max-width: 979px) {
  .page-head .head-actions .btn.collapse-label span { display: none; }
  .page-head .head-actions .btn.collapse-label { width: 40px; padding: 0; }
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ------------------------------------------------------------------ неделя */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
}

.week-day {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 9px 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}

.week-day:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.week-day .wd { font-size: 10px; color: var(--muted); }
.week-day .track { display: flex; align-items: flex-end; width: 10px; height: 54px; border-radius: 6px; background: var(--sage-soft); overflow: hidden; }
.week-day .track i { display: block; width: 100%; border-radius: 6px; background: var(--accent); transition: height 0.4s var(--ease); }
.week-day .wn { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.week-day.blank .track { background: transparent; border: 1px dashed var(--line); }
.week-day.blank .wn { color: var(--muted); }
.week-day.today { border-color: var(--accent-line); background: var(--accent-soft); }
.task.stale .due { color: var(--accent); }

.btn-icon { padding: 0; width: 34px; height: 34px; display: grid; place-items: center; }
.btn-icon .ico { width: 16px; height: 16px; }
[data-week-shift^="-"] .ico { transform: rotate(180deg); }
.head-sub b { color: var(--text-2); font-weight: 500; }

.week-review {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
}

.week-review > .tiny { margin-bottom: 6px; }
.week-review p { margin: 0.55em 0; }
.week-review ul, .week-review ol { margin: 0.55em 0; padding-left: 20px; }

/* офлайн-пометка */
.offline-chip {
  position: fixed;
  top: calc(10px + var(--safe-t));
  right: 12px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--muted);
  font-size: 11.5px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-1);
  pointer-events: none;
}

.offline-chip .ico { width: 13px; height: 13px; }
.offline-chip[hidden] { display: none; }

/* ------------------------------------------------------------------ объекты */
.obj-row .link-row-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.obj-kind {
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: lowercase;
}

.obj-kind.object { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.obj-kind.person { color: var(--sage); background: var(--sage-soft); border-color: transparent; }
.obj-tasks { font-size: 11px; color: var(--accent); }
#objects-kinds .seg-btn b { color: var(--accent); font-weight: 500; margin-left: 5px; font-size: 11px; }

.obj-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.obj-photo { display: block; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.obj-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --------------------------------------------------------------- план дня */
.plan-card { padding: 16px 18px; }
.plan-block + .plan-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.plan-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.plan-label a { color: var(--accent); }
.plan-yesterday { font-size: 13.5px; color: var(--text-2); line-height: 1.5; display: grid; gap: 2px; }
.plan-yesterday div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip.on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.chip .ico { width: 13px; height: 13px; }

/* голос и раскладка */
.btn.rec { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); animation: rec-pulse 1.4s infinite; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.parse-list { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; }
.parse-row { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; line-height: 1.45; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; }
.parse-row .obj-kind { flex: 0 0 auto; margin-top: 2px; }
