@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Source+Code+Pro:wght@400;600&display=swap");

:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --bg-alt: #12131a;
  --card: #171924;
  --text: #f5f6fa;
  --muted: #a0a5b4;
  --accent: #4cc9f0;
  --accent-2: #f72585;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "Space Grotesk",
    system-ui,
    -apple-system,
    sans-serif;
  background:
    radial-gradient(
      circle at 20% 20%,
      rgba(76, 201, 240, 0.15),
      transparent 45%
    ),
    radial-gradient(
      circle at 80% 10%,
      rgba(247, 37, 133, 0.15),
      transparent 40%
    ),
    linear-gradient(120deg, #0a0b12 0%, #111320 50%, #0b0c10 100%);
  color: var(--text);
  min-height: 100vh;
}

h1 {
  margin: 0;
}

.bg-orbit {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(
    rgba(255, 255, 255, 0.05) 1px,
    transparent 1px
  );
  background-size: 32px 32px;
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 14px;
  font-weight: 500;
}

.nav a.ghost {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.card.narrow {
  max-width: 420px;
  margin: 10vh auto 0;
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.hero {
  grid-column: 1 / -1;
}

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.span-all {
  grid-column: 1 / -1;
}

.stats {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 18px;
}

.stat {
  background: var(--bg-alt);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border);
}

.label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.value {
  font-size: 1.6rem;
  font-weight: 600;
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f111a;
  color: var(--text);
  font-size: 1rem;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.2);
}

button {
  border: none;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

button.primary {
  background: #2f80ed;
  color: #f5f6fa;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.primary:hover {
  background: #3c8af2;
  transform: translateY(-1px);
}

.muted {
  color: var(--muted);
}

.flash {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(76, 201, 240, 0.12);
  border: 1px solid rgba(76, 201, 240, 0.35);
}

.flash.error {
  background: rgba(247, 37, 133, 0.12);
  border-color: rgba(247, 37, 133, 0.45);
}

.calendar {
  display: grid;
  gap: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 12, 0.75);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(520px, 92vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.calendar-nav {
  display: flex;
  gap: 10px;
}

.calendar-nav a {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.day-cell {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.day-link {
  text-decoration: none;
  color: inherit;
}

.day-cell.today {
  border-color: rgba(76, 201, 240, 0.6);
  box-shadow: 0 0 0 1px rgba(76, 201, 240, 0.4);
}

.day-cell.empty {
  background: transparent;
  border: none;
  box-shadow: none;
}

.day-number {
  font-weight: 600;
  font-size: 0.9rem;
}

.day-pill {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
}

.day-pill.zero {
  color: var(--muted);
}

.day-pill.level-low {
  color: #7ddf8b;
}

.day-pill.level-mid {
  color: #f6b04f;
}

.day-pill.level-high {
  color: #e88d3d;
}

.day-pill.level-max {
  color: #f07063;
}

.delete-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.delete-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #f07063;
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .card.narrow {
    margin-top: 6vh;
  }

  .card {
    padding: 18px;
  }

  .calendar-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-header {
    align-items: flex-start;
  }

  .calendar-grid {
    gap: 5px;
  }

  .day-cell {
    padding: 8px 4px;
    min-height: 42px;
    align-items: center;
    align-content: center;
  }

  .day-number {
    font-size: 0.8rem;
  }

  .day-pill {
    font-size: 0.68rem;
    max-width: 100%;
    white-space: normal;
  }
}
