:root {
  --bg-deep: #0a0f14;
  --bg-panel: #121a21;
  --bg-panel-alt: #16202a;
  --border-line: #223140;
  --border-line-soft: #1a2530;
  --text-primary: #e9eef2;
  --text-secondary: #8fa0ad;
  --text-muted: #5c6c78;
  --brand-red: #db303f;
  --brand-red-dark: #85040f;
  --accent-cyan: #4cc9f0;
  --accent-amber: #ffb020;
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-display);
}

body {
  background-image:
    linear-gradient(var(--border-line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-line-soft) 1px, transparent 1px);
  background-size: 42px 42px;
  background-position: -1px -1px;
}

a { color: var(--accent-cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(10, 15, 20, 0.9);
  border-bottom: 1px solid var(--border-line);
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  border-radius: 6px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text-primary);
}

.brand-name em {
  font-style: normal;
  color: var(--brand-red);
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  border: 1px solid var(--border-line);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-panel);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-amber);
  box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.15);
  transition: background 0.3s, box-shadow 0.3s;
}

.status-dot.live {
  background: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.18);
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.18); }
  50% { box-shadow: 0 0 0 6px rgba(76, 201, 240, 0.06); }
}

/* Layout */
.container {
  display: flex;
  height: calc(100% - 64px);
  flex-direction: row;
}

.sidebar {
  width: 320px;
  flex-shrink: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  border-right: 1px solid var(--border-line);
  background: rgba(10, 15, 20, 0.6);
}

#map { flex: 1; height: 100%; }

.panel-card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-card h2 {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.panel-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Search */
.input-row { display: flex; gap: 8px; }

input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-line);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 14px;
}

input[type="text"]::placeholder { color: var(--text-muted); }

input[type="text"]:focus,
button:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 1px;
}

button {
  background: var(--brand-red-dark);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, transform 0.1s;
}

button:hover { background: var(--brand-red); }
button:active { transform: scale(0.98); }

button.secondary {
  background: transparent;
  border: 1px solid var(--border-line);
  color: var(--text-secondary);
}

button.secondary:hover {
  background: var(--bg-panel-alt);
  color: var(--text-primary);
}

button:disabled {
  opacity: 0.5;
  cursor: progress;
}

.search-history {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.search-history li {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-line);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

.search-history li:hover { color: var(--accent-cyan); border-color: var(--accent-cyan); }

/* HUD card (current location) */
.hud-card { padding: 18px; }

.hud-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: var(--accent-cyan);
  opacity: 0.6;
}
.hud-corner.tl { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; }
.hud-corner.tr { top: -1px; right: -1px; border-top: 2px solid; border-right: 2px solid; }
.hud-corner.bl { bottom: -1px; left: -1px; border-bottom: 2px solid; border-left: 2px solid; }
.hud-corner.br { bottom: -1px; right: -1px; border-bottom: 2px solid; border-right: 2px solid; }

#coordinates {
  font-size: 19px;
  font-weight: 500;
  color: var(--accent-cyan);
  margin: 4px 0;
}

#address {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 14px 0;
  word-wrap: break-word;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-actions button { flex: 1; min-width: 88px; }

/* Env info */
.env-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.env-grid p { margin: 2px 0 0; font-size: 16px; color: var(--text-primary); }

.small { font-size: 12px; color: var(--text-secondary); margin: 0; }

/* IP info */
.ip-info h2 { color: var(--accent-amber); }
#ip-address, #ip-location {
  margin: 4px 0;
  font-size: 13px;
  word-wrap: break-word;
  color: var(--text-secondary);
}

/* Footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}
.sidebar-footer p { margin: 4px 0; }

/* Custom leaflet marker */
.hud-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand-red);
  border: 3px solid rgba(219, 48, 63, 0.35);
  box-shadow: 0 0 0 4px rgba(219, 48, 63, 0.15);
}

.leaflet-container {
  height: 100%;
  width: 100%;
  background: var(--bg-deep);
}

.leaflet-popup-content-wrapper {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-line);
  font-family: var(--font-mono);
  font-size: 12px;
}
.leaflet-popup-tip { background: var(--bg-panel); }

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3000;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border-line);
  border-left: 3px solid var(--accent-cyan);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  min-width: 220px;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: toast-in 0.2s ease-out;
}

.toast.error { border-left-color: var(--brand-red); }
.toast.success { border-left-color: #2dd4bf; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 4000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(5, 8, 11, 0.75);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-line);
  padding: 28px;
  width: 90%;
  max-width: 420px;
  border-radius: 12px;
  text-align: center;
  margin: 15vh auto 0;
}

.modal-icon .dot {
  display: inline-block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--brand-red);
  position: relative;
}
.modal-icon .dot::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  background: var(--brand-red);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.modal-content h2 { margin: 14px 0 8px; font-size: 18px; color: var(--text-primary); }
.modal-content p { margin: 0 0 20px; color: var(--text-secondary); font-size: 14px; }

.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions button { flex: 1; }

.noscript-banner {
  background: var(--brand-red-dark);
  color: #fff;
  text-align: center;
  padding: 10px;
  font-size: 14px;
}

/* Mobile */
@media (max-width: 768px) {
  .container { flex-direction: column; height: auto; min-height: calc(100% - 64px); }

  .sidebar {
    width: 100%;
    max-height: 55vh;
    order: 2;
    border-right: none;
    border-top: 1px solid var(--border-line);
  }

  #map { height: 45vh; order: 1; }

  .brand-tag { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot.live { animation: none; }
  .toast { animation: none; }
}
