:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --card: rgba(255, 251, 244, 0.82);
  --card-strong: #fffaf1;
  --text: #1f2321;
  --muted: #5a615e;
  --line: rgba(31, 35, 33, 0.08);
  --accent: #d4642a;
  --accent-strong: #b84f18;
  --accent-soft: rgba(212, 100, 42, 0.12);
  --success: #18805d;
  --shadow: 0 20px 60px rgba(60, 46, 20, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font-display: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
  --font-body: "SF Pro Display", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(231, 166, 118, 0.3), transparent 32%),
    radial-gradient(circle at right 20%, rgba(66, 126, 114, 0.18), transparent 26%),
    linear-gradient(180deg, #fbf6ed 0%, #f1ece2 100%);
}

body {
  min-height: 100vh;
}

.page-shell {
  width: min(1400px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
}

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

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 56px);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.hero-copy {
  max-width: 620px;
  margin: 14px 0 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--muted);
}

.status-card,
.control-panel,
.map-panel {
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 210px;
  padding: 18px 20px;
  border-radius: var(--radius-md);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #b6b6b6;
  box-shadow: 0 0 0 8px rgba(182, 182, 182, 0.15);
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 0 8px rgba(24, 128, 93, 0.14);
}

.status-label {
  font-size: 12px;
  color: var(--muted);
}

.status-value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
  gap: 20px;
}

.control-panel {
  padding: 24px;
  border-radius: var(--radius-lg);
}

.panel-title h2 {
  margin: 0;
  font-size: 20px;
}

.panel-title p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.form-grid label.full {
  grid-column: 1 / -1;
}

label span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1px solid rgba(31, 35, 33, 0.12);
  border-radius: 14px;
  background: var(--card-strong);
  padding: 13px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, transform 160ms ease;
}

input:focus {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #e98f45 100%);
  color: #fff7ef;
}

.secondary {
  background: #1f2321;
  color: #fff;
}

.ghost {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.info-card {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 250, 241, 0.86);
  border: 1px solid var(--line);
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding: 6px 0;
}

.info-row span:first-child {
  color: var(--muted);
}

.info-row code {
  font-size: 12px;
  color: var(--accent-strong);
}

.tips {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(24, 128, 93, 0.08);
  border: 1px solid rgba(24, 128, 93, 0.14);
}

.tips strong {
  display: block;
  margin-bottom: 6px;
}

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

.log-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

button.small {
  padding: 10px 14px;
  font-size: 13px;
}

.log-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
}

.log-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
}

.log-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.log-level {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}

.log-level.info {
  background: rgba(24, 128, 93, 0.12);
  color: var(--success);
}

.log-level.warn {
  background: rgba(212, 100, 42, 0.14);
  color: var(--accent-strong);
}

.log-level.error {
  background: rgba(179, 48, 48, 0.14);
  color: #a13030;
}

.log-message {
  font-size: 14px;
  line-height: 1.5;
}

.log-details {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 35, 33, 0.05);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.peer-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.peer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.56);
}

.peer-item-main {
  min-width: 0;
}

.peer-item strong,
.peer-item span {
  display: block;
}

.peer-item strong {
  font-size: 14px;
}

.peer-item span {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.peer-tag {
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(24, 128, 93, 0.12);
  color: var(--success);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.map-panel {
  position: relative;
  min-height: 72vh;
  border-radius: 34px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(212, 100, 42, 0.18), transparent 28%),
    linear-gradient(160deg, rgba(255, 246, 233, 0.92) 0%, rgba(238, 247, 244, 0.92) 100%);
}

#map {
  height: 100%;
  min-height: 72vh;
  background: transparent;
}

.map-overlay {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 500;
  max-width: min(360px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(31, 35, 33, 0.82);
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
}

.self-popup,
.peer-popup {
  font-family: var(--font-body);
}

@media (max-width: 980px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .status-card {
    min-width: 0;
  }

  .map-panel {
    order: -1;
    min-height: 58vh;
  }

  #map {
    min-height: 58vh;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 14px, 100%);
    padding-top: 10px;
  }

  .hero {
    gap: 14px;
    margin-bottom: 14px;
  }

  .control-panel {
    padding: 18px;
  }

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

  .button-row {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .log-header {
    align-items: stretch;
    flex-direction: column;
  }

  .map-panel,
  #map {
    min-height: 52vh;
  }
}
