:root {
  --bg: #1a1f1c;
  --bg-deep: #0f1311;
  --card: #242b26;
  --border: #3a4238;
  --text: #e8e6e0;
  --muted: #7a8580;
  --muted-2: #9ba39d;
  --accent: #d4a545;
  --accent-soft: rgba(212, 165, 69, 0.2);
  --good: #ffc107;
  --excellent: #4caf50;
  --fair: #ff9800;
  --poor: #e57373;
  --major: #9c7fdb;
  --minor: #4aa9d6;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.25);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-display: "Cormorant Garamond", serif;
  --font-body: "Manrope", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.background {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background: radial-gradient(circle at top left, rgba(32, 48, 40, 0.8), transparent 45%),
    radial-gradient(circle at 70% 20%, rgba(90, 72, 34, 0.35), transparent 40%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 80%);
}

.ambient {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 15% 20%, rgba(212, 165, 69, 0.08), transparent 45%),
    radial-gradient(circle at 80% 60%, rgba(74, 169, 214, 0.07), transparent 50%);
}

.haze {
  position: absolute;
  inset: -30% 0 0 0;
  background: linear-gradient(180deg, rgba(15, 19, 17, 0.65) 0%, rgba(15, 19, 17, 0) 70%);
}

.starfield {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.star {
  position: absolute;
  border-radius: 50%;
  opacity: 0.4;
  animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.25;
    transform: scale(0.9);
  }
  50% {
    opacity: 0.9;
    transform: scale(1);
  }
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px clamp(20px, 4vw, 48px);
  gap: 18px;
}

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

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}

.brand-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.appstore-button {
  text-decoration: none;
  color: #1b1b1b;
  background: var(--accent);
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 4;
  max-width: calc(100% - 32px);
  text-align: center;
}

.appstore-button:hover {
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.4);
}

.main {
  padding: 0 clamp(20px, 4vw, 48px) 140px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  align-items: center;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  margin: 0 0 12px;
}

.hero p {
  margin: 0;
  color: var(--muted-2);
  line-height: 1.6;
}

.hero-stats {
  display: grid;
  gap: 10px;
}

.stat {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 14px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.pill {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.pill:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.date-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  border-color: var(--accent);
}

.date-display {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
}

.ghost-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.date-picker {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.unit-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.unit-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toggle-button {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.toggle-button.active {
  background: var(--accent);
  color: #1b1b1b;
}

.control-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.meta-text {
  color: var(--muted);
  font-size: 13px;
}

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

.section-title {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  font-weight: 600;
}

.rating-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.rating-ring {
  position: relative;
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
}

.rating-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 12;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 490;
  stroke-dashoffset: 490;
  filter: url(#glow);
  transition: stroke-dashoffset 1.2s ease;
}

.rating-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.rating-value {
  font-size: 52px;
  font-weight: 700;
}

.rating-percent {
  font-size: 22px;
  color: var(--muted);
  margin-left: 4px;
}

.rating-label {
  font-size: 12px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.rating-markers {
  display: flex;
  gap: 10px;
}

.marker {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.feeding-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-track {
  position: relative;
  height: 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.timeline-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(90deg, transparent 0%, transparent 24.5%, rgba(255,255,255,0.08) 24.5%, rgba(255,255,255,0.08) 25%, transparent 25%, transparent 49.5%, rgba(255,255,255,0.08) 49.5%, rgba(255,255,255,0.08) 50%, transparent 50%, transparent 74.5%, rgba(255,255,255,0.08) 74.5%, rgba(255,255,255,0.08) 75%, transparent 75%, transparent 100%);
  pointer-events: none;
}

.timeline-segment {
  position: absolute;
  height: 100%;
  border-radius: 999px;
  opacity: 0.9;
}

.timeline-segment.major {
  background: var(--major);
}

.timeline-segment.minor {
  background: var(--minor);
}

.timeline-now {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 24px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(212, 165, 69, 0.7);
}

.timeline-markers {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.feeding-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.period-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
}

.period-indicator {
  width: 3px;
  height: 34px;
  border-radius: 999px;
}

.period-type {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.period-time {
  margin-left: auto;
  font-weight: 600;
}

.feeding-status {
  font-size: 13px;
  color: var(--muted-2);
  text-align: right;
}

.moon-card, .sun-card, .weather-card, .tactics-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.moon-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.moon-visual {
  display: grid;
  place-items: center;
  background: none;
  box-shadow: none;
}

.moon-emoji {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}

.moon-phase {
  font-size: 20px;
  font-weight: 600;
}

.moon-illumination {
  color: var(--muted);
  font-size: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.metric {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius-md);
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.metric-value {
  font-size: 18px;
  font-weight: 600;
  margin-top: 6px;
}

.sun-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sun-track {
  position: relative;
  height: 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.sun-segment {
  position: absolute;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(212,165,69,0.3), rgba(212,165,69,0.9), rgba(212,165,69,0.3));
}

.sun-length {
  text-align: center;
  color: var(--muted-2);
  font-size: 14px;
}

.weather-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weather-title {
  font-size: 18px;
  font-weight: 600;
}

.weather-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.tactics-meta {
  color: var(--muted);
  font-size: 12px;
}

.tactics-content {
  display: grid;
  gap: 12px;
}

.tactics-block {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius-md);
}

.tactics-block h4 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.tactics-block p {
  margin: 0;
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1.5;
}

.calendar-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calendar-section.hidden {
  display: none;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calendar-title {
  font-size: 18px;
  font-weight: 600;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-cell {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  border: 1px solid transparent;
}

.calendar-cell.empty {
  background: transparent;
  cursor: default;
}

.calendar-cell.today {
  border-color: #ffffff;
}

.calendar-cell.selected {
  border-color: var(--accent);
}

.calendar-cell.excellent { background: rgba(76, 175, 80, 0.6); }
.calendar-cell.good { background: rgba(255, 193, 7, 0.6); }
.calendar-cell.fair { background: rgba(255, 152, 0, 0.6); }
.calendar-cell.poor { background: rgba(229, 115, 115, 0.6); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--text);
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.3);
}

.legend-swatch.excellent { background: rgba(76, 175, 80, 0.6); }
.legend-swatch.good { background: rgba(255, 193, 7, 0.6); }
.legend-swatch.fair { background: rgba(255, 152, 0, 0.6); }
.legend-swatch.poor { background: rgba(229, 115, 115, 0.6); }

.about {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.about p {
  color: var(--muted-2);
  line-height: 1.6;
}

.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--muted-2);
  line-height: 1.6;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 11, 0.75);
  display: grid;
  place-items: center;
  z-index: 5;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(720px, 92vw);
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.modal-body {
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.search-input {
  flex: 1 1 240px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
}

.location-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.location-list {
  display: grid;
  gap: 10px;
}

.location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid transparent;
  cursor: pointer;
}

.location-item:hover {
  border-color: var(--accent);
}

.location-meta {
  color: var(--muted);
  font-size: 12px;
}

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

.delete-button {
  border: none;
  background: transparent;
  color: var(--poor);
  cursor: pointer;
  font-weight: 600;
}

.error {
  color: var(--poor);
  font-size: 13px;
}

.hidden {
  display: none;
}

@media (max-width: 840px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .rating-ring {
    width: 190px;
    height: 190px;
  }
}

@media (max-width: 600px) {
  .main {
    padding: 0 18px 60px;
  }

  .control-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .unit-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 4px;
  }
}
