/* ГОСТ-редактор — интерфейс как в КОМПАС-График */

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #a8a8a8;
}
.wrap {
  box-sizing: border-box;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gost-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: #c8c8c8;
  border: none;
  border-radius: 0;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 12px;
  color: #1a1a1a;
  user-select: none;
}

/* ----- главное меню ----- */
.gost-menubar {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  background: linear-gradient(#f7f7f7, #e8e8e8);
  border-bottom: 1px solid #9a9a9a;
  min-height: 26px;
  z-index: 40;
  overflow: visible;
}
.gost-menu { position: relative; overflow: visible; }
.gost-menu-btn {
  height: 26px;
  padding: 0 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #1a1a1a;
  font: inherit;
}
.gost-menu-btn:hover,
.gost-menu.open > .gost-menu-btn {
  background: #dce8f8;
}
.gost-menu-drop {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  background: #f4f4f4;
  border: 1px solid #666;
  box-shadow: 2px 2px 10px rgba(0,0,0,.25);
  padding: 4px 0;
  z-index: 60;
}
.gost-menu.open > .gost-menu-drop { display: block; }
.gost-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 5px 14px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: #111;
}
.gost-menu-item:hover { background: #cde0f8; }
.gost-menu-item kbd,
.gost-ctx-item kbd {
  color: #666;
  font-size: 11px;
  font-family: inherit;
}
.gost-menu-drop--file {
  min-width: 300px;
  max-height: min(70vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
}
.gost-menu-item--muted {
  color: #888;
  cursor: default;
  pointer-events: none;
  font-style: italic;
}
.gost-menu-item--muted:hover {
  background: transparent;
}
.gost-menu-item--recent .gost-recent-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.gost-menu-item--recent .gost-recent-date {
  color: #666;
  font-size: 11px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.gost-menu-sep,
.gost-ctx-sep {
  height: 1px;
  margin: 4px 8px;
  background: #bbb;
}
.gost-menu-label {
  padding: 6px 14px 2px;
  font-size: 11px;
  font-weight: 700;
  color: #555;
  letter-spacing: 0.02em;
  user-select: none;
  pointer-events: none;
}

/* ----- разделы меню «Вставка»: имена → flyout с инструментами ----- */
.gost-menu-drop--sections {
  min-width: 220px;
  padding: 2px 0;
  overflow: visible;
}
.gost-menu-section {
  position: relative;
}
.gost-menu-section-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 5px 12px 5px 14px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: #111;
}
.gost-menu-section-btn:hover,
.gost-menu-section.open > .gost-menu-section-btn {
  background: #cde0f8;
}
.gost-menu-chevron {
  color: #555;
  font-size: 11px;
  line-height: 1;
}
/* Flyout вне .gost-shell (overflow:hidden), иначе вложенные подменю обрезались / «протекали» */
.gost-menu-section-flyout {
  display: none;
  position: fixed;
  z-index: 1100;
  min-width: 248px;
  max-height: min(70vh, 480px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f4f4f4;
  border: 1px solid #666;
  box-shadow: 3px 2px 12px rgba(0, 0, 0, 0.28);
  padding: 0 0 4px;
  scrollbar-width: thin;
  scrollbar-color: #9a9a9a #d8d8d8;
  /* same UI face as .gost-shell (stack also set in fonts.css) */
  font-size: 12px;
  color: #1a1a1a;
}
.gost-menu-section-flyout.open { display: block; }
.gost-menu-section-flyout::-webkit-scrollbar { width: 7px; }
.gost-menu-section-flyout::-webkit-scrollbar-thumb {
  background: #9a9a9a;
  border-radius: 3px;
}
.gost-menu-section-flyout::-webkit-scrollbar-track { background: #d8d8d8; }
.gost-menu-section-flyout .gost-menu-item {
  font: inherit;
}
.gost-menu-submenu-title {
  padding: 7px 14px 6px;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.2;
  font-family: inherit;
  color: #111;
  background: linear-gradient(#f7f7f7, #e4e4e4);
  border-bottom: 1px solid #9a9a9a;
  margin-bottom: 2px;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ----- системная панель ----- */
.gost-sysbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  padding: 3px 6px;
  background: linear-gradient(#efefef, #d8d8d8);
  border-bottom: 1px solid #9a9a9a;
  z-index: 30;
}
.gost-sys-btn {
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.gost-sys-btn:hover {
  background: #fff;
  border-color: #9ab;
}
.gost-sys-sep {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: #aaa;
}

.gost-body {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
}

/* ----- контекстное меню ----- */
.gost-ctx {
  display: none;
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  background: #f4f4f4;
  border: 1px solid #555;
  box-shadow: 2px 2px 12px rgba(0,0,0,.3);
  padding: 4px 0;
}
.gost-ctx.open { display: block; }
.gost-ctx-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: none;
  background: transparent;
  padding: 5px 14px;
  text-align: left;
  cursor: pointer;
  font: 12px "Segoe UI", Tahoma, Arial, sans-serif;
  color: #111;
}
.gost-ctx-item:hover { background: #cde0f8; }

/* ----- левая боковая панель инструментов ----- */
.gost-compact {
  display: flex;
  flex-direction: column;
  width: 72px;
  flex: 0 0 72px;
  min-height: 0;
  max-height: 100%;
  align-self: stretch;
  background: linear-gradient(#ececec, #d8d8d8);
  border-right: 1px solid #9a9a9a;
  z-index: 5;
  overflow: hidden;
}
.gost-compact-tools {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 2px 3px 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  scrollbar-width: thin;
  scrollbar-color: #9a9a9a #d8d8d8;
}
.gost-compact-tools::-webkit-scrollbar {
  width: 7px;
}
.gost-compact-tools::-webkit-scrollbar-thumb {
  background: #9a9a9a;
  border-radius: 3px;
}
.gost-compact-tools::-webkit-scrollbar-track {
  background: #d8d8d8;
}

.gost-tool-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin: 0 0 1px;
  border-bottom: 1px solid #a8a8a8;
  flex: 0 0 auto;
}
.gost-tool-group:last-child { border-bottom: none; }
.gost-tool-group.is-active-cat > .gost-tool-group-head {
  background: #f7f7f7;
  border-color: #7a7a7a;
  box-shadow: inset 3px 0 0 #c9a200;
}
.gost-tool-group.is-open > .gost-tool-group-head {
  background: #fff8d6;
  border-color: #c9a200;
  box-shadow: inset 3px 0 0 #c9a200;
}

.gost-tool-group-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
  margin: 0;
  padding: 5px 2px 4px;
  border: 1px solid #b0b0b0;
  border-radius: 2px;
  background: #d0d0d0;
  cursor: pointer;
  color: #111;
  font: 600 9px/1.15 "Segoe UI", Tahoma, Arial, sans-serif;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
}
.gost-tool-group-head:hover {
  background: #e2e2e2;
  border-color: #909090;
}
.gost-tool-group-chev {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 5px;
  border-color: transparent transparent transparent #333;
  margin: 1px 0;
}
.gost-tool-group.is-open .gost-tool-group-chev {
  border-width: 5px 4px 0 4px;
  border-color: #333 transparent transparent transparent;
  margin-bottom: 1px;
}
.gost-tool-group-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.gost-tool-group-ico .tb-ico {
  width: 18px;
  height: 18px;
}
.gost-tool-group-label {
  display: block;
  max-width: 100%;
  padding: 0 1px;
  text-align: center;
  word-break: break-word;
  hyphens: auto;
  overflow: hidden;
  letter-spacing: -0.01em;
}

/* ----- flyout группы справа от рейки ----- */
.gost-group-flyout {
  display: none;
  position: absolute;
  z-index: 46;
  flex-direction: column;
  width: 228px;
  max-height: min(72vh, 560px);
  overflow: hidden;
  background: linear-gradient(#f0f0f0, #dedede);
  border: 1px solid #666;
  border-left: none;
  box-shadow: 3px 2px 12px rgba(0, 0, 0, 0.28);
  border-radius: 0 2px 2px 0;
}
.gost-group-flyout.open {
  display: flex;
}
.gost-group-flyout-title {
  flex: 0 0 auto;
  padding: 7px 10px 6px;
  font: 700 12px/1.2 "Segoe UI", Tahoma, Arial, sans-serif;
  color: #111;
  background: linear-gradient(#f7f7f7, #e4e4e4);
  border-bottom: 1px solid #9a9a9a;
}
.gost-group-flyout-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 4px 6px 8px;
  scrollbar-width: thin;
  scrollbar-color: #9a9a9a #d8d8d8;
}
.gost-group-flyout-body::-webkit-scrollbar { width: 7px; }
.gost-group-flyout-body::-webkit-scrollbar-thumb {
  background: #9a9a9a;
  border-radius: 3px;
}
.gost-group-flyout-body::-webkit-scrollbar-track { background: #d8d8d8; }

.gost-group-flyout .gost-tool-slot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  padding: 5px 0 6px;
  border-top: 1px solid #c4c4c4;
}
.gost-group-flyout .gost-tool-slot:first-child {
  border-top: none;
  padding-top: 2px;
}
.gost-group-flyout .gost-tool-slot-head {
  width: 100%;
  margin: 0;
  padding: 2px 4px;
  font: 600 10px/1.2 "Segoe UI", Tahoma, Arial, sans-serif;
  color: #333;
  text-align: left;
  word-break: break-word;
  user-select: none;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 1px;
}
.gost-group-flyout .gost-tool-slot-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  padding: 0 1px;
}

.gost-tool-sep {
  width: 28px;
  height: 1px;
  margin: 2px 0;
  background: #b0b0b0;
}

.gost-tool-btn {
  width: 40px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  margin: 0;
  border: 1px solid #a8a8a8;
  border-radius: 2px;
  background: #e8e8e8;
  box-shadow: inset 0 1px 0 #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111;
}
.gost-tool-btn:hover { background: #f2f2f2; }
.gost-tool-btn:focus { outline: none; }
.gost-tool-btn.active {
  background: #ffe566;
  border-color: #c9a200;
  box-shadow: inset 0 0 0 1px #e6b800;
}
.gost-tool-btn.gost-tool-action {
  background: #e2e6ec;
}

/* legacy slot/tab (на случай старых ссылок) */
.gost-compact-tabs,
.gost-slot,
.gost-cat-tab { display: none; }

.tb-ico {
  display: block;
  pointer-events: none;
}

/* ----- flyout ----- */
.gost-flyout {
  display: none;
  position: absolute;
  z-index: 50;
  flex-direction: row;
  align-items: stretch;
  gap: 2px;
  padding: 4px;
  background: #ececec;
  border: 1px solid #666;
  box-shadow: 2px 2px 8px rgba(0,0,0,.28);
  border-radius: 2px;
  max-width: min(92vw, 720px);
  flex-wrap: wrap;
}
.gost-flyout.open { display: flex; }

.gost-fly-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 64px;
  max-width: 88px;
  padding: 6px 6px 4px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: #e8e8e8;
  cursor: pointer;
  color: #111;
}
.gost-fly-btn:hover { background: #f7f7f7; border-color: #aaa; }
.gost-fly-btn.active {
  background: #ffe566;
  border-color: #c9a200;
}
.gost-fly-btn .fly-label {
  font-size: 10px;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

/* ----- main + stage ----- */
.gost-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #b9b9b9;
}
.gost-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #a8a8a8;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gost-stage svg {
  width: auto;
  height: auto;
  max-width: none;
  display: block;
  flex: 0 0 auto;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  cursor: crosshair;
}
.gost-bottom {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  z-index: 20;
}
.gost-stage svg.mode-select,
.gost-stage svg.mode-move { cursor: default; }
.gost-stage svg .ed-selected {
  outline: none;
  filter: drop-shadow(0 0 1.5px #3d8bfd) drop-shadow(0 0 0.5px #3d8bfd);
}
.gost-stage svg text[data-gost-field] {
  cursor: text;
}
.gost-stage svg text[data-gost-field]:hover {
  fill: #0a2a8a;
}

/* ----- панель свойств ----- */
.gost-props {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 8px;
  background: linear-gradient(#efefef, #dcdcdc);
  border-top: 1px solid #9a9a9a;
  color: #111;
}
.prop-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding-right: 6px;
  border-right: 1px solid #aaa;
  margin-right: 2px;
}
.prop-special .prop-create {
  background: #e8f5e9;
  border-color: #2e7d32;
  color: #1b5e20;
}
.prop-special .prop-create:hover { background: #c8e6c9; }
.prop-special .prop-create.dirty {
  background: #fff8e1;
  border-color: #f9a825;
  box-shadow: 0 0 0 1px #ffe082;
  animation: gost-commit-pulse 1.4s ease-in-out infinite;
}
.prop-special .prop-create.committed {
  background: #c8e6c9;
  border-color: #2e7d32;
}
.prop-special .prop-abort {
  background: #ffebee;
  border-color: #c62828;
  color: #b71c1c;
}
.prop-special .prop-abort:hover { background: #ffcdd2; }
.prop-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex: 0 0 auto;
}
.prop-btn.prop-commit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e8f5e9;
  border-color: #2e7d32;
  color: #1b5e20;
  font-weight: 700;
  padding: 3px 12px;
  height: 28px;
}
.prop-btn.prop-commit:hover { background: #c8e6c9; }
.prop-btn.prop-commit.dirty {
  background: #fff3cd;
  border-color: #c9a200;
  color: #5a4300;
  animation: gost-commit-pulse 1.4s ease-in-out infinite;
}
.prop-btn.prop-commit.committed {
  background: #2e7d32;
  border-color: #1b5e20;
  color: #fff;
}
@keyframes gost-commit-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 0, 0.35); }
  50% { box-shadow: 0 0 0 3px rgba(201, 162, 0, 0.2); }
}
.prop-mid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
}
.prop-tool-name {
  font-weight: 700;
  color: #0a2a8a;
  margin-right: 6px;
  white-space: nowrap;
}
.prop-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.prop-lbl {
  color: #444;
  font-size: 11px;
}
.prop-font-sel {
  min-width: 140px !important;
  max-width: 190px;
  font-size: 11px !important;
}
.prop-text-input {
  font-family: "GOST Type A", "GOST 2.304", Arial, sans-serif;
}

/* ----- вставка специальных символов в текст ----- */
.prop-sym-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.prop-sym-toggle {
  min-width: 36px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.prop-sym-pop {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 50;
  width: min(460px, 94vw);
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  background: #f7f7f7;
  border: 1px solid #888;
  border-radius: 3px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  color: #111;
}
.prop-sym-wrap.open .prop-sym-pop { display: block; }
.prop-sym-sec {
  font-size: 10px;
  font-weight: 700;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 4px 0 6px;
}
.prop-sym-sec:first-child { margin-top: 0; }
.prop-sym-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 3px;
  margin-bottom: 6px;
}
.prop-sym-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 2px 2px;
  background: #fff;
  border: 1px solid #aaa;
  border-radius: 2px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  font-family: "GOST Type A", "GOST 2.304", "Segoe UI Symbol", "Arial Unicode MS", Arial, sans-serif;
  color: #111;
}
.prop-sym-cell-wide {
  font-size: 12px;
  letter-spacing: 0.01em;
  padding: 2px 3px;
}
.prop-sym-cell:hover {
  background: #e8f0ff;
  border-color: #3d6db5;
}
.prop-sym-hint {
  font-size: 10px;
  line-height: 1.35;
  color: #555;
  margin: -2px 0 8px;
  padding: 0 1px;
  white-space: normal;
  max-width: 100%;
}
.gost-props input[type="text"],
.gost-props input[type="number"],
.gost-props select {
  background: #fff;
  color: #111;
  border: 1px solid #888;
  border-radius: 2px;
  padding: 3px 6px;
  font-size: 12px;
  min-width: 56px;
  height: 24px;
}
.gost-props select.prop-hatch-mat {
  min-width: 110px;
  max-width: 170px;
}
.gost-props input[type="number"] { width: 64px; }
.prop-btn,
.prop-icon-btn {
  background: #e8e8e8;
  border: 1px solid #888;
  border-radius: 2px;
  padding: 3px 8px;
  cursor: pointer;
  height: 26px;
}
.prop-icon-btn {
  width: 28px;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.prop-btn:hover,
.prop-icon-btn:hover { background: #f5f5f5; }
.prop-snaps {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.gost-props .chk {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #333;
  white-space: nowrap;
}

/* стиль линии в нижней панели */
.prop-line-styles {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border-left: 1px solid #aaa;
  border-right: 1px solid #aaa;
  margin: 0 2px;
  min-height: 28px;
}
.prop-line-style-sel {
  min-width: 120px !important;
  max-width: 160px;
}
.prop-style-strip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.prop-style-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 24px;
  padding: 0 2px;
  background: #f0f0f0;
  border: 1px solid #888;
  border-radius: 2px;
  cursor: pointer;
}
.prop-style-btn:hover { background: #fff; border-color: #555; }
.prop-style-btn.active {
  background: #ffe566;
  border-color: #c9a200;
  box-shadow: inset 0 0 0 1px #e0c040;
}
.prop-style-ico {
  display: block;
  pointer-events: none;
}

/* ----- строка подсказок + формат ----- */
.gost-prompt-row {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  border-top: 1px solid #0d2248;
}
.gost-prompt {
  flex: 1 1 auto;
  min-height: 22px;
  padding: 3px 10px;
  background: #1e3a6e;
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
}
.gost-format-badge {
  flex: 0 0 auto;
  min-width: 140px;
  padding: 3px 12px;
  background: #0d2248;
  color: #ffd54f;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-left: 1px solid #163a6e;
  cursor: pointer;
  user-select: none;
}
.gost-format-badge:hover {
  background: #14325f;
}
.gost-page-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: #152e5c;
  border-left: 1px solid #163a6e;
}
.page-bar-lbl {
  color: #c5d4f0;
  font-size: 11px;
  margin-right: 2px;
  white-space: nowrap;
}
.page-tab {
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid #4a6aaa;
  background: #1e3a6e;
  color: #e8eefc;
  border-radius: 2px;
  cursor: pointer;
  font-size: 11px;
  line-height: 16px;
}
.page-tab:hover { background: #2a4f8f; }
.page-tab.active {
  background: #ffd54f;
  color: #0d2248;
  border-color: #ffd54f;
  font-weight: 700;
}
.page-tab.page-add,
.page-tab.page-del {
  font-weight: 700;
}
.prop-geom-chip {
  background: #eef5ff;
  border: 1px solid #7a9cc8;
  border-radius: 2px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #123a6d;
  font-variant-numeric: tabular-nums;
  max-width: min(420px, 46vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prop-geom-chip.empty {
  color: #789;
  font-weight: 500;
  background: #f3f5f8;
  border-color: #b8c0cc;
}
.prop-format-chip {
  background: #fff8e1;
  border: 1px solid #c9a200;
  border-radius: 2px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #0a2a8a;
  cursor: pointer;
  user-select: none;
}
.prop-format-chip:hover {
  background: #fff3c4;
}

/* ----- модальное окно Новый ----- */
.gost-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(20, 28, 40, 0.45);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.gost-modal.open { display: flex; }
.gost-modal-card {
  background: #f2f2f2;
  border: 1px solid #666;
  border-radius: 4px;
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
  min-width: min(420px, 96vw);
  max-width: 520px;
  color: #111;
}
.gost-modal-title {
  padding: 10px 14px;
  font-weight: 700;
  background: linear-gradient(#efefef, #ddd);
  border-bottom: 1px solid #aaa;
}
.gost-modal-body { padding: 12px 14px; }
.gost-modal-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: #444;
  line-height: 1.4;
}
.gost-modal-nav {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.45;
}
.gost-modal-nav a {
  color: #0a2a8a;
  text-decoration: none;
}
.gost-modal-nav a:hover { text-decoration: underline; }
.gost-modal-note {
  margin: 0 0 12px;
  font-size: 11px;
  color: #666;
  line-height: 1.4;
}
.gost-fmt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.gost-frame-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.gost-fmt-btn,
.gost-frame-btn {
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid #888;
  border-radius: 3px;
  background: #e8e8e8;
  cursor: pointer;
}
.gost-fmt-btn:hover,
.gost-frame-btn:hover { background: #f7f7f7; }
.gost-fmt-btn.active,
.gost-frame-btn.active {
  background: #ffe566;
  border-color: #c9a200;
}
.gost-size-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #0a2a8a;
  font-weight: 600;
}
.gost-orient-sel {
  min-width: 200px;
  height: 26px;
}
.gost-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #bbb;
  background: #e6e6e6;
}
.gost-modal-btn {
  padding: 6px 14px;
  border: 1px solid #888;
  border-radius: 3px;
  background: #eee;
  cursor: pointer;
}
.gost-modal-btn.primary {
  background: #3d8bfd;
  border-color: #2a6fd6;
  color: #fff;
  font-weight: 600;
}
.gost-modal-btn:hover { filter: brightness(1.05); }

/* ----- Справка / руководство ----- */
.gost-modal-card.gost-help-card {
  max-width: min(720px, 96vw);
  width: min(720px, 96vw);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
}
.gost-modal-body.gost-help-body {
  flex: 1 1 auto;
  overflow: auto;
  max-height: min(72vh, 760px);
  padding: 10px 16px 16px;
  background: #fafafa;
}
.gost-help-doc {
  font-size: 13px;
  line-height: 1.45;
  color: #1a1a1a;
}
.gost-help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0 0 14px;
  padding: 8px 10px;
  background: #eee;
  border: 1px solid #bbb;
  border-radius: 3px;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.gost-help-toc a {
  color: #0a2a8a;
  text-decoration: none;
  white-space: nowrap;
}
.gost-help-toc a:hover { text-decoration: underline; }
.gost-help-sec {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #ddd;
}
.gost-help-sec:last-child { border-bottom: none; margin-bottom: 0; }
.gost-help-sec h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: #0a2a8a;
}
.gost-help-sec h3 {
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #222;
}
.gost-help-sec p { margin: 0 0 8px; }
.gost-help-sec ul {
  margin: 0 0 8px;
  padding-left: 1.25em;
}
.gost-help-sec li { margin: 0 0 4px; }
.gost-help-sec code {
  font-size: 12px;
  background: #eee;
  padding: 0 3px;
  border-radius: 2px;
}
.gost-help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 6px 0 0;
}
.gost-help-table th,
.gost-help-table td {
  border: 1px solid #bbb;
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.gost-help-table th {
  background: #e4e4e4;
  font-weight: 700;
}
.gost-help-table tr:nth-child(even) td { background: #f3f3f3; }
.gost-help-table td:first-child {
  font-family: Consolas, "Courier New", monospace;
  white-space: nowrap;
  width: 38%;
  color: #0a2a8a;
  font-weight: 600;
}
.gost-help-about .gost-modal-hint { margin-bottom: 10px; }

/* ----- библиотека электрики (ГОСТ 21.210) / строительства (ГОСТ 21.201, те же классы UI) ----- */
.gost-modal-card.gost-elec-card {
  width: min(920px, 96vw);
  max-height: min(88vh, 760px);
}
.gost-modal-body.gost-elec-body {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(72vh, 620px);
  padding-bottom: 4px;
}
.gost-elec-lib {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1;
}
.gost-elec-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid #bbb;
  border-radius: 4px;
  font-size: 13px;
}
.gost-elec-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.gost-elec-tab {
  border: 1px solid #c5c5c5;
  background: #f4f4f4;
  color: #222;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  line-height: 1.3;
  max-width: 100%;
}
.gost-elec-tab:hover { background: #eaeaea; }
.gost-elec-tab.active {
  background: #2f5f9f;
  border-color: #2f5f9f;
  color: #fff;
}
.gost-elec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  overflow: auto;
  flex: 1;
  min-height: 180px;
  padding: 2px 2px 8px;
}
.gost-elec-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 1px solid #ccc;
  background: #fafafa;
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  min-height: 52px;
}
.gost-elec-item:hover {
  border-color: #2f5f9f;
  background: #f0f5fb;
}
.gost-elec-preview-wrap {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 2px;
  overflow: hidden;
}
.gost-elec-preview { display: block; }
.gost-elec-item-title {
  font-size: 11.5px;
  line-height: 1.25;
  color: #1a1a1a;
}
.gost-elec-count {
  font-size: 11px;
  color: #666;
}

.gost-conv-form { max-width: 560px; }
.gost-conv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(58vh, 420px);
  overflow: auto;
  margin-top: 8px;
}
.gost-conv-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid #c8c8c8;
  background: #f7f7f7;
}
.gost-conv-meta { flex: 1; min-width: 0; }
.gost-conv-title {
  font-weight: 600;
  font-size: 13px;
  color: #0a2a8a;
}
.gost-conv-desc {
  font-size: 11px;
  color: #444;
  margin-top: 2px;
  line-height: 1.35;
}
.gost-conv-level {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  padding: 1px 6px;
  border: 1px solid #aaa;
  color: #333;
  background: #eee;
}
.gost-conv-level--full { border-color: #2e7d32; color: #1b5e20; background: #e8f5e9; }
.gost-conv-level--bridge { border-color: #ef6c00; color: #e65100; background: #fff3e0; }
.gost-conv-level--limited { border-color: #757575; color: #424242; background: #f0f0f0; }
.gost-conv-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.gost-conv-actions .gost-modal-btn {
  min-width: 7.5em;
  font-size: 11px;
  padding: 4px 8px;
}
.gost-conv-na {
  font-size: 10px;
  color: #888;
  text-align: center;
  padding: 4px 0;
}

.gost-new-form .prop-font-sel {
  font-size: 11px;
}
.prop-text-input {
  font-family: "GOST Type A", "GOST 2.304", Arial, sans-serif;
}

.gost-snap-dot {
  fill: #e53935;
  stroke: #fff;
  stroke-width: 1;
  pointer-events: none;
}
.gost-snap-tip {
  font-family: "GOST Type A", "GOST 2.304", Arial, sans-serif;
  font-size: 11px;
  pointer-events: none;
  user-select: none;
}
.snap-count {
  background: #fff;
  border: 1px solid #888;
  border-radius: 2px;
  padding: 2px 6px;
  color: #0a2a8a;
  min-width: 1.4em;
  text-align: center;
  font-size: 11px;
}
.snap-live {
  color: #6a4a00;
  font-size: 11px;
  min-width: 100px;
}
.snap-local-badge {
  background: #fff3cd;
  border: 1px solid #c9a227;
  border-radius: 2px;
  padding: 2px 6px;
  color: #5c4800;
  font-size: 11px;
}
.gost-sys-btn.snap-sys-btn.active {
  background: #cde0f8;
  box-shadow: inset 0 0 0 1px #3d6db5;
}
.gost-ctx-head {
  padding: 4px 14px 2px;
  font-size: 11px;
  color: #555;
  font-weight: 600;
}
.gost-snap-form .gost-snap-master {
  display: flex;
  margin-bottom: 8px;
  font-weight: 600;
}
.gost-snap-sec-title {
  margin: 10px 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: #0d2248;
}
.gost-snap-types {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.gost-snap-priority {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid #bbb;
  padding: 4px;
  background: #fafafa;
}
.gost-snap-pri-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.gost-snap-pri-name {
  flex: 1 1 auto;
  font-size: 12px;
}
.gost-snap-pri-row .gost-modal-btn {
  padding: 1px 8px;
  min-width: 28px;
}
.gost-snap-form .prop-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}
.gost-snap-form .chk {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-size: 12px;
}

/* ----- ИИ Агенты / MCP ----- */
.gost-modal-card.gost-ai-card-modal {
  max-width: min(640px, 96vw);
  width: min(640px, 96vw);
  max-height: min(90vh, 920px);
  display: flex;
  flex-direction: column;
  background: #eef0f3;
}
.gost-modal-card.gost-ai-card-modal > .gost-modal-title {
  background: #eef0f3;
  border-bottom: none;
  font-size: 18px;
  font-weight: 700;
  color: #2a2f36;
  padding: 14px 16px 6px;
}
.gost-modal-body.gost-ai-body {
  overflow: auto;
  padding: 8px 16px 14px;
  flex: 1;
  min-height: 0;
}
.gost-ai-agents { color: #2a2f36; }
.gost-ai-tabs {
  display: inline-flex;
  gap: 0;
  margin: 0 0 14px;
  background: #dde1e6;
  border-radius: 8px;
  padding: 3px;
}
.gost-ai-tab {
  border: none;
  background: transparent;
  color: #5c6570;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.gost-ai-tab.active {
  background: #fff;
  color: #1f2430;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.gost-ai-sec-title {
  font-size: 13px;
  font-weight: 700;
  margin: 12px 0 8px;
  color: #1f2430;
}
.gost-ai-sec-title:first-child { margin-top: 0; }
.gost-ai-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(20, 28, 40, 0.08);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.gost-ai-card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}
.gost-ai-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.gost-ai-label {
  font-size: 13px;
  color: #3a424c;
  font-weight: 600;
}
.gost-ai-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  line-height: 1.3;
}
.gost-ai-badge.ok {
  background: #1f9d55;
  color: #fff;
}
.gost-ai-badge.off {
  background: #c5ccd4;
  color: #3a424c;
}
.gost-ai-muted {
  margin: 6px 0 0;
  font-size: 12px;
  color: #6a7380;
  line-height: 1.45;
}
.gost-ai-warn { margin-top: 10px; }
.gost-ai-tok-table {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e4e7eb;
}
.gost-ai-tok-h {
  font-size: 11px;
  color: #8a93a0;
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: none;
}
.gost-ai-tok-v {
  font-size: 13px;
  color: #1f2430;
  font-weight: 600;
}
.gost-ai-term-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.gost-ai-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #c5ccd4;
  border-radius: 6px;
  overflow: hidden;
  background: #f5f6f8;
}
.gost-ai-step-btn {
  width: 32px;
  border: none;
  background: #e8ebef;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: #3a424c;
}
.gost-ai-step-btn:hover { background: #dde2e8; }
.gost-ai-step-input {
  width: 48px;
  border: none;
  border-left: 1px solid #c5ccd4;
  border-right: 1px solid #c5ccd4;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  background: #fff;
  padding: 6px 4px;
}
.gost-ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.gost-ai-btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid #b0b8c2;
  background: #f3f4f6;
  color: #1f2430;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.gost-ai-btn:hover { filter: brightness(1.03); }
.gost-ai-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.gost-ai-btn.primary {
  background: #3a424c;
  border-color: #2a3138;
  color: #fff;
}
.gost-ai-btn.danger {
  background: #fff;
  border-color: #d64545;
  color: #c62828;
}
.gost-ai-once {
  border: 1px solid #c5d4ea;
  background: #f7faff;
}
.gost-ai-subh {
  margin: 12px 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: #3a424c;
}
.gost-ai-code {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: #1e2430;
  color: #e8eef4;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.45;
  overflow: auto;
  max-height: 180px;
  white-space: pre-wrap;
  word-break: break-all;
}
@media (max-width: 520px) {
  .gost-ai-tok-table { grid-template-columns: 1fr; }
}

/* ----- Сессия: время и токены ----- */
.gost-modal-card.gost-session-card-modal {
  max-width: min(720px, 96vw);
  width: min(720px, 96vw);
}
.gost-session-kv {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}
.gost-session-live {
  font-variant-numeric: tabular-nums;
}
.gost-session-rate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.4;
}
.gost-session-rate-table th,
.gost-session-rate-table td {
  text-align: left;
  vertical-align: top;
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid #e4e7eb;
}
.gost-session-rate-table th {
  color: #6a7380;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.gost-session-rate-table td.gost-session-rate {
  font-weight: 700;
  white-space: nowrap;
  color: #1f2430;
}
.gost-session-rate-table td.gost-session-note {
  color: #6a7380;
}
@media (max-width: 520px) {
  .gost-session-kv { grid-template-columns: 1fr; }
  .gost-session-rate-table th:nth-child(4),
  .gost-session-rate-table td:nth-child(4) { display: none; }
}

/* совместимость со старыми классами */
.gost-toolbar { display: none; }
.gost-status { display: none; }

/* ГОСТ 2.307: размерные/выносные — сплошная тонкая; стрелка залитая; число курсивом */
svg .dim,
svg .ext {
  fill: none;
  stroke: #111;
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}
svg .dim-arrow {
  fill: #111;
  stroke: #111;
  stroke-width: 0.25px;
  stroke-linejoin: miter;
}
svg .dimt {
  fill: #111;
  font-style: italic;
}
