@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Newsreader:opsz,wght@6..72,400..700&family=Public+Sans:wght@400;500;600&display=swap");

:root {
  color-scheme: light;
  --bg: #f3ede3;
  --bg-deep: #e7ddd0;
  --surface: rgba(255, 251, 245, 0.82);
  --surface-strong: rgba(255, 253, 250, 0.94);
  --ink: #1f261f;
  --muted: #666d61;
  --line: rgba(38, 52, 42, 0.12);
  --line-strong: rgba(48, 71, 51, 0.24);
  --accent: #4f6549;
  --accent-soft: rgba(79, 101, 73, 0.12);
  --warm: #9b6b45;
  --warm-soft: rgba(155, 107, 69, 0.12);
  --shadow: 0 22px 60px rgba(53, 51, 41, 0.12);
  --radius: 1.5rem;
  --shell-gap: 1rem;
  --dock-height: min(38vh, 25rem);
  --dock-offset: calc(var(--dock-height) + 1.25rem);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at top left, rgba(96, 128, 91, 0.16), transparent 36%),
    radial-gradient(circle at 82% 14%, rgba(155, 107, 69, 0.14), transparent 26%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
  color: var(--ink);
  font-family: "Public Sans", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  min-height: 100vh;
}

.map-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  padding: var(--shell-gap);
}

.map-canvas,
.map-atmosphere {
  position: absolute;
  inset: 0;
}

.map-canvas {
  z-index: 0;
}

.map-atmosphere {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(248, 244, 238, 0.12), rgba(245, 238, 228, 0.22)),
    radial-gradient(circle at center, transparent 44%, rgba(243, 237, 227, 0.3));
}

.surface {
  position: relative;
  z-index: 12;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.2)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.topbar,
.focus-card,
.province-strip,
.dock,
.machine-panel {
  position: absolute;
}

.topbar {
  top: var(--shell-gap);
  left: var(--shell-gap);
  right: var(--shell-gap);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.2rem;
}

.brand-copy {
  display: grid;
  gap: 0.35rem;
  max-width: 38rem;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.77rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar h1,
.focus-card h2,
.detail-title,
.oauth-card h3,
.machine-head h2,
.section-head h3 {
  margin: 0;
  font-family: "Newsreader", serif;
  letter-spacing: -0.03em;
}

.topbar h1 {
  font-size: clamp(1.8rem, 2vw, 2.5rem);
  line-height: 0.92;
}

.quiet-line {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.topbar-actions,
.oauth-flow,
.action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 0.82rem 1.05rem;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  box-shadow: 0 8px 20px rgba(53, 80, 55, 0.18);
}

.button:hover,
.button:focus-visible,
.community-button:hover,
.community-button:focus-visible,
.province-button:hover,
.province-button:focus-visible,
.route-card:hover,
.route-card:focus-visible,
.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-1px);
}

.button-quiet {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: none;
  border: 1px solid var(--line);
}

.focus-card {
  top: 6.6rem;
  left: var(--shell-gap);
  width: min(32rem, calc(100vw - (var(--shell-gap) * 2)));
  display: grid;
  gap: 0.45rem;
  padding: 1.1rem 1.2rem;
}

.focus-card h2 {
  font-size: clamp(2.2rem, 5vw, 3.7rem);
  line-height: 0.94;
  max-width: 12ch;
}

.province-strip {
  left: var(--shell-gap);
  right: var(--shell-gap);
  bottom: var(--dock-offset);
  padding: 1rem 1.1rem 0.85rem;
  display: grid;
  gap: 0.85rem;
}

.strip-head,
.dock-head,
.section-head,
.machine-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.strip-head h3,
.dock-head h2,
.section-head h3,
.machine-head h2 {
  font-size: 1.25rem;
  line-height: 1;
}

.province-list {
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  scrollbar-width: none;
}

.province-list::-webkit-scrollbar,
.community-list::-webkit-scrollbar,
.record-scroll::-webkit-scrollbar,
.machine-log::-webkit-scrollbar {
  display: none;
}

.province-button,
.community-button,
.route-card,
.action-button,
.machine-status-card,
.mini-card,
.source-card {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 1.15rem;
}

.province-button {
  min-width: 13rem;
  padding: 0.9rem 1rem;
  text-align: left;
  display: grid;
  gap: 0.45rem;
  cursor: pointer;
}

.province-button.is-active {
  border-color: var(--line-strong);
  background: rgba(250, 249, 245, 0.98);
  box-shadow: 0 12px 28px rgba(77, 101, 73, 0.12);
}

.province-name,
.community-name,
.mini-card strong,
.source-card strong {
  font-weight: 600;
}

.province-meta,
.community-meta,
.community-trace,
.route-card p,
.machine-log time,
.machine-log p,
.source-card p,
.source-card span {
  color: var(--muted);
}

.dock {
  left: var(--shell-gap);
  right: var(--shell-gap);
  bottom: var(--shell-gap);
  display: grid;
  grid-template-columns: minmax(17rem, 0.9fr) minmax(0, 1.3fr);
  gap: 1rem;
  height: var(--dock-height);
  padding: 1rem;
}

.dock-column {
  min-height: 0;
  display: grid;
  gap: 0.9rem;
  overflow: hidden;
}

.dock-column--list {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.dock-column--detail {
  grid-template-rows: auto minmax(0, 1fr);
}

.search-field {
  display: grid;
  gap: 0.5rem;
}

.search-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.search-field input,
.oauth-card textarea {
  width: 100%;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  padding: 0.88rem 1rem;
}

.community-list,
.record-scroll,
.machine-log {
  min-height: 0;
  overflow: auto;
}

.community-list {
  display: grid;
  gap: 0.65rem;
}

.community-button {
  display: grid;
  gap: 0.42rem;
  text-align: left;
  padding: 0.95rem 1rem;
  cursor: pointer;
}

.community-button.is-active {
  border-color: var(--line-strong);
  box-shadow: 0 14px 28px rgba(77, 101, 73, 0.12);
}

.badge-row,
.chip-row,
.machine-log-item,
.route-card {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.badge,
.chip,
.route-kind {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.33rem 0.62rem;
  font-size: 0.75rem;
  background: rgba(79, 101, 73, 0.1);
  color: var(--accent);
}

.badge[data-band="dark"] {
  background: rgba(155, 107, 69, 0.12);
  color: var(--warm);
}

.record-head {
  display: grid;
  gap: 0.45rem;
}

.detail-back {
  display: none;
  justify-self: start;
}

.detail-title {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.92;
  max-width: 14ch;
}

.record-scroll {
  display: grid;
  gap: 0.9rem;
  padding-right: 0.15rem;
}

.record-section {
  display: grid;
  gap: 0.65rem;
}

.action-row {
  align-items: stretch;
  gap: 0.48rem;
  justify-content: flex-start;
}

.action-button,
.route-card {
  padding: 0.76rem 0.86rem;
  text-decoration: none;
}

.action-button {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  padding: 0.84rem 0.92rem;
  gap: 0.42rem;
  font-weight: 500;
  line-height: 1.2;
}

.route-list,
.card-grid,
.source-grid,
.machine-status {
  display: grid;
  gap: 0.7rem;
}

.route-list,
.machine-status {
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.card-grid,
.source-grid {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.mini-card,
.source-card,
.machine-status-card {
  padding: 0.84rem 0.9rem;
  display: grid;
  gap: 0.28rem;
  align-content: start;
}

.source-card strong,
.route-card strong {
  line-height: 1.2;
  font-size: 0.98rem;
}

.source-card p,
.route-card p {
  margin: 0;
  line-height: 1.35;
  font-size: 0.84rem;
}

.source-card span {
  line-height: 1.35;
  font-size: 0.84rem;
}

.route-list {
  gap: 0.58rem;
}

.source-grid {
  gap: 0.6rem;
}

.route-card {
  align-content: start;
}

#detail-meta,
.detail-meta {
  line-height: 1.35;
  max-width: 48rem;
}

.machine-panel {
  top: 1rem;
  right: 1rem;
  width: min(28rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.machine-panel.is-hidden {
  display: none;
}

.machine-capsule {
  display: grid;
  gap: 0.7rem;
}

.machine-log {
  display: grid;
  gap: 0.65rem;
}

.machine-log-item {
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
}

.oauth-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(100%, 42rem);
}

.oauth-dialog::backdrop {
  background: rgba(24, 32, 25, 0.24);
  backdrop-filter: blur(4px);
}

.oauth-card {
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  border-radius: 1.5rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2)),
    var(--surface-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.oauth-link {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  padding: 0.75rem 0.95rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  word-break: break-all;
}

.hidden {
  display: none;
}

.empty-state {
  color: var(--muted);
  padding: 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.54);
  border: 1px dashed var(--line);
}

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.66) !important;
  color: var(--muted) !important;
}

.leaflet-container,
.leaflet-pane,
.leaflet-control-container {
  z-index: 0 !important;
}

.leaflet-tile {
  filter: saturate(0.82) hue-rotate(-6deg) brightness(1.02);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(255, 253, 249, 0.96);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.popup-card {
  display: grid;
  gap: 0.3rem;
}

@media (max-width: 980px) {
  :root {
    --dock-height: min(48vh, 30rem);
    --dock-offset: calc(var(--dock-height) + 1.15rem);
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .focus-card {
    top: 10.4rem;
    width: calc(100vw - (var(--shell-gap) * 2));
  }

  .dock {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  body[data-dock-mode="list"] .dock-column--detail {
    display: none;
  }

  body[data-dock-mode="detail"] .dock-column--list {
    display: none;
  }

  body[data-dock-mode="detail"] .detail-back {
    display: inline-flex;
  }
}

@media (max-width: 720px) {
  :root {
    --shell-gap: 0.75rem;
    --dock-height: min(52vh, 30rem);
    --dock-offset: calc(var(--dock-height) + 1rem);
  }

  .map-stage {
    padding: var(--shell-gap);
  }

  .topbar {
    top: var(--shell-gap);
  }

  .focus-card {
    top: 11.8rem;
  }

  .dock {
    padding: 0.75rem;
  }

  .province-button {
    min-width: 11rem;
  }

  .action-row {
    gap: 0.5rem;
  }

  .action-button {
    min-height: 3rem;
    flex: 1 1 calc(50% - 0.4rem);
    padding: 0.66rem 0.74rem;
    border-radius: 0.92rem;
    gap: 0.38rem;
    font-size: 0.91rem;
  }

  .action-button .route-kind {
    padding: 0.23rem 0.48rem;
    font-size: 0.7rem;
  }

  .record-scroll {
    gap: 0.82rem;
  }

  .record-section {
    gap: 0.58rem;
  }

  .route-card,
  .source-card,
  .mini-card {
    border-radius: 0.96rem;
  }

  .route-card {
    padding: 0.72rem 0.78rem;
  }

  .source-card,
  .mini-card,
  .machine-status-card {
    padding: 0.85rem 0.9rem;
  }

  .source-card strong,
  .route-card strong {
    font-size: 0.93rem;
  }

  .source-card p,
  .route-card p {
    font-size: 0.84rem;
  }
}
