:root {
  --ink: #172632;
  --muted: #566b77;
  --paper: #ffffff;
  --canvas: #eef7f6;
  --line: #c9dcda;
  --teal: #007f86;
  --teal-dark: #075d64;
  --coral: #d95f46;
  --yellow: #f6d365;
  --focus: #1769aa;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.55;
}

button,
input,
select { font: inherit; }

button,
select { cursor: pointer; }

a { color: var(--teal-dark); }

a:hover { color: var(--coral); }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 72%, white);
  outline-offset: 2px;
}

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 24px 48px;
}

.topbar {
  position: relative;
  z-index: 1000;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
}

.language-menu { position: relative; z-index: 80; }

.language-menu summary {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 6px 16px rgba(23, 38, 50, .12);
  cursor: pointer;
  list-style: none;
}

.language-menu summary::-webkit-details-marker { display: none; }
.language-menu summary::marker { content: ""; }

.language-menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  grid-template-columns: 40px;
  gap: 4px;
  width: 52px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 18px 44px rgba(23, 38, 50, .18);
}

.language-menu:not([open]) .language-menu-list { display: none; }

.language-menu-list a {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  text-decoration: none;
}

.language-menu-list a:hover,
.language-menu-list a:focus-visible,
.language-menu-list a[aria-current="true"] { background: #e0f2f0; }

.flag-circle {
  position: relative;
  display: block;
  width: 24px;
  height: 24px;
  overflow: hidden;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(23, 38, 50, .18);
}

.flag-en { background: linear-gradient(90deg,transparent 46%,#fff 46% 54%,transparent 54%),linear-gradient(transparent 42%,#fff 42% 58%,transparent 58%),linear-gradient(90deg,transparent 48%,#c8102e 48% 52%,transparent 52%),linear-gradient(transparent 46%,#c8102e 46% 54%,transparent 54%),linear-gradient(33deg,transparent 45%,#fff 45% 50%,#c8102e 50% 53%,#fff 53% 58%,transparent 58%),linear-gradient(147deg,transparent 45%,#fff 45% 50%,#c8102e 50% 53%,#fff 53% 58%,transparent 58%),#012169; }
.flag-de { background: linear-gradient(#000 0 33.33%,#dd0000 33.33% 66.66%,#ffce00 66.66%); }
.flag-fr { background: linear-gradient(90deg,#0055a4 0 33.33%,#fff 33.33% 66.66%,#ef4135 66.66%); }
.flag-es { background: linear-gradient(#aa151b 0 25%,#f1bf00 25% 75%,#aa151b 75%); }
.flag-zh { background: #de2910; }
.flag-zh::before { content: "★"; position: absolute; top: 2px; left: 4px; color: #ffde00; font-size: 10px; line-height: 1; }
.flag-ru { background: linear-gradient(#fff 0 33.33%,#0039a6 33.33% 66.66%,#d52b1e 66.66%); }
.flag-bg { background: linear-gradient(#fff 0 33.33%,#00966e 33.33% 66.66%,#d62612 66.66%); }

.tool-header {
  max-width: 920px;
  padding: 40px 0 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 {
  max-width: 860px;
  margin-bottom: 12px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.06;
  letter-spacing: 0;
}

h2 { font-size: 1.32rem; line-height: 1.25; letter-spacing: 0; }
h3 { font-size: 1.05rem; letter-spacing: 0; }

.intro {
  max-width: 780px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 1.04rem;
}

.status-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid #8fc6c2;
  border-radius: 6px;
  background: #dff4f1;
  color: var(--teal-dark);
  font-size: .87rem;
  font-weight: 700;
}

.planner-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, .8fr);
  gap: 18px;
  align-items: start;
}

.planner-main,
.calculator-panel,
.route-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.planner-main { overflow: visible; }

.controlbar {
  position: relative;
  z-index: 510;
  display: grid;
  grid-template-columns: 150px 160px minmax(240px, 1fr);
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

label,
legend {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
}

label > span { display: block; margin-bottom: 5px; }

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #a9c3c1;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input:invalid { border-color: var(--coral); }

.search-wrap { position: relative; }

.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }

button {
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid var(--teal);
  border-radius: 6px;
  background: var(--teal);
  color: #fff;
  font-weight: 750;
}

button:hover:not(:disabled) { background: var(--teal-dark); border-color: var(--teal-dark); }
button:disabled { cursor: not-allowed; opacity: .45; }

button.secondary {
  border-color: #9abbb8;
  background: #f4fbfa;
  color: var(--teal-dark);
}

button.secondary:hover:not(:disabled),
button.secondary.active { border-color: var(--teal); background: #dff4f1; }

button.danger { border-color: #d9a79d; background: #fff3f0; color: #923b2b; }
button.danger:hover:not(:disabled) { border-color: var(--coral); background: #ffe1db; }

.control-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-results {
  position: absolute;
  z-index: 520;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: 290px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(23, 38, 50, .2);
}

.search-result {
  width: 100%;
  min-height: 40px;
  border: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.search-result:hover { background: #e8f6f4; color: var(--ink); }
.search-message { margin: 0; padding: 8px; color: var(--muted); font-size: .88rem; }

#map {
  z-index: 1;
  width: 100%;
  height: clamp(390px, 55vh, 650px);
  background: #d7e4e4;
}

.map-note,
.safety-callout {
  margin: 0;
  padding: 11px 16px;
  font-size: .88rem;
}

.map-note { color: var(--muted); }

.safety-callout {
  border-top: 1px solid #e7d58f;
  background: #fff8d9;
  color: #614f15;
}

.calculator-panel { overflow: hidden; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.metric { min-width: 0; padding: 15px 12px; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span { display: block; min-height: 38px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.metric strong { display: block; font-size: 1.12rem; line-height: 1.2; }
.metric small { display: block; margin-top: 5px; color: var(--muted); overflow-wrap: anywhere; }

.settings-section,
.file-section,
.wind-panel { padding: 16px; border-bottom: 1px solid var(--line); }
.settings-section h2,
.file-section h2 { margin-bottom: 13px; font-size: 1.05rem; }

.settings-grid { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(110px, .8fr); gap: 10px; align-items: center; }
.settings-grid fieldset { grid-column: 1 / -1; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend { margin-bottom: 6px; }
.segmented button { min-height: 36px; padding: 6px 8px; border-color: #aac3c1; background: #fff; color: var(--ink); }
.segmented button.active { border-color: var(--teal); background: #dff4f1; color: var(--teal-dark); }

.input-suffix { position: relative; }
.input-suffix input { padding-right: 34px; }
.input-suffix span { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); color: var(--muted); }

.file-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.field-help { margin: 9px 0 0; color: var(--muted); font-size: .8rem; }

.wind-panel summary { cursor: pointer; font-size: 1.05rem; font-weight: 800; }
.wind-panel > p { margin: 9px 0; color: var(--muted); font-size: .88rem; }
.wind-grid { display: grid; grid-template-columns: minmax(130px, 1fr) 100px; gap: 8px; align-items: center; }
.wind-result { display: block; margin-top: 12px; padding: 10px; border-left: 4px solid var(--coral); background: #fff3f0; font-weight: 800; }

.route-section { margin-top: 18px; padding: 18px; }
.route-section h2 { margin-bottom: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
.table-wrap + .table-wrap { margin-top: 18px; }

.data-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.data-table caption { padding: 0 0 8px; color: var(--muted); font-size: .82rem; font-weight: 700; text-align: left; }
.data-table th,
.data-table td { padding: 9px 8px; border-bottom: 1px solid #dce8e7; text-align: left; vertical-align: middle; }
.data-table th { background: #f0f7f6; color: var(--muted); font-size: .78rem; }
.data-table td { font-size: .88rem; }
.point-role { min-width: 120px; font-weight: 750; }
.name-cell { min-width: 220px; }
.coordinate-cell { width: 145px; }
.table-input { min-height: 36px; padding: 6px 8px; }
.table-actions { display: flex; width: 138px; gap: 5px; }
.icon-button { display: inline-grid; width: 36px; height: 36px; min-height: 36px; padding: 0; place-items: center; font-size: 1.15rem; }
.empty-state { padding: 26px; border: 1px dashed #aac8c5; border-radius: 6px; color: var(--muted); text-align: center; }
.empty-state.compact { padding: 14px; }

.content-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 40px;
  max-width: 1120px;
  margin: 48px auto 0;
}

.content-section > section { padding: 24px 0; border-top: 1px solid var(--line); }
.content-section p,
.content-section li { color: #3f5561; }
.content-section ul,
.content-section ol { padding-left: 22px; }
.worked-example { border-top-color: var(--coral) !important; }
.formula-list code { display: block; padding: 9px; border: 1px solid var(--line); border-radius: 4px; background: #f4f8f8; color: var(--ink); white-space: normal; overflow-wrap: anywhere; }
.faq-section details { border-bottom: 1px solid var(--line); }
.faq-section summary { padding: 12px 0; cursor: pointer; font-weight: 750; }
.faq-section details p { padding: 0 0 12px; }
.sources-section a { overflow-wrap: anywhere; }

.tool-footer { margin-top: 32px; padding: 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.tool-footer p { margin: 0; }

.toast {
  position: fixed;
  z-index: 2000;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 1px solid #87aaa7;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 16px 44px rgba(23, 38, 50, .28);
  font-size: .88rem;
}

@media (max-width: 1080px) {
  .planner-shell { grid-template-columns: 1fr; }
  .calculator-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-column: 1 / -1; }
  .wind-panel { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .page { padding: 0 12px 32px; }
  .topbar { align-items: flex-start; padding: 12px 0; }
  .top-actions { align-items: flex-start; }
  .nav-link { max-width: 150px; }
  .tool-header { padding-top: 28px; }
  h1 { font-size: 2.15rem; }
  .controlbar { grid-template-columns: 1fr 1fr; }
  .search-wrap { grid-column: 1 / -1; }
  .calculator-panel { display: block; }
  .metrics { grid-template-columns: 1fr; }
  .metric + .metric { border-top: 1px solid var(--line); border-left: 0; }
  .metric span { min-height: 0; }
  .content-section { grid-template-columns: 1fr; margin-top: 36px; }
  #map { height: 440px; }
}

@media (max-width: 480px) {
  .brand { max-width: 120px; line-height: 1.2; }
  .nav-link { display: grid; min-height: 40px; align-items: center; padding: 6px 8px; font-size: .78rem; }
  .controlbar { grid-template-columns: 1fr; padding: 12px; }
  .search-wrap,
  .control-actions { grid-column: 1; }
  .search-row { grid-template-columns: 1fr; }
  .control-actions button { flex: 1 1 140px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid fieldset { grid-column: 1; }
  .file-actions { grid-template-columns: 1fr; }
  .wind-grid { grid-template-columns: 1fr; }
  #map { height: 390px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
