/* ── Reset & base ──────────────────────────────────────────────────────────── */

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

/* ── Light theme ───────────────────────────────────────────────────────────── */

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-border: #dee2e6;
  --color-text: #212529;
  --color-muted: #6c757d;
  --color-primary: #0d6efd;
  --color-primary-hover: #0b5ed7;
  --color-success: #198754;
  --color-warning-bg: #fff3cd;
  --color-warning-border: #ffc107;
  --color-warning-text: #664d03;
  --color-error-bg: #f8d7da;
  --color-error-border: #f5c2c7;
  --color-error-text: #842029;
  --color-info-bg: #d1ecf1;
  --color-info-border: #bee5eb;
  --color-info-text: #0c5460;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* ── Dark theme ────────────────────────────────────────────────────────────── */

[data-theme="dark"] {
  --color-bg: #0f1117;
  --color-surface: #1a1d27;
  --color-border: #2e3245;
  --color-text: #e8eaf0;
  --color-muted: #8b90a7;
  --color-primary: #4d8ef8;
  --color-primary-hover: #3a7de0;
  --color-success: #2ea86b;
  --color-warning-bg: #2a2000;
  --color-warning-border: #7a5c00;
  --color-warning-text: #ffd86e;
  --color-error-bg: #2a0a0a;
  --color-error-border: #7a2020;
  --color-error-text: #f28b8b;
  --color-info-bg: #0a1e2a;
  --color-info-border: #1a4a6a;
  --color-info-text: #7ecff5;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
}

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

/* ── Layout ────────────────────────────────────────────────────────────────── */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── Header ────────────────────────────────────────────────────────────────── */

header {
  padding: 2.5rem 0 1.5rem;
  text-align: center;
  position: relative;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

header h1 span {
  color: var(--color-primary);
}

header p {
  margin-top: 0.4rem;
  color: var(--color-muted);
  font-size: 0.95rem;
}

/* ── Theme toggle ──────────────────────────────────────────────────────────── */

#theme-toggle {
  position: absolute;
  top: 2.5rem;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

#theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-muted);
}

/* ── Input section ─────────────────────────────────────────────────────────── */

.input-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

#location-input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg);
  outline: none;
  transition: border-color 0.15s, background 0.2s, color 0.2s;
}

#location-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(77, 142, 248, 0.15);
}

#location-input::placeholder {
  color: var(--color-muted);
}

.btn-primary {
  padding: 0.625rem 1.25rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

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

#input-type-label {
  display: none;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */

#spinner {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.spinner-ring {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Notice ────────────────────────────────────────────────────────────────── */

.notice {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.notice--warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning-text);
}

.notice--error {
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
  color: var(--color-error-text);
}

.notice--info {
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
  color: var(--color-info-text);
}

/* ── Results section ───────────────────────────────────────────────────────── */

#results {
  display: none;
  margin-top: 1.5rem;
}

/* ── Platform cards ────────────────────────────────────────────────────────── */

.platform-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.platform-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.platform-card__header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.platform-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.card-link {
  font-size: 0.75rem;
  color: var(--color-muted);
  word-break: break-all;
  min-height: 2.2em;
}

.platform-card__actions {
  display: flex;
  gap: 0.4rem;
  margin-top: auto;
}

.btn-copy,
.btn-open {
  flex: 1;
  padding: 0.375rem 0.5rem;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border: 1px solid var(--color-border);
}

.btn-copy {
  background: var(--color-bg);
  color: var(--color-text);
}

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

.btn-copy.copied {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}

.btn-open {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

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

/* ── Map preview ───────────────────────────────────────────────────────────── */

#map-preview {
  display: none;
  height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

/* ── Place card ────────────────────────────────────────────────────────────── */

#place-card {
  display: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.place-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.2rem;
}

.place-address {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.6rem;
}

.place-summary {
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.55;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */

footer {
  text-align: center;
  padding: 2rem 0;
  font-size: 0.8rem;
  color: var(--color-muted);
}

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

footer a:hover {
  color: var(--color-text);
}

footer .footer-link {
  color: var(--color-primary);
  text-decoration: underline;
}

footer .footer-link:hover {
  color: var(--color-primary-hover);
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */

@media (max-width: 540px) {
  header h1 {
    font-size: 1.4rem;
  }

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

  .btn-primary {
    width: 100%;
  }

  .platform-cards {
    grid-template-columns: 1fr;
  }

  #map-preview {
    height: 220px;
  }
}
