:root {
  color: #e6ebf0;
  background: #0e1217;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #0e1217;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(310px, 30fr) minmax(0, 70fr);
  gap: 16px;
  width: 100vw;
  height: 100vh;
  padding: 16px;
}

.left-column {
  display: grid;
  grid-template-rows: minmax(250px, 30vh) minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

.control-panel,
.view-panel {
  background: #171c22;
  border: 1px solid #303842;
  border-radius: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.control-panel {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 17px;
  padding: 31px 20px 16px;
}

.language-button {
  position: absolute;
  top: 7px;
  right: 10px;
  z-index: 1;
  height: 21px;
  padding: 0 8px;
  color: #9addd8;
  background: #20262e;
  border: 1px solid #39434e;
  border-radius: 999px;
  cursor: pointer;
  font-size: 10px;
  line-height: 19px;
}

.mode-switch {
  position: absolute;
  top: 7px;
  left: 10px;
  z-index: 1;
  height: 21px;
  display: flex;
  overflow: hidden;
  background: #20262e;
  border: 1px solid #39434e;
  border-radius: 999px;
}

.mode-switch a,
.mode-switch span {
  min-width: 39px;
  padding: 0 8px;
  color: #9aa6b1;
  font-size: 10px;
  line-height: 19px;
  text-align: center;
  text-decoration: none;
}

.mode-switch .active {
  color: #ffffff;
  background: #287a75;
}

.mode-switch a:hover {
  color: #ffffff;
  background: #29333c;
}

.language-button:hover {
  color: #ffffff;
  border-color: #5b6875;
}

.control-row {
  display: grid;
  grid-template-columns: 92px minmax(80px, 1fr) 76px;
  align-items: center;
  gap: 12px;
}

.control-row > label {
  color: #e0e6ec;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.control-row output {
  color: #b9c2cc;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 0;
  appearance: none;
  background: #3a424c;
  border-radius: 999px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  appearance: none;
  background: #171c22;
  border: 2px solid #70c9c2;
  border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  background: #171c22;
  border: 2px solid #70c9c2;
  border-radius: 50%;
}

.direction-output {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

#direction-arrow {
  display: inline-block;
  color: #66c5be;
  font-size: 24px;
  line-height: 1;
  transform-origin: center;
}

.geometry-picker {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

select,
.upload-button {
  height: 36px;
  color: #dce2e8;
  background: #20262e;
  border: 1px solid #39434e;
  border-radius: 7px;
}

select {
  min-width: 0;
  padding: 0 30px 0 10px;
  cursor: pointer;
}

.upload-button {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.upload-button:hover,
select:hover {
  border-color: #5b6875;
}

#predict-button {
  width: 100%;
  height: 39px;
  margin-top: 1px;
  color: #ffffff;
  background: #287a75;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  transition: background 120ms ease, transform 80ms ease;
}

#predict-button:hover:not(:disabled) {
  background: #31918b;
}

#predict-button:active:not(:disabled) {
  transform: translateY(1px);
}

#predict-button:disabled {
  color: #7e8892;
  background: #293039;
  cursor: default;
}

.model-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 15px;
  margin-top: -10px;
  color: #89949f;
  font-size: 11px;
  text-align: center;
}

.gpu-help-button {
  padding: 0;
  color: #70c9c2;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gpu-help-button:hover {
  color: #9addd8;
}

.view-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.view-panel.ready {
  cursor: grab;
}

.view-panel.dragging {
  cursor: grabbing;
}

.height-panel {
  background: #3b528b;
  border-style: dashed;
}

.height-panel.ready {
  border-style: solid;
}

.wind-panel {
  background: rgb(28, 32, 38);
}

#height-canvas,
#height-3d-canvas,
#wind-canvas,
#particle-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* The original 2D height canvas is retained for a one-line rollback. */
#height-canvas {
  display: none;
}

#particle-canvas {
  z-index: 2;
  pointer-events: none;
}

#height-file {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.height-panel.ready #height-file {
  display: none;
}

.upload-placeholder,
.wind-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #aeb8c2;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}

.upload-placeholder strong {
  margin-bottom: 5px;
  color: #86939f;
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
}

.upload-placeholder small {
  color: #747f8a;
  font-size: 12px;
}

.wind-placeholder {
  z-index: 4;
  padding: 20px;
  background: rgba(28, 32, 38, 0.58);
  font-size: 13px;
}

.wind-placeholder.passive {
  background: transparent;
}

.colorbar,
.scale-bar {
  position: absolute;
  right: 18px;
  z-index: 4;
  color: #f2f5f7;
  background: #171c22;
  border-radius: 8px;
  pointer-events: none;
}

.colorbar {
  top: 24px;
  display: grid;
  grid-template-columns: 10px 31px 18px;
  height: 42%;
  min-height: 150px;
  max-height: 330px;
  gap: 5px;
  padding: 11px 9px;
}

.colorbar-gradient {
  width: 10px;
  height: 100%;
  border-radius: 2px;
}

.colorbar-gradient.viridis {
  background: linear-gradient(to top, #3b528b, #2c728e, #21918c, #5ec962, #fde725);
}

.colorbar-gradient.turbo {
  background: linear-gradient(to top, #270f30, #37326d, #2c62b9, #1a99af, #2fbd68, #90c720, #c89a19, #c44f10, #640203);
}

.colorbar-ticks {
  position: relative;
  height: 100%;
  color: #f2f5f7;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.colorbar-ticks span {
  position: absolute;
  left: 0;
  transform: translateY(50%);
  white-space: nowrap;
}

.colorbar-title {
  align-self: center;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

html[lang="zh-CN"] .colorbar-title {
  transform: none;
}

.scale-bar {
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 9px;
  font-size: 13px;
}

.scale-line {
  position: relative;
  width: 9px;
  height: 80px;
  border-left: 2px solid #f2f5f7;
}

.scale-line::before,
.scale-line::after {
  position: absolute;
  left: -2px;
  width: 9px;
  height: 2px;
  background: #f2f5f7;
  content: "";
}

.scale-line::before {
  top: 0;
}

.scale-line::after {
  bottom: 0;
}

.scale-label {
  line-height: 1;
  white-space: nowrap;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.message {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 20;
  max-width: min(620px, calc(100vw - 40px));
  padding: 11px 15px;
  color: #ffd7d7;
  background: #652f34;
  border: 1px solid #935159;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.36);
  font-size: 13px;
}

.gpu-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 8, 11, 0.62);
}

.gpu-help-card {
  position: relative;
  width: min(440px, 100%);
  padding: 23px;
  color: #e6ebf0;
  background: #171c22;
  border: 1px solid #39434e;
  border-radius: 11px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.48);
}

.gpu-help-card h2 {
  margin: 0 32px 15px 0;
  font-size: 17px;
}

.gpu-help-card ol {
  margin: 0 0 17px;
  padding-left: 21px;
  color: #c7d0d8;
  font-size: 13px;
  line-height: 1.7;
}

.gpu-help-close {
  position: absolute;
  top: 11px;
  right: 13px;
  padding: 0;
  color: #97a2ad;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.gpu-address-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.gpu-address-row code {
  min-width: 0;
  padding: 9px 10px;
  overflow: hidden;
  color: #bcd6d3;
  background: #0e1217;
  border: 1px solid #303842;
  border-radius: 6px;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gpu-address-row button {
  padding: 0 13px;
  color: #ffffff;
  background: #287a75;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px), (max-aspect-ratio: 5 / 4) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 70vh);
    height: auto;
    min-height: 100vh;
  }

  .left-column {
    grid-template-rows: auto minmax(400px, 55vh);
  }
}
