:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-tint: #edf7f1;
  --text: #111827;
  --text-soft: #334155;
  --muted: #6b7280;
  --line: #d7dde6;
  --line-strong: #c4ccd8;
  --nav: #111827;
  --green: #15803d;
  --green-dark: #166534;
  --green-soft: #dcfce7;
  --blue: #2563eb;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --shadow: 0 18px 46px rgba(15, 23, 42, 0.14);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--nav);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand,
.topbar-actions,
.identity-row,
.panel-head,
.legend,
.sharing-control {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  min-width: 0;
  font-weight: 850;
  font-size: 17px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
  flex: 0 0 auto;
}

.brand-icon.large {
  width: 46px;
  height: 46px;
}

.brand-icon svg,
.button svg,
.icon-button svg,
.tab svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.topbar-actions {
  gap: 10px;
  flex: 0 0 auto;
}

.auth-view {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 26px 16px;
}

.auth-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 4px;
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 7px rgba(17, 24, 39, 0.08);
}

.form {
  display: grid;
  gap: 14px;
  padding-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input::placeholder {
  color: #9ca3af;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.app-view {
  flex: 1;
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  padding: 16px;
}

.map-stage {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #dbe4ec;
  box-shadow: var(--shadow-soft);
}

#map {
  width: 100%;
  height: 100%;
}

.map-chrome {
  position: absolute;
  left: 16px;
  right: 16px;
  z-index: 500;
  pointer-events: none;
}

.map-chrome.top {
  top: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.map-status,
.legend {
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.map-status {
  min-width: min(360px, 100%);
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.map-status .label {
  color: rgba(255, 255, 255, 0.68);
}

.map-status strong {
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.legend {
  min-height: 42px;
  gap: 12px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.legend-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 999px;
}

.legend-dot.own {
  background: var(--blue);
}

.legend-dot.partner {
  background: #ef4444;
}

.control-rail {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  padding: 16px;
}

.panel-head {
  min-height: 44px;
  justify-content: space-between;
  gap: 12px;
}

.identity-row {
  gap: 12px;
  min-width: 0;
}

.identity-row.compact {
  align-items: flex-start;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.avatar.own {
  background: var(--blue);
}

.avatar.partner {
  background: #ef4444;
}

.label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.sharing-control {
  justify-content: space-between;
  gap: 14px;
  min-height: 74px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.sharing-control span {
  display: block;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 850;
}

.sharing-control strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 62px;
  height: 36px;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.18s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(26px);
}

.info-list {
  display: grid;
  gap: 2px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.info-list div {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
}

.info-list div + div {
  border-top: 1px solid var(--line);
}

.info-list span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.info-list strong {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  text-align: right;
  overflow-wrap: anywhere;
}

.pair-tools {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.invite-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: var(--surface-tint);
  padding: 12px;
}

.invite-box div {
  display: grid;
  gap: 2px;
}

.invite-box span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 950;
  font-size: 24px;
  line-height: 1;
  color: var(--green-dark);
  letter-spacing: 0;
}

.invite-box small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.button {
  min-height: 44px;
  gap: 8px;
  padding: 0 14px;
  background: #fff;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button.primary {
  background: var(--green);
  color: #fff;
}

.button.primary:hover {
  background: var(--green-dark);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface-soft);
}

.button.danger {
  background: #fff;
  color: var(--red);
  border-color: #fecaca;
}

.button.danger:hover {
  background: #fff5f5;
}

.button.wide {
  width: 100%;
}

.icon-button {
  width: 42px;
  height: 42px;
  background: #fff;
  border-color: var(--line);
}

.icon-button.dark {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
}

.badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.live {
  background: var(--green-soft);
  color: var(--green-dark);
}

.badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.muted {
  background: #e5e7eb;
  color: #374151;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.marker-dot {
  width: 22px;
  height: 22px;
  display: block;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.36);
}

.marker-own {
  background: var(--blue);
}

.marker-partner {
  background: #ef4444;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .app-view {
    grid-template-columns: 1fr;
    grid-template-rows: 48vh auto;
    padding: 12px;
  }

  .map-stage {
    min-height: 380px;
  }

  .control-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 0 12px;
  }

  .app-view {
    grid-template-rows: 44vh auto;
  }

  .control-rail {
    grid-template-columns: 1fr;
  }

  .map-chrome.top {
    left: 10px;
    right: 10px;
    top: 10px;
    flex-direction: column;
  }

  .map-status {
    min-width: 0;
    width: 100%;
  }

  .legend {
    align-self: flex-start;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .brand {
    font-size: 16px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .app-view {
    padding: 10px;
    gap: 10px;
  }

  .map-stage,
  .panel,
  .auth-panel {
    border-radius: 8px;
  }

  .panel {
    padding: 14px;
  }

  .sharing-control {
    padding: 12px;
  }

  .info-list div {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .info-list strong {
    text-align: left;
  }

  .invite-box {
    align-items: stretch;
  }

  .invite-box span {
    font-size: 22px;
  }

  h1 {
    font-size: 21px;
  }
}
