:root {
  color-scheme: dark;
  --background: #17191c;
  --panel: #202226;
  --input: #191b1e;
  --line: #34373c;
  --text: #e1e3e6;
  --muted: #a1a6ae;
  --accent: #9bb9db;
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #50555e transparent; }
body { margin: 0; height: 100dvh; overflow: hidden; color: var(--text); background: var(--background); }
button, input, select, summary { font: inherit; }
button, input, select { color: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
button { min-height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 11px; border: 1px solid var(--line); border-radius: 3px; background: #282b30; cursor: pointer; white-space: nowrap; line-height: 1.2; }
button:hover:not(:disabled) { background: #34383e; border-color: #666c75; }
button:disabled { opacity: .42; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, canvas:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="text"], input[type="number"], input[type="search"], select { display: block; width: 100%; height: 34px; min-width: 0; margin: 0; padding: 0 9px; border: 1px solid #41454c; border-radius: 3px; background: var(--input); line-height: normal; }
input::placeholder { color: #9399a2; opacity: 1; font-size: 11px; }
input[type="text"], input[type="number"] { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
input[type="checkbox"] { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); flex: none; }
input[type="range"] { display: block; width: 100%; height: 22px; margin: 6px 0 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m2 4 4 4 4-4' fill='none' stroke='%23b8bec7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}
@media (forced-colors: active) {
  select { appearance: auto; background-image: none; padding-right: 9px; }
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2 { font-size: 13px; font-weight: 600; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.app-header { display: flex; align-items: center; gap: 26px; height: 56px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.app-name { color: var(--text); font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.map-picker { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.map-picker select { width: 150px; height: 32px; color: var(--text); }
#share { margin-left: auto; min-width: 85px; }
.workspace { display: grid; grid-template-columns: 264px minmax(0, 1fr) 316px; height: calc(100dvh - 56px); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; min-height: 49px; padding: 0 18px; border-bottom: 1px solid var(--line); flex: none; }
#right, .results { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
#right { border-right: 1px solid var(--line); }
.search-fields { flex: 1; overflow-y: auto; padding: 0 18px; min-height: 0; }
.form-section { padding: 19px 0; border-bottom: 1px solid var(--line); }
.form-section:last-child { border: 0; }
.form-section h2 { margin-bottom: 13px; }
.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.form-field label span { font-size: 11px; color: var(--muted); }
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 12px; margin-top: 13px; }
.field-note { margin-top: 7px; font-size: 11px; color: var(--muted); text-align: right; }
.check { display: flex; align-items: center; gap: 8px; min-height: 26px; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.spacing-field { display: grid; grid-template-columns: minmax(0, 1fr) 72px; align-items: center; gap: 12px; margin-top: 17px; }
.search-actions { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); flex: none; }
.search-actions button { height: 36px; }
#go { flex: 1; }
.primary { background: #d5dce5; border-color: #d5dce5; color: #1b2027; font-weight: 600; }
.primary:hover:not(:disabled) { background: #edf1f6; border-color: #edf1f6; }
#left { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.preview-toolbar { min-height: 49px; padding: 8px 12px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--panel); z-index: 3; flex: none; }
.view-tabs { display: flex; align-self: stretch; align-items: center; gap: 2px; }
.view-tabs button { min-width: 36px; padding: 0 8px; border: 0; border-radius: 0; background: transparent; color: var(--muted); position: relative; }
.view-tabs button[aria-pressed="true"] { color: var(--text); background: #30343a; }
.view-tabs button[aria-pressed="true"]::after { position: absolute; bottom: -8px; height: 2px; background: var(--accent); left: 6px; right: 6px; content: ""; }
.toolbar-group { display: flex; gap: 3px; padding-left: 12px; border-left: 1px solid var(--line); }
.toolbar-group button { background: transparent; border-color: transparent; min-width: 31px; padding: 0 7px; }
.icon-button { font-size: 18px; }
.toolbar-end { display: flex; gap: 4px; margin-left: auto; }
.preview-menu { position: relative; }
.preview-menu > summary { display: flex; align-items: center; justify-content: center; gap: 5px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 3px; cursor: pointer; list-style: none; user-select: none; }
.preview-menu > summary::-webkit-details-marker { display: none; }
.preview-menu > summary:hover, .preview-menu[open] > summary { background: #30343a; border-color: var(--line); }
.preview-menu svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.menu-panel { position: absolute; top: calc(100% + 9px); right: 0; z-index: 5; width: 248px; max-height: min(480px, calc(100dvh - 120px)); overflow-y: auto; padding: 16px; border: 1px solid #52575f; border-radius: 3px; background: #25282d; line-height: 1.45; }
.camera-panel { left: 0; right: auto; width: 220px; padding: 8px; }
.menu-heading { color: var(--muted); font-size: 11px; font-weight: 600; margin-bottom: 9px; }
.camera-panel .menu-heading { padding: 5px 8px 0; }
.camera-panel > button { display: flex; justify-content: flex-start; width: 100%; min-height: 34px; border-color: transparent; background: transparent; padding: 0 8px; }
.camera-panel > button:hover:not(:disabled) { background: #373c43; border-color: transparent; }
.menu-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid #454a51; }
.camera-panel .menu-section { margin: 8px 8px 5px; }
.range-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; }
.range-label output { font: 11px Consolas, monospace; color: var(--muted); }
.display-panel .check { min-height: 31px; font-size: 12px; }
.display-panel .form-field { margin-bottom: 9px; }
.cut-control { margin-top: 16px; }
.text-button { min-height: 28px; background: none; border: 0; padding: 0; font-size: 11px; color: var(--muted); }
.text-button:hover:not(:disabled) { color: var(--text); background: transparent; text-decoration: underline; }
.help-panel { width: 290px; font-size: 12px; }
.help-panel h2 { margin-bottom: 10px; }
.help-panel p { color: #bdc2ca; line-height: 1.6; }
.help-panel dl { display: grid; grid-template-columns: 1fr 1.2fr; gap: 7px 14px; margin: 16px 0; }
.help-panel dt { color: var(--muted); }
.help-panel .help-note { border-top: 1px solid #454a51; padding-top: 13px; font-size: 11px; }
#mapwrap { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 0; flex: 1; overflow: hidden; background: #141619; isolation: isolate; }
canvas { display: block; touch-action: none; }
#cv3 { position: absolute; inset: 0; }
#mapwrap:not(.three) #cv3, #mapwrap.three #cv { display: none; }
.preview-footer { flex: none; border-top: 1px solid var(--line); padding: 10px 14px; font-size: 11px; color: var(--muted); }
.preview-guidance { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
#hint { line-height: 1.5; }
.legend { display: flex; gap: 12px; flex: none; font-size: 10px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend span::before { content: ""; width: 10px; height: 2px; background: #ff7070; }
.legend .legend-origin::before { background: #73aeec; }
.legend .legend-flight::before { background: #62b991; }
#hud { min-height: 16px; margin-top: 5px; line-height: 1.5; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#load3d { position: absolute; width: min(280px, 85%); left: 50%; top: 50%; transform: translate(-50%,-50%); padding: 16px; border: 1px solid #555b63; border-radius: 3px; background: #25282d; pointer-events: none; font-size: 12px; text-align: center; }
#load3d .bar { margin-top: 12px; height: 3px; background: #464c55; overflow: hidden; }
#load3d .bar i { display: block; height: 100%; width: 0; background: var(--accent); }
#load3d.busy .bar i { width: 35%; animation: loading 1.5s ease-in-out infinite; }
@keyframes loading { 0% { transform: translateX(-100%); } 100% { transform: translateX(390%); } }
#xhair { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; transform: translate(-50%,-50%); pointer-events: none; }
#xhair::before, #xhair::after { content: ""; position: absolute; background: #b7e6a5; }
#xhair::before { left: 9px; top: 0; width: 2px; height: 20px; }
#xhair::after { top: 9px; left: 0; width: 20px; height: 2px; }
.results { border-left: 1px solid var(--line); }
#resultCount { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.result-tools { padding: 13px 16px; flex: none; }
#resultSummary { color: var(--muted); font-size: 11px; margin-bottom: 12px; min-height: 16px; }
#resultSearch { height: 32px; font-size: 12px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.filters select { height: 30px; font-size: 11px; }
.result-columns, .sol { display: grid; grid-template-columns: 23px minmax(0,1fr) 54px 48px; gap: 8px; align-items: center; padding: 0 16px; }
.result-columns { height: 32px; position: sticky; top: 0; z-index: 1; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 10px; color: var(--muted); }
.result-columns span:nth-last-child(-n+2) { text-align: right; }
#out { flex: 1; min-height: 100px; overflow-y: auto; }
.sol { width: 100%; min-height: 64px; border: 0; border-bottom: 1px solid #33363c; border-radius: 0; background: transparent; text-align: left; cursor: pointer; white-space: normal; line-height: 1.4; position: relative; scroll-margin-top: 32px; }
.sol:hover:not(:disabled) { background: #2b2f34; border-color: #33363c; }
.sol.sel { background: #2b3541; }
.sol.sel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.sol:focus-visible { outline-offset: -3px; }
.sol-num { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.sol-type { display: flex; flex-direction: column; gap: 3px; }
.sol-mode { font-size: 12px; font-weight: 500; text-transform: capitalize; }
.sol-stance { font-size: 10px; color: var(--muted); }
.sol-value { text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.sol-value small { font-size: 10px; color: var(--muted); }
.empty { padding: 27px 20px; }
.empty h3 { font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.empty p { color: var(--muted); font-size: 12px; line-height: 1.65; }
.result-note { padding: 9px 16px; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); }
.more { width: calc(100% - 32px); margin: 12px 16px; font-size: 12px; }
#selection { padding: 14px 16px 16px; border-top: 1px solid #4b515a; background: #24272c; max-height: 45%; overflow-y: auto; flex: none; }
.selection-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.selection-heading h3 { font-size: 12px; font-weight: 600; }
#copyLineup { font-size: 11px; min-width: 108px; height: 30px; min-height: 30px; padding: 0 8px; }
.aim-values { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.aim-values dt { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.aim-values dd { font: 13px/1.4 Consolas, "SFMono-Regular", monospace; }
.position-value { font: 11px/1.65 Consolas, "SFMono-Regular", monospace; color: #b6bcc5; margin-top: 13px; overflow-wrap: anywhere; }
#lineupDetails { margin-top: 12px; font-size: 11px; }
#lineupDetails summary { cursor: pointer; color: var(--muted); padding: 3px 0; }
#selectedDetails { font: 11px/1.7 Consolas, "SFMono-Regular", monospace; margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#selection textarea { display: block; width: 100%; min-height: 75px; resize: vertical; background: var(--input); color: var(--text); }
@media (min-width: 1600px) { .workspace { grid-template-columns: 284px minmax(0,1fr) 336px; } }
@media (max-width: 1120px) {
  .workspace { grid-template-columns: 232px minmax(0,1fr) 284px; }
  .search-fields { padding: 0 14px; }
  .panel-heading { padding: 0 14px; }
  .search-actions { padding: 14px; }
  .preview-toolbar { gap: 5px; padding-right: 6px; padding-left: 6px; }
  .toolbar-group { padding-left: 5px; }
  .preview-guidance { display: block; }
  .legend { margin-top: 7px; }
  .result-columns, .sol { padding-right: 12px; padding-left: 12px; gap: 6px; grid-template-columns: 22px minmax(0,1fr) 49px 45px; }
}
@media (min-width: 921px) and (max-height: 740px) {
  .form-section { padding: 14px 0; }
  .form-section h2 { margin-bottom: 10px; }
  .field-pair { margin-top: 10px; }
  .spacing-field { margin-top: 12px; }
}
@media (max-width: 920px) {
  body { height: auto; overflow: auto; }
  .workspace { height: auto; grid-template-columns: 240px minmax(0,1fr); }
  #right { grid-column: 1; grid-row: 1 / 3; }
  .search-fields { flex: none; }
  .search-actions { margin-top: 0; }
  #left { grid-column: 2; grid-row: 1; height: 65dvh; min-height: 470px; }
  .results { grid-column: 2; grid-row: 2; height: 580px; border-top: 1px solid var(--line); }
  .preview-toolbar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .preview-guidance { display: block; }
  #selection { max-height: 44%; }
}
@media (max-width: 640px) {
  .app-header { height: 54px; gap: 14px; padding: 0 12px; }
  .app-name { font-size: 14px; }
  .map-picker > span { display: none; }
  .map-picker select { width: 119px; }
  #share { min-width: 68px; padding: 0 8px; font-size: 12px; }
  .workspace { display: flex; flex-direction: column; }
  #left { order: 0; height: 64dvh; min-height: 390px; }
  #right { order: 1; border-right: 0; border-top: 1px solid var(--line); }
  .search-fields { padding: 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
  .form-section:last-child { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 140px; gap: 0 24px; }
  .form-section:last-child h2 { grid-column: 1 / -1; }
  .spacing-field { margin: 0; grid-template-columns: 1fr 62px; }
  .field-pair { grid-template-columns: 1fr 62px; gap: 8px; }
  .form-field label { font-size: 11px; }
  .field-note { font-size: 10px; }
  .search-actions { justify-content: flex-end; padding: 14px 18px; }
  #go { flex: 0 1 200px; }
  .results { order: 2; border-left: 0; height: 630px; }
  .preview-toolbar { gap: 7px; padding: 8px; }
  .toolbar-group { padding-left: 6px; }
  .preview-menu > summary { padding: 0 6px; font-size: 12px; gap: 3px; }
  .toolbar-end { gap: 0; }
  .display-panel { right: -42px; }
  .camera-panel { left: -50px; }
  .preview-footer { padding: 8px 12px; }
  .legend { margin-top: 6px; }
}
@media (max-width: 420px) {
  .search-fields { display: block; }
  .form-section:last-child { display: block; }
  .spacing-field { display: grid; margin-top: 14px; grid-template-columns: 1fr 72px; }
  .field-pair { grid-template-columns: 1fr 80px; }
  .app-header { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { #load3d.busy .bar i { animation: none; width: 100%; } }
@media (max-width: 360px) {
  .app-header { gap: 8px; padding: 0 10px; }
  .app-name { font-size: 13px; }
  .map-picker select { width: 100px; }
  .preview-toolbar { gap: 5px; padding: 8px 6px; }
  .view-tabs button { min-width: 30px; }
  .toolbar-group { gap: 0; }
  .toolbar-group button { min-width: 27px; padding: 0 5px; }
}
.surface-choice { margin-top: 12px; }
