* {
  box-sizing: border-box;
}

:root {
  --bg: #020617;
  --panel: #07111f;
  --panel-soft: #0f1b2e;
  --panel-glass: rgba(15, 27, 46, 0.82);

  --text: #ffffff;
  --muted: #c9d4e5;

  --focus-bg: #7dd3fc;
  --focus-text: #03111f;

  --today: #facc15;
  --today-glow: rgba(250, 204, 21, 0.9);

  --work: #60a5fa;
  --personal: #34d399;
  --important: #fb923c;
  --urgent: #fb7185;

  --border: rgba(255, 255, 255, 0.42);
  --soft-border: rgba(255, 255, 255, 0.18);
  --shadow: rgba(0, 0, 0, 0.52);
}

html,
body {
  margin: 0;
  padding: 0;
  width: 600px;
  height: 600px;
  max-width: 600px;
  max-height: 600px;
  overflow: hidden;
  background: var(--bg);
  overscroll-behavior: none;
}

body {
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.screen {
  width: 600px;
  height: 600px;
  max-width: 600px;
  max-height: 600px;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 6%, rgba(125, 211, 252, 0.38), transparent 24%),
    radial-gradient(circle at 88% 0%, rgba(52, 211, 153, 0.18), transparent 25%),
    radial-gradient(circle at 92% 92%, rgba(250, 204, 21, 0.22), transparent 30%),
    linear-gradient(145deg, #020617 0%, #07111f 46%, #0b1020 100%);
}

.app-screen {
  display: none;
  width: 600px;
  height: 600px;
  max-width: 600px;
  max-height: 600px;
  padding: 10px 14px 10px;
  overflow: hidden;
}

.app-screen.active {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* ---------- Header ---------- */

.top {
  text-align: center;
  flex: 0 0 auto;
  padding: 4px 8px 5px;
  border: 1px solid var(--soft-border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 27, 46, 0.82), rgba(7, 17, 31, 0.62));
  box-shadow: 0 8px 22px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  font-weight: 850;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 1px;
  font-size: 27px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.8px;
  text-shadow: 0 0 14px rgba(125, 211, 252, 0.28);
}

#rangeLabel,
.muted {
  margin: 0;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  font-weight: 800;
}

/* ---------- Top Buttons ---------- */

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  gap: 7px;
  flex: 0 0 auto;
  padding: 4px;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.42);
  border: 1px solid var(--soft-border);
}

button {
  border: 2px solid var(--border);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(15, 27, 46, 0.96), rgba(7, 17, 31, 0.96));
  color: var(--text);
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  -webkit-tap-highlight-color: transparent;
}

.nav-btn {
  height: 32px;
  font-size: 20px;
}

/* ---------- Weekdays ---------- */

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  text-align: center;
  font-weight: 850;
  flex: 0 0 auto;
}

/* ---------- Calendar Grid ---------- */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(5, 45px);
  gap: 5px;
  height: 245px;
  flex: 0 0 245px;
  padding: 6px;
  border: 1px solid var(--soft-border);
  border-radius: 20px;
  background: rgba(2, 6, 23, 0.42);
  box-shadow: 0 10px 24px var(--shadow), inset 0 0 18px rgba(125, 211, 252, 0.05);
}

.day {
  position: relative;
  width: 100%;
  height: 45px;
  min-height: 45px;

  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 13px;

  background:
    linear-gradient(180deg, rgba(15, 27, 46, 0.98), rgba(7, 17, 31, 0.98));
  color: var(--text);

  font-size: 21px;
  line-height: 1;
  font-weight: 950;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    0 3px 8px rgba(0, 0, 0, 0.28);

  transition:
    transform 100ms ease,
    box-shadow 100ms ease,
    background 100ms ease,
    border-color 100ms ease;
}

.day.outside {
  opacity: 0.16;
  filter: grayscale(0.8);
}

.day.today {
  color: var(--today);
  border-color: var(--today);
  background:
    linear-gradient(180deg, rgba(90, 70, 8, 0.65), rgba(7, 17, 31, 0.96));
  box-shadow:
    0 0 12px var(--today-glow),
    inset 0 0 10px rgba(250, 204, 21, 0.16);
}

.day.has-event::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 20px;
  height: 4px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: var(--personal);
  box-shadow: 0 0 10px var(--personal);
}

.day.event-work::after {
  background: var(--work);
  box-shadow: 0 0 8px var(--work);
}

.day.event-personal::after {
  background: var(--personal);
  box-shadow: 0 0 8px var(--personal);
}

.day.event-important::after {
  background: var(--important);
  box-shadow: 0 0 8px var(--important);
}

.day.event-urgent::after {
  background: var(--urgent);
  box-shadow: 0 0 8px var(--urgent);
}

/* ---------- Focus / Selection ---------- */

.day.selected,
button.selected,
button:focus,
.day:focus {
  outline: none;
  transform: scale(1.04);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.58), transparent 40%),
    linear-gradient(180deg, #7dd3fc, #38bdf8);
  color: var(--focus-text);
  border-color: #ffffff;
  box-shadow:
    0 0 16px rgba(125, 211, 252, 0.98),
    0 0 32px rgba(56, 189, 248, 0.55),
    inset 0 0 10px rgba(255, 255, 255, 0.42);
}

.day.selected.today {
  color: #000000;
}

/* ---------- Details Panel ---------- */

.details {
  flex: 0 0 102px;
  height: 102px;

  background:
    linear-gradient(180deg, rgba(15, 27, 46, 0.92), rgba(7, 17, 31, 0.96));
  border: 1px solid var(--soft-border);
  border-radius: 20px;

  padding: 8px 10px;

  box-shadow:
    0 10px 24px var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 14px rgba(125, 211, 252, 0.04);
}

#selectedDateLabel {
  margin: 0;
  font-size: 20px;
  line-height: 1;
  font-weight: 950;
  color: #f8fbff;
  text-shadow: 0 0 10px rgba(125, 211, 252, 0.2);
}

#eventLabel {
  margin: 3px 0 7px;
  min-height: 18px;

  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  font-weight: 800;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-btn {
  height: 32px;
  font-size: 17px;
}

/* ---------- Add Event Screen ---------- */

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.preset-btn {
  height: 50px;
  font-size: 21px;
  text-align: left;
  padding: 0 20px;
  background: linear-gradient(90deg, rgba(15, 27, 46, 0.96), rgba(7, 17, 31, 0.96));
}

/* ---------- Planner polish + slight animation ---------- */

.app-screen.active {
  animation: screenFadeIn 220ms ease-out;
}

.top,
.toolbar,
.calendar-grid,
.details {
  animation: softRise 260ms ease-out;
}

.day {
  animation: dayAppear 180ms ease-out both;
}

.day:nth-child(7n + 1) {
  animation-delay: 8ms;
}

.day:nth-child(7n + 2) {
  animation-delay: 16ms;
}

.day:nth-child(7n + 3) {
  animation-delay: 24ms;
}

.day:nth-child(7n + 4) {
  animation-delay: 32ms;
}

.day:nth-child(7n + 5) {
  animation-delay: 40ms;
}

.day:nth-child(7n + 6) {
  animation-delay: 48ms;
}

.day:nth-child(7n + 7) {
  animation-delay: 56ms;
}

.day.selected,
button.selected {
  animation: selectedBreath 1.45s ease-in-out infinite;
}

.day.has-event::after {
  animation: eventGlow 1.8s ease-in-out infinite;
}

.details {
  position: relative;
}

.details::before {
  content: "Daily Plan";
  position: absolute;
  top: -9px;
  left: 16px;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(125, 211, 252, 0.95), rgba(52, 211, 153, 0.88));
  color: #03111f;
  font-size: 10px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 0 14px rgba(125, 211, 252, 0.35);
}

#eventLabel::before {
  content: "• ";
  color: var(--personal);
  font-weight: 950;
}

.planner-summary {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planner-flash {
  animation: plannerFlash 260ms ease-out;
}

.actions {
  position: relative;
}

.action-btn:first-child {
  border-color: rgba(52, 211, 153, 0.62);
}

.action-btn:last-child {
  border-color: rgba(251, 113, 133, 0.62);
}

.action-btn:first-child.selected,
.action-btn:first-child:focus {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.45), transparent 38%),
    linear-gradient(180deg, #34d399, #10b981);
  color: #04130d;
}

.action-btn:last-child.selected,
.action-btn:last-child:focus {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.45), transparent 38%),
    linear-gradient(180deg, #fb7185, #f43f5e);
  color: #1a0508;
}

.preset-list {
  padding: 6px;
  border-radius: 22px;
  border: 1px solid var(--soft-border);
  background: rgba(2, 6, 23, 0.42);
  box-shadow: 0 10px 24px var(--shadow);
}

.preset-btn::before {
  content: "+";
  margin-right: 10px;
  color: var(--personal);
}

.preset-btn:last-child::before {
  content: "x";
  color: var(--urgent);
}

.preset-btn.selected {
  transform: scale(1.025);
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: scale(0.985);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes softRise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dayAppear {
  from {
    opacity: 0;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes selectedBreath {
  0%, 100% {
    box-shadow:
      0 0 16px rgba(125, 211, 252, 0.98),
      0 0 32px rgba(56, 189, 248, 0.55),
      inset 0 0 10px rgba(255, 255, 255, 0.42);
  }

  50% {
    box-shadow:
      0 0 20px rgba(125, 211, 252, 1),
      0 0 42px rgba(56, 189, 248, 0.7),
      inset 0 0 12px rgba(255, 255, 255, 0.5);
  }
}

@keyframes eventGlow {
  0%, 100% {
    opacity: 0.72;
    transform: translateX(-50%) scaleX(0.82);
  }

  50% {
    opacity: 1;
    transform: translateX(-50%) scaleX(1);
  }
}

@keyframes plannerFlash {
  from {
    transform: scale(0.985);
    box-shadow:
      0 0 20px rgba(125, 211, 252, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }

  to {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-screen.active,
  .top,
  .toolbar,
  .calendar-grid,
  .details,
  .day,
  .day.selected,
  button.selected,
  .day.has-event::after,
  .planner-flash {
    animation: none;
    transition: none;
  }
}
