/* =========================================================
   LAYOUT — раскладка и поведение элементов.
   Использует только переменные из theme.css.
   ========================================================= */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font: var(--fs-body)/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { max-width: 100%; display: block; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--c-text-muted); }

/* ---------- верхняя панель ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 8px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-line);
}
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.logo { font-family: var(--font-display); font-weight: 800; letter-spacing: .04em; }
.topbar-spacer { width: 44px; margin-left: auto; }

/* ---------- боковое меню ---------- */
.drawer-backdrop, .sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30;
}
.drawer-backdrop.is-open, .sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 31;
  width: min(84vw, 320px); overflow-y: auto;
  padding: 20px 12px calc(20px + env(safe-area-inset-bottom));
  background: var(--c-surface);
  transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: none; }
.drawer-title { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-h2); padding: 0 12px 16px; }
.nav-item, .nav-sub {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; min-height: 48px; padding: 0 12px;
  border-radius: var(--radius-btn); text-align: left;
}
.nav-item.is-active { background: var(--c-surface-2); }
.nav-sub { min-height: 40px; padding-left: 28px; color: var(--c-text-muted); font-size: 15px; }
.nav-group[hidden] { display: none; }
.nav-chevron { transition: transform .2s; }
.nav-item[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }
.drawer-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--c-line); }

/* ---------- страницы ---------- */
.view { padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.page-title { font-family: var(--font-display); font-size: var(--fs-h1); line-height: 1.1; margin: 8px 0 12px; }
.section-title { font-size: var(--fs-h2); margin: 32px 0 12px; }
.lead { color: var(--c-text-muted); margin: 0 0 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* главная */
.hero { min-height: 58vh; display: flex; flex-direction: column; justify-content: flex-end; padding: 24px 0; border-bottom: 1px solid var(--c-line); }
.hero-name { font-family: var(--font-display); font-size: var(--fs-display); font-weight: 900; line-height: .95; letter-spacing: -.02em; margin: 0; }
.hero-slogan { margin: 16px 0 0; color: var(--c-text-muted); }
.scroll-hint { margin-top: 28px; font-size: var(--fs-small); color: var(--c-text-muted); }
.cta-block { margin-top: 32px; padding: 24px 0; }
.cta-phrase { font-family: var(--font-display); font-size: var(--fs-h1); font-weight: 800; line-height: 1.1; margin: 0 0 20px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* карточки */
.card {
  display: block; padding: 16px;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius-card);
}
.card-title { font-weight: 700; margin: 0 0 4px; }
.card-text { color: var(--c-text-muted); font-size: 15px; margin: 0; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* баннер группы */
.banner { position: relative; overflow: hidden; padding: 18px 16px; border-left: 6px solid var(--accent, var(--c-accent)); }
.banner .card-title { font-size: 18px; }

/* статус набора: цвет + текст моноширинным */
.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; text-transform: lowercase; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.is-open { color: var(--c-open); }
.status.is-closed { color: var(--c-closed); }

/* переключатель все / ICE ENT / группы */
.segmented { display: flex; padding: 4px; gap: 4px; background: var(--c-surface); border-radius: var(--radius-btn); margin-bottom: 16px; }
.segmented button { flex: 1; min-height: 40px; border-radius: calc(var(--radius-btn) - 4px); color: var(--c-text-muted); font-size: 15px; }
.segmented button.is-active { background: var(--c-surface-2); color: var(--c-text); }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; width: 100%;
  border-radius: var(--radius-btn); font-weight: 700;
  background: var(--c-accent); color: var(--c-accent-text);
}
.btn-secondary { background: var(--c-surface-2); color: var(--c-text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-small { min-height: 36px; padding: 0 14px; width: auto; font-size: 14px; }

/* шапка группы */
.group-header { padding: 28px 16px; margin: -20px -16px 20px; background: linear-gradient(160deg, var(--accent, var(--c-accent)) 0%, var(--c-bg) 85%); }
.group-header .page-title { margin-top: 12px; }
.description { font-family: var(--font-mono); font-size: 14px; white-space: pre-line; }
.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.person-photo { aspect-ratio: 3 / 4; border-radius: calc(var(--radius-card) - 4px); background: var(--c-surface-2); display: grid; place-items: center; font-size: 28px; font-weight: 800; color: var(--c-text-muted); margin-bottom: 10px; }

/* пустое состояние */
.empty { text-align: center; padding: 40px 16px; color: var(--c-text-muted); }

/* ---------- всплывающая форма (bottom sheet) ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-height: 92vh; overflow-y: auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--c-surface); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: var(--shadow-sheet);
  transform: translateY(100%); transition: transform .28s ease;
  max-width: 640px; margin: 0 auto;
}
.sheet.is-open { transform: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--c-line); margin: 0 auto 16px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.sheet-head h2 { margin: 0; font-size: var(--fs-h2); }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 14px; margin-bottom: 6px; }
.req { color: var(--c-accent); }
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--c-bg); color: var(--c-text);
  border: 1px solid var(--c-line); border-radius: var(--radius-input);
  font: inherit; outline: none;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--c-text-muted); }
.field.has-error .input, .field.has-error .textarea, .field.has-error .select, .field.has-error .file { border-color: var(--c-error); }
.field-error { color: var(--c-error); font-size: var(--fs-small); margin-top: 6px; display: none; }
.field.has-error .field-error { display: block; }
.file {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px;
  border: 1px dashed var(--c-line); border-radius: var(--radius-input); color: var(--c-text-muted);
}
.file input { display: none; }
.form-error { color: var(--c-error); font-size: 14px; margin: 0 0 12px; }
.success { text-align: center; padding: 24px 0 8px; }
.success-icon { font-size: 44px; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

body.no-scroll { overflow: hidden; }
