:root {
  --bg: #eef2ef;
  --paper: #fffdf7;
  --ink: #17211d;
  --muted: #65716d;
  --line: #d8ded8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 33, 29, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(208, 126, 42, 0.14), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.loading-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loading-card {
  width: min(460px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
  border-radius: 8px;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(460px, 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 22px;
  background: rgba(255, 253, 247, 0.9);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.topbar h1 {
  margin: 4px 0 8px;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

.lede,
.hint,
.field span,
.media-card small {
  color: var(--muted);
}

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

.topbar-actions,
.button-row,
.button-grid,
.map-toolbar,
.tabbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tabbar {
  margin: 16px 0;
}

.tabbar button,
.map-toolbar button,
.ghost-button,
.accent-button,
.danger-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.tabbar button.active,
.map-toolbar button.active,
.accent-button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.accent-button:hover {
  background: var(--accent-strong);
}

.danger-button {
  color: var(--danger);
}

.wide {
  width: 100%;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.compact {
  gap: 10px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 10px 32px rgba(23, 33, 29, 0.08);
  border-radius: 8px;
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 22px;
}

.panel-head,
.zone-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
}

.compact-field {
  margin-bottom: 8px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 7px;
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: #e6f3ef;
  border: 1px solid #a9d8cd;
  color: #064e3b;
  border-radius: 8px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 16px;
}

.map-panel {
  min-height: 620px;
}

.map {
  height: 540px;
  width: 100%;
  margin-top: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.12) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 118, 110, 0.12) 1px, transparent 1px),
    #dfe9e2;
  background-size: 32px 32px;
  overflow: hidden;
}

.hidden-map {
  display: none;
}

.fallback-map {
  cursor: crosshair;
}

.fallback-map svg {
  width: 100%;
  height: 100%;
  display: block;
}

.map-label {
  fill: #17211d;
  font-size: 28px;
  font-weight: 700;
}

.map-start circle {
  fill: #ef4444;
  stroke: white;
  stroke-width: 4;
}

.map-start text,
.map-zone text {
  fill: #17211d;
  font-size: 22px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fffdf7;
  stroke-width: 5px;
  stroke-linejoin: round;
}

.map-zone {
  cursor: pointer;
}

.map-zone circle:first-child {
  fill: rgba(15, 118, 110, 0.2);
  stroke: #0f766e;
  stroke-width: 4;
}

.map-zone circle:nth-child(2) {
  fill: #0f766e;
  stroke: white;
  stroke-width: 3;
}

.map-zone.active circle:first-child {
  fill: rgba(239, 68, 68, 0.2);
  stroke: #ef4444;
}

.map-zone.active circle:nth-child(2) {
  fill: #ef4444;
}

.zone-list {
  display: grid;
  gap: 12px;
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
}

.zone-card {
  border: 1px solid var(--line);
  background: #fbfaf4;
  border-radius: 8px;
  padding: 12px;
}

.zone-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.media-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fbfaf4;
  border-radius: 8px;
  padding: 10px;
}

.media-card img,
.media-card audio,
.file-preview {
  width: 100%;
  min-height: 120px;
  object-fit: cover;
  border-radius: 6px;
  background: #e8eee9;
}

.file-preview {
  display: grid;
  place-items: center;
  padding: 14px;
}

.file-button {
  position: relative;
  overflow: hidden;
  display: inline-grid;
  place-items: center;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.issue-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.issue {
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: white;
}

.issue.error {
  border-color: #f2b8b5;
  background: #fff0ef;
}

.issue.warn {
  border-color: #f2d48a;
  background: #fff8e1;
}

.issue.success {
  border-color: #9bd7c7;
  background: #e8f6f2;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  background: #18211d;
  color: #f4f4ed;
  border-radius: 8px;
  padding: 14px;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

@media (max-width: 900px) {
  .topbar,
  .grid.two,
  .map-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .map-panel {
    min-height: 480px;
  }

  .map {
    height: 380px;
  }
}
