:root {
  --panel-width: 344px;
  --ink: #f8fafc;
  --muted: #aab6c8;
  --panel: rgba(16, 24, 36, 0.88);
  --line: rgba(226, 232, 240, 0.18);
  --blue: #3b82f6;
  --green: #20c997;
  --red: #ff7b72;
}

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

body {
  background: #0a0f18;
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

#cesiumContainer {
  position: absolute;
  inset: 0;
}

.control-panel {
  position: absolute;
  z-index: 20;
  top: 12px;
  left: 12px;
  width: min(var(--panel-width), calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  box-sizing: border-box;
  padding: 12px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
}

.panel-header {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header h1 {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
}

.panel-header span,
.panel-header strong {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  color: #d9e9ff;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(96, 165, 250, 0.36);
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
}

.switch-control,
.select-control {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  margin-bottom: 10px;
  color: var(--ink);
}

.switch-control input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.select-control select {
  width: 100%;
  min-width: 0;
  height: 32px;
  color: var(--ink);
  background: rgba(30, 41, 59, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.46);
  border-radius: 5px;
}

.terrain-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(226, 232, 240, 0.12);
}

.terrain-section h2 {
  margin: 0 0 8px;
  color: #d7e7ff;
  font-size: 14px;
}

.terrain-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.terrain-list label {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
  min-height: 30px;
  padding: 0 8px;
  background: rgba(15, 23, 42, 0.58);
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 5px;
  color: #e5edf7;
  font-size: 13px;
}

.terrain-list input {
  flex: 0 0 auto;
  accent-color: var(--blue);
}

.terrain-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.action-row button {
  height: 34px;
  color: var(--ink);
  background: rgba(37, 99, 235, 0.82);
  border: 1px solid rgba(147, 197, 253, 0.54);
  border-radius: 5px;
  cursor: pointer;
}

.action-row button:hover {
  background: #2563eb;
}

.provider-info {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px;
  background: rgba(2, 6, 23, 0.32);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 5px;
}

.provider-info div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
}

.provider-info dt {
  color: var(--muted);
  font-size: 12px;
}

.provider-info dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #e8f2ff;
  font-size: 12px;
}

.status-line {
  margin-top: 10px;
  color: #c9fff1;
  font-size: 13px;
  line-height: 1.45;
}

.status-line.is-error {
  color: var(--red);
}

.map-caption,
.legend {
  position: absolute;
  z-index: 18;
  right: 12px;
  color: var(--ink);
  background: rgba(16, 24, 36, 0.78);
  border: 1px solid var(--line);
  border-radius: 6px;
  backdrop-filter: blur(8px);
}

.map-caption {
  bottom: 12px;
  display: grid;
  gap: 4px;
  width: min(520px, calc(100vw - 24px));
  box-sizing: border-box;
  padding: 10px 12px;
}

.map-caption strong {
  font-size: 15px;
}

.map-caption span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.legend {
  top: 12px;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  font-size: 13px;
}

.legend div {
  display: flex;
  gap: 8px;
  align-items: center;
}

.swatch {
  width: 16px;
  height: 10px;
  border-radius: 2px;
}

.swatch.terrain {
  background: #20c997;
}

.swatch.ellipsoid {
  background: #94a3b8;
}

@media (max-width: 720px) {
  .control-panel {
    right: 12px;
    width: auto;
    max-height: 58vh;
  }

  .legend {
    display: none;
  }

  .map-caption {
    left: 12px;
    right: 12px;
    width: auto;
  }
}
