/* Base document flow also works without flexbox or background graphics. */
* {
  box-sizing: border-box;
}

html {
  background: #f5f7f4;
  color: #1c3033;
  font-family: sans-serif;
  line-height: 1.65;
}

body {
  margin: 0;
}

header, nav, main, section, article, aside, footer, figure, figcaption, details {
  display: block;
}

main {
  padding-top: 3rem;
  padding-bottom: 4rem;
}

.container {
  width: 90%;
  max-width: 1120px;
  margin: 0 auto;
}

a {
  color: #00675d;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

a:hover {
  color: #00483f;
}

a:focus, button:focus, [tabindex]:focus {
  outline: 3px solid #b45618;
  outline-offset: 4px;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 1rem;
}

h1 {
  font-size: 2.8rem;
  letter-spacing: -0.035em;
}

h2 {
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 1rem;
}

ul, ol {
  padding-left: 1.4rem;
}

li + li {
  margin-top: 0.4rem;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -10rem;
  z-index: 10;
  padding: 0.7rem 1rem;
  background: #fff;
  font-weight: bold;
}

.skip-link:focus {
  top: 0.5rem;
}

.site-header {
  border-bottom: 1px solid #d9e2dc;
  background: #fff;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.brand {
  display: inline-block;
  margin-right: 1.5rem;
  color: #1c3033;
  font-size: 1.2rem;
  font-weight: bold;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-block;
  padding: 0.3rem 0.5rem;
  margin-right: 0.35rem;
  border: 1px solid #00675d;
  border-radius: 6px;
  color: #00675d;
  font-size: 0.85rem;
}

.navigation {
  padding: 0;
  margin: 0.4rem 0;
  list-style: none;
}

.navigation li {
  display: inline-block;
  margin: 0.2rem 0.9rem 0.2rem 0;
}

.navigation a {
  display: inline-block;
  padding: 0.3rem 0;
  color: #40585b;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.navigation a:hover, .navigation a[aria-current="page"] {
  color: #00675d;
  border-bottom-color: #00675d;
}

.navigation a[aria-current="page"] {
  font-weight: bold;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  margin: 1rem -1rem 0;
}

.hero-copy {
  flex: 1 1 570px;
  min-width: 0;
  padding: 1rem;
}

.route-panel {
  flex: 1 1 300px;
  min-width: 0;
  margin: 1rem;
  padding: 1.6rem;
  background: #e7efea;
  border: 1px solid #ceddd3;
  border-radius: 8px;
}

.eyebrow {
  margin-bottom: 1rem;
  color: #40635b;
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead {
  color: #40585b;
  font-size: 1.2rem;
}

.steps {
  margin: 1.5rem 0;
}

.steps li {
  padding-left: 0.3rem;
  margin-bottom: 1.2rem;
}

.steps strong, .steps span {
  display: block;
}

.steps span {
  margin-top: 0.25rem;
  color: #40585b;
  font-size: 0.9rem;
}

.actions {
  margin-top: 1.75rem;
}

.button {
  display: inline-block;
  padding: 0.75rem 1.2rem;
  margin: 0.4rem 1rem 0.4rem 0;
  border: 1px solid #00675d;
  border-radius: 5px;
  background: #00675d;
  color: #fff;
  font-weight: bold;
  text-decoration: none;
}

.button:hover {
  background: #00483f;
  color: #fff;
}

.text-link {
  display: inline-block;
  padding: 0.6rem 0;
}

.section {
  margin-top: 3.5rem;
}

.columns {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -0.6rem;
}

.card {
  flex: 1 1 260px;
  min-width: 0;
  padding: 1.6rem;
  margin: 0.6rem;
  border: 1px solid #d9e2dc;
  border-radius: 7px;
  background: #fff;
}

.card p:last-child {
  margin-bottom: 0;
}

.card-number {
  color: #40635b;
  font-size: 0.85rem;
}

.page-heading {
  max-width: 800px;
  margin-bottom: 2.5rem;
}

.reading-width {
  max-width: 740px;
}

.example-card {
  flex-basis: 380px;
}

.example-card h3 {
  margin-top: 1.6rem;
}

.author-note {
  max-width: 800px;
  padding: 1.5rem 0 0 1.5rem;
  border-left: 3px solid #00675d;
}

.page-index {
  margin: 0 0 2rem;
  padding: 1.2rem 1.5rem;
  background: #e7efea;
  border: 1px solid #ceddd3;
  border-radius: 6px;
}

.page-index p, .page-index ul {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.source-note, figcaption {
  color: #52666a;
  font-size: 0.9rem;
}

.source-note {
  margin-top: 1rem;
}

.instruction-list li, .source-list li {
  margin-bottom: 0.8rem;
}

.network-figure {
  margin: 1.5rem 0;
}

.network-figure img {
  display: block;
  width: 100%;
  max-width: 540px;
  height: auto;
  margin: 0 auto 0.75rem;
}

.question {
  margin: 0.8rem 0;
  padding: 1rem;
  border: 1px solid #ceddd3;
  border-radius: 5px;
  background: #fff;
}

.question summary {
  cursor: pointer;
  color: #00675d;
  font-weight: bold;
}

.question summary:focus {
  outline: 3px solid #b45618;
  outline-offset: 4px;
}

.question p {
  margin: 0.8rem 0 0;
}

.contact-link {
  font-size: 1.2rem;
  font-weight: bold;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.preparation {
  margin-bottom: 2rem;
}

.notice {
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid #9e671f;
  background: #faf1df;
}

.notice p {
  margin: 0.4rem 0 0;
}

.workspace {
  overflow: hidden;
  border: 1px solid #cbd9d0;
  border-radius: 8px;
  background: #fff;
}

.workspace-header {
  padding: 1.3rem 1.5rem 0;
}

.workspace-header h2 {
  margin-bottom: 0.4rem;
}

.muted {
  color: #52666a;
}

.device-tools {
  min-width: 0;
  padding: 0.6rem 1.5rem 1rem;
  margin: 0;
  border: 0;
}

.device-tools legend {
  padding: 0;
  color: #52666a;
  font-size: 0.85rem;
}

button {
  padding: 0.6rem 0.9rem;
  margin: 0.3rem 0.4rem 0.3rem 0;
  border: 1px solid #cbd9d0;
  border-radius: 4px;
  font: inherit;
}

button:disabled {
  background: #f1f4f2;
  color: #52666a;
  cursor: not-allowed;
}

.site-footer {
  padding: 1.75rem 0;
  border-top: 1px solid #d9e2dc;
  color: #52666a;
  font-size: 0.85rem;
}

.site-footer p {
  margin-bottom: 0.4rem;
}

@media (max-width: 600px) {
  main {
    padding-top: 2rem;
    padding-bottom: 2.5rem;
  }

  h1 {
    font-size: 2rem;
  }

  .header-inner {
    display: block;
  }

  .navigation {
    margin-top: 0.75rem;
  }

  .hero {
    margin-top: 0;
  }

  .section {
    margin-top: 2.5rem;
  }
}

@media print {
  html {
    background: #fff;
    color: #000;
  }

  .container {
    width: 100%;
  }

  .skip-link, .navigation {
    display: none;
  }

  .hero, .columns {
    display: block;
  }

  .card, .route-panel {
    break-inside: avoid;
  }
}

/* Редактор: модель хранит координаты, масштаб меняет только представление. */
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
label { display: block; font-weight: bold; margin: 0.5rem 0 0.25rem; }
input, select, textarea { font: inherit; max-width: 100%; }
input[type="text"], input[type="number"], select, textarea { width: 100%; min-width: 0; padding: 0.55rem 0.65rem; border: 1px solid #91a49e; border-radius: 5px; background: #fff; color: #1c3033; }
input:focus, select:focus, textarea:focus, .field-scroll:focus, .table-scroll:focus { outline: 3px solid #b45618; outline-offset: 2px; }
button { cursor: pointer; background: #fff; color: #00675d; font-weight: bold; }
button:hover:not(:disabled) { background: #e7efea; }
button.danger { color: #923a25; }
button[aria-pressed="true"] { background: #d8eeea; border-color: #00675d; }
.editor-page .container { width: calc(100% - 3rem); max-width: 1560px; }
.editor-page main { padding-top: 0; padding-bottom: 2rem; }
.editor-heading { max-width: none; margin-bottom: 0.5rem; display: flex; align-items: center; justify-content: space-between; gap: 2rem; padding: 1.5rem 0; }
.editor-heading h1 { margin: 0; font-size: 2rem; }
.editor-heading p { margin: 0; max-width: 440px; }
.editor-heading .eyebrow { margin-bottom: 0.35rem; }
.project-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; }
.inline-form, .project-actions, .form-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem; }
.project-bar .inline-form { flex: 1 1 360px; }
.grow { flex: 1; min-width: 120px; }
.editor-page button { margin: 0; padding: 0.55rem 0.7rem; font-size: 0.875rem; line-height: 1.45; }
.project-actions { flex: 1 1 auto; margin: 0; }
.file-control { flex: 1 1 180px; min-width: 0; max-width: 245px; font-size: 0.875rem; }
.file-control label { margin-top: 0; }
.compact-note { font-size: 0.875rem; margin: 0.5rem 0; }
.storage-status { margin: 0.25rem 0; font-size: 0.875rem; color: #52666a; }
.editor-message { position: sticky; top: 0; z-index: 5; padding: 0.6rem 0.8rem; margin: 0.75rem 0; background: #e7efea; border-left: 3px solid #00675d; font-size: 0.875rem; }
.editor-message.is-error { background: #fff0e9; border-color: #923a25; color: #752d1d; }
dialog { width: 90%; max-width: 520px; padding: 1.5rem; border: 1px solid #58796b; border-radius: 8px; background: #fff; color: #1c3033; }
dialog::backdrop { background: rgba(28, 48, 51, 0.5); }
.editor-workbench { display: grid; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; gap: 1rem; }
.editor-page .workspace { margin: 0; overflow: hidden; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; }
.workspace-header h2 { font-size: 1.25rem; margin: 0; overflow-wrap: anywhere; }
.workspace-header p { margin: 0.25rem 0 0; font-size: 0.875rem; }
.zoom-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; max-width: 260px; font-size: 0.875rem; }
.zoom-tools label { margin: 0; }
#zoom-level { width: 100px; accent-color: #00675d; }
.palette { display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0.35rem 1rem 0.75rem; margin: 0; border: 0; }
.palette legend { padding: 0; font-size: 0.875rem; color: #52666a; }
.palette button { flex: 1 1 90px; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; background: #f5f9f7; border: 1px solid #d9e2dc; }
.palette img { width: 40px; height: 34px; }
.palette-bus { display: block; width: 44px; height: 18px; border: 2px solid #58796b; border-radius: 12px; background: #e7efea; margin: 8px 0; }
.example-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0 1rem; font-size: 0.875rem; }
.example-tools label { margin: 0; }
.example-tools select { width: auto; flex: 1; max-width: 300px; }
.field-help { font-size: 0.875rem; color: #52666a; padding: 0 1rem; margin: 0.75rem 0; }
.field-mode { display: flex; gap: 0.75rem; align-items: center; padding: 0 1rem 0.75rem; font-size: 0.875rem; }
.field-scroll { height: 660px; overflow: auto; border-top: 1px solid #cbd9d0; background: #f6faf8; }
#field-surface { width: 1600px; height: 1000px; }
.network-field { position: relative; width: 1600px; height: 1000px; transform-origin: 0 0; background-color: #fff; background-image: radial-gradient(#d5e0dc 1px, transparent 1px); background-size: 20px 20px; }
#link-layer { overflow: visible; z-index: 1; position: absolute; inset: 0; pointer-events: none; }
#annotation-layer { overflow: visible; z-index: 3; position: absolute; inset: 0; pointer-events: none; font: 14px monospace; fill: #1c3033; }
.network-link { fill: none; stroke: #4e6a62; stroke-width: 2; stroke-linejoin: round; }
.network-link.wan { stroke: #336f8f; stroke-width: 2.5; }
.port-label { font: bold 14px sans-serif; fill: #1c3033; }
.editor-page .device { z-index: 2; position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 120px; height: 112px; padding: 4px; border: 1px solid transparent; border-radius: 7px; background: #fff; color: #1c3033; text-align: center; cursor: grab; touch-action: none; user-select: none; }
.device-icon { flex-shrink: 0; display: block; width: 78px; height: 65px; pointer-events: none; }
.device-label { display: block; max-width: 100%; overflow-wrap: anywhere; font-size: 14px; font-weight: bold; line-height: 18px; white-space: pre-line; flex-shrink: 0; }
.device-copy { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.editor-page .device[data-type="subnet"] { border: 2px solid #58796b; border-radius: 26px; background: #eff7f4; padding: 3px 12px; }
.device[data-type="subnet"]::before { content: ""; position: absolute; left: 7px; top: 3px; bottom: 3px; width: 10px; border: 1px solid #9eb7ad; border-radius: 50%; }
.device[data-type="subnet"] .device-copy { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); gap: 0; }
.device[data-orientation="vertical"] .device-copy { transform: translate(-50%, -50%) rotate(90deg); }
.device[data-orientation="vertical"]::before { left: 3px; top: 7px; right: 3px; width: auto; height: 10px; bottom: auto; }
.editor-page .device[aria-pressed="true"] { outline: 3px solid #00675d; outline-offset: 3px; background: #eaf6f2; }
.editor-page .device:focus { outline: 3px solid #b45618; outline-offset: 3px; }
.device.is-dragging { cursor: grabbing; z-index: 2; }
.is-connecting .device { cursor: crosshair; }
.empty-field { padding: 3rem 2rem; margin: 0; max-width: 420px; color: #52666a; }
.inspector { background: #fff; border: 1px solid #d9e2dc; border-radius: 8px; overflow: hidden; }
.inspector-section { padding: 1rem; }
.inspector-section + .inspector-section { border-top: 1px solid #d9e2dc; }
.inspector h2 { font-size: 1.125rem; margin: 0 0 0.5rem; }
.inspector p, .inspector label, .inspector input, .inspector select { font-size: 0.875rem; }
.inspector p { overflow-wrap: anywhere; }
.form-fields { padding: 0; margin: 0; min-width: 0; border: 0; }
.coordinate-fields { display: flex; gap: 0.6rem; }
.coordinate-fields > div { flex: 1; min-width: 0; }
.form-actions { margin-top: 0.75rem; }
#link-form > button { margin-top: 0.75rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.section-heading h2, .section-heading p { margin: 0; }
.route-form { background: #eaf1ee; padding: 1rem; border: 1px solid #cbd9d0; border-radius: 8px; margin-bottom: 1rem; }
.route-inputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; font-size: 0.875rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; margin: 0 auto 0 0; font-size: 0.875rem; }
.checkbox-label input { width: 18px; height: 18px; accent-color: #00675d; }
.route-tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.route-card { min-width: 0; padding: 1rem; border: 1px solid #cbd9d0; border-radius: 8px; background: #fff; }
.route-card h3 { margin: 0 0 0.75rem; font-size: 1.125rem; overflow-wrap: anywhere; }
.route-card > button { margin-top: 0.75rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
#device-table { min-width: 600px; }
caption { text-align: left; color: #52666a; margin-bottom: 0.5rem; }
th, td { padding: 0.7rem; border-bottom: 1px solid #d9e2dc; text-align: left; }
td:first-child { overflow-wrap: anywhere; }
tr.is-selected { background: #e7efea; }
.routing-table { font-size: 0.875rem; }
.routing-table th, .routing-table td { border: 1px solid #9eafa7; padding: 0.5rem; }
.routing-table th { background: #f2f6f4; white-space: nowrap; }
.routing-table td { white-space: nowrap; }
.routing-table .default-route { text-align: center; font-style: italic; }
.routing-table .route-actions { width: 1%; }
.route-actions button { display: block; padding: 0.15rem 0.35rem; border: 0; background: transparent; text-decoration: underline; }
.connection-list { list-style: none; padding: 0; }
.connection-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid #d9e2dc; }
.connection-list span { flex: 1 1 250px; overflow-wrap: anywhere; }
.object-details > summary { font-size: 1.125rem; font-weight: bold; cursor: pointer; }
@media (max-width: 1000px) {
  .editor-workbench { grid-template-columns: minmax(0, 1fr) 240px; }
  .route-tables { grid-template-columns: 1fr; }
  .editor-heading { max-width: none; margin-bottom: 0.5rem; display: block; }
  .editor-heading > p { margin-top: 0.5rem; max-width: none; }
  .route-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .editor-page .container { width: calc(100% - 1.5rem); }
  .editor-workbench { grid-template-columns: 1fr; }
  .inspector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inspector-section + .inspector-section { border-top: 0; border-left: 1px solid #d9e2dc; }
  .field-scroll { height: 520px; }
  .workspace-header { align-items: start; flex-direction: column; }
  .palette button { flex-basis: 85px; }
}
@media (max-width: 460px) {
  .inspector, .route-inputs { grid-template-columns: 1fr; }
  .inspector-section + .inspector-section { border-left: 0; border-top: 1px solid #d9e2dc; }
  .inline-form button { flex: 1; }
  .project-actions button { flex: 1 1 110px; }
  .section-heading { align-items: start; flex-direction: column; }
  .field-mode { align-items: start; flex-direction: column; }
}
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .editor-page .site-header, .editor-page .site-footer, .editor-heading, .project-bar, #file-help, #storage-status, #editor-message, .palette, .batch-tools, .shape-tools, .example-tools, .field-help, .field-mode, .zoom-tools, .inspector, .route-form, .route-actions, .route-card > button, #print-project, .object-details, #help-title, .editor-page main > .reading-width { display: none !important; }
  .editor-page .container { width: 100%; max-width: none; padding: 0; }
  .editor-workbench { display: block; }
  .editor-page .workspace { border: 0; }
  .workspace-header { padding: 0 0 0.5rem; }
  .field-scroll { height: 600px; overflow: hidden; border: 0; background: #fff; }
  #field-surface { width: 960px !important; height: 600px !important; }
  .network-field { transform: var(--print-transform, scale(0.6)) !important; background: #fff; }
  .device { outline: none !important; }
  .routes-section { break-before: page; }
  .route-tables { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .route-card { break-inside: avoid; border: 0; padding: 0; }
  .table-scroll { overflow: visible; }
  .routing-table { font-size: 11pt; }
  .routing-table th { white-space: normal; }
  .routing-table td { white-space: nowrap; }
}

/* Свободная топология и пояснения. Размер схемы определяется её содержимым. */
.batch-tools, .shape-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0 1rem 0.75rem; font-size: 0.875rem; }
.batch-tools label { margin: 0; }
#add-count { width: 5.5rem; }
.shape-tools { margin-bottom: 0.5rem; }
#export-svg { margin-left: auto; }
textarea { resize: vertical; min-height: 90px; }
.device-details { display: block; white-space: pre-line; overflow-wrap: anywhere; font-size: 12px; line-height: 16px; font-weight: normal; flex-shrink: 0; }
.network-link.wifi { stroke: #8056a3; stroke-dasharray: 7 5; }
.network-link.fiber { stroke: #b56518; stroke-width: 3; }
.editor-page .device[data-type="room"], .editor-page .device[data-type="desk"] { z-index: 0; justify-content: flex-start; padding: 8px; border: 2px solid #91a49e; border-radius: 3px; }
.editor-page .device[data-type="room"] { border-style: dashed; background: transparent; }
.editor-page .device[data-type="desk"] { background: #f0eee8; }
.editor-page .device[data-type="note"] { justify-content: flex-start; padding: 8px; border: 1px solid #91a49e; border-radius: 3px; }
.editor-page .device[data-type="room"][aria-pressed="true"] { background: transparent; }

.device-label, .device-details { font-family: monospace; }
.interface-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.interface-item { border: 1px solid #d9e2dc; border-radius: 5px; padding: 0.6rem; margin-bottom: 0.6rem; }
.interface-item p { white-space: pre-line; margin: 0 0 0.5rem; font-family: monospace; }
.interface-item button + button { margin-left: 0.4rem; }
.interface-preview { display: block; margin: 0.75rem 0; font-size: 0.875rem; overflow-wrap: anywhere; }
.interface-error { color: #a12b26; font-size: 0.875rem; }
