:root,
[data-theme="light"] {
  color-scheme: light;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --code-bg: #f1f5f9;
  --badge-bg: #e2e8f0;
  --badge-text: #334155;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --map-filter: none;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-color: #0b0f19;
  --card-bg: #111827;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border-color: #1f2937;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;
  --code-bg: #1e293b;
  --badge-bg: #1f2937;
  --badge-text: #e5e7eb;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --map-filter: invert(90%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-color: #0b0f19;
    --card-bg: #111827;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: #1f2937;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e293b;
    --code-bg: #1e293b;
    --badge-bg: #1f2937;
    --badge-text: #e5e7eb;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --map-filter: invert(90%) hue-rotate(180deg) brightness(95%) contrast(90%);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

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

.brand-icon {
  font-size: 2rem;
  line-height: 1;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--card-bg);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--code-bg);
}

.btn-icon {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  font-size: 1.1rem;
  padding: 8px 12px;
  border-radius: 8px;
}

.btn-icon:hover {
  background-color: var(--code-bg);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* Hero Section */
.hero-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.hero-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.hero-ip-wrapper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.hero-ip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--primary);
  word-break: break-all;
}

.btn-copy {
  font-size: 0.9rem;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  background-color: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--border-color);
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .hero-ip {
    font-size: 1.6rem;
  }
}

/* Cards */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.card-icon {
  font-size: 1.25rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

/* Data Rows */
.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  gap: 12px;
}

.data-row.data-col {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.data-label {
  color: var(--text-muted);
  font-weight: 500;
}

.data-value {
  color: var(--text-main);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

.code-font {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
}

.text-break {
  word-break: break-all;
  text-align: left;
}

/* Map */
.card-map {
  min-height: 280px;
}

.map-body {
  padding: 0;
  height: 100%;
}

.map-container {
  width: 100%;
  height: 220px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-color);
  background-color: var(--code-bg);
}

.map-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: none;
  filter: var(--map-filter);
  transition: filter 0.2s ease;
}

.map-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.875rem;
  background-color: var(--code-bg);
}

/* CLI Card */
.cli-card {
  margin-bottom: 24px;
}

.cli-intro {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.cli-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cli-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
}

@media (max-width: 640px) {
  .cli-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .cli-code-wrap {
    width: 100%;
    justify-content: space-between;
  }
}

.cli-desc {
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
}

.cli-code-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cli-code-wrap code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--primary);
  user-select: all;
}

.btn-copy-code {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-copy-code:hover {
  background: var(--badge-bg);
}

/* JSON Card */
.json-card {
  margin-bottom: 24px;
}

.json-viewer {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  max-height: 360px;
  line-height: 1.45;
  color: var(--text-main);
}

/* Footer */
.footer {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.footer a {
  color: var(--primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #10b981;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.spin {
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}
