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

:root {
  --navy: #0f2439;
  --navy-mid: #1a3a5c;
  --blue: #2d6aad;
  --blue-light: #e8f0fa;
  --gold: #d4930e;
  --gold-bg: #fdf3d7;
  --bg: #f0f4f8;
  --white: #ffffff;
  --text: #1a1a2e;
  --muted: #64748b;
  --border: #d1d9e6;
  --red: #dc3545;
  --green: #16a34a;
  --radius: 10px;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Header ---- */
header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  color: #fff;
  text-align: center;
  padding: 2rem 1rem 1.4rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  opacity: 0.75;
  font-size: 0.95rem;
  margin-top: 0.3rem;
}

/* ---- Fishmas banner ---- */
.fishmas-banner {
  background: var(--gold-bg);
  border-bottom: 3px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  text-align: center;
  font-size: 0.95rem;
}

.fishmas-icon { font-size: 1.6rem; }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  background: var(--navy);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 1;
  min-width: max-content;
  padding: 0.75rem 1.2rem;
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab:hover { color: #fff; background: rgba(255,255,255,0.06); }
.tab.active {
  color: #fff;
  border-bottom-color: var(--gold);
  background: rgba(255,255,255,0.08);
}

/* ---- Main content ---- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--navy);
}

h3 { margin-bottom: 0.5rem; color: var(--navy-mid); }

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Temperature cards */
.temp-card { text-align: center; }
.big-num {
  font-size: 3rem;
  font-weight: 700;
  color: var(--blue);
  line-height: 1.1;
}
.label { font-size: 0.85rem; color: var(--muted); }
.sub { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }

/* Stat cards */
.stat-card { text-align: center; }
.stat-num {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1.1;
}
.stat-label { font-weight: 600; margin-top: 0.2rem; }
.stat-total { font-size: 0.85rem; color: var(--muted); }

/* Snow report */
.snow-card { width: 100%; }
.snow-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
}
.snow-card dt { font-weight: 600; color: var(--navy-mid); }
.snow-card dd { color: var(--text); }

/* Webcam */
.webcam-card {
  margin-top: 1rem;
}
.webcam-card img {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  display: block;
}

/* ---- Crowley ---- */
.station-info {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.detail-card { width: 100%; }
.detail-card table { width: 100%; border-collapse: collapse; }
.detail-card td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
.detail-card td:first-child { font-weight: 600; color: var(--navy-mid); width: 45%; }
.last-updated { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }

/* ---- Forecasts ---- */
.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}
.forecast-col > h3 {
  text-align: center;
  margin-bottom: 0.75rem;
}
.forecast-list { display: flex; flex-direction: column; gap: 0.6rem; }
.fc-period {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}
.fc-period .fc-name { font-weight: 700; color: var(--navy); }
.fc-period .fc-temp {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blue);
}
.fc-period .fc-detail { font-size: 0.85rem; color: var(--muted); margin-top: 0.2rem; }

/* ---- Rating form ---- */
.rating-form-card { max-width: 500px; }
.note { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.star-select {
  display: flex;
  gap: 0.3rem;
  font-size: 2.2rem;
  margin-bottom: 0.8rem;
}
.star {
  cursor: pointer;
  color: var(--border);
  transition: color 0.15s;
  user-select: none;
}
.star.active { color: var(--gold); }
.star.hover-preview { color: var(--gold); opacity: 0.7; }

textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  resize: vertical;
  margin-bottom: 0.6rem;
}

.msg { margin-top: 0.5rem; font-size: 0.9rem; min-height: 1.4em; }
.msg.error { color: var(--red); font-weight: 600; }
.msg.success { color: var(--green); }

.ratings-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.rating-entry {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: baseline;
}
.rating-entry .re-stars { color: var(--gold); font-size: 1.1rem; letter-spacing: 1px; }
.rating-entry .re-comment { flex: 1; color: var(--text); }
.rating-entry .re-time { font-size: 0.75rem; color: var(--muted); }

/* ---- Demo section ---- */
.demo-card {
  margin-bottom: 1.2rem;
}
.demo-card p { font-size: 0.9rem; margin-bottom: 0.6rem; }
.demo-card code {
  background: var(--blue-light);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}

.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.input-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }

.input {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  flex: 1;
  min-width: 200px;
}

.result-box {
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 0.5rem;
  min-height: 2.5rem;
  max-height: 320px;
  overflow-y: auto;
}
.result-box.error-text { color: #f87171; }
.result-box.success-text { color: #4ade80; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1.1rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.btn:hover { background: #245d96; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b52d3a; }

.btn-outline {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--blue);
}
.btn-outline:hover { background: var(--blue-light); }

/* ---- Footer ---- */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  header h1 { font-size: 1.4rem; }
  .big-num { font-size: 2.2rem; }
  .stat-num { font-size: 2rem; }
  .forecast-grid { grid-template-columns: 1fr; }
  .tabs { gap: 0; }
  .tab { font-size: 0.78rem; padding: 0.6rem 0.6rem; }
}
