:root {
  --bg: #0f1115;
  --panel: #161920;
  --panel-2: #1c2029;
  --border: #272b36;
  --border-soft: #21242d;
  --text: #e7e9ee;
  /* --muted был #8a90a0 — контраст 4:1 на --panel-2. Поднят до ≈5:1 (WCAG AA).
     Все тонкие подписи, хинты и мета-текст светлее — читаются на тёмном фоне. */
  --muted: #a3a9ba;
  --accent: #4f8cff;
  --accent-2: #6ea3ff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --danger: #ef4b6b;
  --ok: #33c07a;
  --warn: #f6b73c;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --canvas-bg: #0a0c11;
  --canvas-grid: rgba(255, 255, 255, 0.04);
  --canvas-grid-strong: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  display: grid;
  grid-template-rows: auto 1fr;
  /* minmax(0, 1fr) — без 0 grid-колонка разрастается до min-content,
     и topbar начинает выступать за вьюпорт вместо того чтобы скроллиться внутри. */
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  user-select: none;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  /* Высота topbar === ширина sidebar (56px). Визуально угол "┐" ровный,
     кнопки в обеих панелях одного touch-масштаба (40-44px). */
  height: 56px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.topbar .btn { min-height: 40px; }
.topbar .btn.icon-only { min-width: 40px; }
.topbar::-webkit-scrollbar { height: 4px; }
.topbar::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 2px;
}
.topbar > * { flex-shrink: 0; }
.topbar > .topbar-actions {
  display: flex; gap: 8px; align-items: center;
  margin-inline-start: auto;  /* actions жмутся к правому краю когда места хватает */
}
.topbar > .topbar-actions > * { flex-shrink: 0; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #8b5cff);
  color: #fff;
  border-radius: 8px;
  display: grid; place-items: center;
}
.brand-title {
  font-weight: 700; font-size: 14px; letter-spacing: -0.01em;
  max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-title[contenteditable="plaintext-only"]:focus {
  white-space: normal; overflow: visible; text-overflow: unset;
}
.brand-sub { color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.btn:hover { background: #232733; border-color: #343949; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--danger); border-color: rgba(239, 75, 107, 0.25); }
.btn.danger:hover { background: rgba(239, 75, 107, 0.1); }
.btn.icon-only {
  padding: 0;
  justify-content: center;  /* выравнивание svg-иконки по центру кнопки */
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; border-color: var(--border); }

/* ---------- Workspace ----------
   На desktop и sidebar, и inspector плавают поверх canvas через position: absolute —
   canvas-wrap занимает всю площадь, не ограничиваясь их высотой. На mobile sidebar
   становится обычной grid-колонкой (media-query ниже). */
.workspace {
  display: block;
  min-height: 0;
  height: 100%;
  position: relative;
}

/* Для editor'а делаем body/swup полноэкранным контейнером: body — flex column,
   swup внутри — grid с auto topbar + 1fr workspace. Остальные страницы (landing,
   pricing и т.д.) оверрайдят body display, так что их layout не задет. */
body.page-editor {
  display: flex;
  flex-direction: column;
}
body.page-editor .swup-container {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ---------- Sidebar ----------
   Desktop: плавает в левом верхнем углу workspace (по той же схеме, что inspector).
   Авто-высота от контента, max-height упирается в viewport — при коротком экране
   включается внутренний scroll. Mobile override — в media-query ниже. */
.sidebar {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 56px;
  max-height: calc(100% - 24px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  z-index: 5;
}
.tool-group { display: flex; flex-direction: column; gap: 4px; }
/* Group-заголовки (TOOLS/OBJECTS/...) скрыты: узкий sidebar не помещает их,
   а иконки + лейблы самих кнопок уже дают достаточно контекста. */
.tool-title { display: none; }
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
}
.tool:hover { background: var(--panel-2); border-color: var(--border); }
.tool.active {
  background: var(--accent-soft);
  border-color: rgba(79, 140, 255, 0.4);
  color: var(--accent-2);
}
.tool.danger:hover { background: rgba(239, 75, 107, 0.1); color: var(--danger); }

/* ---------- Canvas ---------- */
.canvas-wrap {
  position: relative;
  background: var(--canvas-bg);
  overflow: hidden;
  min-width: 0;
  width: 100%;
  height: 100%;
}
#stage { width: 100%; height: 100%; }

.hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  /* width по контенту, но не шире 560px — короткие хинты остаются компактной
     pill'ой, длинные (например hint'ы у align-bg) переносятся в 2 строки. */
  width: max-content;
  max-width: min(560px, calc(100% - 32px));
  text-align: center;
  background: rgba(22, 25, 32, 0.95);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.hint.show { opacity: 1; }
/* На мобильном pill-форма (999px) плохо смотрится когда текст в 3-4 строки.
   Тянем hint на всю доступную ширину и делаем углы умеренно скруглёнными. */
@media (max-width: 720px) {
  .hint {
    left: 8px; right: 8px;
    transform: none;
    max-width: none;
    border-radius: 12px;
  }
}

.canvas-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.round {
  width: 44px;  /* HIG / Material touch-target min */
  height: 44px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.round:hover { background: var(--panel-2); border-color: #343949; }

/* ---------- Inspector ----------
   Desktop: плавает поверх canvas в правом верхнем углу workspace.
   Высота = content-size, ограниченная viewport'ом (max-height: calc(100% - 24px)).
   Когда контента мало — панель маленькая, под ней свободное место для чертежа.
   Когда много — внутри .inspector-body появляется scroll.
   Видимость регулируется классом .open — click outside / Escape / FAB её тогглят. */
.inspector {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: auto;
  width: 300px;
  height: auto;
  max-height: calc(100% - 24px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 5;
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform-origin: top right;
}
/* На desktop без .open инспектор скрыт — opacity/scale-ридер, pointer-events off.
   display:none не используем — хочется плавный fade при toggle. */
.inspector:not(.open) {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
}
.inspector-handle { display: none; }
/* FAB — открывает скрытый инспектор на desktop (в углу, где он был).
   На mobile стили переопределяются в media-query ниже (круглая кнопка внизу). */
.btn-inspector-open {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  transition: background 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-inspector-open:hover { background: var(--panel-2); }
.btn-inspector-open.hidden { display: none; }
/* ⋮ More: без бордера/фона, только иконка, как типичное trailing-меню в интерфейсах.
   Только на mobile (в media-query ниже получает display: inline-flex). */
.btn-more {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0;
  width: 40px; height: 40px;
  border-radius: 999px;
  cursor: pointer;
  align-items: center; justify-content: center;
  font-family: inherit;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.btn-more:hover { background: var(--panel-2); }
.btn-more:active { background: #232733; }
.inspector-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.inspector-header .title { font-weight: 600; font-size: 13px; }
.inspector-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}
.empty-icon {
  font-size: 32px;
  opacity: 0.3;
  margin-bottom: 12px;
}
.empty .muted { font-size: 11px; margin-top: 6px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.field label, .field .label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field input[type="number"], .field input[type="text"], .field select {
  padding: 7px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s ease;
}
.field input:focus, .field select:focus { border-color: var(--accent); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.prop-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.prop-title:first-child { margin-top: 0; }

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent-2);
}

.muted { color: var(--muted); }

/* ---------- Dialog ---------- */
.dialog {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  max-width: 360px;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); }
.dialog form { padding: 20px; }
.dialog h3 { margin: 0 0 6px; font-size: 15px; }
.dialog .muted { font-size: 12px; margin-bottom: 16px; }
.dialog label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.dialog label span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dialog input {
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.dialog input:focus { border-color: var(--accent); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(51, 192, 122, 0.4); }
.toast.err { border-color: rgba(239, 75, 107, 0.4); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #343949; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .inspector { width: 260px; }
}
@media (max-width: 720px) {
  /* На mobile sidebar тоже плавает слева (как на desktop) — просто наследует
     базовые стили. При вертикальной нехватке места внутри появляется scroll
     (max-height + overflow-y: auto уже выставлены в базовом .sidebar). */

  /* Скрываем ползунки у плавающих панелей на мобильном — на узком экране они
     выглядят неопрятно и съедают ширину. Скролл по-прежнему работает свайпом. */
  .sidebar,
  .inspector-body {
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* Legacy Edge/IE */
  }
  .sidebar::-webkit-scrollbar,
  .inspector-body::-webkit-scrollbar {
    display: none;                /* Chromium/Safari */
  }

  /* Текстовая часть brand (title + "Not saved yet") скрыта на mobile —
     освобождает место для action-кнопок. Название редактируется через Properties. */
  .topbar .brand > div:not(.logo) { display: none; }

  /* --- Inspector как bottom sheet ---
     Фиксируем внизу экрана. Высота = content-size (но не больше 70vh — чтобы
     можно было видеть холст и закрывать). Открытие/закрытие — через класс .open. */
  .inspector {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    width: auto;
    height: auto;
    z-index: 20;
    max-height: 70vh;
    background: var(--panel);
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
    display: flex; flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    /* Отключаем user-select во время drag — чтобы свайп не выделял текст */
    touch-action: none;
  }
  .inspector.dragging { transition: none; }

  /* --- Peek state ---
     Когда выбран объект, sheet выдвигается только на высоту handle+header с
     названием объекта. Tap или свайп вверх по handle/header раскрывают его
     полностью. Высота пика = handle (~20px) + header (~48px) ≈ 68px. */
  .inspector.peek {
    transform: translateY(calc(100% - 68px));
  }
  .inspector.peek .inspector-header {
    display: block;
    padding: 8px 18px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .inspector.peek .inspector-header .title {
    font-size: 14px;
    font-weight: 600;
  }

  /* .open идёт ПОСЛЕ .peek, чтобы при наличии обоих классов переопределять
     peek-смещение на полное раскрытие (специфичность у них одинаковая, решает
     порядок). */
  .inspector.open { transform: translateY(0); }

  /* Drag handle — видимая "полоска" сверху, hit-area крупная */
  .inspector-handle {
    display: flex; justify-content: center;
    padding: 10px 0 6px;
    cursor: grab;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .inspector-handle::before {
    content: "";
    width: 44px; height: 4px;
    background: var(--border);
    border-radius: 999px;
  }
  .inspector-handle:active { cursor: grabbing; }

  /* На desktop handle не нужен */
  .inspector-body { overflow-y: auto; flex: 1; }
  .inspector-header { display: none; }  /* Заголовок Properties не нужен в sheet — handle сам маркирует */

  /* На mobile FAB (desktop-only кнопка re-open инспектора) не нужен — его роль
     играет peek: выделение объекта → автоматически выдвигается peek-заголовок. */
  .btn-inspector-open { display: none; }

  /* На mobile инспектор без .open и .peek — bottom-sheet полностью скрыт через
     translateY. Отменяем desktop-правило opacity/scale, чтобы работала slide-
     анимация. Peek и open обрабатываются своими правилами выше. */
  .inspector:not(.open):not(.peek) {
    opacity: 1;
    transform: translateY(100%);
    pointer-events: auto;
  }
  /* У .peek тоже нужно сбросить desktop-opacity/pointer-events */
  .inspector.peek {
    opacity: 1;
    pointer-events: auto;
  }

  /* 44px touch target. Чтобы undo/redo не выбивались по высоте от Save и т.д. —
     одинаковый min-height для всех топбар-кнопок. */
  .topbar .btn { min-height: 44px; }
  .topbar .btn.icon-only { min-width: 44px; }

  /* Versions / Share / Import — редкие действия, прячем на mobile и кладём
     в "⋮" меню (btn-more → открывает инспектор в режиме 'more'). */
  .topbar #btn-versions,
  .topbar #btn-share,
  .topbar label.btn.ghost { display: none; }  /* label.btn.ghost = Import */
  .btn-more { display: inline-flex; width: 44px; height: 44px; }
}


/* ============================================================
   Landing / marketing pages
   ============================================================ */
body.page-landing,
body.page-pricing,
body.page-list { display: block; height: auto; min-height: 100vh; }

.swup-container { min-height: 100%; }

.site-topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 14px 28px;
    background: rgba(15, 17, 21, 0.85); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
}
.site-brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.site-brand-mark {
    width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent);
}
.site-brand-title { font-weight: 700; font-size: 15px; display: block; }
.site-brand-sub { font-size: 11px; color: var(--muted); display: block; }
.site-nav { display: inline-flex; align-items: center; gap: 18px; }
.site-nav-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.site-nav-link:hover { color: var(--text); }
.site-nav-cta {
    background: var(--accent); color: white; text-decoration: none;
    padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
}
.site-nav-cta:hover { background: var(--accent-2); }
.site-lang-switcher select {
    background: var(--panel); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 6px 10px; font-size: 12px;
}
/* Language switcher внутри инспектора — растягиваем на всю ширину field-slot'а */
#inspector .site-lang-switcher { width: 100%; }
#inspector .site-lang-switcher select { width: 100%; padding: 8px 10px; font-size: 13px; }

.landing { max-width: 1120px; margin: 0 auto; padding: 40px 28px 80px; }
.landing-hero { padding: 60px 0 40px; text-align: center; }
.landing-hero h1 { font-size: 42px; margin: 0 0 14px; letter-spacing: -0.02em; }
.landing-lede { font-size: 17px; color: var(--muted); max-width: 640px; margin: 0 auto 24px; line-height: 1.5; }
.landing-cta { display: inline-flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.landing-tags { margin-top: 28px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.landing-tags span {
    font-size: 12px; color: var(--muted);
    border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px;
}

.btn.lg { padding: 12px 22px; font-size: 14px; font-weight: 600; }

.landing-features { padding: 60px 0; }
.landing-features h2 { font-size: 24px; margin: 0 0 24px; }
.feature-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.feature {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
}
.feature h3 { margin: 0 0 8px; font-size: 15px; }
.feature p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.landing-cta-band {
    margin-top: 40px; padding: 48px 24px; text-align: center;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.landing-cta-band h2 { font-size: 22px; margin: 0 0 10px; }
.landing-cta-band p { color: var(--muted); max-width: 520px; margin: 0 auto 20px; }

.pricing-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px; margin-top: 40px;
}
.pricing-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    display: flex; flex-direction: column; gap: 10px;
}
.pricing-card.highlight { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.pricing-card h3 { margin: 0; font-size: 18px; }
.pricing-price { font-size: 32px; font-weight: 700; margin: 8px 0; }
.pricing-price span { font-size: 14px; color: var(--muted); font-weight: 400; margin-inline-start: 4px; }
.pricing-card ul { list-style: none; padding: 0; margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.pricing-card ul li::before { content: '✓'; color: var(--ok); margin-inline-end: 6px; }

.projects-list { padding: 40px 0; }
.project-cards { list-style: none; padding: 0; margin: 0;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.project-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.project-card a { display: block; padding: 18px; color: inherit; text-decoration: none; }
.project-card a:hover { background: var(--panel-2); }
.project-card h3 { margin: 0 0 4px; font-size: 15px; }

.site-footer {
    border-top: 1px solid var(--border-soft); margin-top: 60px;
    padding: 24px 0; color: var(--muted); font-size: 12px;
}
.site-footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 16px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }
.center { text-align: center; }

/* ============================================================
   Editor: share / versions dialogs + save-status in topbar
   ============================================================ */
#save-status.error { color: var(--danger); }
.share-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.share-row {
    display: flex; align-items: center; gap: 8px;
    background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 10px; font-size: 12px;
}
.share-row code { flex: 1; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, Menlo, monospace; }
.share-row .tag {
    background: var(--accent-soft); color: var(--accent);
    padding: 2px 8px; border-radius: 999px; font-size: 11px;
}
.share-new { display: flex; gap: 8px; margin-top: 8px; }
.share-new select {
    background: var(--panel); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 10px;
}
.versions-list { display: flex; flex-direction: column; gap: 6px; max-height: 400px; overflow-y: auto; margin: 16px 0; }
.version-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--panel-2); font-size: 12px;
}
.version-row .tag { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.version-row .tag.manual { background: rgba(51, 192, 122, 0.2); color: var(--ok); }
.version-row .when { color: var(--muted); }
.version-row .comment { color: var(--text); flex: 1; }
.btn.sm { padding: 4px 10px; font-size: 11px; }

/* Responsive landing */
@media (max-width: 720px) {
    .site-nav { display: none; }
    .landing-hero h1 { font-size: 32px; }
    .landing { padding: 20px 14px 60px; }
}

/* ============================================================
   Auth / Settings
   ============================================================ */
body.page-auth,
body.page-settings { display: block; height: auto; min-height: 100vh; }

.auth-wrap {
    max-width: 460px; margin: 60px auto; padding: 0 20px;
}
.auth-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 32px;
}
.auth-card h1 { margin: 0 0 10px; font-size: 22px; }
.auth-card p.muted { color: var(--muted); margin: 0 0 20px; }
.auth-card p.small { font-size: 12px; margin-top: 16px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.auth-card input[type="email"],
.auth-card input[type="text"] {
    background: var(--panel-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.auth-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.alert {
    padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--panel-2);
    font-size: 13px;
}
.alert.error { border-color: rgba(239, 75, 107, 0.4); color: var(--danger); }
.alert.success { border-color: rgba(51, 192, 122, 0.4); color: var(--ok); }

.settings-section {
    max-width: 640px; margin: 24px auto; padding: 24px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.settings-section h2 { margin: 0 0 14px; font-size: 16px; }
.settings-section.danger { border-color: rgba(239, 75, 107, 0.3); }
.settings-form { display: flex; flex-direction: column; gap: 12px; }
.settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.settings-form input,
.settings-form input[disabled] {
    background: var(--panel-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.settings-form input[disabled] { color: var(--muted); }
.settings-form .btn { align-self: start; }

.btn.danger {
    background: transparent; color: var(--danger);
    border: 1px solid rgba(239, 75, 107, 0.4);
}
.btn.danger:hover { background: rgba(239, 75, 107, 0.1); }

.checkbox { flex-direction: row; align-items: center; gap: 10px; }

/* Account dropdown in topbar */
.site-account { position: relative; }
.site-account summary {
    list-style: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.site-account summary::-webkit-details-marker { display: none; }
.site-account-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}
.site-account-menu {
    position: absolute; top: calc(100% + 6px); right: 0;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 220px; padding: 10px; z-index: 30;
    display: flex; flex-direction: column; gap: 2px;
}
[dir="rtl"] .site-account-menu { right: auto; left: 0; }
.site-account-email {
    padding: 6px 10px; color: var(--muted); font-size: 12px;
    border-bottom: 1px solid var(--border-soft); margin-bottom: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-account-menu a {
    padding: 8px 10px; border-radius: var(--radius-sm);
    color: var(--text); text-decoration: none; font-size: 13px;
}
.site-account-menu a:hover { background: var(--panel-2); }

/* ---------- Background rotation card (в правой панели Properties) ----------
   Видна только когда фон загружен. Layout вертикальный — ширины инспектора
   (~300px) хватает с запасом для горизонтального ряда кнопок. */
.bg-card {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--panel-2);
    display: flex; flex-direction: column; gap: 8px;
}
.bg-card-title {
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--muted);
}
/* Download-секция в инспекторе — 3 кнопки формата в один ряд */
.download-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
    margin-bottom: 10px;
}
.download-grid .btn {
    padding: 8px 4px; font-size: 12px;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    min-height: 36px;
}
.download-grid .btn svg { flex-shrink: 0; }

.bg-row {
    display: grid; grid-template-columns: auto 1fr auto; gap: 6px;
    align-items: center;
}
.bg-row .btn.sm {
    padding: 6px 10px; font-size: 11px; white-space: nowrap;
}
.bg-card-hint {
    font-size: 11px; color: #a3a9ba; /* WCAG AA — поднят с var(--muted) */
    line-height: 1.4;
}
.bg-rot-input {
    position: relative;
    display: flex; align-items: center;
}
.bg-rot-input input {
    width: 100%;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 6px 18px 6px 8px; font-size: 12px; font-family: inherit;
    text-align: center;
    -moz-appearance: textfield;
}
.bg-rot-input input::-webkit-outer-spin-button,
.bg-rot-input input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
.bg-rot-input span {
    position: absolute; right: 7px;
    color: var(--muted); font-size: 11px; pointer-events: none;
}
.align-by-line-btn {
    display: inline-flex; align-items: center; gap: 8px;
    justify-content: flex-start;
    padding: 7px 10px; font-size: 12px;
}
.align-by-line-btn.active {
    border-color: var(--accent); color: var(--accent);
}
