/* Палитра, типографика и размеры компонентов по nko080/sait_activebot (a770963). */
@font-face {
  font-family: "Liberation Serif";
  src: url("/static/fonts/LiberationSerif-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --bg: #110f0c;
  --surface: #211e19;
  --surface-raised: #28231d;
  --surface-soft: #191612;
  --line: #39332b;
  --line-soft: #302b24;
  --text: #f1eae1;
  --muted: #b1a79b;
  --accent: #df914f;
  --accent-soft: #3c291b;
  --green: #71b996;
  --danger: #ef938b;
  --radius: 24px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.5 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}
button,
a {
  touch-action: manipulation;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: clamp(26px, 3vw, 32px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.035em;
}
h2 {
  font-size: 19px;
  font-weight: 550;
  line-height: 1.35;
  letter-spacing: -0.02em;
}
h3 {
  font-size: 17px;
  font-weight: 550;
}
small,
.muted {
  color: var(--muted);
}
small {
  font-size: 12px;
}
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: #2d1c0e;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
button:hover {
  background: #e9a569;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button.secondary {
  border-color: #5d4937;
  background: #33271c;
  color: #edbd96;
}
button.secondary:hover {
  background: #493120;
}
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #4b4237;
  border-radius: 13px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 10px 14px;
}
select {
  min-height: 40px;
  font-size: 12px;
}
textarea {
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}
[hidden] {
  display: none !important;
}
.skip-link {
  position: fixed;
  top: -70px;
  left: 16px;
  padding: 12px 20px;
  background: var(--accent);
  z-index: 30;
  border-radius: 12px;
}
.skip-link:focus {
  top: 12px;
}
.topbar {
  min-height: 88px;
  padding: 16px max(32px, calc((100vw - 1500px) / 2));
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 550;
  letter-spacing: 0.1em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 42px;
  border-radius: 13px;
  background: var(--accent);
  color: #2b1a0d;
  font:
    600 34px/1 Georgia,
    serif;
}
.brand small {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.035em;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.icon-button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 18px;
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.status-dot,
.legend-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--green);
}
.legend-dot {
  background: var(--accent);
}
.muted-dot {
  background: var(--muted);
}
.page {
  max-width: 1580px;
  margin: 0 auto;
  padding: 36px 40px 64px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.section-head p {
  margin-top: 9px;
  font-size: 13px;
}
.eyebrow {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
}
.workspace {
  display: grid;
  grid-template-columns: 206px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 28px;
  display: grid;
  gap: 20px;
}
.sidebar-card {
  display: flex;
  flex-direction: column;
  align-items: start;
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.sidebar-card strong {
  max-width: 100%;
  font-size: 20px;
  font-weight: 550;
  overflow-wrap: anywhere;
  margin-bottom: 16px;
}
.role-badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #cec2b5;
  font-size: 11px;
  font-weight: 450;
  line-height: 1.4;
  padding: 5px 10px;
}
.side-menu,
.diagram-list {
  display: grid;
  gap: 6px;
}
.nav-item,
.diagram-button {
  width: 100%;
  display: flex;
  justify-content: start;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 0;
  border-radius: 15px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
}
.nav-item:hover,
.diagram-button:hover {
  background: var(--surface);
  color: var(--text);
}
.nav-item.active,
.diagram-button.active {
  background: var(--accent-soft);
  color: #f0b986;
}
.nav-item > span:first-child {
  font-size: 18px;
}
.nav-item .count-badge {
  margin-left: auto;
  padding: 2px 7px;
}
.sidebar-divider {
  height: 1px;
  background: var(--line-soft);
}
.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-heading .eyebrow {
  margin: 0;
}
.diagram-button {
  display: block;
  padding: 12px 14px;
  overflow-wrap: anywhere;
}
.diagram-button small {
  display: block;
  font-size: 10px;
  margin-top: 3px;
}
.sidebar-note {
  display: flex;
  align-items: start;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  padding: 12px 8px;
}
.sidebar-note .status-dot {
  margin-top: 5px;
}
.quiet-small {
  font-size: 12px;
  color: var(--muted);
  padding: 0 10px;
}
.work-main {
  min-width: 0;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat {
  min-width: 0;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: start;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat > span {
  font-size: 12px;
  color: var(--muted);
}
.stat strong {
  margin: 10px 0 4px;
  font-size: 34px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.stat strong.stat-status {
  font-size: 23px;
  margin-top: 16px;
  margin-bottom: 10px;
}
.stat small {
  font-size: 10px;
}
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 20px;
  align-items: stretch;
}
.panel {
  min-width: 0;
  margin-bottom: 22px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-head p {
  font-size: 12px;
  margin-top: 6px;
}
.small-button {
  min-height: 34px;
  padding: 8px 12px;
  font-size: 11px;
}
.code-panel,
.preview-panel {
  display: flex;
  flex-direction: column;
  padding: 22px;
  overflow: hidden;
}
.filebar {
  display: flex;
  gap: 6px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}
.file-tabs {
  display: flex;
  gap: 4px;
  overflow: auto;
  flex: 1;
  scrollbar-width: thin;
}
.file-tab {
  font:
    11px/1.3 ui-monospace,
    SFMono-Regular,
    monospace;
  min-height: 32px;
  padding: 8px 13px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.file-tab.active {
  background: var(--accent-soft);
  color: #f0b986;
}
.mini-button {
  min-height: 30px;
  min-width: 30px;
  padding: 2px 7px;
  background: transparent;
  color: var(--muted);
  font-size: 21px;
  font-weight: 400;
  border-radius: 9px;
}
.entry-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  font-size: 10px;
  color: var(--muted);
}
.entry-row label {
  white-space: nowrap;
}
.entry-row select {
  border: 0;
  min-height: 28px;
  padding: 4px 9px;
  font-size: 10px;
  background: var(--surface);
}
.entry-row .mini-button {
  font-size: 17px;
}
.code-editor {
  position: relative;
  display: flex;
  flex: 1;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  overflow: hidden;
  min-height: 455px;
}
.code-editor pre,
.code-editor textarea {
  margin: 0;
  font:
    12px/1.9 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  tab-size: 4;
  letter-spacing: 0;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}
.code-editor #line-numbers {
  width: 42px;
  min-width: 42px;
  padding: 15px 9px;
  text-align: right;
  color: #746b60;
  overflow: hidden;
  border-right: 1px solid var(--line-soft);
  user-select: none;
}
.editor-surface {
  position: relative;
  flex: 1;
  min-width: 0;
}
.editor-surface #highlight {
  position: absolute;
  inset: 0;
  padding: 15px 12px;
  overflow: hidden;
  pointer-events: none;
  color: #d1c7bc;
}
.code-editor textarea {
  position: absolute;
  inset: 0;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 15px 12px;
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  outline: 0;
  overflow: auto;
}
.code-editor textarea::selection {
  background: #df914f44;
}
.code-editor .k,
.code-editor .kn,
.code-editor .kc,
.code-editor .ow {
  color: #df914f;
}
.code-editor .s,
.code-editor .s1,
.code-editor .s2,
.code-editor .sa,
.code-editor .si {
  color: #a4c6a3;
}
.code-editor .mi,
.code-editor .mf {
  color: #e5b88a;
}
.code-editor .c1 {
  color: #897e70;
}
.code-editor .nf,
.code-editor .nb {
  color: #d9bc9f;
}
.editor-foot {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  padding: 10px 2px;
}
.build-row {
  display: flex;
  gap: 8px;
  padding-top: 6px;
}
.build-row select {
  flex: 1;
  font-size: 10px;
  padding: 8px;
}
.build-row button {
  font-size: 11px;
  padding: 10px 14px;
  white-space: nowrap;
}
.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 0 11px;
  border-bottom: 1px solid var(--line);
}
.tool-group {
  display: flex;
  gap: 4px;
}
.tool {
  padding: 4px;
  width: 30px;
  min-height: 30px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  font-weight: 400;
}
.tool:hover {
  background: var(--surface-raised);
}
.tool.wide {
  font-size: 10px;
  width: auto;
  padding: 5px 8px;
}
.tool.zoom-label {
  font-size: 10px;
  width: 42px;
}
.pagebar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 11px 0;
  font-size: 10px;
  color: var(--muted);
}
.pagebar select {
  width: 52px;
  min-height: 26px;
  padding: 3px 7px;
  font-size: 10px;
}
.text-button {
  padding: 3px;
  min-height: 26px;
  background: transparent;
  color: var(--accent);
  font-size: 10px;
  margin-left: auto;
}
.text-button:hover {
  background: transparent;
  color: #e9a569;
}
.canvas {
  flex: 1;
  overflow: auto;
  height: 460px;
  min-height: 460px;
  max-height: 520px;
  background: #171410;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  scrollbar-width: thin;
  scrollbar-color: #64503c transparent;
  padding: 16px;
  position: relative;
}
.canvas > svg {
  display: block;
  height: auto;
  max-width: none;
  flex-shrink: 0;
  touch-action: none;
}
.canvas-empty {
  min-height: 410px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  color: var(--muted);
}
.canvas-empty h3 {
  margin: 20px 0 9px;
  font-size: 15px;
}
.canvas-empty p {
  font-size: 12px;
  line-height: 1.7;
}
.empty-diagram {
  font:
    30px/0.65 Georgia,
    serif;
  color: #89725d;
  letter-spacing: 0;
}
.canvas-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 9px;
}
.canvas-foot > span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
}
.canvas-foot .legend-dot {
  width: 5px;
  height: 5px;
}
.validation-scope {
  font-size: 11px;
  color: var(--muted);
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.validation-panel .panel-head {
  margin-bottom: 12px;
}
.diagnostic {
  display: flex;
  gap: 12px;
  align-items: start;
  border-top: 1px solid var(--line-soft);
  padding: 13px 0;
  font-size: 12px;
}
.diagnostic .severity {
  color: var(--danger);
  font-size: 10px;
  padding-top: 2px;
  flex-shrink: 0;
  min-width: 70px;
}
.diagnostic.warning .severity {
  color: var(--accent);
}
.diagnostic small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
}
.diagnostic button {
  font-size: 11px;
  text-align: left;
  font-weight: 400;
  display: block;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  padding: 0;
  min-height: 0;
}
.pass-note {
  color: var(--green);
  font-size: 12px;
  margin: 12px 0;
}
.footer {
  display: flex;
  justify-content: space-between;
  max-width: 1500px;
  margin: auto;
  padding: 0 40px 28px;
  color: #897e70;
  font-size: 11px;
}
dialog {
  width: min(610px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  padding: 28px;
  max-height: 90vh;
  overflow: auto;
}
dialog::backdrop {
  background: #0009;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
dialog > p {
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 14px;
}
.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
  margin-top: 24px;
}
.format-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  border: 0;
  margin: 22px 0;
  padding: 0;
}
.format-options legend {
  font-size: 12px;
  color: var(--muted);
  padding: 0;
  margin-bottom: 10px;
}
.format-options label {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 16px 10px;
  cursor: pointer;
}
.format-options input {
  width: auto;
  margin: 0 5px 0 0;
  accent-color: var(--accent);
}
.format-options label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.format-options strong {
  font-size: 13px;
}
.format-options small {
  display: block;
  font-size: 10px;
  margin-top: 6px;
}
.notice {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--danger);
  font-size: 12px;
  margin-top: 16px;
}
.document-preview {
  width: min(900px, 95vw);
  background: var(--surface-soft);
}
#document-pages {
  display: grid;
  gap: 20px;
}
#document-pages svg {
  width: 100%;
  height: auto;
  display: block;
}
.document-title {
  font-size: 13px;
  color: var(--muted);
  padding: 12px 0;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(600px, 90vw);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-raised);
  color: var(--text);
  padding: 14px 20px;
  font-size: 12px;
  z-index: 100;
}
@media (min-width: 1700px) {
  .page {
    max-width: 1720px;
  }
  .code-editor {
    min-height: 520px;
  }
  .canvas {
    height: 525px;
    max-height: 590px;
  }
}
@media (max-width: 1200px) {
  .page {
    padding: 28px 24px;
  }
  .workspace {
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 20px;
  }
  .editor-grid {
    grid-template-columns: 1fr;
  }
  .sidebar-card {
    padding: 20px 15px;
  }
  .stat {
    padding: 18px 16px;
  }
  .canvas {
    height: 600px;
    max-height: 650px;
  }
  .code-editor {
    min-height: 360px;
  }
  .topbar {
    padding: 16px 24px;
  }
  .sidebar-note {
    font-size: 10px;
  }
}
@media (max-width: 700px) {
  .topbar {
    padding: 14px 16px;
    min-height: 76px;
    gap: 10px;
  }
  .brand {
    font-size: 16px;
    gap: 9px;
  }
  .brand-mark {
    width: 31px;
    height: 36px;
    font-size: 28px;
  }
  .top-actions {
    gap: 6px;
  }
  .top-actions .status {
    display: none;
  }
  .top-actions .secondary {
    font-size: 10px;
    padding: 8px 11px;
    min-height: 36px;
  }
  .top-actions .icon-button {
    width: 32px;
    height: 32px;
    min-height: 32px;
  }
  .page {
    padding: 24px 16px 40px;
  }
  .section-head {
    align-items: start;
    gap: 12px;
  }
  .section-head h1 {
    font-size: 25px;
  }
  .section-head p {
    font-size: 11px;
  }
  .section-head > button {
    font-size: 10px;
    padding: 9px 12px;
    min-height: 36px;
  }
  .workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .sidebar {
    position: static;
    gap: 12px;
  }
  .sidebar-card,
  .sidebar-divider,
  .sidebar-note,
  .sidebar-heading {
    display: none;
  }
  .side-menu {
    display: flex;
    gap: 4px;
  }
  .nav-item {
    padding: 10px;
    font-size: 11px;
    gap: 6px;
    min-height: 36px;
    white-space: nowrap;
  }
  .nav-item > span:first-child {
    font-size: 15px;
  }
  .nav-item .count-badge {
    display: none;
  }
  .diagram-list {
    display: flex;
    overflow: auto;
    gap: 5px;
  }
  .diagram-button {
    width: auto;
    min-width: 120px;
    max-width: 200px;
    white-space: nowrap;
    padding: 10px;
    font-size: 11px;
  }
  .diagram-button small {
    font-size: 9px;
  }
  .stats-grid {
    gap: 8px;
    margin-bottom: 16px;
  }
  .stat {
    padding: 14px 11px;
    min-height: 100px;
    border-radius: 17px;
  }
  .stat > span {
    font-size: 10px;
  }
  .stat strong {
    font-size: 27px;
  }
  .stat strong.stat-status {
    font-size: 17px;
    margin-top: 14px;
  }
  .stat small {
    font-size: 8px;
  }
  .panel {
    padding: 17px;
    border-radius: 20px;
    margin-bottom: 16px;
  }
  .panel-head {
    margin-bottom: 16px;
    gap: 8px;
  }
  .panel-head h2 {
    font-size: 17px;
  }
  .panel-head p {
    font-size: 10px;
  }
  .small-button {
    font-size: 10px;
    padding: 7px 10px;
  }
  .canvas {
    height: 480px;
    max-height: 520px;
    padding: 10px;
  }
  .canvas-foot {
    font-size: 8px;
  }
  .canvas-foot > span:last-child {
    display: none;
  }
  .build-row button {
    font-size: 10px;
    padding: 8px 12px;
  }
  .build-row select {
    font-size: 9px;
  }
  .footer {
    padding: 0 16px 24px;
    font-size: 9px;
  }
  .format-options {
    gap: 7px;
  }
  .format-options label {
    padding: 12px 6px;
  }
  .format-options small {
    font-size: 9px;
  }
  .dialog-actions button {
    font-size: 11px;
    padding: 9px 13px;
  }
  dialog {
    padding: 22px;
  }
}
@media print {
  body {
    background: white;
  }
  .topbar,
  .page,
  .footer,
  dialog .dialog-head {
    display: none;
  }
  dialog[open] {
    position: static;
    display: block;
    border: 0;
    padding: 0;
    width: auto;
    max-height: none;
    background: white;
  }
  #document-pages svg {
    page-break-after: always;
    width: 210mm;
    height: 297mm;
  }
}

@media (max-width: 480px) {
  .format-options {
    grid-template-columns: repeat(2, 1fr);
  }
}
