* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  background: linear-gradient(160deg, #1a3a3a 0%, #0d1f2d 50%, #152238 100%);
  min-height: 100vh;
  color: #e8eef2;
  line-height: 1.5;
  padding: 16px;
}

a {
  color: #7dd3c0;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
}

.back {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.dev-banner {
  margin: 0 0 18px;
  padding: 10px 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #f2e8d4;
  background: rgba(180, 100, 30, 0.22);
  border: 1px solid rgba(230, 170, 80, 0.4);
  border-radius: 8px;
}

header.page-head {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  row-gap: 12px;
  align-items: start;
  margin-bottom: 20px;
}

header.page-head h1 {
  grid-column: 1;
  grid-row: 1;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  color: #f0f7f4;
  min-width: 0;
}

/* Дети участвуют в сетке шапки: «?» остаётся в 1-й строке справа, панель — 2-й строкой на всю ширину (поток документа) */
.page-help {
  display: contents;
}

.page-help > .help-toggle {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  justify-self: end;
}

.page-help > .help-content {
  grid-column: 1 / -1;
  grid-row: 2;
}

.help-toggle {
  list-style: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #c5ebe0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

.help-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(125, 211, 192, 0.45);
}

.help-toggle::-webkit-details-marker {
  display: none;
}

.help-toggle::marker {
  content: '';
}

.page-help[open] .help-toggle {
  background: rgba(125, 211, 192, 0.2);
  border-color: rgba(125, 211, 192, 0.5);
  color: #f0f7f4;
}

.help-toggle:focus-visible {
  outline: 2px solid #7dd3c0;
  outline-offset: 3px;
}

.help-content {
  width: 100%;
  box-sizing: border-box;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  max-height: min(70vh, 28rem);
  overflow-y: auto;
}

.lead {
  color: #a8bcc8;
  font-size: 0.95rem;
  max-width: 65ch;
  margin: 0 0 14px;
}

.intro {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px 16px;
}

.intro h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: #9ee5d6;
}

.intro ul {
  margin-left: 1.2rem;
  color: #b8cad4;
  font-size: 0.88rem;
}

.intro li + li {
  margin-top: 6px;
}

.intro code {
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: #c5ebe0;
}

.help-footnote {
  margin-top: 12px;
  font-size: 0.82rem;
  color: #8fa8b8;
}

#rr-calculator.calculator-section.url_synced {
  background: rgba(10, 22, 32, 0.85);
  border: 1px solid rgba(125, 211, 192, 0.25);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.calc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.share-hint {
  flex: 1 1 100%;
  min-width: 0;
  font-size: 0.88rem;
  color: #9ee5d6;
  line-height: 1.4;
}

.share-hint--error {
  color: #f0b0a8;
}

.legs-add {
  margin-top: 16px;
  padding-top: 4px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

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

.btn-primary {
  background: #2d8a78;
  color: #fff;
}

.btn-primary:hover {
  background: #3aa08e;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #e8eef2;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-danger {
  background: rgba(180, 60, 60, 0.35);
  color: #ffc9c9;
}

.btn-danger:hover {
  background: rgba(200, 70, 70, 0.5);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

#share-hint {
  font-size: 0.85rem;
  color: #9ee5d6;
  min-height: 1.2em;
}

section.initial-point,
section.leg {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

section.initial-point h2,
section.leg h3 {
  font-size: 1.05rem;
  margin-bottom: 14px;
  color: #c5ebe0;
}

.segment h4,
.end-point h4 {
  font-size: 0.9rem;
  color: #7dd3c0;
  margin: 14px 0 10px;
}

.segment h4:first-child {
  margin-top: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field .label {
  font-size: 0.8rem;
  color: #8fa8b8;
}

.inp {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: #f0f7f4;
  font-size: 1rem;
}

.inp:focus {
  outline: 2px solid #3aa08e;
  outline-offset: 1px;
}

.inp::placeholder {
  color: #5a7080;
}

.computed-line {
  font-size: 0.88rem;
  color: #a8bcc8;
  margin-top: 8px;
}

.computed-line strong {
  color: #e8f4ef;
  font-weight: 600;
}

.err {
  color: #f0a8a8;
  font-weight: 500;
}

.leg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.leg-head h3 {
  margin-bottom: 0;
}

footer.page-foot {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  color: #7a909e;
}

@media (max-width: 520px) {
  body {
    padding: 12px;
  }

  #rr-calculator.calculator-section.url_synced {
    padding: 14px;
  }

  .calc-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .leg-head .btn-sm {
    width: auto;
  }
}
