:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #637083;
  --panel: #ffffff;
  --panel-soft: #f5f7fa;
  --line: #d9e0e8;
  --accent: #0b6bcb;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --shadow: 0 16px 44px rgba(19, 35, 54, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #e8edf3;
}

button,
input {
  font: inherit;
}

button,
.file-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  border-color: #9db1c7;
  background: #f8fbff;
}

button:focus-visible,
input:focus-visible,
.file-button:focus-visible {
  outline: 3px solid rgba(11, 107, 203, 0.26);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  height: 100%;
  min-height: 100vh;
}

.map-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #dce5ee;
}

.map-canvas,
gmp-map-3d {
  display: block;
  width: 100%;
  height: 100%;
}

.annotation-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-stage::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: rgba(255, 255, 255, var(--presentation-fade, 0));
  content: "";
}

.map-stage.is-presenting .annotation-layer {
  z-index: 3;
}

.map-stage.is-drawing .annotation-layer {
  cursor: crosshair;
  pointer-events: auto;
}

.annotation-shape {
  pointer-events: visiblePainted;
  cursor: grab;
}

.annotation-shape.is-active {
  filter: drop-shadow(0 0 5px rgba(11, 107, 203, 0.95));
}

.annotation-shape.is-spotlight {
  filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.95));
}

.annotation-handle {
  cursor: move;
  pointer-events: all;
}

.map-controls {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(2, 42px);
  gap: 8px;
}

.map-controls button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-color: rgba(23, 32, 42, 0.2);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(20, 34, 48, 0.18);
  font-weight: 800;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  padding: 24px;
  text-align: center;
  color: #25364a;
  background: linear-gradient(135deg, #edf2f7, #dce6ef);
}

.empty-state h1 {
  margin: 0 0 8px;
  font-size: 44px;
  line-height: 1;
}

.empty-state p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
}

.api-key-form {
  display: grid;
  gap: 10px;
  width: min(520px, 90vw);
  margin-top: 22px;
  padding: 16px;
  border: 1px solid rgba(23, 32, 42, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 32px rgba(20, 34, 48, 0.12);
  text-align: left;
}

.api-key-form label {
  color: #35465c;
  font-size: 13px;
  font-weight: 800;
}

.api-key-form div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.api-key-form input {
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.api-key-form button {
  min-height: 38px;
}

#clear-api-key {
  justify-self: start;
  color: #4b5966;
  background: #ffffff;
}

.control-panel {
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
  padding: 20px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-row h2,
.status-box h3,
.annotation-list h3 {
  margin: 0;
}

.brand-row h2 {
  font-size: 24px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-weight: 800;
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-group label,
.style-row label,
.project-card label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.project-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.project-card input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.search-row input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-row button,
.tool-button.active,
.action-row button.primary {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-button {
  padding: 0 10px;
  text-align: center;
}

.shape-drawer {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.shape-drawer summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.shape-button {
  min-height: 38px;
  font-size: 20px;
  font-weight: 800;
}

.shape-button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #eef6ff;
}

.style-row {
  display: grid;
  grid-template-columns: auto 52px auto minmax(100px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.style-row input[type="color"] {
  width: 52px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.style-row input[type="range"] {
  width: 100%;
}

.palette-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.color-swatch {
  min-width: 0;
  min-height: 32px;
  border: 2px solid #ffffff;
  border-radius: 8px;
  background: var(--swatch-color);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.color-swatch.active {
  outline: 3px solid rgba(11, 107, 203, 0.35);
  outline-offset: 1px;
}

.layer-controls,
.presentation-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.layer-controls h3,
.presentation-controls h3 {
  grid-column: 1 / -1;
  margin: 0;
}

.layer-controls label,
.presentation-controls label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #35465c;
  font-size: 13px;
  font-weight: 700;
}

.layer-controls input,
.presentation-controls input {
  accent-color: var(--accent);
}

.presentation-controls input[type="range"],
.presentation-controls button {
  grid-column: 1 / -1;
}

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

.note-editor {
  display: grid;
  gap: 8px;
}

.note-editor label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.note-editor textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.note-editor input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.annotation-note-label {
  pointer-events: none;
}

.file-button {
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
}

.status-box,
.annotation-list,
.project-stats {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.status-box p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.project-stats h3 {
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-pill {
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.stat-pill strong {
  font-size: 17px;
}

.stat-pill span {
  color: var(--muted);
  font-size: 11px;
}

.annotation-list {
  min-height: 160px;
}

.annotation-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.annotation-delete {
  min-height: 30px;
  padding: 0 8px;
  border-color: #f0b7b3;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.annotation-item.active {
  border-color: var(--accent);
}

.annotation-item.muted {
  opacity: 0.48;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.annotation-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-meta {
  color: var(--muted);
  font-size: 12px;
}

.annotation-note-preview {
  overflow: hidden;
  color: #35465c;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 58vh) auto;
  }

  .control-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
    box-shadow: none;
  }
}

@media (max-width: 460px) {
  .control-panel {
    padding: 14px;
  }

  .tool-grid,
  .action-row,
  .search-row {
    grid-template-columns: 1fr;
  }

  .style-row {
    grid-template-columns: auto 52px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-shell {
    display: block;
    height: auto;
  }

  .map-stage {
    height: 100vh;
  }

  .control-panel,
  .map-controls {
    display: none;
  }
}
