/* Hallmark: Семейный устав Учитопии (uchitopia.ru/ustav) — живой лист А4 на тёплой бумаге бренда */
:root {
  --uch-brand-600: #0050D2;
  --uch-brand-700: #0047BF;
  --uch-graphite-800: #3B4763;
  --uch-graphite-600: #4A5679;
  --uch-graphite-500: #5E6884;
  --uch-ink-500: #6B7493;
  --uch-ink-300: #858CA8;
  --uch-paper-50: #FFFDF9;
  --uch-paper-100: #FAF6EE;
  --uch-paper-200: #E7DECD;
  --uch-paper-300: #D8CCB6;
  --uch-gold-500: #FFC81F;
  --uch-gold-300: #FFD755;
  --uch-gold-100: #FFF2C7;
  --uch-gold-900: #6A4800;
  --uch-sky-600: #1F63D6;
  --uch-sky-500: #2F7BF0;
  --uch-sky-200: #C9D6F2;
  --uch-sky-100: #E8F0FD;
  --uch-sky-900: #183A8C;
  --uch-green-700: #2A6F34;
  --uch-green-100: #E6F3E3;
  --uch-red-700: #B23A12;
  --uch-red-100: #FBE7DF;
  --uch-font-display: 'Geologica', system-ui, sans-serif;
  --uch-font-text: 'Golos Text', system-ui, sans-serif;
  --uch-page: var(--uch-paper-100);
  --uch-surface: var(--uch-paper-50);
  --uch-line: var(--uch-paper-200);
  --uch-line-strong: var(--uch-paper-300);
  --uch-line-field: var(--uch-ink-500);
  --uch-heading: var(--uch-graphite-800);
  --uch-text: var(--uch-graphite-600);
  --uch-text-muted: var(--uch-graphite-500);
  --uch-action: var(--uch-brand-600);
  --uch-action-hover: var(--uch-brand-700);
  --uch-action-active: var(--uch-sky-900);
  --uch-on-action: var(--uch-paper-50);
  --uch-selected: var(--uch-sky-100);
  --uch-selected-line: var(--uch-sky-200);
  --uch-on-selected: var(--uch-brand-700);
  --uch-child-soft: var(--uch-gold-100);
  --uch-child-ink: var(--uch-gold-900);
  --uch-focus: var(--uch-brand-600);
  --uch-shadow-sheet: 0 2px 8px rgba(59, 71, 99, 0.06), 0 12px 32px rgba(59, 71, 99, 0.08);
  --uch-r-control: 12px;
  --uch-r-sheet: 16px;
  --uch-r-pill: 999px;
  --uch-motion-fast: 120ms;
  --uch-motion-base: 220ms;
  --uch-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  background-color: var(--uch-page);
  color: var(--uch-text);
  font-family: var(--uch-font-text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  caret-color: var(--uch-action);
  accent-color: var(--uch-action);
}

button,
a,
[role="button"] {
  touch-action: manipulation;
}

button,
[role="button"],
.signer-pill {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

::selection {
  background-color: var(--uch-selected);
  color: var(--uch-on-selected);
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--uch-heading);
  font-family: var(--uch-font-display);
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: var(--uch-action);
  text-underline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  a:hover {
    color: var(--uch-action-hover);
  }
}

a:active {
  color: var(--uch-action-active);
}

:focus-visible {
  outline: 3px solid var(--uch-focus);
  outline-offset: 2px;
}

.print-only {
  display: none;
}

.wrap {
  max-width: 1360px;
  margin-inline: auto;
  padding-inline: 48px;
}

/* Шапка */
.site-top {
  border-bottom: 1px solid var(--uch-line);
  background-color: var(--uch-page);
}

.site-top .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 12px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}

.brand-link img {
  height: 36px;
  width: auto;
  display: block;
}

.home-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 12px;
  border-radius: var(--uch-r-control);
  font-weight: 600;
  font-size: 15px;
  color: var(--uch-text);
  text-decoration: none;
  transition: background-color var(--uch-motion-fast) var(--uch-ease), color var(--uch-motion-fast) var(--uch-ease);
}

@media (hover: hover) and (pointer: fine) {
  .home-link:hover {
    background-color: var(--uch-surface);
    color: var(--uch-heading);
  }
}

.home-link:active {
  transform: scale(0.98);
}

/* Рабочий стол: слева управление, справа настоящий лист устава */
.desk {
  padding-block: 32px 64px;
}

.desk-grid {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  grid-template-areas:
    "intro sheet"
    "tools sheet";
  align-items: start;
  column-gap: 40px;
  row-gap: 24px;
}

.desk-intro {
  grid-area: intro;
  display: grid;
  gap: 16px;
}

.desk-intro h1 {
  font-weight: 800;
  font-size: clamp(32px, 3.2vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.desk-lead {
  font-size: 18px;
  line-height: 1.5;
  color: var(--uch-text);
  max-width: 36ch;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 4px;
}

.btn-primary,
.btn-secondary,
.btn-quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding-inline: 20px;
  border-radius: var(--uch-r-control);
  font-family: var(--uch-font-text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--uch-motion-fast) var(--uch-ease), border-color var(--uch-motion-fast) var(--uch-ease), color var(--uch-motion-fast) var(--uch-ease), transform var(--uch-motion-fast) var(--uch-ease);
}

.btn-primary {
  background-color: var(--uch-action);
  color: var(--uch-on-action);
  border: 1px solid var(--uch-action);
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background-color: var(--uch-action-hover);
    border-color: var(--uch-action-hover);
    color: var(--uch-on-action);
  }
}

.btn-primary:active {
  background-color: var(--uch-action-active);
  transform: scale(0.98);
}

.btn-secondary {
  background-color: transparent;
  color: var(--uch-heading);
  border: 1px solid var(--uch-line-field);
}

@media (hover: hover) and (pointer: fine) {
  .btn-secondary:hover {
    background-color: var(--uch-selected);
    border-color: var(--uch-action);
    color: var(--uch-on-selected);
  }
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-quiet {
  min-height: 44px;
  padding-inline: 16px;
  background-color: transparent;
  color: var(--uch-text-muted);
  border: 1px solid var(--uch-line-field);
  font-size: 14px;
}

@media (hover: hover) and (pointer: fine) {
  .btn-quiet:hover {
    background-color: var(--uch-surface);
    color: var(--uch-heading);
    border-color: var(--uch-heading);
  }
}

.btn-quiet:active {
  transform: scale(0.98);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-quiet:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Панель состава подписей и черновика */
.desk-tools {
  grid-area: tools;
  display: grid;
  gap: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--uch-line);
}

.tool-group {
  display: grid;
  gap: 12px;
}

.tool-group h2 {
  font-weight: 700;
  font-size: 20px;
  line-height: 1.25;
}

.tool-hint {
  font-size: 14px;
  line-height: 1.45;
  color: var(--uch-text-muted);
}

.signer-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.signer-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding-inline: 16px;
  border-radius: var(--uch-r-pill);
  border: 1px solid var(--uch-line-field);
  background-color: var(--uch-surface);
  color: var(--uch-text);
  font-family: var(--uch-font-text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--uch-motion-fast) var(--uch-ease), border-color var(--uch-motion-fast) var(--uch-ease), color var(--uch-motion-fast) var(--uch-ease), transform var(--uch-motion-fast) var(--uch-ease);
}

@media (hover: hover) and (pointer: fine) {
  .signer-pill:hover {
    border-color: var(--uch-action);
    color: var(--uch-heading);
  }
}

.signer-pill:active {
  transform: scale(0.97);
}

.signer-pill[aria-pressed="true"] {
  background-color: var(--uch-selected);
  border-color: var(--uch-action);
  color: var(--uch-on-selected);
}

.privacy-box {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--uch-line);
}

.privacy-note {
  font-size: 14px;
  line-height: 1.45;
  color: var(--uch-text-muted);
}

.status-line {
  min-height: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--uch-green-700);
}

/* Правая колонка: сам лист А4 и лоток выключенных пунктов */
.sheet-col {
  grid-area: sheet;
  display: grid;
  gap: 24px;
  min-width: 0;
}

@keyframes sheet-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sheet {
  background-color: var(--uch-surface);
  border-radius: var(--uch-r-sheet);
  box-shadow: var(--uch-shadow-sheet);
  padding: 40px 40px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: sheet-enter var(--uch-motion-base) var(--uch-ease) both;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--uch-heading);
}

.sheet-title-wrap {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.sheet-title {
  font-family: var(--uch-font-display);
  font-weight: 800;
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1.15;
  color: var(--uch-heading);
}

.sheet-sub {
  font-size: 15px;
  line-height: 1.45;
  color: var(--uch-text-muted);
}

.sheet-mark {
  width: 40px;
  height: 40px;
  flex: none;
}

/* Список активных правил на листе */
.sheet-rules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}

.rule-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
  border-bottom: 1px solid var(--uch-line);
}

.rule-num {
  font-family: var(--uch-font-display);
  font-weight: 800;
  font-size: 20px;
  line-height: 1.2;
  color: var(--uch-action);
  font-variant-numeric: tabular-nums;
}

.rule-body {
  font-size: 16px;
  line-height: 1.55;
  color: var(--uch-heading);
  min-width: 0;
}

.ctrl-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
  margin-block: 2px;
}

.rule-input,
.rule-select {
  min-height: 44px;
  padding-block: 8px;
  padding-inline: 12px;
  border: 1px solid var(--uch-line-field);
  border-radius: 8px;
  background-color: var(--uch-child-soft);
  color: var(--uch-heading);
  font-family: var(--uch-font-text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  transition: border-color var(--uch-motion-fast) var(--uch-ease), background-color var(--uch-motion-fast) var(--uch-ease);
}

.rule-input {
  width: 80px;
  text-align: center;
}

.rule-input-narrow {
  width: 68px;
}

@media (hover: hover) and (pointer: fine) {
  .rule-input:hover,
  .rule-select:hover {
    border-color: var(--uch-action);
  }
}

.rule-input:active,
.rule-select:active {
  background-color: var(--uch-selected);
}

.rule-fill {
  font-weight: 700;
  color: var(--uch-heading);
  border-bottom: 1.5px solid var(--uch-heading);
  padding-inline: 2px;
  font-variant-numeric: tabular-nums;
}

.rule-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding-inline: 12px;
  border-radius: 8px;
  border: 1px solid var(--uch-line-field);
  background-color: transparent;
  color: var(--uch-text-muted);
  font-family: var(--uch-font-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--uch-motion-fast) var(--uch-ease), color var(--uch-motion-fast) var(--uch-ease), border-color var(--uch-motion-fast) var(--uch-ease), transform var(--uch-motion-fast) var(--uch-ease);
}

@media (hover: hover) and (pointer: fine) {
  .rule-remove:hover {
    background-color: var(--uch-red-100);
    border-color: var(--uch-red-700);
    color: var(--uch-red-700);
  }
}

.rule-remove:active {
  transform: scale(0.96);
}

.rules-empty {
  padding-block: 20px;
  padding-inline: 16px;
  border: 1px dashed var(--uch-line-field);
  border-radius: var(--uch-r-control);
  color: var(--uch-text-muted);
  font-size: 15px;
}

/* Своё правило (живёт только на листе и в печати) */
.own-rule-block {
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.own-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--uch-heading);
}

.own-label span {
  font-weight: 400;
  color: var(--uch-text-muted);
}

.own-input {
  width: 100%;
  min-height: 44px;
  padding-block: 8px;
  padding-inline: 12px;
  border: 1px solid var(--uch-line-field);
  border-radius: 8px;
  background-color: var(--uch-page);
  color: var(--uch-heading);
  font-family: var(--uch-font-text);
  font-size: 16px;
  line-height: 1.4;
}

@media (hover: hover) and (pointer: fine) {
  .own-input:hover {
    border-color: var(--uch-action);
  }
}

.own-input:active {
  background-color: var(--uch-surface);
}

.own-print-lines {
  display: grid;
  gap: 16px;
  padding-top: 4px;
}

.own-print-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--uch-heading);
  border-bottom: 1.5px solid var(--uch-heading);
  padding-bottom: 4px;
}

.pen-line {
  display: block;
  height: 24px;
  border-bottom: 1px solid var(--uch-line-strong);
}

/* Подписи ролей */
.signs-section {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.signs-caption {
  font-size: 14px;
  color: var(--uch-text-muted);
}

.signs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  padding-top: 8px;
}

.sign-slot {
  display: grid;
  gap: 4px;
}

.sign-space {
  height: 36px;
  border-bottom: 1.5px solid var(--uch-heading);
}

.sign-role {
  font-size: 14px;
  color: var(--uch-text-muted);
}

/* Подвал самого листа */
.sheet-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--uch-line);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--uch-text-muted);
}

.sheet-foot strong {
  color: var(--uch-heading);
  font-weight: 700;
}

.sheet-date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Лоток выключенных правил (вне листа, не печатается) */
.disabled-tray {
  background-color: var(--uch-surface);
  border: 1px solid var(--uch-line);
  border-radius: var(--uch-r-sheet);
  padding: 20px 24px;
  display: grid;
  gap: 12px;
}

.disabled-tray[hidden],
.rules-empty[hidden],
.own-print-text[hidden],
.own-print-lines[hidden] {
  display: none;
}

.disabled-tray h2 {
  font-size: 18px;
  font-weight: 700;
}

.disabled-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.disabled-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 8px;
  border-top: 1px solid var(--uch-line);
  font-size: 15px;
  color: var(--uch-text-muted);
}

.disabled-add {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 16px;
  border-radius: 8px;
  border: 1px solid var(--uch-line-field);
  background-color: var(--uch-page);
  color: var(--uch-heading);
  font-family: var(--uch-font-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--uch-motion-fast) var(--uch-ease), border-color var(--uch-motion-fast) var(--uch-ease), transform var(--uch-motion-fast) var(--uch-ease);
}

@media (hover: hover) and (pointer: fine) {
  .disabled-add:hover {
    background-color: var(--uch-selected);
    border-color: var(--uch-action);
    color: var(--uch-on-selected);
  }
}

.disabled-add:active {
  transform: scale(0.97);
}

/* Нижняя строка о кабинете / приглашении в бету */
.invite-band {
  border-top: 1px solid var(--uch-line);
  background-color: var(--uch-selected);
}

.invite-band .wrap {
  padding-block: 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.invite-copy {
  font-size: 17px;
  line-height: 1.5;
  color: var(--uch-heading);
  max-width: 56ch;
}

/* Подвал сайта */
.site-foot {
  border-top: 1px solid var(--uch-line);
  background-color: var(--uch-page);
}

.site-foot .wrap {
  padding-block: 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  font-size: 14px;
  color: var(--uch-text-muted);
}

.foot-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.site-foot a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.export-canvas {
  display: none;
}

/* Планшет и телефон */
@media (max-width: 1024px) {
  .wrap {
    padding-inline: 24px;
  }

  .desk-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "intro"
      "sheet"
      "tools";
    row-gap: 24px;
  }

  .desk-lead {
    max-width: 52ch;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding-inline: 16px;
  }

  .desk {
    padding-block: 20px 40px;
  }

  .brand-link img {
    height: 32px;
  }

  .sheet {
    padding: 20px 16px;
    gap: 16px;
  }

  .rule-item {
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
  }

  .rule-remove {
    grid-column: 2;
    justify-self: start;
    margin-top: 4px;
  }

  .rule-select {
    width: 100%;
  }

  .signs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .action-row .btn-primary,
  .action-row .btn-secondary {
    flex: 1 1 200px;
  }
}

@media (max-width: 380px) {
  .signs-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet {
    animation: none;
  }

  .home-link,
  .btn-primary,
  .btn-secondary,
  .btn-quiet,
  .signer-pill,
  .rule-input,
  .rule-select,
  .rule-remove,
  .disabled-add {
    transition: none;
  }
}

/* Печать строго на один лист А4 без обрезки и без меню сайта */
@page {
  size: A4 portrait;
  margin: 10mm 12mm;
}

@media print {
  html,
  body {
    background-color: var(--uch-surface);
    color: var(--uch-heading);
    font-size: 14px;
    line-height: 1.4;
    overflow: visible;
  }

  .no-print,
  .screen-only {
    display: none !important;
  }

  .print-only {
    display: inline !important;
  }

  div.print-only {
    display: grid !important;
  }

  .print-only[hidden] {
    display: none !important;
  }

  .wrap {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .desk {
    padding: 0;
  }

  .desk-grid,
  .sheet-col {
    display: block;
  }

  .sheet {
    width: 100%;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 4mm 4mm 2mm;
    border: none;
    border-radius: 0;
    box-shadow: none;
    gap: 12px;
    animation: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .sheet-head {
    padding-bottom: 8px;
  }

  .sheet-title {
    font-size: 24px;
  }

  .sheet-sub {
    font-size: 13px;
  }

  .sheet-mark {
    width: 32px;
    height: 32px;
  }

  .rule-item {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 8px;
    padding-block: 8px;
    break-inside: avoid;
  }

  .rule-num {
    font-size: 16px;
  }

  .rule-body {
    font-size: 14px;
    line-height: 1.42;
  }

  .own-rule-block {
    padding-top: 4px;
    gap: 4px;
    break-inside: avoid;
  }

  .own-label {
    font-size: 13px;
  }

  .pen-line {
    height: 20px;
  }

  .signs-section {
    padding-top: 8px;
    gap: 8px;
    break-inside: avoid;
  }

  .signs-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding-top: 4px;
  }

  .sign-space {
    height: 28px;
  }

  .sign-role {
    font-size: 12px;
  }

  .sheet-foot {
    padding-top: 12px;
    font-size: 11px;
    break-inside: avoid;
  }
}
