:root {
  --bg: #080c11;
  --bg-2: #0b1118;
  --panel: #111923;
  --panel-2: #151f2b;
  --panel-3: #1a2634;
  --line: rgba(164, 189, 214, 0.13);
  --line-strong: rgba(164, 189, 214, 0.24);
  --text: #eaf1f8;
  --muted: #92a4b8;
  --muted-2: #6f8297;
  --accent: #ff7a1a;
  --accent-2: #ffb15c;
  --ok: #42d392;
  --info: #59c2ff;
  --danger: #ff5c6c;
  --violet: #c9a7ff;
  --gold: #ffd166;
  --pink: #ff9ec7;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% -8%, rgba(255, 122, 26, 0.11), transparent 34%),
    radial-gradient(circle at 88% 3%, rgba(89, 194, 255, 0.08), transparent 30%),
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: auto, auto, 64px 64px, 64px 64px;
  background-attachment: fixed;
}

body.admin {
  background-image:
    radial-gradient(circle at 8% -5%, rgba(255, 122, 26, 0.08), transparent 30%),
    radial-gradient(circle at 92% 4%, rgba(66, 211, 146, 0.05), transparent 26%),
    linear-gradient(rgba(255, 255, 255, 0.014) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
  background-size: auto, auto, 64px 64px, 64px 64px;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  letter-spacing: -0.025em;
}

::selection {
  background: rgba(255, 122, 26, 0.32);
  color: #fff;
}

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

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.container {
  width: min(1520px, calc(100% - 40px));
  margin-inline: auto;
}

.muted {
  color: var(--muted-2) !important;
}

.required {
  color: var(--accent);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted-2);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
}

.eyebrow__line {
  width: 22px;
  height: 1px;
  background: var(--accent);
  display: inline-block;
}

/* Header ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 17, 0.82);
  backdrop-filter: blur(18px);
}

.header-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #1a0d02;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: -0.06em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(255, 122, 26, 0.2);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-text strong {
  font-size: 0.98rem;
  letter-spacing: 0.08em;
}

.brand-text small {
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.site-nav a:hover,
.site-nav a.is-active {
  color: var(--text);
  background: var(--panel-2);
}

.site-nav .nav-admin {
  margin-left: 5px;
  border: 1px solid var(--line);
}

.site-nav .nav-admin:hover,
.site-nav .nav-admin.is-active {
  border-color: rgba(255, 122, 26, 0.35);
  background: rgba(255, 122, 26, 0.08);
}

.admin-session {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
}

.admin-badge {
  padding: 4px 8px;
  border: 1px solid rgba(66, 211, 146, 0.25);
  border-radius: 999px;
  color: var(--ok);
  background: rgba(66, 211, 146, 0.07);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Buttons ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
  background: var(--panel-3);
  font-size: 0.87rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
  border-color: rgba(255, 122, 26, 0.35);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  border-color: transparent;
  color: #1b0d02;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(255, 122, 26, 0.18);
}

.btn--primary:hover {
  box-shadow: 0 14px 36px rgba(255, 122, 26, 0.28);
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  color: #ffd7dc;
  background: rgba(255, 92, 108, 0.09);
  border-color: rgba(255, 92, 108, 0.3);
}

.btn--danger:hover {
  background: rgba(255, 92, 108, 0.16);
  border-color: rgba(255, 92, 108, 0.5);
}

.btn--small {
  min-height: 34px;
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 0.78rem;
}

.btn--wide {
  width: 100%;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

/* Panels and hero --------------------------------------------------------- */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(24, 34, 45, 0.94), rgba(13, 19, 27, 0.97));
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(380px, 0.88fr);
  gap: 44px;
  align-items: end;
  padding: 58px 0 36px;
}

.hero h1 {
  max-width: 920px;
  margin: 10px 0 20px;
  font-size: clamp(2.6rem, 5.5vw, 5.2rem);
  line-height: 0.97;
  letter-spacing: -0.055em;
}

.hero h1 span {
  color: var(--accent);
}

.hero__lead {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.hero__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.chip {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  font-size: 0.74rem;
  font-weight: 600;
}

.model-picker {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.model-picker__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.model-picker h2 {
  margin: 6px 0 0;
  font-size: 1.38rem;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  color: var(--ok);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.live-dot span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(66, 211, 146, 0.1);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(66, 211, 146, 0.08);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(66, 211, 146, 0.02);
  }
}

.model-form {
  margin: 0;
}

.select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.model-picker__summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.model-picker__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
}

.model-picker__meta strong {
  color: var(--accent);
  font-size: 0.95rem;
}

.empty-inline {
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-inline p {
  margin: 0 0 6px;
}

.empty-inline a {
  color: var(--accent);
  font-weight: 700;
}

/* Workspace --------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  gap: 28px;
  align-items: start;
  padding-bottom: 72px;
}

.diagram-panel {
  position: sticky;
  top: 94px;
  padding: 22px;
}

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel__head h2 {
  margin: 5px 0 0;
  font-size: 1.3rem;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.69rem;
  white-space: nowrap;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend__item span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px rgba(66, 211, 146, 0.45);
}

.legend__item--off span {
  background: var(--muted-2);
  box-shadow: none;
}

.diagram-wrap {
  margin: 14px -6px 0;
}

.radio-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.diagram-hint {
  margin: 12px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.controls-column {
  display: flex;
  flex-direction: column;
  gap: 26px;
  min-width: 0;
}

.controls-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
}

.controls-intro h2 {
  margin: 6px 0 8px;
  font-size: 1.6rem;
}

.controls-intro p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.controls-intro__count {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.controls-intro__count strong {
  color: var(--accent);
  font-size: 2.5rem;
  line-height: 1;
}

.controls-intro__count span {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-section--radio {
  margin-top: 8px;
  padding-top: 24px;
  border-top: 1px solid var(--line-strong);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 4px 0;
  font-size: 1.34rem;
}

.section-heading p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.count-badge {
  flex-shrink: 0;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.count-badge--info {
  color: var(--info);
  border-color: rgba(89, 194, 255, 0.2);
  background: rgba(89, 194, 255, 0.06);
}

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

/* Control cards ----------------------------------------------------------- */

.control-card {
  position: relative;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(23, 33, 44, 0.96), rgba(12, 18, 25, 0.98));
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, opacity 180ms ease;
  overflow: hidden;
}

.control-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: transparent;
  transition: background 180ms ease;
}

.control-card.is-active {
  border-color: rgba(255, 122, 26, 0.7);
  box-shadow: 0 0 0 1px rgba(255, 122, 26, 0.16), 0 14px 34px rgba(0, 0, 0, 0.28);
  transform: translateY(-2px);
}

.control-card.is-active::before {
  background: var(--accent);
}

.control-card.is-off {
  opacity: 0.68;
}

.control-card.is-radio {
  border-color: rgba(89, 194, 255, 0.18);
  background: linear-gradient(180deg, rgba(18, 31, 43, 0.96), rgba(10, 17, 24, 0.98));
}

.control-card.is-radio.is-active {
  border-color: rgba(255, 122, 26, 0.7);
}

.control-card__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.control-badge {
  flex-shrink: 0;
  min-width: 36px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid rgba(255, 122, 26, 0.25);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(255, 122, 26, 0.09);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.control-badge--analog {
  color: var(--info);
  border-color: rgba(89, 194, 255, 0.22);
  background: rgba(89, 194, 255, 0.08);
}

.control-badge--gimbals {
  color: var(--violet);
  border-color: rgba(201, 167, 255, 0.22);
  background: rgba(201, 167, 255, 0.08);
}

.control-badge--trims {
  color: var(--gold);
  border-color: rgba(255, 209, 102, 0.22);
  background: rgba(255, 209, 102, 0.08);
}

.control-badge--buttons {
  color: var(--pink);
  border-color: rgba(255, 158, 199, 0.22);
  background: rgba(255, 158, 199, 0.08);
}

.control-badge--radio {
  color: var(--info);
  border-color: rgba(89, 194, 255, 0.22);
  background: rgba(89, 194, 255, 0.08);
}

.control-card__title {
  flex: 1;
  min-width: 0;
}

.control-card__title h3 {
  margin: 0;
  font-size: 0.97rem;
  line-height: 1.25;
}

.control-card__title p {
  margin: 4px 0 0;
  color: var(--muted-2);
  font-size: 0.7rem;
  line-height: 1.3;
}

.status-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-pill__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill--on {
  color: var(--ok);
  border-color: rgba(66, 211, 146, 0.2);
  background: rgba(66, 211, 146, 0.07);
}

.status-pill--off {
  color: var(--muted-2);
}

.status-pill--system {
  color: var(--info);
  border-color: rgba(89, 194, 255, 0.2);
  background: rgba(89, 194, 255, 0.07);
}

.positions {
  margin: 12px 0 0;
  padding: 0;
}

.position-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 9px;
  padding: 7px 0;
  border-top: 1px dashed var(--line);
}

.position-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.position-row dt {
  padding-top: 2px;
  color: var(--muted-2);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.position-row dd {
  margin: 0;
  color: var(--text);
  font-size: 0.81rem;
  line-height: 1.45;
  white-space: pre-line;
}

.is-empty {
  color: var(--muted-2) !important;
  font-style: italic;
}

.control-description {
  margin: 12px 0 0;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-line;
}

.control-card__off {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.control-note {
  margin-top: 12px;
  padding: 9px 10px;
  border-left: 2px solid rgba(255, 122, 26, 0.55);
  border-radius: 0 8px 8px 0;
  background: rgba(255, 122, 26, 0.045);
}

.control-note__label {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.control-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-line;
}

/* SVG diagram ------------------------------------------------------------- */

.radio-svg .svg-control {
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
}

.radio-svg .control-label {
  fill: #b8c6d6;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
  transition: fill 150ms ease, opacity 150ms ease;
}

.radio-svg .control-label--stick {
  font-size: 10px;
  letter-spacing: 0.1em;
}

.radio-svg .svg-control.is-configured .control-label {
  fill: var(--ok);
}

.radio-svg .svg-control.is-unconfigured .control-label {
  fill: var(--muted-2);
  opacity: 0.72;
}

.radio-svg .svg-control.is-unconfigured .control-visual {
  opacity: 0.52;
}

.radio-svg .svg-control.is-radio .control-label {
  fill: #b8c6d6;
  opacity: 1;
}

.radio-svg .svg-control.is-radio .control-visual {
  opacity: 1;
}

.radio-svg .svg-control.is-active .control-label,
.radio-svg .svg-control:focus-visible .control-label {
  fill: var(--accent);
  opacity: 1;
}

.radio-svg .svg-control.is-active .control-visual,
.radio-svg .svg-control:focus-visible .control-visual {
  filter: drop-shadow(0 0 7px rgba(255, 122, 26, 0.9));
  opacity: 1;
}

.radio-svg .control-visual {
  transition: opacity 150ms ease, filter 150ms ease;
}

.radio-svg .control-hit {
  cursor: pointer;
}

.radio-svg .control-hit:focus {
  outline: none;
}

/* Wide annotated diagram -------------------------------------------------- */

.diagram-stage {
  padding: 22px;
  margin-bottom: 30px;
}

.panel__lead {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.panel__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.diagram-scroll {
  margin-top: 14px;
  padding-bottom: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(89, 194, 255, 0.35) transparent;
}

.diagram-scroll::-webkit-scrollbar {
  height: 8px;
}

.diagram-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.diagram-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(89, 194, 255, 0.3);
}

.diagram-scroll .radio-svg {
  width: 100%;
  min-width: 1050px;
}

.controls-column--wide {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.controls-column--wide .cards-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.annotations {
  pointer-events: none;
}

.annotation-line {
  fill: none;
  stroke: var(--info);
  stroke-width: 1.2;
  opacity: 0.38;
  transition: stroke 150ms ease, opacity 150ms ease, stroke-width 150ms ease;
}

.annotation-dot {
  fill: var(--ok);
  opacity: 0.9;
  transition: fill 150ms ease;
}

.annotation-joint {
  fill: var(--info);
  opacity: 0.8;
  transition: fill 150ms ease;
}

.annotation-text {
  font-family: var(--font);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}

.annotation-name {
  fill: var(--text);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.annotation-sep {
  fill: var(--muted-2);
  font-size: 14px;
}

.annotation-summary {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.annotation.is-active .annotation-line {
  stroke: var(--accent);
  stroke-width: 1.8;
  opacity: 1;
}

.annotation.is-active .annotation-dot,
.annotation.is-active .annotation-joint {
  fill: var(--accent);
}

.annotation.is-active .annotation-name {
  fill: var(--accent);
}

.annotation.is-active .annotation-summary {
  fill: var(--text);
}

.annotation.is-unconfigured .annotation-line {
  stroke: var(--muted-2);
  opacity: 0.22;
}

.annotation.is-unconfigured .annotation-dot,
.annotation.is-unconfigured .annotation-joint {
  fill: var(--muted-2);
}

.annotation.is-unconfigured .annotation-name,
.annotation.is-unconfigured .annotation-summary {
  fill: var(--muted-2);
}

.annotation.is-unconfigured.is-active .annotation-line {
  stroke: var(--accent);
  opacity: 0.7;
}

.annotation.is-unconfigured.is-active .annotation-name,
.annotation.is-unconfigured.is-active .annotation-summary {
  fill: var(--muted);
}

.radio-svg .svg-control--rear .control-visual {
  opacity: 0.78;
}

.radio-svg .svg-control--rear.is-active .control-visual,
.radio-svg .svg-control--rear:focus-visible .control-visual {
  opacity: 1;
}

/* Control tooltip --------------------------------------------------------- */

.tooltip-sources[hidden] {
  display: none;
}

.control-tooltip {
  position: fixed;
  z-index: 200;
  width: min(380px, calc(100vw - 24px));
  max-height: min(72vh, 620px);
  padding: 16px;
  border: 1px solid rgba(255, 122, 26, 0.42);
  border-radius: 16px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(23, 33, 44, 0.98), rgba(10, 16, 23, 0.99));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 122, 26, 0.1);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.control-tooltip[hidden] {
  display: none;
}

.control-tooltip.is-sheet {
  left: 12px !important;
  right: 12px;
  top: auto !important;
  bottom: 12px;
  width: auto;
  max-height: 72vh;
}

.control-tooltip__close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(8, 12, 17, 0.75);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.control-tooltip__close:hover {
  color: var(--text);
  border-color: rgba(255, 122, 26, 0.4);
}

.control-tooltip__content {
  max-height: min(68vh, 580px);
  padding-right: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(89, 194, 255, 0.35) transparent;
}

.control-tooltip__content .control-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  opacity: 1;
  transform: none;
}

.control-tooltip__content .control-card::before {
  display: none;
}

.control-tooltip__content .control-card.is-active {
  border: 0;
  box-shadow: none;
  transform: none;
}

.control-tooltip__content .control-card__head {
  padding-right: 30px;
}

/* Empty and error states -------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 44px 28px;
  text-align: center;
}

.empty-state--compact {
  padding: 28px;
}

.empty-state__mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 122, 26, 0.28);
  border-radius: 16px;
  color: var(--accent);
  background: rgba(255, 122, 26, 0.08);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.empty-state h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
}

.empty-state p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.empty-state .btn {
  margin-top: 8px;
}

.error-main {
  min-height: calc(100vh - 170px);
  display: grid;
  place-items: center;
  padding: 50px 0;
}

.error-card {
  width: min(580px, 100%);
  padding: 34px;
  text-align: center;
}

.error-card__code {
  display: block;
  margin-bottom: 8px;
  color: rgba(255, 122, 26, 0.22);
  font-size: clamp(5rem, 18vw, 10rem);
  font-weight: 900;
  line-height: 0.8;
  letter-spacing: -0.08em;
}

.error-card .eyebrow {
  justify-content: center;
}

.error-card h1 {
  margin: 10px 0;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.error-card p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.6;
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted-2);
  font-size: 0.72rem;
}

.footer-inner p {
  margin: 0;
}

.footer-inner span {
  color: var(--muted);
}

.site-footer--admin {
  margin-top: 20px;
}

/* Admin ------------------------------------------------------------------- */

.admin-main {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 40px 0 80px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-heading--form {
  align-items: flex-start;
}

.page-heading h1 {
  margin: 6px 0 10px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

.page-heading p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.back-link {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.back-link:hover {
  color: var(--accent);
}

.admin-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(22, 32, 43, 0.9), rgba(12, 18, 25, 0.96));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

.admin-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.admin-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.admin-card small {
  color: var(--muted-2);
  font-size: 0.7rem;
}

.admin-card--split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pill--info {
  color: var(--info);
  border-color: rgba(89, 194, 255, 0.22);
  background: rgba(89, 194, 255, 0.07);
}

.model-list {
  display: flex;
  flex-direction: column;
}

.model-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.model-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.model-row:last-child {
  padding-bottom: 0;
}

.model-row__main {
  min-width: 0;
}

.model-row__title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.model-row h3 {
  margin: 0;
  font-size: 1.06rem;
}

.model-row p {
  max-width: 760px;
  margin: 5px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.model-row small {
  color: var(--muted-2);
  font-size: 0.7rem;
}

.model-row__actions {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.84rem;
  line-height: 1.5;
}

.notice--success {
  color: var(--ok);
  border-color: rgba(66, 211, 146, 0.22);
  background: rgba(66, 211, 146, 0.07);
}

.notice--error {
  color: #ffb9c1;
  border-color: rgba(255, 92, 108, 0.25);
  background: rgba(255, 92, 108, 0.07);
}

.notice__dot {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.notice ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form-card {
  padding: 22px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid--basics {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.form-help {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(89, 194, 255, 0.14);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(89, 194, 255, 0.035);
  font-size: 0.8rem;
  line-height: 1.55;
}

.form-help__mark {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid rgba(89, 194, 255, 0.3);
  border-radius: 50%;
  color: var(--info);
  font-size: 0.68rem;
  font-weight: 800;
}

.form-help p {
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field__label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field__label small {
  color: var(--muted-2);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: var(--bg-2);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
  color: #556678;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 122, 26, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.12);
}

textarea {
  min-height: 74px;
  resize: vertical;
  line-height: 1.5;
}

select {
  appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.field--compact .field__label {
  font-size: 0.61rem;
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-heading--editor {
  align-items: flex-end;
}

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

.editor-control {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.014);
  transition: opacity 160ms ease, border-color 160ms ease;
}

.editor-control.is-off {
  opacity: 0.6;
  border-style: dashed;
}

.editor-control__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.editor-control__identity {
  display: flex;
  align-items: center;
  gap: 9px;
}

.editor-control__name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.editor-control__name strong {
  font-size: 0.88rem;
  line-height: 1.2;
}

.editor-control__name small {
  color: var(--muted-2);
  font-size: 0.66rem;
}

.editor-control__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch__track {
  position: relative;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #29323d;
  transition: background 160ms ease, border-color 160ms ease;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #8fa0b5;
  transition: transform 160ms ease, background 160ms ease;
}

.switch input:checked + .switch__track {
  border-color: rgba(66, 211, 146, 0.45);
  background: rgba(66, 211, 146, 0.18);
}

.switch input:checked + .switch__track::after {
  transform: translateX(14px);
  background: var(--ok);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.form-actions {
  position: sticky;
  bottom: 16px;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(8, 12, 17, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

/* Login ------------------------------------------------------------------ */

.login-main {
  min-height: calc(100vh - 170px);
  display: grid;
  place-items: center;
  padding: 48px 0;
}

.login-card {
  width: min(460px, 100%);
  padding: 32px;
}

.login-card__mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 122, 26, 0.28);
  border-radius: 14px;
  color: var(--accent);
  background: rgba(255, 122, 26, 0.08);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.login-card h1 {
  margin: 8px 0 8px;
  font-size: 2rem;
  line-height: 1.05;
}

.login-card__lead {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

.login-card__foot {
  margin: 18px 0 12px;
  color: var(--muted-2);
  font-size: 0.72rem;
  line-height: 1.55;
}

.login-card code {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.68rem;
}

.text-link {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.text-link:hover {
  color: var(--accent);
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1220px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
    align-items: start;
  }

  .model-picker {
    max-width: 760px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .diagram-panel {
    position: static;
  }

  .diagram-wrap {
    max-width: 780px;
    margin-inline: auto;
  }
}

@media (max-width: 960px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 12px 18px;
    padding: 12px 0;
  }

  .site-nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .admin-session {
    margin-left: auto;
  }

  .hero {
    padding-top: 40px;
  }

  .hero h1 {
    font-size: clamp(2.5rem, 9vw, 4.2rem);
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-heading--form .btn {
    align-self: flex-start;
  }

  .form-grid--basics {
    grid-template-columns: 1fr;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .model-row {
    flex-direction: column;
    gap: 12px;
  }

  .model-row__actions {
    width: 100%;
  }

  .admin-card--split {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .container {
    width: min(1520px, calc(100% - 28px));
  }

  .site-header .brand-text small {
    display: none;
  }

  .site-nav a {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .hero {
    padding: 34px 0 26px;
  }

  .hero__lead {
    font-size: 0.96rem;
  }

  .hero__chips {
    margin-top: 18px;
  }

  .model-picker,
  .diagram-panel,
  .controls-intro,
  .admin-card,
  .form-card {
    padding: 18px;
  }

  .controls-intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls-intro__count {
    align-self: flex-end;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .count-badge {
    align-self: flex-start;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .control-card__head {
    flex-wrap: wrap;
  }

  .status-pill {
    margin-left: 46px;
  }

  .diagram-panel .panel__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .form-actions {
    bottom: 8px;
  }

  .login-card {
    padding: 24px;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .error-card {
    padding: 24px;
  }
}

@media (max-width: 520px) {
  .select-row {
    grid-template-columns: 1fr;
  }

  .select-row .btn {
    width: 100%;
  }

  .admin-session .admin-badge {
    display: none;
  }

  .hero h1 {
    font-size: 2.55rem;
  }

  .control-card {
    padding: 14px;
  }

  .position-row {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .btn {
    width: 100%;
  }

  .model-row__actions .btn {
    flex: 1;
  }

  .model-row__actions .inline-form {
    flex: 1;
  }

  .model-row__actions .inline-form .btn {
    width: 100%;
  }
}

@media (max-width: 1300px) {
  .controls-column--wide .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .diagram-stage .panel__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel__side {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px 18px;
  }
}

@media (max-width: 720px) {
  .diagram-stage {
    padding: 18px;
  }

  .controls-column--wide .cards-grid {
    grid-template-columns: 1fr;
  }

  .diagram-scroll .radio-svg {
    min-width: 1050px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
