:root {
  color-scheme: dark;
  --body: #121613;
  --panel: #1a211b;
  --inner: #131a15;
  --line: #344036;
  --subtle: #a9b7ac;
  --strong: #f0f4ec;
  --lime: #d8f58e;
  --earth: #a17b53;
  --forest: #659752;
  --rock: #aaa9a0;
  --water: #568da2;
  --route: #ed3d45;
  --frame: #dfe4dc;
  --lettering: #293630;
  font: 16px/1.45 'Inter', 'Avenir Next', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; background: var(--body); color: var(--strong); }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, a, summary, label[for='gpx'] { -webkit-tap-highlight-color: transparent; }
button, summary, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
a { color: #c6d1c7; text-underline-offset: 3px; }
a:hover { color: var(--lime); }
h1, h2, p { margin: 0; }
h2 { font-size: 1rem; font-weight: 690; letter-spacing: -.022em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.topbar {
  height: 66px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #2a322b;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 1.22rem; font-weight: 740; letter-spacing: -.04em; }
.brand-mark { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--lime); flex-shrink: 0; }
.brand-mark i { position: absolute; width: 22px; height: 13px; background: #21321c; clip-path: polygon(0 78%, 36% 21%, 47% 41%, 70% 0, 100% 78%, 100% 94%, 70% 24%, 48% 62%, 36% 43%, 0 99%); }
.brand-mark i:first-child { transform: translateY(-4px); }
.brand-mark i:last-child { transform: translateY(4px); }
.language { position: relative; flex-shrink: 0; }
.language::after { content: ''; position: absolute; right: 12px; top: 14px; width: 6px; height: 6px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg); pointer-events: none; }
.language select { appearance: none; min-height: 38px; padding: 6px 30px 6px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--strong); background: var(--panel); font-size: .88rem; }
.workspace {
  min-width: 0;
  height: calc(100dvh - 66px);
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(315px, 27vw, 390px);
  gap: 14px;
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 17px; min-width: 0; min-height: 0; overflow: hidden; box-shadow: 0 8px 30px #080d0921; }
.preview { display: grid; grid-template-rows: auto minmax(120px, 1fr) auto auto auto; position: relative; }
.preview-head { min-width: 0; min-height: 68px; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; gap: 8px 14px; }
.preview-title { min-width: 0; }
.preview-head h2 { font-size: 1.08rem; }
.preview-head p { font-size: .83rem; color: var(--subtle); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions, .view-modes { display: flex; flex-shrink: 0; align-items: center; gap: 6px; }
.view-modes { gap: 2px; border: 1px solid var(--line); background: var(--inner); padding: 3px; border-radius: 10px; }
.view-modes button, .navigation button, .icon-button { display: grid; place-items: center; border: 0; background: transparent; color: var(--subtle); border-radius: 6px; }
.view-modes button { min-width: 39px; min-height: 30px; padding: 4px 9px; font-size: .86rem; font-weight: 650; }
.view-modes button[aria-pressed='true'] { background: #354639; color: #edf5dd; }
.view-modes button:hover, .navigation button:hover, .icon-button:hover { color: var(--strong); }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--inner); }
.expand-icon { width: 15px; height: 15px; background:
  linear-gradient(currentColor, currentColor) left top / 5px 1.5px, linear-gradient(currentColor, currentColor) left top / 1.5px 5px,
  linear-gradient(currentColor, currentColor) right top / 5px 1.5px, linear-gradient(currentColor, currentColor) right top / 1.5px 5px,
  linear-gradient(currentColor, currentColor) left bottom / 5px 1.5px, linear-gradient(currentColor, currentColor) left bottom / 1.5px 5px,
  linear-gradient(currentColor, currentColor) right bottom / 5px 1.5px, linear-gradient(currentColor, currentColor) right bottom / 1.5px 5px;
  background-repeat: no-repeat;
}
.icon-button[aria-pressed='true'] .expand-icon { transform: rotate(45deg); width: 12px; height: 12px; }
.stage { position: relative; min-width: 0; min-height: 0; isolation: isolate; border-block: 1px solid #354037; background: radial-gradient(ellipse at 48% 38%, #2a392f 0%, #19241d 57%, #131914 100%); }
.stage::before { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: -1; background: radial-gradient(circle, #8ba49265 1px, transparent 1.5px) center / 19px 19px; mask-image: radial-gradient(ellipse at 50% 51%, #000b 0%, #0006 62%, transparent); }
#terrain { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#terrain:active { cursor: grabbing; }
#terrain:focus-visible { outline-offset: -3px; }
.source-badge, .canvas-hint { position: absolute; color: #d2ddd2; background: #172019de; border: 1px solid #5261519f; padding: 5px 9px; font-size: .77rem; pointer-events: none; }
.source-badge { left: 14px; top: 14px; border-radius: 99px; }
.canvas-hint { left: 14px; bottom: 14px; border-radius: 7px; }
.navigation { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; padding: 3px; border: 1px solid #526151a8; border-radius: 10px; background: #172019ef; }
.navigation button { width: 35px; height: 35px; font-size: 1.17rem; }
.navigation button + button { border-top: 1px solid #40504095; }
.navigation button:hover { background: #303d31; }
.reset-icon { width: 11px; height: 11px; border: 1.5px solid currentColor; border-radius: 100%; box-shadow: 0 0 0 3px #435648; }
.canvas-error { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 22px; pointer-events: none; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; }
.metrics > div { min-width: 0; padding: 11px 15px; }
.metrics > div + div { border-left: 1px solid var(--line); }
.metrics dt { font-size: .8rem; color: var(--subtle); }
.metrics dd { margin: 3px 0 0; font-size: clamp(.91rem, 1.5vw, 1.15rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.legend { border-top: 1px solid var(--line); list-style: none; margin: 0; padding: 9px 15px; display: flex; flex-wrap: wrap; gap: 5px 15px; color: #c0ccbd; font-size: .77rem; }
.legend li { display: flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.data-info { padding: 6px 15px; border-top: 1px solid var(--line); font-size: .75rem; color: var(--subtle); }
.data-info p { padding: 4px 0; }
.data-info div { display: flex; flex-wrap: wrap; gap: 4px 13px; padding-bottom: 4px; }
.controls { display: flex; flex-direction: column; }
.control-section { padding: 16px 17px; }
.upload-section { padding-bottom: 13px; max-height: 42%; overflow: auto; scrollbar-width: thin; }
.upload-section h2 { margin-bottom: 9px; }
.dropzone { min-height: 67px; display: flex; align-items: center; gap: 11px; padding: 9px 11px; position: relative; border: 1px dashed #667963; border-radius: 11px; color: #edf5e9; background: var(--inner); cursor: pointer; }
.dropzone:hover, .dropzone.dragging, .dropzone:focus-within { border-color: var(--lime); background: #243125; }
.upload-copy { min-width: 0; display: grid; gap: 2px; }
.upload-copy strong { font-size: .89rem; }
.upload-copy span { color: var(--subtle); font-size: .78rem; }
.settings-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 17px; border-bottom: 1px solid var(--line); gap: 4px; flex-shrink: 0; }
.settings-tabs button { min-width: 0; padding: 8px 4px 10px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--subtle); font-size: .86rem; font-weight: 620; }
.settings-tabs button:hover, .settings-tabs button[aria-selected='true'] { color: var(--strong); }
.settings-tabs button[aria-selected='true'] { border-color: var(--lime); }
.panel-scroll { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #576a57 transparent; }
.panel-scroll > section { min-width: 0; }
.export-bar { padding: 12px 17px; border-top: 1px solid var(--line); background: var(--panel); }
.export-bar .primary { display: flex; align-items: center; justify-content: space-between; gap: 9px; width: 100%; padding: 9px 12px; min-height: 46px; border: 0; border-radius: 9px; background: var(--lime); color: #152010; font-size: .94rem; font-weight: 750; }
.export-bar .primary:hover:not(:disabled) { background: #ebffb0; }
.earth { background: var(--earth); }
.forest { background: var(--forest); }
.rock { background: var(--rock); }
.water { background: var(--water); }
.route { background: var(--route); }
.frame { background: var(--frame); border: 1px solid #717b73; }
.lettering { background: var(--lettering); border: 1px solid #717b73; }
.mapped-paths { background: #ddb682; }
.grass { background: #a8a95a; }
.cropland { background: #bc9562; }
.urban-ground { background: #ada59d; }
.buildings { background: #dcd2c3; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { width: 27px; height: 25px; color: var(--lime); position: relative; margin-bottom: 3px; }
.upload-icon::after { content: ''; position: absolute; left: 5px; bottom: 2px; width: 15px; height: 5px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 3px 3px; }
.upload-icon i { position: absolute; top: 5px; left: 12px; width: 1.5px; height: 11px; background: currentColor; }
.upload-icon i::before { content: ''; position: absolute; top: -1px; left: -3px; width: 6px; height: 6px; border-left: 1.5px solid currentColor; border-top: 1.5px solid currentColor; transform: rotate(45deg); }
.upload-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; font-size: .875rem; }
.upload-footer > span { color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-button { background: none; border: 0; padding: 2px 0; color: var(--lime); font-size: .875rem; white-space: nowrap; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.status { border-radius: 7px; margin-top: 8px; padding: 8px 10px; background: #2a3827; font-size: .875rem; color: #d3e6c9; }
.status[data-kind='error'] { background: #462c23; color: #ffc8ae; }
.status-actions { display: flex; gap: 12px; }
.shape-field { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; font-size: .875rem; }
.shape-field legend { margin-bottom: 5px; padding: 0; }
.shape-options { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--inner); padding: 3px; }
.shape-options label { position: relative; cursor: pointer; }
.shape-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.shape-options label > span { display: block; text-align: center; padding: 5px 4px; border-radius: 5px; color: var(--subtle); }
.shape-options input:checked + span { background: #364537; color: #f0f6d9; font-weight: 650; }
.shape-options input:focus-visible + span { outline: 2px solid var(--lime); }
.rotation-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 7px; }
.rotation-buttons button { border: 1px solid var(--line); border-radius: 7px; padding: 5px 4px; background: var(--inner); color: var(--strong); }
.rotation-buttons button:hover { border-color: var(--lime); }
.text-field { margin-bottom: 13px; font-size: .875rem; }
.text-field label { display: block; margin-bottom: 4px; }
.text-field label .optional, .text-field p { color: var(--subtle); }
.text-field input { display: block; width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; background: var(--inner); color: var(--strong); font-variant-numeric: tabular-nums; }
.detail-field { margin-top: 9px; }
.detail-field select { appearance: none; width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 6px 28px 6px 8px; background: var(--inner); color: var(--strong); font: inherit; }
.detail-field label { position: relative; }
.detail-field label::after { content: ''; position: absolute; pointer-events: none; top: 36px; right: 11px; width: 7px; height: 7px; border-right: 1px solid var(--subtle); border-bottom: 1px solid var(--subtle); transform: rotate(45deg); }
.text-field input[aria-invalid='true'] { border-color: #f1827f; }
.text-field input[aria-invalid='true'] + p { color: #ffc1b6; }
.text-field p { margin-top: 3px; font-size: .82rem; }
.range-help { font-size: .82rem; color: var(--subtle); }
.route-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 9px; margin-bottom: 13px; }
.route-values .text-field { margin-bottom: 0; }
.route-values > .range-help { grid-column: 1 / -1; }
.layer-field { margin: 0 0 12px; padding: 0; border: 0; min-width: 0; font-size: .875rem; }
.layer-field legend { padding: 0; margin-bottom: 4px; }
.layer-field label { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.layer-field input { margin: 0; width: 16px; height: 16px; accent-color: var(--lime); }
.layer-field label:has(:disabled) { color: var(--subtle); }
.layer-field .path-field { margin-bottom: 0; }
.layer-field .path-field label { display: block; min-height: 0; }
.layer-field .path-field p:empty { display: none; }
.range-field + .range-field { margin-top: 9px; }
.range-label { display: flex; justify-content: space-between; align-items: center; gap: 5px; font-size: .875rem; }
.range-label output { color: var(--lime); white-space: nowrap; font-variant-numeric: tabular-nums; }
input[type='range'] { display: block; appearance: none; width: 100%; height: 21px; margin: 2px 0 0; background: transparent; cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: linear-gradient(to right, #afc676 var(--range-progress), #3a473a var(--range-progress)); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 99px; background: linear-gradient(to right, #afc676 var(--range-progress), #3a473a var(--range-progress)); }
input[type='range']::-webkit-slider-thumb { appearance: none; margin-top: -5px; width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--lime); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--lime); }
.details { font-size: .875rem; margin-top: 9px; border-top: 1px solid var(--line); padding-top: 9px; }
.details summary { color: #c5d0c3; cursor: pointer; }
.details[open] summary { margin-bottom: 10px; }
.exports { display: grid; gap: 7px; }
.filament-field { min-width: 0; margin: 3px 0 5px; padding: 7px 9px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: .875rem; }
.filament-field legend { padding-inline: 4px; }
.filament-mode { display: flex; align-items: center; gap: 8px; min-height: 27px; }
.filament-mode input { width: 16px; height: 16px; margin: 0; accent-color: var(--lime); }
.filament-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin: 7px 0; }
.filament-slots label { display: grid; gap: 3px; color: var(--subtle); text-align: center; font-size: .75rem; }
.filament-slots input { width: 100%; min-width: 0; height: 27px; padding: 2px; border: 1px solid #4a5749; border-radius: 5px; background: var(--inner); cursor: pointer; }
.filament-assignments { display: grid; gap: 5px; margin-top: 7px; }
.filament-assignment { display: grid; grid-template-columns: minmax(0, 1fr) 10px auto; align-items: center; gap: 7px; }
.filament-assignment i { width: 10px; height: 10px; border-radius: 2px; border: 1px solid #717b73; }
.filament-assignment select { padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: var(--inner); color: var(--strong); font: inherit; }
.exports button { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 41px; border-radius: 8px; padding: 6px 11px; font-size: .925rem; font-weight: 720; border: 1px solid transparent; }
.exports .secondary { color: var(--strong); background: transparent; border-color: #4a5749; }
.exports .secondary:hover:not(:disabled) { background: #2a3829; }
.exports p { font-size: .82rem; color: var(--subtle); }
.assembly .text-field { margin: 9px 0; }
.assembly .text-field input { width: 100px; }
#assembly-status:not(:empty) { margin-top: 6px; }
.download-icon { width: 18px; height: 18px; position: relative; border-bottom: 1.5px solid currentColor; }
.download-icon::before { content: ''; position: absolute; top: 1px; left: 8px; width: 1.5px; height: 11px; background: currentColor; }
.download-icon::after { content: ''; position: absolute; top: 5px; left: 5px; width: 6px; height: 6px; border-bottom: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(45deg); }
.upload-icon { flex: 0 0 35px; height: 35px; margin: 0; border-radius: 9px; background: #293b29; }
.upload-icon::after { left: 10px; bottom: 8px; }
.upload-icon i { left: 17px; top: 8px; }
.shape-options label > span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 3px; }
.shape-icon { display: inline-block; flex-shrink: 0; width: 12px; height: 10px; border: 1px solid currentColor; border-radius: 2px; }
.shape-icon.hexagon { border: 0; border-radius: 0; background: currentColor; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%, 25% 0, 30% 16%, 16% 50%, 30% 84%, 70% 84%, 84% 50%, 70% 16%, 30% 16%, 25% 0); }
.settings > .details:first-of-type { margin-top: 12px; }
.settings .layer-field + .layer-field { padding-top: 7px; border-top: 1px solid var(--line); }
.settings .layer-field input { flex-shrink: 0; }
.panel-scroll .detail-field:first-child { margin-top: 0; }
.preview:fullscreen, .preview.is-expanded { inset: 0; width: 100%; height: 100dvh; border: 0; border-radius: 0; z-index: 5; }
.preview.is-expanded { position: fixed; }
body.preview-expanded { overflow: hidden; }
@media (max-width: 800px), (max-height: 570px) {
  .workspace { height: auto; }
  .preview:not(.is-expanded):not(:fullscreen) { grid-template-rows: auto clamp(290px, 55dvh, 520px) auto auto auto; }
  .upload-section { max-height: none; }
}
@media (max-width: 800px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 10px; }
  .topbar { padding-inline: 13px; height: 58px; }
  .controls { min-height: 420px; }
  .export-bar { position: sticky; bottom: 0; }
  .preview:not(.is-expanded):not(:fullscreen) { grid-template-rows: auto clamp(280px, 43dvh, 480px) auto auto auto; }
}
@media (max-width: 480px) {
  .brand { font-size: 1.05rem; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .preview-head { min-height: 56px; padding: 8px 10px; }
  .preview-head h2 { font-size: .93rem; }
  .preview-head p { font-size: .77rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics > div { padding: 7px 10px; }
  .metrics > div:nth-child(3) { border-left: 0; }
  .metrics > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .legend, .data-info { padding-inline: 10px; }
  .navigation button { width: 38px; height: 38px; }
  .text-field input, .detail-field select { font-size: 1rem; }
}
