/* ──────────────────────────────────────────────────────────────
   Живое Присутствие — lp-theme
   Phase 13 UI polish, based on Claude Design V1 Classic handoff.
   Standalone CSS (no Tailwind build step). Works alongside daisyUI 5.
   Custom classes are `lp-*`-prefixed to avoid daisyUI collisions.
   Uses CSS variables so the light/dark toggle flips the whole palette.
   ────────────────────────────────────────────────────────────── */

:root {
  --lp-bg:        #fafaf9;
  --lp-surface:   #ffffff;
  --lp-surface-2: #f4f4f3;
  --lp-border:    #e7e5e4;
  --lp-border-2:  #d6d3d1;
  --lp-text:      #1c1917;
  --lp-text-2:    #57534e;
  --lp-text-3:    #a8a29e;

  --lp-primary:      #2563eb;
  --lp-primary-ink:  #ffffff;
  --lp-primary-soft: #dbeafe;

  --lp-success:      #16a34a;
  --lp-success-soft: #dcfce7;
  --lp-warning:      #d97706;
  --lp-warning-soft: #fef3c7;
  --lp-danger:       #dc2626;
  --lp-danger-soft:  #fee2e2;
  --lp-info:         #0891b2;
  --lp-info-soft:    #cffafe;

  --lp-od-accent:       #7c3aed;
  --lp-od-accent-soft:  #ede9fe;
  --lp-sem-accent:      #c2410c;
  --lp-sem-accent-soft: #ffedd5;

  --lp-shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 1px rgba(0, 0, 0, .03);
  --lp-shadow:    0 1px 3px rgba(0, 0, 0, .05), 0 2px 6px rgba(0, 0, 0, .04);
  --lp-radius:    8px;
  --lp-radius-sm: 6px;

  --lp-font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --lp-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

html[data-theme="dark"] {
  --lp-bg:        #0f0f10;
  --lp-surface:   #17171a;
  --lp-surface-2: #1e1e22;
  --lp-border:    #27272a;
  --lp-border-2:  #3f3f46;
  --lp-text:      #f4f4f5;
  --lp-text-2:    #a1a1aa;
  --lp-text-3:    #71717a;

  --lp-primary:      #60a5fa;
  --lp-primary-ink:  #0b1220;
  --lp-primary-soft: #1e3a8a55;

  --lp-success:      #4ade80;
  --lp-success-soft: #14532d55;
  --lp-warning:      #fbbf24;
  --lp-warning-soft: #78350f55;
  --lp-danger:       #f87171;
  --lp-danger-soft:  #7f1d1d55;
  --lp-info:         #22d3ee;
  --lp-info-soft:    #164e6355;

  --lp-od-accent:       #a78bfa;
  --lp-od-accent-soft:  #4c1d9555;
  --lp-sem-accent:      #fb923c;
  --lp-sem-accent-soft: #7c2d1255;

  --lp-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --lp-shadow:    0 1px 3px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .4);
}

/* ── Base (scoped to lp-shell to avoid bleed into daisyUI pages) ────── */

.lp-shell {
  font-family: var(--lp-font-sans);
  background: var(--lp-bg);
  color: var(--lp-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.lp-shell * {
  box-sizing: border-box;
}

.lp-mono {
  font-family: var(--lp-font-mono);
  font-size: 12.5px;
}

/* ── Top-bar ──────────────────────────────────────────────────────── */

.lp-topbar {
  height: 44px;
  background: var(--lp-surface);
  border-bottom: 1px solid var(--lp-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.lp-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 2px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--lp-text);
  font-size: 13.5px;
  text-decoration: none;
  border-right: 1px solid var(--lp-border);
  height: 100%;
  margin-right: 6px;
}

.lp-topbar-brand .lp-leaf {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--lp-od-accent);
}

.lp-topnav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.lp-topnav::-webkit-scrollbar { display: none; }

.lp-topnav a {
  color: var(--lp-text-2);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  transition: background .12s, color .12s;
  cursor: pointer;
  white-space: nowrap;
}

.lp-topnav a:hover {
  background: var(--lp-surface-2);
  color: var(--lp-text);
}

.lp-topnav a.active {
  background: var(--lp-surface-2);
  color: var(--lp-text);
  font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--lp-border);
}

.lp-topnav a .lp-n {
  color: var(--lp-text-3);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.lp-topnav a.active .lp-n { color: var(--lp-text-2); }

.lp-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lp-ws-switch {
  display: inline-flex;
  align-items: center;
  background: var(--lp-surface-2);
  border: 1px solid var(--lp-border);
  border-radius: 7px;
  padding: 2px;
  height: 28px;
  font-size: 12.5px;
}

.lp-ws-switch a,
.lp-ws-switch button {
  border: 0;
  background: transparent;
  color: var(--lp-text-2);
  padding: 0 10px;
  height: 22px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  text-decoration: none;
}

.lp-ws-switch a.on,
.lp-ws-switch button.on {
  background: var(--lp-surface);
  color: var(--lp-text);
  box-shadow: var(--lp-shadow-sm);
  font-weight: 500;
}

.lp-ws-switch .lp-dot {
  width: 6px;
  height: 6px;
  border-radius: 3px;
}

.lp-ws-switch .lp-dot.od { background: var(--lp-od-accent); }
.lp-ws-switch .lp-dot.sem { background: var(--lp-sem-accent); }

.lp-icon-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--lp-text-2);
  cursor: pointer;
  text-decoration: none;
}

.lp-icon-btn:hover {
  background: var(--lp-surface-2);
  color: var(--lp-text);
}

.lp-avatar {
  width: 26px;
  height: 26px;
  border-radius: 13px;
  background: var(--lp-od-accent-soft);
  color: var(--lp-od-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

/* ── Sub-header ───────────────────────────────────────────────────── */

.lp-subhead {
  background: var(--lp-surface);
  border-bottom: 1px solid var(--lp-border);
  padding: 10px 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex-wrap: wrap;
  position: sticky;
  top: 44px; /* высота lp-topbar */
  z-index: 30;
}

/* Actions слева, breadcrumbs справа (через order — чтобы DOM-порядок не трогать) */
.lp-subhead .lp-subhead-actions { order: -1; }
.lp-subhead .lp-crumbs { order: 1; margin-left: auto; }

.lp-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--lp-text-3);
}

.lp-crumbs a {
  color: var(--lp-text-2);
  text-decoration: none;
}

.lp-crumbs a:hover { color: var(--lp-text); }

.lp-crumbs .lp-sep {
  color: var(--lp-text-3);
  opacity: .6;
}

.lp-crumbs .lp-current {
  color: var(--lp-text);
  font-weight: 500;
}

.lp-subhead-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Page title block ─────────────────────────────────────────────── */

.lp-page-title {
  padding: 20px 28px 4px;
}

.lp-page-title h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin: 0;
  color: var(--lp-text);
}

.lp-page-title .lp-meta {
  color: var(--lp-text-3);
  font-size: 12.5px;
  margin-top: 3px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.lp-page-title .lp-meta .lp-sep {
  opacity: .5;
}

/* ── Page body container ──────────────────────────────────────────── */

.lp-page {
  padding: 16px 28px 32px;
}

/* ── Card (alt, co-exists with daisyUI .card) ─────────────────────── */

.lp-card {
  background: var(--lp-surface);
  border: 1px solid var(--lp-border);
  border-radius: var(--lp-radius);
  box-shadow: var(--lp-shadow-sm);
}

.lp-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--lp-border);
  min-height: 44px;
}

.lp-card-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--lp-text);
  letter-spacing: -0.1px;
}

.lp-card-head .lp-sub {
  color: var(--lp-text-3);
  font-size: 12px;
}

.lp-card-head .lp-right {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.lp-card-body {
  padding: 14px 16px;
}

.lp-card-body.tight { padding: 6px 8px; }

.lp-card + .lp-card { margin-top: 16px; }

/* ── Button (alt) ─────────────────────────────────────────────────── */

.lp-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--lp-radius-sm);
  border: 1px solid var(--lp-border);
  background: var(--lp-surface);
  color: var(--lp-text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
  text-decoration: none;
}

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

.lp-btn-primary {
  background: var(--lp-primary);
  border-color: var(--lp-primary);
  color: var(--lp-primary-ink);
}

.lp-btn-primary:hover {
  filter: brightness(0.94);
  background: var(--lp-primary);
  border-color: var(--lp-primary);
  color: var(--lp-primary-ink);
}

.lp-btn-ghost {
  background: transparent;
  border-color: transparent;
}

.lp-btn-ghost:hover { background: var(--lp-surface-2); }

.lp-btn-danger { color: var(--lp-danger); }

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

.lp-btn-sm {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

.lp-btn-xs {
  height: 22px;
  padding: 0 8px;
  font-size: 11.5px;
  border-radius: 4px;
}

/* ── Dropdown (native <details>) ──────────────────────────────────── */

details.lp-dd {
  position: relative;
}

details.lp-dd > summary {
  list-style: none;
  cursor: pointer;
}

details.lp-dd > summary::-webkit-details-marker { display: none; }

details.lp-dd[open] > .lp-dd-menu { display: flex; }

.lp-dd-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 220px;
  background: var(--lp-surface);
  border: 1px solid var(--lp-border);
  border-radius: 8px;
  box-shadow: var(--lp-shadow);
  padding: 4px;
  z-index: 30;
  flex-direction: column;
}

.lp-dd-menu button,
.lp-dd-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 5px;
  background: transparent;
  border: 0;
  color: var(--lp-text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
}

.lp-dd-menu button:hover,
.lp-dd-menu a:hover {
  background: var(--lp-surface-2);
}

.lp-dd-menu .lp-hint {
  color: var(--lp-text-3);
  font-size: 11.5px;
  margin-left: auto;
}

.lp-dd-menu .lp-menu-sep {
  height: 1px;
  background: var(--lp-border);
  margin: 4px 0;
}

.lp-dd-menu .lp-danger {
  color: var(--lp-danger);
}

.lp-dd-menu .lp-danger:hover {
  background: var(--lp-danger-soft);
}

/* ── Badges (alt) ─────────────────────────────────────────────────── */

.lp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1;
}

.lp-badge .lp-pulse {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: currentColor;
}

.lp-badge-draft     { background: var(--lp-surface-2);    color: var(--lp-text-2); border-color: var(--lp-border); }
.lp-badge-published { background: var(--lp-success-soft); color: var(--lp-success); }
.lp-badge-ongoing   { background: var(--lp-info-soft);    color: var(--lp-info); }
.lp-badge-past      { background: var(--lp-surface-2);    color: var(--lp-text-3); }
.lp-badge-cancelled { background: var(--lp-danger-soft);  color: var(--lp-danger); }
.lp-badge-od        { background: var(--lp-od-accent-soft);  color: var(--lp-od-accent); }
.lp-badge-sem       { background: var(--lp-sem-accent-soft); color: var(--lp-sem-accent); }
.lp-badge-muted     { background: var(--lp-surface-2);    color: var(--lp-text-2); border-color: var(--lp-border); }

/* ── Definition list ──────────────────────────────────────────────── */

.lp-dl {
  display: grid;
  grid-template-columns: 150px 1fr;
  row-gap: 10px;
  column-gap: 16px;
  font-size: 13px;
  margin: 0;
}

.lp-dl dt {
  color: var(--lp-text-3);
  font-weight: 400;
  font-size: 12.5px;
  padding-top: 1px;
}

.lp-dl dd {
  margin: 0;
  color: var(--lp-text);
}

.lp-dl dd .lp-muted { color: var(--lp-text-3); }

/* ── Table ────────────────────────────────────────────────────────── */

.lp-tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.lp-tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--lp-text-3);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--lp-border);
  background: var(--lp-surface);
  position: sticky;
  top: 0;
}

.lp-tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--lp-border);
  vertical-align: middle;
  color: var(--lp-text);
}

.lp-tbl tbody tr:hover { background: var(--lp-surface-2); }
.lp-tbl tbody tr:last-child td { border-bottom: 0; }

.lp-tbl a {
  color: var(--lp-text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.lp-tbl a:hover { border-bottom-color: var(--lp-border-2); }

.lp-tbl .lp-tg {
  color: var(--lp-primary);
  font-family: var(--lp-font-mono);
  font-size: 12px;
}

.lp-tbl .lp-rsvp-yes  { color: var(--lp-success); }
.lp-tbl .lp-rsvp-no   { color: var(--lp-danger); }
.lp-tbl .lp-rsvp-none { color: var(--lp-text-3); }

/* reminder chips */
.lp-chip {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--lp-surface-2);
  color: var(--lp-text-3);
  border: 1px solid var(--lp-border);
  margin-right: 3px;
  font-variant-numeric: tabular-nums;
}

.lp-chip.on {
  background: var(--lp-success-soft);
  color: var(--lp-success);
  border-color: transparent;
}

/* ── Tabs (filter bar above table) ────────────────────────────────── */

.lp-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--lp-border);
  padding: 0 12px;
}

.lp-tabs a,
.lp-tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--lp-text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.lp-tabs a:hover,
.lp-tabs button:hover { color: var(--lp-text); }

.lp-tabs a.on,
.lp-tabs button.on {
  color: var(--lp-text);
  border-bottom-color: var(--lp-text);
  font-weight: 500;
}

.lp-tabs .lp-n {
  font-variant-numeric: tabular-nums;
  color: var(--lp-text-3);
  background: var(--lp-surface-2);
  border-radius: 3px;
  padding: 0 5px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
}

/* ── Inputs (alt) ─────────────────────────────────────────────────── */

.lp-input,
.lp-select {
  appearance: none;
  background: var(--lp-surface);
  border: 1px solid var(--lp-border);
  border-radius: 6px;
  height: 28px;
  padding: 0 10px;
  color: var(--lp-text);
  font: inherit;
  font-size: 13px;
  outline: 0;
  font-family: inherit;
}

.lp-input:focus,
.lp-select:focus {
  border-color: var(--lp-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lp-primary) 20%, transparent);
}

textarea.lp-input {
  height: auto;
  padding: 8px 10px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
}

/* ── Inline-editable hint (visual only — clicks still go to /edit) ── */

.lp-ineditable {
  border: 1px dashed transparent;
  border-radius: 4px;
  padding: 1px 4px;
  margin: -1px -4px;
  transition: border-color .12s, background .12s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: inline;
}

.lp-ineditable:hover {
  border-color: var(--lp-border-2);
  background: var(--lp-surface-2);
}

/* ── Utilities ────────────────────────────────────────────────────── */

.lp-row { display: flex; }
.lp-col { display: flex; flex-direction: column; }
.lp-gap-2 { gap: 8px; }
.lp-gap-3 { gap: 12px; }
.lp-gap-4 { gap: 16px; }
.lp-flex-1 { flex: 1 1 auto; min-width: 0; }
.lp-mt-2 { margin-top: 8px; }
.lp-mt-3 { margin-top: 12px; }
.lp-mt-4 { margin-top: 16px; }
.lp-mb-2 { margin-bottom: 8px; }
.lp-muted   { color: var(--lp-text-3); }
.lp-muted-2 { color: var(--lp-text-2); }
.lp-tabnum  { font-variant-numeric: tabular-nums; }
.lp-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Progress bar for signups count ───────────────────────────────── */

.lp-progress {
  height: 6px;
  background: var(--lp-surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.lp-progress > div {
  height: 100%;
  background: var(--lp-success);
  transition: width .25s;
}

/* ── Event details specific (reminders list, latest signups) ──────── */

.lp-reminder-row {
  display: flex;
  align-items: center;
  font-size: 12.5px;
}

.lp-reminder-row svg {
  color: var(--lp-text-3);
  margin-right: 8px;
}

.lp-reminder-row .lp-when {
  color: var(--lp-text-3);
  margin-left: auto;
}

.lp-latest-row {
  display: flex;
  align-items: center;
  font-size: 12.5px;
}

.lp-latest-row .lp-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Layout grid for event detail ─────────────────────────────────── */

.lp-detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.lp-detail-grid .lp-full {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .lp-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Big stat inside card ─────────────────────────────────────────── */

.lp-stat-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.lp-stat-row .lp-big {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--lp-success);
}

/* ── Forms (V1 Classic) ───────────────────────────────────────────── */

/* Wrapper — ограничивает ширину, но тянется на всю column в .lp-page. */
.lp-form {
  max-width: 900px;
}

/* Секция — визуальная группа полей. Между секциями — горизонтальные
   разделители. Первая секция без верхнего border. */
.lp-form-section {
  padding: 16px 20px;
  border-top: 1px solid var(--lp-border);
}

.lp-form-section:first-child {
  border-top: 0;
}

/* Группа "label + control" (stacked). */
.lp-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lp-form-group + .lp-form-group {
  margin-top: 14px;
}

.lp-form-label {
  color: var(--lp-text);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
}

.lp-form-label .lp-hint,
.lp-form-hint {
  color: var(--lp-text-3);
  font-size: 11.5px;
  font-weight: 400;
  margin-left: 4px;
}

.lp-form-sub {
  color: var(--lp-text-3);
  font-size: 11.5px;
  margin-top: 4px;
}

/* Парная 2-кол сетка внутри секции. */
.lp-form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
}

@media (max-width: 700px) {
  .lp-form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Поля формы — переопределяем базовые .lp-input/.lp-select на полную
   ширину и высоту 32px для форм. */
.lp-form .lp-input,
.lp-form .lp-select,
.lp-form .lp-textarea {
  width: 100%;
  height: 32px;
  font-size: 13px;
}

.lp-form textarea.lp-input,
.lp-form .lp-textarea {
  height: auto;
  min-height: 120px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

.lp-form input[type="datetime-local"],
.lp-form input[type="date"],
.lp-form input[type="time"] {
  font-family: inherit;
}

.lp-form input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.lp-form .lp-input:disabled,
.lp-form .lp-select:disabled {
  background: var(--lp-surface-2);
  color: var(--lp-text-3);
  cursor: not-allowed;
}

/* Checkbox + текст: отдельный блок (обычно внизу формы). */
.lp-form-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
}

.lp-form-option > input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--lp-primary);
}

.lp-form-option .lp-form-option-body {
  flex: 1;
  min-width: 0;
}

.lp-form-option-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--lp-text);
  cursor: pointer;
}

.lp-form-option-sub {
  color: var(--lp-text-3);
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.45;
}

/* Char counter (справа под textarea). */
.lp-form-counter {
  color: var(--lp-text-3);
  font-size: 11px;
  text-align: right;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE (≤480px): iPhone SE/14/15/16/Pro Max. Single source of truth.
   Только переопределения — десктоп >= 481px не затрагивается.
   ══════════════════════════════════════════════════════════════════ */

/* Hamburger через CSS-only checkbox-hack. На десктопе чекбокс и его
   лейбл скрыты, nav рендерится как обычно (flex-row). На мобильном
   лейбл становится кнопкой ☰, nav прячется и показывается по клику
   (через :checked ~ .lp-topnav). */
.lp-nav-toggle { display: none; }
.lp-nav-burger { display: none; }

@media (max-width: 480px) {

  /* —— Корневой layout: убираем горизонтальный скролл body ——
     overflow-x:clip (а не hidden!) — clip не создаёт scroll-context,
     поэтому position:sticky у потомков (topbar, subhead) продолжает работать.
     С overflow-x:hidden Safari ломает sticky — известный quirk. */
  html, body {
    overflow-x: clip;
    max-width: 100vw;
  }

  /* —— Topbar: hamburger + сжатый бренд. position:sticky сохраняем
     (наследуется из десктопного правила), чтобы topbar не уезжал
     при скролле. Мобильный dropdown nav будет position:fixed —
     не зависит от родителя. —— */
  .lp-topbar {
    padding: 0 10px;
    gap: 6px;
  }
  .lp-topbar-brand {
    font-size: 0; /* прячем текст бренда, оставляем только иконку */
    border-right: 0;
    margin-right: 0;
    padding: 0 4px;
    gap: 0;
  }
  .lp-topbar-brand .lp-leaf {
    font-size: 14px; /* возвращаем размер иконке-родителю */
  }

  /* hamburger button (label) показывается на мобильном */
  .lp-nav-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--lp-text);
    font-size: 20px;
    line-height: 1;
    user-select: none;
    flex: 1;
    justify-content: flex-start;
  }
  .lp-nav-burger:hover {
    background: var(--lp-surface-2);
  }
  /* при :checked меняем иконку ☰ → ✕ через ::before/::after — но проще
     просто оставить ☰, юзер привычен к обоим состояниям */

  /* Мобильный nav: position:fixed (не зависит от родителя). Hide через
     max-height:0 + overflow:hidden — БЕЗ transform/translate, потому что
     Safari кэширует paint-слой transform-элемента и оставляет «серый
     призрак» после скрытия. max-height + overflow вычеркивают элемент
     визуально полностью. Border-bottom + box-shadow тоже выключаются
     при свёрнутом состоянии. */
  .lp-topbar .lp-topnav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: 44px;
    left: 0;
    right: 0;
    background: var(--lp-surface);
    z-index: 50;
    overflow: hidden;
    max-height: 0;
    border-bottom: 0 solid var(--lp-border);
    box-shadow: none;
    padding: 0 6px;
    gap: 2px;
    pointer-events: none;
    transition:
      max-height 0.18s ease-out,
      padding 0.18s ease-out,
      border-bottom-width 0s 0.18s,
      box-shadow 0s 0.18s;
  }
  .lp-nav-toggle:checked ~ .lp-topnav {
    /* 500px достаточно для 9 пунктов × ~40px + padding/gap. Меню
       вырастает только на размер контента, не во весь экран. Если
       пунктов станет больше 12 — увеличить или поменять на 80vh. */
    max-height: 500px;
    overflow-y: auto;
    border-bottom-width: 1px;
    box-shadow: var(--lp-shadow);
    padding: 6px;
    pointer-events: auto;
    transition:
      max-height 0.22s ease-out,
      padding 0.18s ease-out,
      border-bottom-width 0s 0s,
      box-shadow 0s 0s;
  }
  .lp-topbar .lp-topnav a {
    height: 38px;
    padding: 8px 12px;
    width: 100%;
    flex-shrink: 0;
  }

  /* —— Sub-header: меньше padding, остальное как на десктопе (flex-wrap) —— */
  .lp-subhead {
    padding: 8px 14px;
    gap: 8px;
  }
  .lp-subhead .lp-subhead-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .lp-subhead .lp-crumbs {
    flex-wrap: wrap;
  }

  /* —— Page padding —— */
  .lp-page {
    padding: 12px 14px 24px;
  }

  /* —— Page title compact —— */
  .lp-page-title h1 {
    font-size: 22px;
  }

  /* —— Card padding compact —— */
  .lp-card-body { padding: 12px 14px; }
  .lp-card-head { padding: 10px 14px; }

  /* —— Таблицы: sticky первой колонки + снимаем фикс-ширины —— */
  .lp-tbl {
    font-size: 12.5px;
  }
  .lp-tbl th, .lp-tbl td {
    padding: 8px 10px;
  }
  .lp-tbl th[style*="width"],
  .lp-tbl td[style*="width"] {
    width: auto !important;
    min-width: 90px;
  }
  .lp-tbl th:first-child,
  .lp-tbl td:first-child {
    position: sticky;
    left: 0;
    background: var(--lp-surface);
    z-index: 2;
    box-shadow: 1px 0 0 var(--lp-border);
    min-width: 130px;
    max-width: 180px;
  }
  .lp-tbl thead th:first-child {
    background: var(--lp-surface-2);
  }
  .lp-tbl tbody tr:hover td:first-child {
    background: var(--lp-surface-2);
  }
  .lp-tbl tbody tr:nth-child(even) td:first-child {
    background: var(--lp-surface);
  }

  /* —— Универсальный override: ВСЕ inline grid-template-columns → 1 col ——
     Это покрывает: фильтры (people/lead-magnets/inbox/waitlists/signups
     где grid на <form>), edit-страницы (lead-magnets/waitlists с
     grid `1fr 320px` на .lp-page), settings/broadcasts/analytics детали.
     Исключения ниже. */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* Исключение #1: dashboard 6 stat-cards → 2x3 (а не 1 col stack — слишком
     длинно). Специфичность .lp-page > div[style*=...] выше универсального
     [style*=...], поэтому это правило побеждает. */
  .lp-page > div[style*="repeat(6"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  /* Stat-card: title слева + число справа → стэк (title сверху, число снизу) */
  .lp-page div[style*="min-height:62px"],
  .lp-page div[style*="min-height: 62px"] {
    min-height: 0 !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }
  .lp-page div[style*="min-height:62px"] > * {
    text-align: left !important;
  }

  /* Кнопки "Применить" + "Сбросить" в filter-формах — последний div
     внутри формы. Оставляем их в строку (display:flex уже inline), но
     flex-wrap на случай узкого экрана. */
  .lp-card form[style*="grid-template-columns"] > div:last-child,
  .lp-card form[style*="display:grid"] > div:last-child {
    flex-wrap: wrap;
  }

  /* —— Tabs: горизонтальный скролл если не помещаются —— */
  .lp-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .lp-tabs::-webkit-scrollbar { display: none; }

  /* —— Detail-grid (1fr 320px → 1 col уже на 900px, но sidebar на 390 узковат) —— */
  .lp-detail-grid {
    gap: 12px;
  }

  /* —— Form 2-col → 1 col (уже на 700px). Доп: padding sections —— */
  .lp-form-section {
    padding: 14px 14px;
  }
  .lp-form-option {
    padding: 12px 14px;
  }

  /* —— Кнопки в подзаголовках/actions: сжимаем чуть —— */
  .lp-btn-sm {
    font-size: 12px;
  }

  /* —— Таблицы-обёртки в шаблонах: <div style="overflow-x:auto"> —
     добавим небольшой momentum scroll для iOS —— */
  div[style*="overflow-x:auto"],
  div[style*="overflow-x: auto"] {
    -webkit-overflow-scrolling: touch;
  }
}

