:root {
  /* palette — Notion paper */
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F7F6F3;
  --hover: #EFEEEC;
  --ink: #37352F;
  --ink-soft: #5A584F;
  --muted: #9B9A93;
  --muted-soft: #BFBEB7;
  --rule: rgba(55, 53, 47, 0.09);
  --rule-strong: rgba(55, 53, 47, 0.16);
  --accent: #2383E2;
  --danger: #C8483B;

  /* legacy aliases (still used elsewhere in this file) */
  --border: var(--rule);
  --text: var(--ink);

  /* density / layout */
  --side-w: 248px;
  --pad-x: 32px;
  --pad-y: 18px;
  --side-item-h: 28px;
  --row-h: 116px;

  /* type */
  --display: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: 'DM Serif Display', 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --t-display-xl: 56px;
  --t-display: 32px;
  --t-display-sm: 22px;
  --t-h1: 22px;
  --t-h2: 16px;
  --t-body: 14px;
  --t-small: 12px;
  --t-micro: 11px;

  --radius: 6px;
  --radius-sm: 4px;
}

body.dark, [data-theme="noir"] {
  --bg: #191919;
  --surface: #1F1F1F;
  --surface-2: #2A2A2A;
  --hover: #2F2F2F;
  --ink: #E6E6E5;
  --ink-soft: #B8B8B5;
  --muted: #8B8B85;
  --muted-soft: #5A5A55;
  --rule: rgba(255, 255, 255, 0.07);
  --rule-strong: rgba(255, 255, 255, 0.13);
  --accent: #5BA0E0;
  --danger: #E66F61;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }

/* ── LOGIN (two-pane) ── */
.login-screen, .login {
  position: fixed; inset: 0; background: var(--bg);
  z-index: 200;
  display: grid; grid-template-columns: 1fr 1fr;
}
.login-art {
  background: var(--surface-2);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 36px;
}
.login-mast {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted);
  letter-spacing: 0.04em;
}
.login-logo-big {
  display: flex; flex-direction: column; align-items: flex-start; gap: 24px;
}
.login-logo-mark {
  width: 140px; height: 140px;
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
body.dark .login-logo-mark { filter: invert(1); }
.login-logo-name {
  font-size: 38px; line-height: 1;
  letter-spacing: -0.02em; font-weight: 600;
  color: var(--ink);
  font-family: var(--display);
}
.login-logo-tag {
  font-size: 13px; color: var(--muted);
  max-width: 320px; line-height: 1.5;
  margin-top: 8px;
}
.login-foot {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted);
}

.login-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 36px;
}
.login-form { width: 100%; max-width: 360px; }
.modal-eyebrow {
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 12px;
}
.login-form-h {
  font-size: 32px; line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 6px; font-weight: 700;
  color: var(--ink);
  font-family: var(--display);
}
.login-sub {
  font-size: 14px; color: var(--muted);
  margin-bottom: 28px; line-height: 1.5;
}

.modal-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .login-field label {
  font-size: 12px; font-weight: 500;
  letter-spacing: 0; text-transform: none;
  color: var(--muted);
}
.field input, .field select,
.login-field input {
  padding: 8px 10px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  outline: none;
  transition: border-color .1s, box-shadow .1s;
}
.field input:focus, .field select:focus,
.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(35,131,226,0.18);
}
.field input::placeholder,
.login-field input::placeholder { color: var(--muted); }
.login-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 0; }
.login-error {
  font-size: 12px; color: var(--danger);
  min-height: 18px;
}
.btn-primary {
  width: 100%; padding: 10px 14px;
  background: var(--ink); color: var(--bg);
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-enter { /* alias kept */
  width: 100%; padding: 10px 14px;
  background: var(--ink); color: var(--bg);
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn-enter:hover { filter: brightness(1.05); }

@media (max-width: 760px) {
  .login-screen, .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}

/* ── APP SHELL ── */
.app {
  display: grid;
  grid-template-columns: var(--side-w, 248px) 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.app.sidebar-hidden { grid-template-columns: 0 1fr; }
.app.sidebar-hidden .sidebar { width: 0; padding: 0; border-right-color: transparent; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  background: var(--surface-2, #F7F6F3);
  border-right: 1px solid var(--rule, rgba(55,53,47,0.09));
  padding: 12px 8px;
  display: flex; flex-direction: column; gap: 4px;
  overflow-x: hidden;
  transition: width 0.2s ease, padding 0.2s ease, border-color 0.2s ease;
  min-width: 0;
}
#sidebar-body { flex: 1; overflow-y: auto; min-height: 0; }
.side-foot {
  flex-shrink: 0;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--rule, rgba(55,53,47,0.09));
}
.side-foot-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--radius, 6px);
  cursor: default;
}
.side-foot-user:hover { background: var(--hover, #EFEEEC); }
.side-foot-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.side-foot-info { min-width: 0; flex: 1; }
.side-foot-name {
  font-size: 13px; font-weight: 500; color: var(--ink, #37352F);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.side-foot-role {
  font-size: 11px; color: var(--muted, #9B9A93);
  line-height: 1.2; margin-top: 1px;
}

.brand {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius, 6px);
  cursor: pointer; flex-shrink: 0;
}
.brand:hover { background: var(--hover, #EFEEEC); }
.brand .logo-mark {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--ink, #37352F);
  display: inline-block; flex-shrink: 0;
}
.brand-name {
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink, #37352F);
  white-space: nowrap;
}
.brand-name .it { font-weight: 400; color: var(--muted, #9B9A93); font-style: normal; }

/* keep old .logo for any leftover */
.logo { display: none; }

.sidebar-section, .side-section { display: flex; flex-direction: column; gap: 1px; margin-top: 8px; }
.sidebar-section h4, .side-section h4 {
  padding: 6px 10px 4px;
  font-size: 11px; letter-spacing: 0.02em;
  color: var(--muted, #9B9A93);
  font-weight: 600;
  text-transform: none;
  margin: 0;
  display: flex; align-items: center; justify-content: space-between;
}
.model-list { display: flex; flex-direction: column; gap: 0; }
.model-item {
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px;
  height: var(--side-item-h, 28px);
  border: none; background: transparent;
  text-align: left; width: 100%;
  font-size: 14px; color: var(--ink-soft, #5A584F);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: background .08s;
  white-space: nowrap; overflow: hidden;
}
.model-item:hover { background: var(--hover, #EFEEEC); }
.model-item.active { background: var(--hover, #EFEEEC); color: var(--ink, #37352F); font-weight: 500; }
.model-dot {
  width: 10px; height: 10px; border-radius: 3px;
  flex-shrink: 0;
}
.view-count {
  margin-left: auto;
  font-size: 12px; color: var(--muted, #9B9A93);
  font-variant-numeric: tabular-nums;
  background: transparent; padding: 0 4px; border-radius: 0;
}

.model-profile {
  display: flex; flex-direction: column;
  gap: 8px; padding: 10px;
  margin: 4px 4px 8px;
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--rule, rgba(55,53,47,0.09));
  border-radius: var(--radius, 6px);
}
.model-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans, 'Inter', sans-serif);
  font-size: 13px; font-weight: 600; color: #fff;
}
.model-profile-name {
  font-family: var(--sans, 'Inter', sans-serif);
  font-size: 14px; font-weight: 600; line-height: 1.2;
  color: var(--ink, #37352F);
}
.model-stats { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.model-stat {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--ink-soft, #5A584F);
}
.model-stat-label { color: var(--muted, #9B9A93); }
.model-stat-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.upcoming-list { display: flex; flex-direction: column; gap: 2px; padding: 0 4px; }
.upcoming-item {
  padding: 6px 8px; border-radius: var(--radius-sm, 4px);
  background: transparent;
  border-left: 2px solid var(--rule-strong, rgba(55,53,47,0.16));
}
.upcoming-item-date {
  font-size: 11px; color: var(--muted, #9B9A93);
  margin-bottom: 2px; font-variant-numeric: tabular-nums;
}
.upcoming-item-title { font-size: 12px; font-weight: 500; color: var(--ink, #37352F); }

/* ── MAIN ── */
.main {
  display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
  position: relative;
  background: var(--bg, #FFFFFF);
}

/* ── TOPBAR (crumb row) ── */
.topbar {
  display: flex; align-items: center;
  padding: 8px var(--pad-x, 24px);
  border-bottom: 1px solid var(--rule, rgba(55,53,47,0.09));
  gap: 8px; min-height: 44px;
  background: var(--bg, #FFFFFF);
  flex-shrink: 0;
}
.topbar-crumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted, #9B9A93);
  flex-shrink: 0;
}
.topbar-crumb .it {
  font-weight: 600; color: var(--ink, #37352F);
  padding: 3px 6px; border-radius: var(--radius-sm, 4px);
  cursor: pointer;
}
.topbar-crumb .it:hover { background: var(--hover, #EFEEEC); }
.topbar-crumb .sep { color: var(--muted-soft, #BFBEB7); }
.topbar-spacer { flex: 1; }

.tb-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--ink-soft, #5A584F);
  border-radius: var(--radius-sm, 4px);
  display: inline-flex; align-items: center;
  gap: 4px; height: 28px;
  cursor: pointer;
  font-family: inherit;
}
.tb-btn:hover { background: var(--hover, #EFEEEC); color: var(--ink, #37352F); }
.tb-btn.icon { padding: 4px 6px; width: 28px; justify-content: center; }
.hamburger-btn { font-size: 15px; }

/* legacy topbar-btn alias */
.topbar-btn {
  background: transparent; border: 1px solid transparent;
  padding: 4px 8px; font-size: 13px;
  color: var(--ink-soft, #5A584F);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer; height: 28px;
  font-family: inherit;
}
.topbar-btn:hover { background: var(--hover, #EFEEEC); color: var(--ink, #37352F); }

/* search */
.search-input {
  border: 1px solid var(--rule-strong, rgba(55,53,47,0.16));
  background: var(--bg, #FFFFFF);
  padding: 4px 10px;
  font-family: inherit; font-size: 13px;
  color: var(--ink, #37352F);
  width: 200px; height: 28px;
  outline: none; border-radius: var(--radius-sm, 4px);
}
.search-input:focus { border-color: var(--accent, #2383E2); }
.search-input::placeholder { color: var(--muted, #9B9A93); }

.user-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted, #9B9A93);
  padding: 0 6px;
}
.user-badge-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ── PAGE HEAD (title row) ── */
.page-head {
  padding: 28px var(--pad-x, 24px) 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-shrink: 0;
}
.page-head-l { display: flex; flex-direction: column; gap: 6px; }
.page-head-title { display: flex; align-items: center; gap: 12px; }
.page-head-title h1 {
  font-family: var(--display, 'Inter', sans-serif);
  font-size: var(--t-display, 32px);
  font-weight: 700; line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink, #37352F);
  margin: 0;
  cursor: pointer;
}
.page-head-title h1:hover { color: var(--ink-soft, #5A584F); }
[data-type="editorial"] .page-head-title h1 { font-weight: 400; }

.month-nav { display: flex; gap: 2px; align-items: center; margin-left: 4px; }
.icon-btn {
  width: 28px; height: 28px; border: none;
  background: transparent;
  border-radius: var(--radius-sm, 4px);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-soft, #5A584F);
  font-size: 14px; cursor: pointer;
  font-family: inherit;
}
.icon-btn:hover { background: var(--hover, #EFEEEC); color: var(--ink, #37352F); }
.nav-btn { /* legacy */
  width: 28px; height: 28px; border-radius: var(--radius-sm, 4px);
  border: none; background: transparent;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-soft, #5A584F); font-size: 14px; line-height: 1;
}
.nav-btn:hover { background: var(--hover, #EFEEEC); color: var(--ink, #37352F); }
.today-btn {
  border: 1px solid var(--rule-strong, rgba(55,53,47,0.16));
  background: var(--bg, #FFFFFF);
  padding: 4px 10px; font-size: 12px;
  color: var(--ink-soft, #5A584F);
  border-radius: var(--radius-sm, 4px);
  font-weight: 500; height: 28px;
  cursor: pointer; font-family: inherit;
}
.today-btn:hover { background: var(--hover, #EFEEEC); color: var(--ink, #37352F); }

/* Hide calendar-only sidebar sections (Вид/Статус) when not in calendar mode */
body.mode-db .sb-cal-only,
body.mode-wiki .sb-cal-only { display: none !important; }

/* ── VIEW TOGGLE (tabs) ── */
.view-toggle {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--rule, rgba(55,53,47,0.09));
  padding: 0 var(--pad-x, 24px);
  margin-top: 8px;
  background: transparent;
  border-radius: 0;
  flex-shrink: 0;
}
.view-toggle button, .vt-btn {
  border: none; background: transparent;
  padding: 8px 12px; font-size: 13px;
  color: var(--muted, #9B9A93);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; font-family: inherit;
  white-space: nowrap;
  box-shadow: none; border-radius: 0;
}
.view-toggle button .ic, .vt-btn .ic { font-size: 13px; color: var(--muted, #9B9A93); }
.view-toggle button.active, .vt-btn.active {
  color: var(--ink, #37352F);
  border-color: var(--ink, #37352F);
  background: transparent;
  box-shadow: none;
  font-weight: 600;
}
.view-toggle button.active .ic, .vt-btn.active .ic { color: var(--ink, #37352F); }
.view-toggle button:not(.active):hover, .vt-btn:not(.active):hover { color: var(--ink-soft, #5A584F); }

body[data-role="model"] #vt-list,
body[data-role="model"] #vt-year,
body[data-role="model"] #vt-kanban,
body[data-role="model"] #vt-timeline { display: none !important; }

/* ── CONTENT AREA ── */
.content-area { flex: 1; display: flex; overflow: hidden; }
.views-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── MONTH VIEW ── */
.cal-container {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 0 var(--pad-x) var(--pad-x);
  background: var(--bg);
}
.day-headers {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10; flex-shrink: 0;
}
.day-header {
  padding: 8px 10px; text-align: left;
  font-size: 12px; font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  border-right: 1px solid var(--rule);
}
.day-header:last-child { border-right: none; }

/* Week-row grid */
.cal-grid {
  display: flex; flex-direction: column; flex: 1;
  border-left: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
}

.cal-week {
  display: grid; grid-template-columns: repeat(7, 1fr);
  position: relative;
}

/* ── Multi-day bars overlay (month view) ── */
.cal-bars {
  position: absolute;
  left: 0; right: 0;
  pointer-events: none;
  z-index: 4;
  padding: 0 2px;
}
.cal-bar {
  position: absolute;
  pointer-events: auto;
  display: flex; align-items: center; gap: 5px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
  box-shadow: none;
  transition: filter 0.12s;
}
.cal-bar:hover { filter: brightness(0.97); }
.cal-bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cell-bars-spacer { flex-shrink: 0; pointer-events: none; }

.day-cell {
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 6px 8px 8px;
  cursor: pointer;
  background: var(--bg);
  transition: background .08s;
  display: flex; flex-direction: column; gap: 2px;
  min-height: var(--row-h, 116px);
  position: relative;
}
.day-cell:hover { background: var(--surface-2); }
.day-cell.other-month { background: var(--surface-2); }
.day-cell.other-month .day-num { color: var(--muted-soft); }
.day-cell.selected { background: var(--hover); }

.day-num {
  font-size: 13px; color: var(--ink-soft);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: space-between;
  gap: 5px; height: 22px;
  margin-bottom: 2px;
}
.today-badge {
  width: 22px; height: 22px;
  background: var(--accent); color: #fff;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.day-add-btn {
  width: 20px; height: 20px; border-radius: var(--radius-sm);
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--muted); line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .1s, background .1s; flex-shrink: 0;
  font-family: inherit;
}
.day-cell:hover .day-add-btn { opacity: 1; }
.day-add-btn:hover { background: var(--hover); color: var(--ink); }

/* ── Drag & drop ── */
.ev-card[draggable="true"],
.week-event[draggable="true"] { cursor: grab; }
.ev-card.dragging,
.week-event.dragging { opacity: 0.35; }
.day-cell.drag-over,
.week-col-body.drag-over {
  background: rgba(55,53,47,0.04) !important;
  outline: 2px dashed rgba(55,53,47,0.18);
  outline-offset: -3px;
}
body.dark .day-cell.drag-over,
body.dark .week-col-body.drag-over {
  background: rgba(255,255,255,0.05) !important;
  outline-color: rgba(255,255,255,0.18);
}

/* ── Event resize handle ── */
.ev-resize-handle {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 8px;
  cursor: ew-resize;
  opacity: 0;
  background: transparent;
  z-index: 3;
  transition: opacity .12s, background .12s;
}
.ev-card:hover > .ev-resize-handle,
.wk-allday-bar:hover > .ev-resize-handle { opacity: 1; }
.ev-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%; right: 2px;
  width: 3px; height: 14px;
  margin-top: -7px;
  border-radius: 2px;
  background: var(--rule-strong);
}
.ev-resize-handle:hover { background: rgba(35,131,226,0.10); }
.ev-resize-handle:hover::after { background: var(--accent); }
.ev-resize-handle-bar { width: 6px; }
.ev-resize-handle-bar::after { height: 10px; margin-top: -5px; }
body.resizing-ev,
body.resizing-ev * { cursor: ew-resize !important; user-select: none; }
.day-cell.resize-target,
.wk-col.resize-target {
  background: rgba(35,131,226,0.10) !important;
  outline: 2px dashed var(--accent);
  outline-offset: -3px;
}
body.dark .day-cell.resize-target,
body.dark .wk-col.resize-target {
  background: rgba(80,160,255,0.14) !important;
}

/* ── Event card (flow layout inside day cell) ── */
.ev-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  overflow: hidden; box-sizing: border-box;
  cursor: pointer; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 2px;
  box-shadow: none;
  transition: background .08s, border-color .08s;
}
.ev-card:hover { background: var(--hover); border-color: var(--rule-strong); }
.ev-card.ev-multiday { border-style: dashed; }

/* ── Date range tag for multi-day events ── */
.ev-date-range {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Shared inner content ── */
.ev-title {
  font-size: 12px; font-weight: 500; color: var(--ink);
  display: flex; align-items: center; gap: 4px;
  overflow: hidden; line-height: 1.3;
}
.ev-page-icon { font-size: 11px; opacity: 0.4; flex-shrink: 0; line-height: 1; }
.ev-title-main {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.ev-model-prefix { font-weight: 400; color: var(--muted); font-size: 11px; }
.ev-title-dot { color: var(--muted-soft); font-weight: 400; }

.ev-status-row {
  display: flex; align-items: center;
  overflow: hidden;
}
.ev-status-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500;
  white-space: nowrap; overflow: hidden; max-width: 100%;
}
.ev-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ev-status-lbl {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ev-agencies {
  display: flex; gap: 3px; flex-wrap: nowrap;
  overflow: hidden;
}
.ev-agency {
  font-size: 11px; color: var(--ink-soft);
  background: var(--surface-2);
  padding: 1px 6px; border-radius: var(--radius-sm);
  white-space: nowrap; max-width: 100px;
  overflow: hidden; text-overflow: ellipsis; flex-shrink: 0;
}

.ev-jobrow { overflow: hidden; }
.ev-job-chip {
  font-size: 11px; font-weight: 400;
  background: var(--surface-2); color: var(--ink-soft);
  padding: 1px 6px; border-radius: var(--radius-sm);
  white-space: nowrap; display: inline-block;
}


/* ── TIMELINE VIEW ── */
.timeline-container { flex: 1; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.tl-wrap { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

/* Header */
.tl-head-row {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.tl-corner {
  flex-shrink: 0;
  border-right: 1px solid var(--rule);
  background: var(--bg);
}
.tl-head-outer { flex: 1; overflow: hidden; }
.tl-head-inner { display: flex; }
.tl-day-hd {
  flex-shrink: 0; text-align: center;
  border-right: 1px solid var(--rule);
  padding: 10px 2px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tl-day-hd.tl-we { background: var(--surface-2); }
.tl-day-hd.tl-tod-hd { background: transparent; }
.tl-dnum { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }
.tl-dnum.tl-tod-num {
  background: var(--accent); color: #fff;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.tl-day-hd small {
  font-size: 10px; color: var(--muted);
  letter-spacing: 0; text-transform: none;
}
.tl-day-hd.tl-tod-hd small { color: var(--accent); }

/* Body */
.tl-body-row { display: flex; flex: 1; overflow: hidden; }
.tl-name-col {
  flex-shrink: 0; overflow: hidden;
  border-right: 1px solid var(--rule);
  background: var(--bg);
}
.tl-name-cell {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--rule);
}
.tl-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 11px;
  font-weight: 600; color: #fff;
}
.tl-name-txt {
  font-size: 13px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Events area */
.tl-ev-outer { flex: 1; overflow: auto; }
.tl-ev-row { position: relative; border-bottom: 1px solid var(--rule); flex-shrink: 0; }
.tl-bg-col {
  position: absolute; top: 0; bottom: 0;
  border-right: 1px solid var(--rule);
}
.tl-bg-col.tl-we-bg { background: var(--surface-2); }
.tl-bg-col.tl-tod-bg {
  background: transparent;
  border-left: 2px solid var(--accent);
}

/* Event bars */
.tl-ev-bar {
  position: absolute; border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px; font-weight: 500;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: grab; user-select: none;
  transition: filter 0.15s;
}
.tl-ev-bar:hover { filter: brightness(0.92); }
.tl-ev-bar:active { cursor: grabbing; }

/* ── KANBAN VIEW ── */
.kanban-container {
  flex: 1; overflow-x: auto; overflow-y: hidden;
  background: var(--bg);
}
.kanban-board {
  display: flex; gap: 12px;
  padding: 0 var(--pad-x) var(--pad-x);
  height: 100%;
  align-items: flex-start; min-width: min-content;
  box-sizing: border-box;
}
.kb-col {
  width: 280px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: none;
  max-height: 100%; overflow: hidden;
  padding: 10px;
  gap: 6px;
}
.kb-col-header {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 6px; flex-shrink: 0;
}
.kb-col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kb-col-title { font-size: 13px; font-weight: 600; flex: 1; color: var(--ink); }
.kb-col-count {
  font-size: 12px; color: var(--muted);
  background: transparent; padding: 0; border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.kb-col-body {
  flex: 1; overflow-y: auto;
  padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 80px;
}
.kb-col-body.drag-over {
  background: var(--hover);
  outline: 2px dashed var(--rule-strong); outline-offset: -4px;
  border-radius: var(--radius-sm);
}
.kb-card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: grab;
  transition: border-color .12s, box-shadow .12s;
  flex-shrink: 0;
  position: relative;
}
.kb-card-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
  line-height: 1;
}
.kb-card:hover .kb-card-del { opacity: 1; }
.kb-card-del:hover { background: var(--danger, #FEE2E2); color: #991B1B; }
.kb-card:hover { border-color: var(--rule-strong); box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.kb-card.dragging { opacity: 0.35; }
.kb-card-title {
  font-size: 13px; font-weight: 500; color: var(--ink);
  margin-bottom: 5px; line-height: 1.35;
}
.kb-card-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.kb-card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.kb-empty { font-size: 12px; color: var(--muted); padding: 8px 4px; text-align: center; }

/* ── YEAR VIEW ── */
.year-container {
  flex: 1; overflow-y: auto;
  padding: 0 var(--pad-x) var(--pad-x);
  background: var(--bg);
}
.year-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}
.year-month {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.year-month:hover { border-color: var(--rule-strong); background: var(--surface-2); }
.year-month-title {
  font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--ink); margin-bottom: 10px;
}
.year-mini-headers {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.year-mini-headers span {
  text-align: center; font-size: 10px; font-weight: 500;
  color: var(--muted); text-transform: none; letter-spacing: 0;
}
.year-mini-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.year-day {
  text-align: center; font-size: 10px; color: var(--muted);
  padding: 2px 0; line-height: 1.7; border-radius: 3px;
  position: relative;
  font-variant-numeric: tabular-nums;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
}
.year-day.today {
  background: var(--accent); color: #fff;
  font-weight: 600;
}
.year-day.has-ev { color: var(--ink); font-weight: 500; }
.year-day.has-ev::after {
  content: ''; position: absolute;
  bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--dot, var(--accent));
}
.year-day.today.has-ev::after { background: #fff; }

/* ── WEEK VIEW ── */
.week-container {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 0 var(--pad-x) var(--pad-x);
  background: var(--bg);
}
.wk-inner { display: flex; flex-direction: column; min-height: 100%; }

.wk-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky; top: 0; z-index: 6;
}
.wk-day-hd {
  padding: 10px 12px 8px; text-align: left;
  border-right: 1px solid var(--rule);
}
.wk-day-hd:last-child { border-right: none; }
.wk-today-hd { background: transparent; }
.wk-hd-name {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0; text-transform: none;
  color: var(--muted); margin-bottom: 4px;
}
.wk-today-hd .wk-hd-name { color: var(--accent); }
.wk-hd-date { margin-bottom: 5px; line-height: 1; }
.wk-date-num {
  font-size: 18px; font-weight: 600;
  font-family: inherit; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.wk-today-hd .wk-date-num { color: var(--accent); }
.wk-today-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; font-size: 13px;
  background: var(--accent); color: #fff; border-radius: 50%;
  font-weight: 700;
}
.wk-hd-meta {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 5px; min-height: 20px;
}
.wk-count {
  font-size: 11px; color: var(--muted);
  background: transparent; padding: 0; border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.wk-day-hd:hover .day-add-btn { opacity: 1 !important; }

/* Multi-day (all-day) bar row */
.wk-allday {
  position: relative; flex-shrink: 0;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  overflow: hidden;
}
.wk-allday-bar {
  position: absolute; border-radius: var(--radius-sm);
  padding: 3px 8px; font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; display: flex; align-items: center; gap: 5px;
  box-shadow: none;
  transition: filter 0.12s;
}
.wk-allday-bar:hover { filter: brightness(0.97); }
.wk-allday-bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.wk-allday-bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* Single-day columns */
.wk-body {
  display: grid; grid-template-columns: repeat(7, 1fr);
  flex: 1;
  border-left: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
}
.wk-col {
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 6px 5px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  min-height: 160px; transition: background .08s;
  background: var(--bg);
}
.wk-col:hover { background: var(--surface-2); }
.wk-today-col { background: transparent; }
.wk-today-col:hover { background: var(--surface-2); }

/* ── LIST VIEW ── */
.list-container {
  flex: 1; overflow-y: auto;
  padding: 0 var(--pad-x) 80px;
  background: var(--bg);
}
#list-body { max-width: 1100px; }
.list-group { margin-bottom: 36px; }
.list-group-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--rule);
}
.list-group-dot {
  width: 10px; height: 10px; border-radius: 3px;
  flex-shrink: 0;
}
.list-group-name {
  font-family: var(--display);
  font-size: 18px; font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.list-group-count {
  font-size: 12px; color: var(--muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.list-item {
  display: flex; align-items: center; gap: 16px;
  padding: 8px;
  border-bottom: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  margin: 0 -8px;
  cursor: pointer;
  transition: background .08s;
}
.list-item:hover { background: var(--surface-2); }
.list-item:last-child { border-bottom: none; }
.list-item-date {
  width: 110px; font-size: 13px; font-weight: 500;
  color: var(--ink); flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.list-item-title { font-size: 14px; color: var(--ink); flex: 1; }
.list-item-badge {
  padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--ink-soft);
}
.list-item-del {
  padding: 3px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--rule); background: transparent;
  cursor: pointer; font-size: 11px; color: var(--muted);
  transition: all 0.15s; opacity: 0;
}
.list-item:hover .list-item-del { opacity: 1; }
.list-item-del:hover { background: var(--hover); color: var(--danger); border-color: var(--danger); }
.list-empty { font-size: 13px; color: var(--muted); padding: 8px 0; }

/* ── SIDE PANEL ── */
.side-panel {
  width: 0; flex-shrink: 0; overflow: hidden;
  border-left: 1px solid transparent; background: var(--bg);
  transition: width 0.22s ease, border-color 0.22s ease;
}
.side-panel.open { width: 420px; border-left-color: var(--rule); }
.side-panel-inner {
  width: 420px; height: 100%; overflow-y: auto;
  padding: 0 0 64px;
}

/* ── NOTION-STYLE EVENT CARD ── */
.spn { display: flex; flex-direction: column; }

/* Top toolbar: collapse button + delete */
.spn-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 4px; gap: 8px; flex-shrink: 0;
}
.spn-collapse-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 15px; padding: 4px 8px;
  border-radius: 5px; transition: background 0.1s; line-height: 1;
  display: flex; align-items: center; letter-spacing: -1px;
}
.spn-collapse-btn:hover { background: var(--bg); color: var(--text); }
.spn-dup-btn {
  width: 26px; height: 26px; background: none; border: none; cursor: pointer;
  border-radius: 5px; font-size: 15px; display: flex; align-items: center; justify-content: center;
  transition: background 0.1s; opacity: 0.45;
}
.spn-dup-btn:hover { background: var(--bg); opacity: 1; }
.spn-del-btn {
  width: 26px; height: 26px; background: none; border: none; cursor: pointer;
  border-radius: 5px; font-size: 13px; display: flex; align-items: center; justify-content: center;
  transition: background 0.1s; opacity: 0.45;
}
.spn-del-btn:hover { background: var(--hover); opacity: 1; }


/* Title */
.spn-title {
  font-family: var(--display); font-size: 28px; font-weight: 400;
  line-height: 1.2; padding: 0 24px 14px; color: var(--text);
  outline: none; word-break: break-word;
}
.spn-title-editable:hover { background: var(--surface-2); border-radius: 4px; }
.spn-title-editable:focus { background: var(--surface-2); border-radius: 4px; }

/* Properties grid */
.spn-props { display: flex; flex-direction: column; padding: 0 20px; }
.spn-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 5px 4px; border-bottom: none; min-height: 32px;
  border-radius: 4px;
}
.spn-row:hover { background: var(--surface-2); }
.spn-label {
  width: 130px; flex-shrink: 0; font-size: 13px; color: var(--muted);
  padding-top: 4px; font-weight: 400;
}
.spn-val {
  flex: 1; font-size: 13px; color: var(--text); display: flex;
  align-items: center; flex-wrap: wrap; gap: 5px; padding-top: 2px;
}
.spn-muted { color: var(--muted); font-size: 13px; }
.spn-empty { color: var(--muted); font-size: 13px; }

/* Status tag with dot */
.spn-status-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: filter 0.15s; user-select: none;
}
.spn-status-tag:hover { filter: brightness(0.94); }
.spn-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Date display chip + inline edit inputs */
.spn-date-chip {
  font-size: 13px; color: var(--text);
  border-radius: 4px; padding: 2px 4px; display: inline-block;
}
.spn-date-chip-edit { cursor: pointer; }
.spn-date-chip-edit:hover { background: var(--bg); }

.spn-dates { gap: 6px; align-items: center; }
.spn-date-in {
  border: none; background: none; outline: none; font-family: inherit;
  font-size: 13px; color: var(--text); padding: 2px 4px; cursor: pointer;
  border-radius: 4px; transition: background 0.1s;
}
.spn-date-in:hover, .spn-date-in:focus { background: var(--bg); }
.spn-arrow { color: var(--muted); font-size: 12px; }

/* Tag inputs */
.spn-tags-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.spn-tag {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg); border-radius: 4px; padding: 2px 7px;
  font-size: 12px; color: var(--text);
}
.spn-tag-del {
  background: none; border: none; cursor: pointer; font-size: 13px;
  color: var(--muted); padding: 0; line-height: 1; display: flex; align-items: center;
}
.spn-tag-del:hover { color: var(--danger); }
.spn-tag-input {
  border: none; outline: none; background: none; font-family: inherit;
  font-size: 13px; color: var(--text); width: 80px; padding: 2px 4px;
}
.spn-tag-input::placeholder { color: var(--muted); }

/* Text inputs in rows */
.spn-text-in {
  border: none; background: none; outline: none; font-family: inherit;
  font-size: 13px; color: var(--text); width: 100%; padding: 2px 4px;
  border-radius: 4px; transition: background 0.1s;
}
.spn-text-in:hover, .spn-text-in:focus { background: var(--bg); }
.spn-text-in::placeholder { color: var(--muted); }

.spn-job-tag {
  display: inline-flex; align-items: center; gap: 3px;
  border-radius: 4px; padding: 2px 8px; font-size: 12px; font-weight: 500;
}
.spn-job-in { width: 120px; }

/* Add property button */
.spn-add-prop {
  margin: 6px 20px 0; padding: 5px 8px; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--muted);
  border-radius: 4px; text-align: left; transition: background 0.1s; width: calc(100% - 40px);
}
.spn-add-prop:hover { background: var(--bg); color: var(--text); }

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

/* Comments */
.spn-comments { padding: 18px 24px 0; }
.spn-section-title {
  font-size: 11px; font-weight: 500; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 14px;
}
.spn-comment-input-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.spn-avatar-sm {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; font-family: var(--display);
}
.spn-comment-in {
  flex: 1; border: 1px solid var(--border); background: var(--bg);
  border-radius: 6px; outline: none; font-family: inherit;
  font-size: 13px; color: var(--text);
  padding: 7px 12px; transition: border-color 0.15s;
}
.spn-comment-in:focus { border-color: rgba(55,53,47,0.3); background: #fff; }
.spn-comment-in::placeholder { color: var(--muted); }
.spn-comments-list { display: flex; flex-direction: column; gap: 14px; }
.spn-comment { display: flex; gap: 10px; }
.spn-comment-body { flex: 1; }
.spn-comment-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.spn-comment-author { font-size: 12px; font-weight: 500; }
.spn-comment-time { font-size: 11px; color: var(--muted); }
.spn-comment-text { font-size: 13px; line-height: 1.5; }

/* Description */
.spn-desc-section { padding: 18px 24px 0; }
.spn-desc {
  width: 100%; min-height: 120px; border: none; background: none; outline: none; resize: none;
  font-family: inherit; font-size: 14px; line-height: 1.65; color: var(--text);
  padding: 4px; border-radius: 4px; transition: background 0.1s;
}
.spn-desc:hover, .spn-desc:focus { background: var(--bg); }
.spn-desc::placeholder { color: var(--muted); }
.spn-desc-ro { font-size: 14px; line-height: 1.65; color: var(--text); padding: 4px; }

/* Status dropdown menu */
.spn-status-menu {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 500; min-width: 170px; overflow: hidden;
}
.spn-status-opt {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  font-size: 13px; cursor: pointer; transition: background 0.1s;
}
.spn-status-opt:hover { background: var(--bg); }

/* ── MODALS ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,15,15,0.30); z-index: 400;
  align-items: center; justify-content: center;
  animation: modal-fadein .15s;
}
@keyframes modal-fadein { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 22px 24px;
  width: 420px; max-width: 92vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  position: relative;
  animation: modal-rise .18s;
}
@keyframes modal-rise { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h3 {
  font-family: var(--display);
  font-size: 22px; font-weight: 700; line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 4px;
}
.modal-date {
  font-size: 13px; color: var(--muted);
  margin-bottom: 18px;
}
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form label {
  font-size: 12px; font-weight: 500;
  letter-spacing: 0; color: var(--muted);
  text-transform: none; display: block; margin-bottom: 4px;
}
.modal-form input, .modal-form select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  outline: none;
  transition: border-color .1s, box-shadow .1s;
  height: 32px;
}
.modal-form input:focus, .modal-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(35,131,226,0.18);
}
.modal-form-row { display: flex; gap: 10px; }
.modal-form-row > div { min-width: 0; }
.modal-hint { color: var(--muted); font-weight: 400; font-size: 11px; }
.modal-tags-wrap {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  min-height: 32px; align-items: center;
}
.modal-tags { display: contents; }
.modal-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--hover); color: var(--ink);
  border-radius: 4px; padding: 2px 6px;
  font-size: 12px; line-height: 1.4;
}
.modal-tag-del {
  background: transparent; border: 0; color: var(--muted);
  cursor: pointer; padding: 0 2px; font-size: 14px; line-height: 1;
}
.modal-tag-del:hover { color: var(--ink); }
.modal-tag-input {
  flex: 1; min-width: 100px;
  border: 0 !important; background: transparent !important;
  padding: 2px 0 !important; height: 22px !important;
  outline: none;
}
.modal-tag-input:focus { box-shadow: none !important; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.modal-actions .btn-primary { flex: 0 0 auto; width: auto; padding: 7px 14px; height: 32px; }
.modal-actions .btn-cancel { padding: 7px 14px; height: 32px; }
.btn-cancel {
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--rule-strong);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .1s;
}
.btn-cancel:hover { background: var(--hover); color: var(--ink); }
.modal-error {
  font-size: 12px; color: var(--danger);
  min-height: 18px; margin-top: 6px;
}
.detail-close, .modal-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: none;
  cursor: pointer;
  font-size: 16px; color: var(--muted);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.detail-close:hover, .modal-close:hover { background: var(--hover); color: var(--ink); }
.modal-title {
  font-size: 18px; font-weight: 700; line-height: 1.2;
  letter-spacing: -0.01em; color: var(--ink);
  margin-bottom: 14px;
}
.modal-input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  outline: none; height: 32px;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(35,131,226,0.18); }

/* ── USERS MODAL ── */
.users-modal { width: 480px; }
.users-modal h3 { margin-bottom: 18px; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--rule);
}
.user-row:last-child { border-bottom: none; }
.user-row-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; font-weight: 600;
}
.user-row-info { flex: 1; min-width: 0; }
.user-row-name { font-size: 14px; font-weight: 500; color: var(--ink); }
.user-row-login { font-size: 12px; color: var(--muted); }
.user-row-actions { display: flex; gap: 5px; flex-shrink: 0; }
.user-row-actions .icon-btn {
  width: auto; height: auto;
  padding: 4px 9px;
  border: 1px solid var(--rule, var(--border));
  border-radius: var(--radius-sm, 5px);
  background: transparent;
  font-size: 11px; line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
}
.user-row-actions .icon-btn:hover { background: var(--hover); color: var(--ink, var(--text)); }
.user-row-actions .icon-btn.danger:hover {
  background: var(--hover); color: var(--danger, #D95F5F);
  border-color: var(--danger, #D95F5F);
}
.add-user-btn {
  width: 100%; margin-top: 14px; padding: 9px;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-sm);
  background: transparent; cursor: pointer;
  font-size: 13px; font-family: inherit;
  color: var(--muted);
  transition: all 0.15s;
}
.add-user-btn:hover { border-color: var(--ink-soft); color: var(--ink); background: var(--surface-2); }
.color-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.color-swatch.selected { border-color: var(--ink); transform: scale(1.15); }
.form-divider { height: 1px; background: var(--rule); margin: 4px 0; }
.sub-label {
  font-size: 12px; color: var(--muted);
  font-weight: 500; margin-bottom: 4px;
}

/* ── Permissions panel ── */
.perm-panel {
  margin: 0 0 8px 42px;
  padding: 10px 12px;
  background: var(--bg); border-radius: 8px;
  border: 1px solid var(--border);
}
.perm-role-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.perm-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.perm-select {
  flex: 1; padding: 4px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-family: inherit;
  font-size: 12px; background: var(--surface); color: var(--text); outline: none;
}
.perm-checks { display: flex; flex-direction: column; gap: 6px; }
.perm-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text); cursor: pointer;
}
.perm-check input { cursor: pointer; accent-color: #2563EB; }
.perm-self { font-size: 11px; color: var(--muted); font-weight: 400; }
.sub-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; }

/* ── Search input ── */
.search-input {
  border: 1px solid var(--border); background: var(--bg);
  border-radius: 6px; padding: 5px 10px;
  font-family: inherit; font-size: 12px; color: var(--text);
  outline: none; width: 148px;
  transition: border-color 0.15s, width 0.2s;
}
.search-input:focus { border-color: rgba(55,53,47,0.3); width: 196px; }
.search-input::placeholder { color: var(--muted); }

/* ── Event tooltip ── */
.ev-tooltip {
  position: fixed; z-index: 600;
  background: #1C1C1C; color: #F0F0F0;
  border-radius: 8px; padding: 10px 14px;
  font-family: inherit;
  min-width: 160px; max-width: 240px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.28);
  pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity 0.12s;
}
.ev-tooltip.visible { opacity: 1; visibility: visible; }
.ev-tt-title { font-weight: 600; font-size: 13px; margin-bottom: 7px; color: #fff; }
.ev-tt-meta { font-size: 11.5px; color: rgba(255,255,255,0.6); margin-bottom: 3px; }

/* ── Inline quick create ── */
.quick-create-wrap {
  padding: 3px 2px;
}
.quick-create-in {
  width: 100%; padding: 5px 8px;
  border: 1.5px solid rgba(55,53,47,0.25); border-radius: 6px;
  font-family: inherit; font-size: 13px;
  color: var(--text); background: #fff;
  outline: none; box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.quick-create-in::placeholder { color: var(--muted); }

/* ── Day event count badge ── */
.day-ev-count {
  font-size: 10px; color: var(--muted);
  margin-right: auto;
  background: rgba(55,53,47,0.05);
  padding: 1px 5px; border-radius: 8px;
  line-height: 1.4; pointer-events: none;
}

/* ── Save toast ── */
.save-toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1A1A1A; color: #fff;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-family: inherit;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none; z-index: 1000;
}
.save-toast.visible { opacity: 1; transform: translateY(0); }

/* ── Month picker ── */
.month-picker {
  position: fixed; z-index: 600;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  width: 224px;
}
.mp-year-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.mp-year { font-family: var(--display); font-size: 18px; }
.mp-nav-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 20px; line-height: 1;
  padding: 2px 8px; border-radius: 4px; transition: background 0.1s;
}
.mp-nav-btn:hover { background: var(--bg); color: var(--text); }
.mp-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.mp-month-btn {
  padding: 7px 4px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 12px; color: var(--text);
  border-radius: 6px; transition: background 0.1s; text-align: center;
}
.mp-month-btn:hover { background: var(--bg); }
.mp-month-btn.active { background: var(--text); color: #fff; font-weight: 600; }

/* ── Dark theme ── */
body.dark {
  --bg: #1E1E1E;
  --surface: #262626;
  --border: rgba(255,255,255,0.08);
  --text: #E8E8E5;
  --muted: #7A7A76;
}
body.dark .ev-card {
  background: #2C2C2C;
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
body.dark .ev-card:hover { border-color: rgba(255,255,255,0.2); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
body.dark .tl-ev-bar { opacity: 0.88; }
body.dark .ev-title { color: #E0E0DC; }
body.dark .ev-model-prefix { color: #888; }
body.dark .ev-agency,
body.dark .ev-job-chip { background: rgba(255,255,255,0.07); color: #AAA8A4; border-color: transparent; }
body.dark .day-cell { background: var(--surface); }
body.dark .day-cell:hover { background: #2E2E2E; }
body.dark .day-cell.other-month { background: var(--bg); }
body.dark .day-cell.selected { background: #323232; }
body.dark .day-cell,
body.dark .cal-week,
body.dark .day-headers,
body.dark .day-header { border-color: rgba(255,255,255,0.05); }
body.dark .day-num { color: #888; }
body.dark .login-card,
body.dark .modal { background: var(--surface); }
body.dark .modal-form input,
body.dark .modal-form select,
body.dark .search-input,
body.dark .quick-create-in,
body.dark .spn-comment-in { background: #333; border-color: rgba(255,255,255,0.1); color: var(--text); }
body.dark .spn-title,
body.dark .spn-desc,
body.dark .spn-desc-ro,
body.dark .spn-text-in { color: var(--text); }
body.dark .spn-desc:hover,
body.dark .spn-desc:focus,
body.dark .spn-text-in:hover,
body.dark .spn-text-in:focus { background: rgba(255,255,255,0.04); }
body.dark .week-event { filter: brightness(0.8) saturate(0.9); }
body.dark .mp-month-btn.active { background: #E8E8E5; color: #1E1E1E; }
#pw-modal-inner { width: 320px; max-width: 100%; }
body.dark .spn-status-menu {
  background: var(--surface); border-color: var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
body.dark .spn-status-opt:hover { background: rgba(255,255,255,0.06); }

/* spinner */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ HAMBURGER & BACKDROP ══ */
.hamburger-btn {
  display: flex;
  width: 36px; height: 36px; flex-shrink: 0;
  align-items: center; justify-content: center;
  background: none; border: none;
  cursor: pointer; font-size: 18px; color: var(--muted);
  border-radius: 6px; transition: color 0.15s, background 0.15s;
}
.hamburger-btn:hover { background: var(--bg); color: var(--text); }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.35); z-index: 149;
}
.sidebar-backdrop.visible { display: block; }

/* Desktop: hide mobile-only elements */
.vt-short { display: none; }
.day-dots { display: none !important; }

/* ── Day Sheet (тап по дню на мобильном) ── */
.day-sheet { display: none; position: fixed; inset: 0; z-index: 300; }
.day-sheet.visible { display: block; }
.ds-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.ds-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-radius: 18px 18px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  max-height: 78vh; display: flex; flex-direction: column;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.15);
}
.ds-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 12px auto 4px; flex-shrink: 0;
}
.ds-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ds-date { font-family: var(--display); font-size: 19px; }
.ds-add-btn {
  padding: 0 18px; height: 40px; background: var(--text); color: #fff;
  border: none; border-radius: 8px; font-family: inherit;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.ds-list { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; padding: 4px 0 8px; }
.ds-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; min-height: 60px; cursor: pointer;
}
.ds-item:active { background: var(--bg); }
.ds-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ds-item-body { flex: 1; min-width: 0; }
.ds-item-title {
  font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ds-item-meta { font-size: 12px; color: var(--muted); }
.ds-arrow { color: var(--muted); font-size: 20px; flex-shrink: 0; }
.ds-empty { padding: 28px 20px; text-align: center; font-size: 15px; color: var(--muted); }
body.dark .ds-panel { background: var(--surface); }

/* ══ MOBILE (≤ 768px) ══ */
@media (max-width: 768px) {

  /* Fast tap, no double-tap zoom */
  button, a, [onclick] { touch-action: manipulation; }
  body { overflow-x: hidden; }

  :root { --pad-x: 18px; }

  /* App grid: collapse sidebar column — sidebar is position:fixed overlay */
  .app { grid-template-columns: 1fr !important; }
  .main { min-width: 0; }

  /* ── Sidebar → fixed 80% overlay ── */
  .sidebar {
    position: fixed; top: 0; bottom: 0;
    left: calc(-80vw - 4px); width: 80vw; max-width: 300px;
    z-index: 150; transition: left 0.25s ease; box-shadow: none;
  }
  .sidebar.mobile-open { left: 0; box-shadow: 4px 0 28px rgba(0,0,0,0.22); }
  .hamburger-btn { display: flex !important; }

  /* ── Topbar ── single row, icon-only actions ── */
  .topbar {
    padding: 6px 10px; gap: 4px; min-height: 48px;
    flex-wrap: nowrap; overflow: hidden;
  }
  .topbar-crumb { font-size: 13px; min-width: 0; flex-shrink: 1; overflow: hidden; }
  .topbar-crumb .it { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-spacer { flex: 1; }
  .search-input { display: none; }
  .user-badge { display: none; }
  /* Compact "Пользователи" / "Выйти" */
  .tb-btn { padding: 4px 8px; font-size: 12px; flex-shrink: 0; }
  .tb-btn.icon { width: 36px; height: 36px; }
  #users-btn { padding: 4px 6px; font-size: 11px; }

  /* ── Page head (title row) ── */
  .page-head { padding: 16px var(--pad-x) 10px; gap: 8px; }
  .page-head-title { gap: 6px; flex-wrap: wrap; }
  .page-head-title h1 {
    font-size: 24px; letter-spacing: -0.01em;
    white-space: nowrap;
  }
  .month-nav { margin-left: 0; }
  .today-btn { height: 32px; padding: 0 10px; font-size: 12px; }

  /* ── View toggle — horizontal scroll if needed ── */
  .view-toggle {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding: 0 var(--pad-x);
    flex-wrap: nowrap;
  }
  .view-toggle::-webkit-scrollbar { display: none; }
  .vt-btn { flex-shrink: 0; padding: 8px 10px; font-size: 12px; white-space: nowrap; }

  /* ── Calendar — make sure it fills width ── */
  .cal-container { padding: 0 8px 8px; }
  .cal-grid { width: 100%; }
  .day-headers { padding: 0; }

  /* ── Month calendar — dots mode ── */
  .day-cell { min-height: 52px; padding: 4px 3px 5px; gap: 0; }
  .day-num { height: 22px; font-size: 12px; }
  .day-ev-count { display: none; }
  .day-add-btn { display: none; }
  .ev-card { display: none; }
  .day-dots {
    display: flex !important; flex-wrap: wrap;
    gap: 3px; padding: 2px 1px 0;
  }
  .day-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

  /* ── Week view — swipe navigation ── */
  .week-container { overflow: hidden; touch-action: pan-y; }
  .wk-inner { min-width: unset; }
  .wk-allday { display: none; }
  .wk-day-hd { padding: 6px 2px 5px; }
  .wk-hd-name { font-size: 9px; }
  .wk-date-num { font-size: 18px; }
  .wk-today-num { width: 28px; height: 28px; font-size: 13px; }
  .wk-hd-meta { display: none; }
  .wk-col { padding: 5px 3px; min-height: 120px; cursor: pointer; }
  .wk-col .ev-card { display: none; }
  .wk-col .day-dots { display: flex !important; padding: 0; }

  /* ── Year view ── */
  .year-container { padding: 12px; }
  .year-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* ── Kanban ── */
  .kanban-container { overflow-x: auto; }
  .kanban-board { padding: 12px; gap: 10px; }
  .kb-col { width: 240px; }

  /* ── List view ── */
  .list-container { padding: 14px var(--pad-x) 80px; }
  .list-group { margin-bottom: 28px; }
  .list-group-header { padding: 10px 4px; }
  .list-item { flex-wrap: wrap; gap: 8px; padding: 12px 4px; margin: 0; }
  .list-item-date { width: auto; font-size: 12px; }
  .list-item-title { font-size: 15px; flex-basis: 100%; order: -1; }
  .list-item-del { opacity: 1; height: 40px; padding: 0 14px; }

  /* ── Side panel → full screen с кнопкой Назад ── */
  .side-panel.open {
    position: fixed; inset: 0; z-index: 160;
    width: 100% !important; border-left: none;
  }
  .side-panel-inner { width: 100% !important; }
  .spn-collapse-btn { font-size: 0; width: auto; padding: 0 12px; min-height: 44px; }
  .spn-collapse-btn::before { content: '← Назад'; font-size: 14px; font-weight: 500; color: var(--text); letter-spacing: 0; }
  .spn-dup-btn, .spn-del-btn { width: 44px; height: 44px; }
  .spn-title { font-size: 22px; padding: 0 16px 12px; }
  .spn-props { padding: 0 12px; }
  .spn-row { min-height: 48px; padding: 6px 4px; }
  .spn-label { width: 110px; }
  .spn-toolbar { padding: 8px 8px 4px; }

  /* ── Модалки → полный экран снизу ── */
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100vw !important; max-width: 100vw !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 92dvh; overflow-y: auto;
    padding: 20px 16px 20px;
  }
  /* iOS Safari: padding-bottom игнорируется в overflow:auto — используем ::after */
  .modal::after { content: ''; display: block; height: env(safe-area-inset-bottom, 0px); }
  .users-modal { width: 100vw !important; max-width: 100vw !important; }

  /* font-size ≥ 16px — iOS Safari не зумит поле при фокусе */
  input, select, textarea { font-size: 16px !important; }
  .modal-form input, .modal-form select { padding: 13px 14px; min-height: 48px; }
  .login-field input { min-height: 48px; padding: 12px 14px; }
  .btn-primary, .btn-enter { min-height: 50px; font-size: 15px; }
  .btn-cancel { min-height: 50px; padding: 0 20px; }
  .add-user-btn { min-height: 50px; font-size: 14px; }

  /* Цветовые свотчи — крупнее */
  .color-swatch { width: 36px; height: 36px; }
  .color-grid { gap: 10px; }

  /* Пикер месяца */
  .month-picker { width: calc(100vw - 24px); left: 12px !important; }

  /* iOS Safari: login screen под клавиатурой */
  .login-screen { overflow-y: auto; -webkit-overflow-scrolling: touch; align-items: flex-start; padding-top: 10vh; }

  /* Тост */
  .save-toast { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); right: 16px; }
}

/* ══ Убираем hover на тач-устройствах ══ */
@media (hover: none) {
  .ev-card:hover { box-shadow: 0 1px 2px rgba(0,0,0,0.06); border-color: #E8E8E8; }
  .day-cell:hover { background: var(--surface); }
  .day-cell.other-month:hover { background: #F9F9F7; }
  body.dark .day-cell:hover { background: var(--surface); }
  body.dark .day-cell.other-month:hover { background: var(--bg); }
  .model-item:hover { background: transparent; }
  .model-item.active { background: var(--bg); }
  .kb-card:hover { box-shadow: none; border-color: var(--border); }
  .year-month:hover { box-shadow: none; border-color: var(--border); }
  .topbar-btn:hover { background: none; color: var(--muted); }
  .nav-btn:hover { background: none; color: var(--muted); }
  .today-btn:hover { background: none; }
  .tl-ev-bar:hover { opacity: 1; transform: none; }
  .vt-btn:hover { background: none; color: var(--muted); }
  .vt-btn.active { background: var(--surface); color: var(--text); }
}

/* ══ DARK + MOBILE ══ */
body.dark .sidebar.mobile-open { box-shadow: 4px 0 28px rgba(0,0,0,0.5); }

/* ══ CHAT ══ */
.chat-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 200;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--text); color: var(--surface);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: transform 0.15s, box-shadow 0.15s;
}
.chat-fab:hover { transform: scale(1.07); box-shadow: 0 6px 22px rgba(0,0,0,0.22); }
.chat-unread {
  display: none; position: absolute; top: 6px; right: 6px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 600;
  align-items: center; justify-content: center; padding: 0 4px;
  border: 2px solid var(--bg);
}
.chat-panel {
  position: fixed; bottom: 92px; right: 28px; z-index: 199;
  width: 460px; height: 520px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,0.14);
  display: flex; overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(12px) scale(0.97);
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform-origin: bottom right;
}
.chat-panel.visible { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }

/* Sidebar — conversation list */
.chat-sidebar {
  width: 180px; flex-shrink: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-conv-list { flex: 1; overflow-y: auto; }
.chat-conv-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; cursor: pointer;
  transition: background 0.1s; border: none; background: none;
  width: 100%; text-align: left;
}
.chat-conv-item:hover { background: var(--bg); }
.chat-conv-item.active { background: var(--bg); }
.chat-conv-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; position: relative;
}
.chat-conv-avatar.group {
  background: linear-gradient(135deg, #8BA89B, #B08BB5);
  font-size: 14px;
}
.chat-conv-info { flex: 1; min-width: 0; }
.chat-conv-name-row { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.chat-conv-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chat-conv-time { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.chat-conv-last { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.chat-conv-badge {
  min-width: 17px; height: 17px; border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 600; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.chat-new-row {
  display: flex; gap: 4px; padding: 8px;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.chat-new-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 4px; border-radius: 6px; border: 1px solid var(--border);
  background: none; cursor: pointer; font-size: 11px; color: var(--text);
  transition: background 0.1s;
}
.chat-new-btn:hover { background: var(--bg); }

/* Message view */
.chat-view { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-back-btn {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--muted); padding: 0 4px; line-height: 1;
}
.chat-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-view-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: none; }
.chat-menu-btn {
  background: none; border: none; cursor: pointer; flex-shrink: 0;
  color: var(--muted); font-size: 18px; padding: 2px 6px; line-height: 1;
  border-radius: 4px; transition: background 0.1s; letter-spacing: 1px;
}
.chat-menu-btn:hover { background: var(--bg); color: var(--text); }
.chat-close-btn {
  background: none; border: none; cursor: pointer; flex-shrink: 0;
  color: var(--muted); font-size: 16px; padding: 2px 6px;
  border-radius: 4px; transition: background 0.1s;
}
.chat-close-btn:hover { background: var(--bg); color: var(--text); }
.chat-dropdown {
  position: absolute; top: 48px; right: 44px; z-index: 210;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  min-width: 190px; padding: 4px; display: none;
}
.chat-dropdown.open { display: block; }
.chat-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text); border: none; background: none;
  width: 100%; text-align: left; transition: background 0.1s;
}
.chat-dd-item:hover { background: var(--bg); }
.chat-dd-item.danger { color: var(--danger); }
.chat-dd-item.danger:hover { background: var(--hover); }
.chat-dd-sep { height: 1px; background: var(--border); margin: 4px 0; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-msg { display: flex; gap: 8px; align-items: flex-end; margin-top: 6px; }
.chat-msg.same-author { margin-top: 2px; }
.chat-msg.mine { flex-direction: row-reverse; }
.chat-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff; align-self: flex-end;
}
.chat-msg.same-author .chat-avatar { visibility: hidden; }
.chat-bubble { display: flex; flex-direction: column; gap: 2px; max-width: 210px; }
.chat-msg.mine .chat-bubble { align-items: flex-end; }
.chat-name { font-size: 11px; color: var(--muted); padding: 0 10px; font-weight: 500; }
.chat-text {
  background: var(--surface-2); color: var(--ink);
  border-radius: 12px 12px 12px 2px;
  padding: 7px 11px; font-size: 13px; line-height: 1.45;
  word-break: break-word;
}
.chat-msg.mine .chat-text {
  background: var(--ink); color: var(--bg);
  border-radius: 12px 12px 2px 12px;
}
.chat-msg.same-author .chat-text { border-radius: 4px 12px 12px 4px; }
.chat-msg.mine.same-author .chat-text { border-radius: 12px 4px 4px 12px; }
.chat-time { font-size: 10px; color: var(--muted); padding: 0 10px; }
.chat-empty { font-size: 13px; color: var(--muted); text-align: center; margin: auto; padding: 20px; }
.chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.chat-input {
  flex: 1; padding: 7px 12px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 13px; color: var(--text); outline: none; transition: border-color 0.15s;
}
.chat-input:focus { border-color: var(--text); }
.chat-send-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--text); color: var(--surface);
  border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: opacity 0.15s;
}
.chat-send-btn:hover { opacity: 0.8; }
.chat-msg-actions {
  display: none; flex-direction: row; gap: 2px;
  align-self: center; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.chat-msg:hover .chat-msg-actions { display: flex; }
.chat-msg-act {
  background: none; border: none; cursor: pointer;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--muted); transition: background 0.1s;
}
.chat-msg-act:hover { background: var(--bg); color: var(--text); }
.chat-msg-act-del:hover { background: var(--hover); color: var(--danger); }
.chat-view { position: relative; }

/* Reply quote inside bubble */
.chat-reply-quote {
  border-left: 2px solid var(--text); padding: 3px 8px; margin-bottom: 4px;
  background: rgba(0,0,0,0.04); border-radius: 4px;
  cursor: pointer; transition: background 0.1s;
  max-width: 200px;
}
.chat-reply-quote:hover { background: rgba(0,0,0,0.07); }
.chat-msg.mine .chat-reply-quote { border-left-color: var(--surface); background: rgba(255,255,255,0.12); }
.chat-reply-quote .chat-reply-name { font-size: 11px; font-weight: 600; opacity: 0.85; }
.chat-reply-quote .chat-reply-text { font-size: 11px; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Reply bar above input */
.chat-reply-bar {
  display: none; align-items: center; gap: 8px;
  padding: 8px 12px; border-top: 1px solid var(--border);
  background: var(--bg);
}
.chat-reply-bar.open { display: flex; }
.chat-reply-bar-info { flex: 1; min-width: 0; border-left: 2px solid var(--text); padding-left: 8px; }
.chat-reply-bar .chat-reply-name { font-size: 11px; font-weight: 600; }
.chat-reply-bar .chat-reply-text { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-reply-cancel {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 14px; padding: 4px 6px; border-radius: 4px;
}
.chat-reply-cancel:hover { background: var(--surface); color: var(--text); }

/* Reactions */
.chat-reactions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.chat-reaction {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 7px; font-size: 11px;
  cursor: pointer; transition: background 0.1s, border-color 0.1s;
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--text);
}
.chat-reaction:hover { background: var(--surface); }
.chat-reaction.mine { background: var(--text); color: var(--surface); border-color: var(--text); }
.chat-msg.mine .chat-reactions { justify-content: flex-end; }

/* Emoji picker popup */
.chat-emoji-pop {
  position: fixed; z-index: 250;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 6px;
  display: flex; gap: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.chat-emoji-btn {
  background: none; border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 17px; transition: transform 0.1s, background 0.1s;
  display: flex; align-items: center; justify-content: center;
}
.chat-emoji-btn:hover { background: var(--bg); transform: scale(1.18); }

/* Read checkmarks */
.chat-meta { display: flex; align-items: baseline; gap: 4px; padding: 0 10px; justify-content: flex-end; }
.chat-msg.mine .chat-meta { justify-content: flex-end; }
.chat-msg:not(.mine) .chat-meta { justify-content: flex-start; }
.chat-time { font-size: 10px; color: var(--muted); padding: 0; }
.chat-read { font-size: 11px; color: var(--muted); letter-spacing: -2px; }
.chat-msg.mine .chat-read { color: rgba(255,255,255,0.65); }

/* Flash on jump-to-message */
.chat-msg-flash .chat-text { animation: chat-flash 1.2s ease; }
@keyframes chat-flash {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  30% { box-shadow: 0 0 0 4px rgba(59,130,246,0.4); }
}

/* Hide FAB while chat panel is open */
body.chat-open .chat-fab { display: none; }
.chat-date-divider {
  text-align: center; font-size: 11px; color: var(--muted); position: relative; margin: 4px 0;
}
.chat-date-divider::before, .chat-date-divider::after {
  content: ''; position: absolute; top: 50%; width: 28%; height: 1px; background: var(--border);
}
.chat-date-divider::before { left: 0; }
.chat-date-divider::after { right: 0; }

/* New DM/Group modal */
.chat-new-overlay { z-index: 300; }
.chat-new-modal { width: 320px; max-height: 420px; overflow-y: auto; }
.chat-new-user-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; max-height: 220px; overflow-y: auto; }
.chat-new-user-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  transition: background 0.1s; user-select: none;
}
.chat-new-user-item:hover { background: var(--bg); }
.chat-new-user-item.selected { background: var(--bg); }
.chat-new-check {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, border-color 0.1s;
}
.chat-new-user-item.selected .chat-new-check { background: var(--text); border-color: var(--text); color: var(--surface); font-size: 11px; }

@media (max-width: 768px) {
  .chat-fab { bottom: 18px; right: 18px; }
  .chat-panel {
    right: 0; bottom: 0; width: 100vw; height: 80dvh;
    border-radius: 20px 20px 0 0; border-bottom: none;
    flex-direction: column;
  }
  .chat-sidebar { width: 100%; height: 100%; border-right: none; }
  .chat-view { position: absolute; inset: 0; background: var(--surface); transform: translateX(100%); transition: transform 0.22s ease; }
  .chat-view.mobile-open { transform: translateX(0); }
  .chat-back-btn { display: block; }
}

/* ── Brand button & sidebar nav ── */
.brand.brand-btn {
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
}
.brand.brand-btn:hover { background: var(--hover, #EFEEEC); }

.nav-section {
  display: flex; flex-direction: column;
  margin: 2px 0 6px;
  padding: 0 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 0 8px;
  height: var(--side-item-h, 28px);
  border: 0; background: transparent;
  text-align: left;
  font: inherit;
  font-size: 14px;
  color: var(--ink-soft, #5A584F);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: background .08s;
}
.nav-item:hover { background: var(--hover, #EFEEEC); }
.nav-item.active { background: var(--hover, #EFEEEC); color: var(--ink, #37352F); font-weight: 500; }
.nav-item-ico {
  width: 16px;
  display: inline-flex;
  align-items: center; justify-content: center;
  color: var(--muted, #9B9A93);
  font-size: 12px;
}
.nav-item.active .nav-item-ico { color: var(--ink, #37352F); }
.nav-item-label { flex: 1; }

/* ── Models DB view ── */
.mdb-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface, #fff);
}
.mdb-list {
  border-right: 1px solid var(--border, #E9E8E5);
  overflow-y: auto;
  padding: 12px 8px;
  background: var(--surface-1, #FBFBFA);
}
.mdb-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border: 0; background: transparent;
  border-radius: 6px; cursor: pointer;
  text-align: left; font: inherit;
  margin-bottom: 2px;
  color: var(--ink, #37352F);
}
.mdb-row:hover { background: var(--hover, #EFEEEC); }
.mdb-row.active { background: var(--surface-2, #E9E8E5); }
.mdb-row-av {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.mdb-row-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mdb-row-name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mdb-row-status { font-size: 11px; color: var(--muted, #9B9A93); }
.mdb-empty { padding: 24px; color: var(--muted, #9B9A93); font-size: 13px; }
.mdb-empty-val { color: var(--muted, #9B9A93); }

.mdb-detail {
  overflow-y: auto;
  padding: 32px 48px 64px;
}
.mdb-detail-inner { max-width: 760px; margin: 0 auto; }

.mdb-head { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.mdb-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
}
.mdb-name {
  font-size: 32px; font-weight: 700; margin: 0;
  color: var(--ink, #37352F);
}

.mdb-props { display: flex; flex-direction: column; gap: 2px; }
.mdb-prop {
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: start;
  gap: 12px;
  padding: 6px 4px;
  min-height: 32px;
  border-radius: 4px;
}
.mdb-prop:hover { background: var(--hover, rgba(0,0,0,.02)); }
.mdb-prop-l {
  color: var(--muted, #9B9A93);
  font-size: 13px;
  padding-top: 7px;
}
.mdb-prop-v { font-size: 14px; color: var(--ink, #37352F); }
.mdb-val { display: inline-block; padding: 6px 4px; }
.mdb-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: 4px;
  font: inherit;
  color: inherit;
  outline: none;
  font-size: 14px;
}
.mdb-input:hover { border-color: var(--border, #E9E8E5); }
.mdb-input:focus { border-color: var(--ink, #37352F); background: var(--surface, #fff); }
.mdb-textarea { resize: vertical; min-height: 32px; line-height: 1.4; }

.mdb-photos { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.mdb-photo {
  position: relative;
  width: 48px; height: 48px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2, #E9E8E5);
}
.mdb-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mdb-photo-del {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff;
  border: 0; cursor: pointer;
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
}
.mdb-photo-add { display: flex; gap: 6px; margin-top: 8px; }
.mdb-btn {
  padding: 6px 12px;
  border: 1px solid var(--border, #E9E8E5);
  background: var(--surface, #fff);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.mdb-btn:hover { background: var(--hover, #EFEEEC); }

@media (max-width: 720px) {
  .mdb-container { grid-template-columns: 1fr; }
  .mdb-list { max-height: 200px; }
  .mdb-detail { padding: 20px; }
  .mdb-prop { grid-template-columns: 1fr; gap: 2px; }
  .mdb-name { font-size: 24px; }
}

/* ── Wiki view ── */
.wiki-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}
.wiki-list {
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  padding: 12px 8px;
  background: var(--surface-2);
}
.wiki-list-head {
  padding: 4px 6px 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 10px;
}
.wiki-new-btn {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.wiki-new-btn:hover { background: var(--hover); }

.wiki-cats { display: flex; flex-direction: column; gap: 14px; }
.wiki-cat-h {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 4px 8px 4px 6px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  user-select: none;
}
.wiki-cat-h:hover { background: var(--hover); color: var(--ink); }
.wiki-cat-h:hover .wiki-cat-plus { opacity: 1; }
.wiki-cat-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-cat-caret {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; font-size: 14px;
  color: var(--ink);
  font-weight: 900;
  transition: transform 120ms;
  flex-shrink: 0;
}
.wiki-cat-caret.open { transform: rotate(90deg); }
.wiki-cat-plus {
  border: 0; background: transparent;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink);
  font-size: 20px; line-height: 1;
  font-weight: 900;
  padding: 0;
  opacity: 0.65;
  flex-shrink: 0;
  transition: background 120ms, color 120ms, opacity 120ms;
}
.wiki-cat-plus:hover {
  background: var(--ink);
  color: var(--surface);
  opacity: 1;
}
.wiki-cat-empty {
  font-size: 12px;
  color: var(--muted-soft);
  padding: 4px 10px;
}
.wiki-row {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 5px 10px;
  border: 0; background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left; font: inherit;
  margin-bottom: 1px;
  color: var(--ink);
}
.wiki-row:hover { background: var(--hover); }
.wiki-row.active { background: var(--hover); font-weight: 600; }
.wiki-row-title {
  font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.wiki-caret {
  border: 0; background: transparent;
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  transition: transform 120ms;
  flex-shrink: 0;
  padding: 0;
}
.wiki-caret:hover { color: var(--ink); }
.wiki-caret.open { transform: rotate(90deg); }
.wiki-caret-spacer { width: 16px; height: 16px; flex-shrink: 0; }
.wiki-shared-dot {
  color: var(--accent, #2563EB);
  font-size: 10px;
  line-height: 1;
}

/* Breadcrumbs above the title */
.wiki-crumbs {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex; flex-wrap: wrap; align-items: center;
}
.wiki-crumb {
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}
.wiki-crumb:hover { color: var(--ink); text-decoration: underline; }
.wiki-crumb-sep { margin: 0 6px; opacity: 0.5; }

/* Children list (auto overview at bottom of parent article) */
.wiki-children {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.wiki-children-h {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
}
.wiki-children-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.wiki-child-card {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms;
}
.wiki-child-card:hover { background: var(--hover); }
.wiki-child-title { font-weight: 500; }

/* Share block */
.wiki-share-block {
  margin-top: 40px;
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-2, var(--surface));
}
.wiki-share-h {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.wiki-share-row {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.wiki-share-input {
  flex: 1; min-width: 240px;
  padding: 7px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.wiki-share-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.wiki-detail {
  overflow-y: auto;
  padding: 32px 48px 64px;
}
.wiki-detail-inner { max-width: 760px; margin: 0 auto; }
.wiki-empty { padding: 24px; color: var(--muted); font-size: 13px; }

.wiki-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.wiki-meta { display: flex; align-items: center; gap: 10px; }
.wiki-cat-tag {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.wiki-date { font-size: 12px; color: var(--muted); }
.wiki-actions { display: flex; gap: 6px; }
.wiki-btn {
  padding: 6px 12px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.wiki-btn:hover { background: var(--hover); }
.wiki-btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.wiki-btn-primary:hover { background: var(--ink-soft); border-color: var(--ink-soft); }
.wiki-btn-danger { color: var(--danger); border-color: var(--rule-strong); }
.wiki-btn-danger:hover { background: var(--hover); }

.wiki-title {
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 24px;
  font-weight: 400;
}

.wiki-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
}
.wiki-body h1, .wiki-body h2, .wiki-body h3,
.wiki-body h4, .wiki-body h5, .wiki-body h6 {
  font-family: var(--serif);
  color: var(--ink);
  font-weight: 400;
  line-height: 1.25;
  margin: 28px 0 10px;
  letter-spacing: -0.01em;
}
.wiki-body h1 { font-size: 30px; }
.wiki-body h2 { font-size: 24px; }
.wiki-body h3 { font-size: 19px; }
.wiki-body h4 { font-size: 16px; }
.wiki-body p { margin: 10px 0; }
.wiki-body ul, .wiki-body ol { margin: 10px 0 10px 22px; }
.wiki-body li { margin: 4px 0; }
.wiki-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.wiki-body strong { font-weight: 600; }
.wiki-body em { font-style: italic; }
.wiki-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
}
.wiki-body pre {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 14px 0;
}
.wiki-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 13px;
}
.wiki-body blockquote {
  border-left: 3px solid var(--rule-strong);
  padding: 4px 0 4px 14px;
  margin: 14px 0;
  color: var(--ink-soft);
  font-style: italic;
}
.wiki-body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 24px 0;
}
.wiki-body img { max-width: 100%; border-radius: var(--radius); }

/* Editor */
.wiki-editor .wiki-input {
  width: 100%;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
}
.wiki-editor .wiki-input:focus { border-color: var(--ink); }
.wiki-cat-select { width: auto; min-width: 160px; padding: 6px 10px; font-size: 13px; }
.wiki-title-input {
  font-family: var(--serif);
  font-size: 28px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.wiki-content-input {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 460px;
  resize: vertical;
}
.wiki-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* ── Wiki: list head with two buttons ── */
.wiki-new-btn-secondary {
  background: var(--surface, #fff);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
}
.wiki-new-btn-secondary:hover { background: var(--hover); }
.wiki-cat-lock { font-size: 11px; opacity: 0.6; }

/* ── Wiki sections manager modal ── */
.wiki-sections-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  align-items: flex-start; justify-content: center;
  padding: 60px 16px 24px;
  overflow-y: auto;
}
.wiki-sections-overlay.open { display: flex; }
.wiki-sections-modal {
  width: 100%; max-width: 640px;
  background: var(--surface, #fff);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.28);
  padding: 22px 24px 20px;
}
.wiki-sec-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.wiki-sec-title { font-size: 18px; font-weight: 600; }
.wiki-sec-list { display: flex; flex-direction: column; gap: 8px; }
.wiki-sec-row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-2, var(--surface));
}
.wiki-sec-row-editing {
  display: block;
  border-color: var(--rule-strong);
}
.wiki-sec-label-strong { font-weight: 600; margin-bottom: 10px; }
.wiki-sec-label { font-weight: 500; }
.wiki-sec-mode { font-size: 12px; color: var(--muted); }
.wiki-sec-actions { display: flex; gap: 6px; }
.wiki-sec-lock { opacity: 0.6; }
.wiki-sec-editor { display: flex; flex-direction: column; gap: 12px; }
.wiki-sec-field label {
  display: block; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px;
}
.wiki-sec-vis { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.wiki-sec-vis label { display: inline-flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 0; }
.wiki-sec-members {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--surface);
}
.wiki-sec-member {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: var(--radius);
  font-size: 13px; color: var(--ink);
  cursor: pointer;
}
.wiki-sec-member:hover { background: var(--hover); }
.wiki-sec-member-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.wiki-sec-empty { color: var(--muted); font-size: 12px; padding: 6px; }
.wiki-sec-actions-row { display: flex; justify-content: flex-end; gap: 6px; }
.wiki-sec-footer { margin-top: 14px; }
.wiki-sec-new { width: 100%; }

/* ── Quill WYSIWYG (Wiki editor) ── */
.wiki-quill { background: var(--surface); }
.wiki-quill .ql-toolbar {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 0;
  background: var(--surface-2, var(--surface));
}
.wiki-quill .ql-container {
  border: 1px solid var(--rule-strong);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: inherit;
  font-size: 15px;
  min-height: 420px;
  background: var(--surface);
  color: var(--ink);
}
.wiki-quill .ql-editor { min-height: 420px; line-height: 1.6; padding: 16px 18px; }
.wiki-quill .ql-editor.ql-blank::before { color: var(--muted); font-style: normal; }
.wiki-quill .ql-stroke { stroke: var(--ink); }
.wiki-quill .ql-fill   { fill: var(--ink); }
.wiki-quill .ql-picker { color: var(--ink); }
.wiki-quill .ql-picker-options { background: var(--surface); color: var(--ink); border: 1px solid var(--rule); }
.wiki-quill .ql-snow.ql-toolbar button:hover .ql-stroke,
.wiki-quill .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent, #2563EB); }
.wiki-quill .ql-snow.ql-toolbar button:hover .ql-fill,
.wiki-quill .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent, #2563EB); }
.wiki-quill .ql-editor blockquote {
  border-left: 3px solid var(--rule-strong);
  padding-left: 12px;
  color: var(--muted);
  margin: 1em 0;
}
.wiki-quill .ql-editor pre,
.wiki-quill .ql-editor .ql-code-block-container {
  background: var(--hover);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Render wiki body the same way both views see headings/lists/etc */
.wiki-body img { max-width: 100%; height: auto; border-radius: var(--radius); }
.wiki-body blockquote {
  border-left: 3px solid var(--rule-strong);
  padding-left: 12px;
  color: var(--muted);
  margin: 1em 0;
}

@media (max-width: 720px) {
  .wiki-container { grid-template-columns: 1fr; }
  .wiki-list { max-height: 220px; }
  .wiki-detail { padding: 20px; }
  .wiki-title { font-size: 28px; }
  .wiki-head { flex-direction: column; align-items: flex-start; }
}
