:root {
  --ocean: #091821;
  --panel: #0f2029;
  --mint: #5cf0c4;
  --orange: #ff9f0a;
  --text: #ffffff;
  --secondary: rgba(235, 235, 245, 0.6);
  --hairline: rgba(255, 255, 255, 0.12);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--ocean);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:disabled { opacity: 0.35; cursor: default; }
button:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 12px calc(18px + env(safe-area-inset-left));
  background: var(--panel);
  flex: none;
}

.app-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(92, 240, 196, 0.12);
  color: var(--mint);
  font-size: 22px;
  flex: none;
}

.app-icon svg { fill: currentColor; stroke: none; transform: rotate(90deg); }

.titles { min-width: 0; flex: 1; }
.titles h1 { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.titles p { margin: 2px 0 0; font-size: 12px; color: var(--secondary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--secondary);
  background: rgba(255, 255, 255, 0.06);
  flex: none;
}

.badge svg { font-size: 14px; }
.badge[data-state="ready"] { color: var(--mint); background: rgba(92, 240, 196, 0.1); }

/* Map */
.map {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

.chip {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  font-size: 11px;
  pointer-events: none;
}

.chip.north {
  top: 12px;
  left: calc(12px + env(safe-area-inset-left));
  padding: 7px;
  font-weight: 500;
  background: var(--panel);
}

.chip.credit {
  bottom: 10px;
  left: calc(10px + env(safe-area-inset-left));
  padding: 8px;
  color: var(--secondary);
  background: rgba(9, 24, 33, 0.85);
}

.map-buttons {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right));
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-buttons button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--hairline);
  font-size: 19px;
}

.map-buttons button.accent { color: var(--mint); }
.map-buttons button.filled svg { fill: currentColor; }

/* Panel */
.panel {
  flex: none;
  padding: 14px calc(18px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  background: var(--panel);
}

.install-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(92, 240, 196, 0.08);
  box-shadow: inset 0 0 0 1px rgba(92, 240, 196, 0.2);
}

.install-hint[hidden] { display: none; }
.install-hint p { margin: 0; flex: 1; font-size: 12px; line-height: 1.45; }
.install-hint button { font-size: 16px; color: var(--secondary); padding: 2px; }

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-icon { display: inline-flex; font-size: 17px; }
.status-icon.fresh { color: var(--mint); }
.status-icon.fresh svg { fill: currentColor; }
.status-icon.stale { color: var(--orange); }

.status-row h2 { margin: 0; flex: 1; font-size: 17px; font-weight: 600; }

.status-action {
  font-size: 15px;
  font-weight: 600;
  color: var(--mint);
  padding: 4px 0 4px 8px;
}

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

.status-detail {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--secondary);
}

.fix[hidden] { display: none; }

.fix hr {
  margin: 10px 0;
  border: 0;
  border-top: 0.5px solid rgba(84, 84, 88, 0.65);
}

.coords {
  margin: 0;
  font-family: var(--mono);
  font-size: 15px;
}

.fix.stale .coords { color: var(--secondary); }
.fix.stale .metrics { display: none; }

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 10px;
}

.metrics div { display: flex; flex-direction: column; gap: 3px; }
.metrics span { font-size: 11px; color: var(--secondary); }
.metrics strong { font-family: var(--mono); font-size: 12px; font-weight: 500; white-space: nowrap; }
