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

:root {
  --bg: linear-gradient(135deg, #f5f7fa 0%, #e8f4f8 100%);
  --color: #333;
  --card-bg: #fff;
  --card-shadow: rgba(0,0,0,0.07);
  --input-border: #d1e8dd;
  --hint: #888;
  --subtitle: #666;
  --analysis-text: #444;
  --restaurant-item-bg: #f9fafb;
  --restaurant-name: #111;
  --restaurant-addr: #888;
  --meal-breakfast: #fff7ed;
  --meal-lunch: #f0fdf4;
  --meal-dinner: #eff6ff;
  --meal-menu: #222;
  --meal-reason: #666;
  --btn-reset-border: #ccc;
  --btn-reset-color: #666;
  --btn-reset-hover: #333;
}

body.dark {
  --bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --color: #e0e0e0;
  --card-bg: #1e1e2e;
  --card-shadow: rgba(0,0,0,0.3);
  --input-border: #2d6a4f;
  --hint: #aaa;
  --subtitle: #aaa;
  --analysis-text: #ccc;
  --restaurant-item-bg: #2a2a3e;
  --restaurant-name: #f0f0f0;
  --restaurant-addr: #aaa;
  --meal-breakfast: #2a2010;
  --meal-lunch: #0f2a1a;
  --meal-dinner: #0f1a2a;
  --meal-menu: #f0f0f0;
  --meal-reason: #aaa;
  --btn-reset-border: #555;
  --btn-reset-color: #aaa;
  --btn-reset-hover: #eee;
}

body {
  font-family: 'Segoe UI', 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  padding: 24px 16px;
  color: var(--color);
  transition: background 0.3s, color 0.3s;
}

/* Dark mode toggle */
.theme-toggle {
  background: none;
  border: 1.5px solid var(--input-border);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color);
  transition: all 0.2s;
  white-space: nowrap;
}

.theme-toggle:hover {
  background: var(--restaurant-item-bg);
}

.container {
  max-width: 680px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 24px;
}

header h1 {
  font-size: 2rem;
  color: #2d6a4f;
  margin-bottom: 6px;
}

.subtitle {
  color: var(--subtitle);
  font-size: 0.95rem;
}

/* Card */
.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px var(--card-shadow);
  transition: background 0.3s;
}

.card h2 {
  font-size: 1.1rem;
  color: #2d6a4f;
  margin-bottom: 14px;
  font-weight: 700;
}

.hint {
  color: var(--hint);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

/* Meal input rows */
.meal-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.meal-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--input-border);
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  background: var(--card-bg);
  color: var(--color);
  transition: border-color 0.2s, background 0.3s, color 0.3s;
}

.meal-input:focus {
  border-color: #2d6a4f;
}

.btn-remove {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 8px;
  width: 36px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}

.btn-remove:hover {
  background: #fecaca;
}

.btn-add {
  background: none;
  border: 1.5px dashed #2d6a4f;
  color: #2d6a4f;
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
  margin-bottom: 16px;
  transition: background 0.2s;
}

.btn-add:hover {
  background: #f0faf5;
}

/* Location */
.location-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.location-status {
  font-size: 0.85rem;
  color: var(--subtitle);
  flex: 1;
  min-width: 120px;
}

.location-status.active {
  color: #2d6a4f;
  font-weight: 600;
}

.btn-location {
  background: #e8f5e9;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  color: #2d6a4f;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-location:hover {
  background: #c8e6c9;
}

.btn-submit {
  width: 100%;
  background: linear-gradient(135deg, #2d6a4f, #40916c);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-submit:hover {
  opacity: 0.9;
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: #555;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #d1e8dd;
  border-top-color: #2d6a4f;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 12px;
}

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

/* Weather */
.weather-card {
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
}

.weather-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.weather-icon {
  font-size: 3rem;
}

.weather-desc {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0369a1;
}

.weather-temp {
  font-size: 1.8rem;
  font-weight: 700;
  color: #0c4a6e;
}

/* Nutrition analysis */
.analysis-text {
  line-height: 1.7;
  color: var(--analysis-text);
  font-size: 0.95rem;
}

/* Meal cards */
.meal-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 500px) {
  .meal-cards {
    grid-template-columns: 1fr;
  }
}

.meal-card {
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.meal-card.breakfast { background: var(--meal-breakfast); }
.meal-card.lunch     { background: var(--meal-lunch); }
.meal-card.dinner    { background: var(--meal-dinner); }

.meal-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 8px;
}

.meal-menu {
  font-size: 1rem;
  font-weight: 700;
  color: var(--meal-menu);
  margin-bottom: 6px;
}

.meal-reason {
  font-size: 0.8rem;
  color: var(--meal-reason);
  line-height: 1.4;
}

/* Keyword badge */
.keyword-badge {
  background: #d1fae5;
  color: #065f46;
  font-size: 0.78rem;
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
  vertical-align: middle;
  margin-left: 6px;
}

/* Restaurant list */
.restaurant-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.restaurant-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--restaurant-item-bg);
  border-radius: 10px;
  gap: 10px;
  transition: background 0.3s;
}

.restaurant-info { flex: 1; }

.restaurant-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--restaurant-name);
  margin-bottom: 2px;
}

.restaurant-address {
  font-size: 0.8rem;
  color: var(--restaurant-addr);
}

.restaurant-distance {
  font-size: 0.8rem;
  color: var(--restaurant-addr);
  margin-top: 2px;
}

.restaurant-link {
  display: inline-block;
  background: #fee;
  color: #dc2626;
  text-decoration: none;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
  font-weight: 600;
  transition: background 0.2s;
}

.restaurant-link:hover {
  background: #fecaca;
}

/* Reset button */
.btn-reset {
  width: 100%;
  background: none;
  border: 1.5px solid var(--btn-reset-border);
  border-radius: 12px;
  padding: 12px;
  color: var(--btn-reset-color);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
  margin-top: 4px;
}

.btn-reset:hover {
  border-color: #888;
  color: var(--btn-reset-hover);
}

/* Error */
.error-box {
  background: #fee2e2;
  border: 1.5px solid #fca5a5;
  border-radius: 12px;
  padding: 16px 20px;
  color: #b91c1c;
  font-size: 0.9rem;
  margin-top: 12px;
}

.hidden { display: none !important; }

/* Navigation */
.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--input-border);
  flex-wrap: wrap;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: #2d6a4f;
  text-decoration: none;
  flex: 1;
}

.nav-links {
  display: flex;
  gap: 16px;
}

.nav-links a {
  font-size: 0.88rem;
  color: var(--subtitle);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #2d6a4f;
  font-weight: 600;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 32px 0 20px;
  margin-top: 8px;
  border-top: 1px solid var(--input-border);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 0.85rem;
  color: var(--subtitle);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: #2d6a4f;
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--hint);
}

/* Info section */
.info-section {
  margin-top: 8px;
}

.info-text {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--analysis-text);
  margin-bottom: 20px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.info-item {
  background: var(--restaurant-item-bg);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: background 0.3s;
}

.info-icon { font-size: 1.8rem; margin-bottom: 8px; }
.info-title { font-weight: 700; font-size: 0.9rem; color: #2d6a4f; margin-bottom: 6px; }
.info-desc { font-size: 0.82rem; color: var(--hint); line-height: 1.5; }

/* Weather guide */
.weather-guide {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.weather-guide-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--restaurant-item-bg);
  border-radius: 12px;
  padding: 14px 16px;
  transition: background 0.3s;
}

.wg-icon { font-size: 1.6rem; flex-shrink: 0; }
.wg-title { font-weight: 700; font-size: 0.92rem; color: var(--color); margin-bottom: 4px; }
.wg-desc { font-size: 0.85rem; color: var(--hint); line-height: 1.6; }

/* header — no longer needs position:relative since nav handles top area */
header {
  text-align: center;
  margin-bottom: 24px;
}
