@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap");

:root {
  --bg: #111316;
  --surface-1: #171a1f;
  --surface-2: #1d2228;
  --surface-3: #252b33;
  --surface-4: #303842;
  --border: rgba(210, 220, 232, 0.14);
  --border-strong: rgba(241, 151, 82, 0.5);
  --text: #eef2f6;
  --text-soft: #b8c1cc;
  --text-muted: #89939f;
  --accent: #f19752;
  --accent-hover: #ffad72;
  --accent-on: #211006;
  --success: #7ec891;
  --error: #ff9a91;
  --warning: #ffc078;
  --focus: #ffb276;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  --radius-sm: 6px;
  --radius-md: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --font-main: "Manrope", "Inter", "Segoe UI", "Trebuchet MS", "Verdana", "Tahoma", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  margin: 0;
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  padding: var(--space-4);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app {
  width: min(100%, 1680px);
  min-height: calc(100dvh - 32px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: var(--space-3);
}

.topbar,
.status,
.panel,
.drop-zone,
.viewer {
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.topbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-logo {
  display: block;
  width: 104px;
  height: auto;
  flex: 0 0 auto;
}

.brand-copy {
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.35;
}

.top-actions,
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.quick-actions .btn.is-active {
  border-color: var(--accent, #ff8b3d);
  background: rgba(255, 139, 61, 0.18);
  color: #fff;
}

.btn {
  min-height: 44px;
  min-width: 112px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.2;
  letter-spacing: 0;
  appearance: none;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.btn:hover {
  border-color: rgba(241, 151, 82, 0.38);
  background: linear-gradient(180deg, var(--surface-4), var(--surface-3));
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.drop-zone:focus-visible,
.control-select:focus-visible,
input[type="range"]:focus-visible,
input[type="checkbox"]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  box-shadow: none;
  transform: none;
}

.btn-primary {
  min-width: 124px;
  color: var(--accent-on);
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
}

.btn-primary:hover {
  border-color: transparent;
  background: linear-gradient(180deg, #ffc093, var(--accent-hover));
}

.btn-compact {
  min-width: 92px;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.84rem;
}

#file-input {
  display: none;
}

.status {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-soft);
  background: var(--surface-2);
}

.status-body {
  min-width: 0;
  display: grid;
  gap: var(--space-2);
}

.status #status-text {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.status-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-progress[hidden] {
  display: none;
}

.progress-track {
  position: relative;
  flex: 1;
  min-width: 80px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warning));
  transition: width 180ms ease;
}

.progress-label {
  min-width: 42px;
  text-align: right;
  color: var(--text-soft);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.status.success {
  border-color: rgba(126, 200, 145, 0.34);
}

.status.success #status-text {
  color: var(--success);
}

.status.error {
  border-color: rgba(255, 154, 145, 0.44);
}

.status.error #status-text {
  color: var(--error);
}

.loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-right-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.85s linear infinite;
  transition: opacity 140ms ease;
}

.status.loading .loader {
  opacity: 1;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 392px);
  gap: var(--space-3);
}

.viewer {
  position: relative;
  min-width: 0;
  min-height: 640px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    #0f1115;
  background-size: 32px 32px;
  box-shadow: var(--shadow);
}

.viewer-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  text-align: center;
  pointer-events: none;
  color: var(--text-soft);
  background: radial-gradient(circle at center, rgba(31, 36, 43, 0.8), rgba(15, 17, 21, 0.72));
  transition: opacity 160ms ease;
}

.viewer-overlay p {
  margin: 0 0 var(--space-1);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 800;
}

.viewer-overlay small {
  display: block;
  color: var(--text-soft);
  font-size: 0.86rem;
}

#viewer-empty[hidden] {
  display: none;
}

.geojson-card {
  position: absolute;
  z-index: 18;
  top: 64px;
  left: 50%;
  width: min(620px, calc(100% - 32px));
  height: min(68dvh, 660px);
  max-height: calc(100dvh - 80px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(210, 220, 232, 0.22);
  border-radius: 10px;
  color: var(--text);
  background: rgba(18, 21, 26, 0.94);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
}

@media (min-width: 861px) {
  body:not(.inspector-hidden) .geojson-card {
    left: calc(50% - 195px);
  }
}

.geojson-card[hidden] {
  display: none;
}

.geojson-card-header {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(37, 43, 51, 0.72);
}

.geojson-card-heading {
  min-width: 0;
  display: grid;
  gap: 2px;
  margin-right: auto;
}

.geojson-card-heading strong,
.geojson-card-heading small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.geojson-card-heading strong {
  font-size: 0.88rem;
}

.geojson-card-heading small {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.geojson-card-close {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  flex: 0 0 34px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.geojson-card-content {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: scroll;
  padding: 12px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.geojson-card-content > * {
  flex: 0 0 auto;
}

.geojson-feature,
.geojson-error,
.geojson-warning {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.geojson-warning {
  color: var(--warning);
  font-size: 0.76rem;
  line-height: 1.4;
}

.geojson-error {
  color: var(--error);
  font-size: 0.78rem;
  line-height: 1.45;
}

.geojson-section-title {
  margin: 0;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
}

.geojson-feature {
  padding: 0;
  overflow: hidden;
}

.geojson-feature > summary,
.geojson-nested > summary {
  cursor: pointer;
  list-style-position: inside;
}

.geojson-feature > summary {
  padding: 9px 10px;
  color: var(--text);
  background: var(--surface-3);
  font-size: 0.76rem;
  font-weight: 800;
}

.geojson-feature-content {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.geojson-data-section {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(37, 43, 51, 0.5);
}

.geojson-data-details {
  display: block;
  padding: 0;
  overflow: hidden;
}

.geojson-data-details > summary {
  cursor: pointer;
  padding: 9px 10px;
  color: var(--text);
  background: var(--surface-3);
  font-size: 0.74rem;
  font-weight: 800;
}

.geojson-data-section-content {
  padding: 10px;
}

.geojson-characteristics > .geojson-properties > .geojson-property-row:first-child {
  padding-top: 0;
}

.geojson-characteristics > .geojson-properties > .geojson-property-row:last-child {
  padding-bottom: 0;
}

.geojson-coordinates-block {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.geojson-coordinates-block small {
  color: var(--text-muted);
  font-size: 0.66rem;
  line-height: 1.4;
}

.geojson-coordinates-block .geojson-coordinate-value {
  max-height: 180px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}

.geojson-image-section .geojson-embedded-image img {
  max-height: 260px;
}

.geojson-other-section .geojson-long-text {
  max-height: 220px;
}

.geojson-properties {
  min-width: 0;
  display: grid;
  gap: 0;
  margin: 0;
}

.geojson-property-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(110px, 0.42fr) minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(210, 220, 232, 0.09);
}

.geojson-property-row:last-child {
  border-bottom: 0;
}

.geojson-property-row dt,
.geojson-property-row dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.geojson-property-row dt {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.geojson-property-key {
  display: block;
  color: var(--text-soft);
}

.geojson-property-description {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 500;
  line-height: 1.35;
}

.geojson-property-row dd {
  color: var(--text-soft);
  font-size: 0.72rem;
  line-height: 1.45;
}

.geojson-nested {
  min-width: 0;
}

.geojson-nested > summary {
  color: var(--accent-hover);
  font-size: 0.7rem;
  font-weight: 700;
}

.geojson-nested-content {
  margin-top: 6px;
  padding-left: 8px;
  border-left: 1px solid var(--border-strong);
}

.geojson-long-text,
.geojson-coordinate-value {
  max-height: 150px;
  margin: 0;
  overflow: auto;
  color: var(--text-soft);
  font: 0.68rem/1.45 ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.geojson-embedded-image {
  display: grid;
  gap: 6px;
  margin: 0;
}

.geojson-embedded-image img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0f1115;
}

.geojson-embedded-image figcaption {
  color: var(--text-muted);
  font-size: 0.64rem;
}

.viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.inspector {
  min-width: 0;
  max-height: calc(100dvh - 126px);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow: auto;
  padding-right: 2px;
}

.drop-zone {
  display: grid;
  gap: var(--space-1);
  min-height: 104px;
  padding: var(--space-4);
  border-style: dashed;
  border-color: rgba(184, 193, 204, 0.28);
  border-radius: var(--radius-md);
  color: var(--text-soft);
  background: var(--surface-2);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.drop-zone p {
  margin: 0;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 800;
}

.drop-zone span,
.drop-zone small {
  display: block;
  color: var(--text-soft);
  font-size: 0.8rem;
  line-height: 1.35;
}

.drop-zone small {
  color: var(--text-muted);
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(241, 151, 82, 0.12);
  transform: translateY(-1px);
}

.panel {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

.panel-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.panel-heading h2 {
  margin-right: auto;
}

.panel-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.panel-collapse-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.panel-collapse-icon {
  width: 9px;
  height: 9px;
  display: block;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
  transition: transform 160ms ease;
}

.collapsible-panel.is-collapsed {
  gap: 0;
}

.collapsible-panel.is-collapsed > :not(.panel-heading) {
  display: none;
}

.collapsible-panel.is-collapsed .panel-collapse-icon {
  transform: rotate(-45deg);
}

.panel h2 {
  margin: 0;
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0;
}

.panel-help {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.model-count {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-2);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.visibility-list {
  display: grid;
  gap: var(--space-2);
}

.visibility-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(92px, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.visibility-label {
  min-width: 0;
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.3;
}

.visibility-actions {
  display: inline-flex;
  gap: 6px;
}

.visibility-row-with-opacity .visibility-opacity {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr) 42px;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.visibility-opacity input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

.visibility-opacity output {
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.btn-visibility {
  min-width: 72px;
  min-height: 36px;
  padding: 7px 9px;
  font-size: 0.76rem;
}

.vpm-parts-panel {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.vpm-parts-panel[hidden] {
  display: none;
}

.vpm-parts-heading {
  display: grid;
  gap: 2px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.vpm-parts-heading small {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
}

.vpm-parts-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
  padding-right: 2px;
}

.topbar-geojson-panel {
  min-width: 0;
  overflow: hidden;
}

.geojson-files-list {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1px 2px 3px;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
}

.geojson-file-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
}

.geojson-file-button:hover,
.geojson-file-button.is-active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface-3);
}

.geojson-file-button.is-error {
  border-color: rgba(255, 154, 145, 0.4);
}

.vpm-part-tab {
  min-width: 0;
  min-height: 34px;
  max-width: 100%;
  padding: 7px 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 750;
  line-height: 1.2;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vpm-part-tab:hover {
  border-color: rgba(241, 151, 82, 0.38);
  color: var(--text);
  background: var(--surface-3);
}

.vpm-part-tab.is-active {
  border-color: var(--accent);
  color: var(--accent-on);
  background: var(--accent);
}

.vpm-part-tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.control-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}

.control-line {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.control-line-label {
  min-width: 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
}

.control-value {
  color: var(--text);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.control-line input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

.ifc-controls-panel {
  gap: var(--space-3);
}

.ifc-transform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ifc-transform-grid label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.ifc-transform-grid input {
  min-width: 0;
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-3);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.ifc-transform-grid input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.ifc-transform-grid input:disabled {
  opacity: 0.55;
}

.ifc-transform-actions {
  display: flex;
  gap: 8px;
}

.ifc-transform-actions .btn {
  flex: 1 1 0;
}

.control-select {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-3);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.control-select:hover {
  border-color: rgba(241, 151, 82, 0.38);
  background: var(--surface-4);
}

.control-select:disabled {
  color: rgba(238, 242, 246, 0.5);
  background: rgba(37, 43, 51, 0.7);
}

.control-toggle-card {
  min-width: 0;
  display: grid;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.control-toggle-row {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.35;
}

.control-toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.control-toggle-note {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.advanced-panel {
  min-width: 0;
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.advanced-panel summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.advanced-panel[open] summary {
  margin-bottom: var(--space-2);
}

.ao-advanced-grid[hidden] {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 1280px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 380px;
  }

  .viewer {
    min-height: calc(100dvh - 126px);
  }
}

@media (max-width: 1023px) {
  body {
    padding: var(--space-3);
  }

  .app {
    min-height: calc(100dvh - 24px);
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .btn {
    flex: 1 1 148px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .viewer {
    min-height: 58dvh;
  }

  .inspector {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 520px) {
  body {
    padding: var(--space-2);
  }

  .app {
    min-height: calc(100dvh - 16px);
    gap: var(--space-2);
  }

  .topbar,
  .status,
  .panel,
  .drop-zone {
    padding: var(--space-2);
  }

  .brand-logo {
    width: 82px;
  }

  h1 {
    font-size: 1rem;
  }

  .subtitle {
    font-size: 0.78rem;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
    white-space: normal;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .viewer {
    min-height: 48dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

/* Full-screen viewer shell, inspired by the compact agr.vision layout. */
html,
body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  padding: 0;
  overscroll-behavior: none;
}

.app {
  position: fixed;
  inset: 0;
  width: 100%;
  min-height: 0;
  margin: 0;
  display: block;
  overflow: hidden;
}

.workspace {
  position: fixed;
  inset: 0;
  display: block;
  min-width: 0;
  min-height: 0;
}

.viewer {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.topbar {
  position: fixed;
  z-index: 30;
  top: 10px;
  left: 10px;
  right: 10px;
  min-height: 42px;
  padding: 5px 7px;
  border-color: rgba(210, 220, 232, 0.18);
  border-radius: 9px;
  background: rgba(18, 21, 26, 0.88);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.brand-lockup {
  gap: 8px;
}

.brand-logo {
  width: 76px;
}

.brand-copy h1 {
  font-size: 0.86rem;
}

.brand-copy .subtitle {
  display: none;
}

.top-actions {
  width: auto;
  flex-wrap: nowrap;
  gap: 5px;
}

.topbar .btn {
  min-width: 0;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.74rem;
  white-space: nowrap;
}

.btn-icon {
  width: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 1.15rem;
}

.menu-toggle-button {
  flex: 0 0 34px;
}

body.inspector-hidden .menu-toggle-button {
  border-color: var(--accent);
  color: var(--accent);
}

.status {
  position: fixed;
  z-index: 26;
  left: 10px;
  bottom: 10px;
  width: min(620px, calc(100vw - 32px));
  min-height: 36px;
  padding: 6px 10px;
  border-color: rgba(210, 220, 232, 0.18);
  border-radius: 8px;
  background: rgba(18, 21, 26, 0.88);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.status #status-text {
  max-height: 42px;
  overflow: hidden;
  font-size: 0.75rem;
  line-height: 1.35;
}

.inspector {
  position: fixed;
  z-index: 25;
  top: 62px;
  right: 10px;
  bottom: 10px;
  width: min(380px, calc(100vw - 20px));
  max-height: none;
  padding: 0 3px 0 0;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  transition: transform 180ms ease, opacity 180ms ease;
}

body.inspector-hidden .inspector {
  opacity: 0;
  transform: translateX(calc(100% + 24px));
  pointer-events: none;
}

.inspector .drop-zone,
.inspector .panel {
  border-color: rgba(210, 220, 232, 0.18);
  background: rgba(18, 21, 26, 0.9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.inspector .drop-zone {
  min-height: 76px;
  padding: 11px;
}

.inspector .panel {
  gap: 10px;
  padding: 11px;
}

.flight-help {
  position: absolute;
  z-index: 4;
  left: 12px;
  bottom: 60px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}

.flight-help > span,
.movement-speed-control {
  padding: 5px 8px;
  border: 1px solid rgba(210, 220, 232, 0.18);
  border-radius: 6px;
  color: rgba(238, 242, 246, 0.76);
  background: rgba(18, 21, 26, 0.72);
  font-size: 0.68rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.movement-speed-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  pointer-events: auto;
  user-select: none;
}

.movement-speed-control span {
  white-space: nowrap;
}

.movement-speed-control input {
  width: 112px;
  min-width: 80px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: none;
}

.movement-speed-control output {
  min-width: 3.2em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.flight-joystick {
  position: absolute;
  z-index: 8;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(66px, calc(env(safe-area-inset-bottom) + 58px));
  display: none;
  place-items: center;
  gap: 5px;
  color: rgba(238, 242, 246, 0.78);
  font-size: 0.66rem;
  font-weight: 700;
  user-select: none;
  touch-action: none;
}

.flight-joystick-pad {
  position: relative;
  width: 116px;
  height: 116px;
  border: 1px solid rgba(238, 242, 246, 0.26);
  border-radius: 50%;
  background: rgba(18, 21, 26, 0.48);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  touch-action: none;
}

.flight-joystick-pad::before,
.flight-joystick-pad::after {
  content: "";
  position: absolute;
  inset: 50% 12px auto;
  height: 1px;
  background: rgba(238, 242, 246, 0.14);
}

.flight-joystick-pad::after {
  inset: 12px auto;
  left: 50%;
  width: 1px;
  height: auto;
}

.flight-joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  background: rgba(241, 151, 82, 0.82);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
  transform: translate(-50%, -50%);
  will-change: transform;
}

@media (max-width: 860px) {
  .geojson-card {
    top: calc(max(6px, env(safe-area-inset-top)) + 54px);
    width: calc(100% - 12px);
    height: calc(100dvh - max(6px, env(safe-area-inset-top)) - 66px);
    max-height: none;
  }

  .geojson-card-content {
    padding: 9px;
  }

  .geojson-property-row {
    grid-template-columns: minmax(92px, 0.38fr) minmax(0, 1fr);
  }

  .topbar {
    top: max(6px, env(safe-area-inset-top));
    left: 6px;
    right: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 46px;
    padding: 5px 7px;
  }

  .topbar-geojson-panel {
    flex: 1 1 auto;
  }

  .geojson-file-button {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 0.67rem;
  }

  .brand-lockup {
    flex: 0 0 auto;
  }

  .brand-copy {
    display: none;
  }

  .brand-logo {
    width: 58px;
  }

  .top-actions {
    display: flex;
    width: auto;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    margin-left: auto;
  }

  .topbar .top-actions .btn {
    width: 34px;
    flex: 0 0 34px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  #file-button::before,
  #reset-view-button::before,
  #clear-button::before {
    font-size: 1.15rem;
    line-height: 1;
  }

  #file-button::before {
    content: "+";
  }

  #reset-view-button::before {
    content: "↺";
  }

  #clear-button::before {
    content: "×";
  }

  .inspector {
    top: calc(max(6px, env(safe-area-inset-top)) + 48px);
    right: 6px;
    bottom: max(6px, env(safe-area-inset-bottom));
    width: min(360px, calc(100vw - 12px));
  }

  .status {
    left: 6px;
    bottom: max(6px, env(safe-area-inset-bottom));
    width: calc(100vw - 12px);
  }

  .status:not(.loading):not(.error) {
    display: none;
  }

  .status.loading #status-text {
    display: none;
  }

  .status.loading .status-body {
    width: 100%;
  }

  .status.loading .status-progress {
    width: 100%;
  }

  .flight-help {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(66px, calc(env(safe-area-inset-bottom) + 58px));
    left: auto;
    display: flex;
    max-width: min(210px, calc(100vw - 168px));
  }

  .flight-help > span {
    display: none;
  }

  .movement-speed-control {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 7px 9px;
  }

  .movement-speed-control input {
    order: 3;
    width: 100%;
    height: 24px;
    touch-action: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  .flight-joystick {
    display: grid;
  }

  body:not(.inspector-hidden) .flight-joystick {
    opacity: 0.34;
  }
}
