:root {
  --background: 35 100% 96%;
  --foreground: 223 34% 30%;
  --primary: 342 73% 78%;
  --secondary: 198 66% 84%;
  --muted: 34 58% 91%;
  --destructive: 8 72% 74%;
  --border: 22 42% 82%;
  --card: 0 0% 100% / 0.7;

  --shadow-sm: 0 6px 18px hsl(342 43% 76% / 0.15);
  --shadow-md: 0 14px 30px hsl(210 38% 55% / 0.18);
  --shadow-lg: 0 24px 60px hsl(342 43% 76% / 0.22);

  --transition-fast: 180ms ease;
  --transition-smooth: 320ms cubic-bezier(0.22, 1, 0.36, 1);

  --radius-sm: 14px;
  --radius-md: 22px;
  --radius-lg: 32px;
}

.dark {
  --background: 242 49% 16%;
  --foreground: 34 82% 93%;
  --primary: 332 61% 72%;
  --secondary: 213 62% 68%;
  --muted: 246 28% 24%;
  --destructive: 4 72% 68%;
  --border: 247 20% 35%;
  --card: 246 28% 20% / 0.78;

  --shadow-sm: 0 8px 18px hsl(242 60% 6% / 0.25);
  --shadow-md: 0 16px 34px hsl(242 60% 6% / 0.35);
  --shadow-lg: 0 24px 70px hsl(242 60% 6% / 0.4);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at top left, hsl(342 100% 91%) 0%, transparent 28%),
    radial-gradient(circle at top right, hsl(198 100% 92%) 0%, transparent 30%),
    linear-gradient(180deg, hsl(var(--background)), hsl(var(--muted) 65%, hsl(var(--background)));
  color: hsl(var(--foreground));
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition-smooth), color var(--transition-smooth);
}

/* Subtle grain for cozy lofi vibe */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 22%, hsl(var(--foreground) / 0.06) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 66%, hsl(var(--foreground) / 0.05) 0 1px, transparent 2px),
    radial-gradient(circle at 42% 78%, hsl(var(--foreground) / 0.045) 0 1px, transparent 2px),
    radial-gradient(circle at 64% 30%, hsl(var(--foreground) / 0.04) 0 1px, transparent 2px);
  background-size: 140px 140px;
  opacity: 0.18;
  mix-blend-mode: soft-light;
}

/* Environment modes (data-env on <html>) */
html[data-env='day'] body {
  background:
    radial-gradient(circle at top left, hsl(342 100% 91%) 0%, transparent 28%),
    radial-gradient(circle at top right, hsl(198 100% 92%) 0%, transparent 30%),
    linear-gradient(180deg, hsl(var(--background)), hsl(var(--muted)) 65%, hsl(var(--background)));
}

html[data-env='night'] body {
  background:
    radial-gradient(circle at 20% 10%, hsl(265 65% 30% / 0.65), transparent 48%),
    radial-gradient(circle at 70% 20%, hsl(215 70% 36% / 0.55), transparent 50%),
    linear-gradient(180deg, hsl(242 52% 14%), hsl(242 46% 18%) 55%, hsl(250 44% 16%));
}

html[data-env='rain'] body {
  background:
    radial-gradient(circle at 18% 14%, hsl(205 60% 66% / 0.34), transparent 52%),
    radial-gradient(circle at 82% 20%, hsl(265 50% 70% / 0.26), transparent 54%),
    linear-gradient(180deg, hsl(220 32% 90%), hsl(220 28% 88%) 55%, hsl(225 30% 92%));
}

html[data-env='cafe'] body {
  background:
    radial-gradient(circle at 20% 18%, hsl(30 95% 86% / 0.9), transparent 44%),
    radial-gradient(circle at 78% 18%, hsl(12 90% 86% / 0.6), transparent 52%),
    linear-gradient(180deg, hsl(32 90% 94%), hsl(34 76% 92%) 55%, hsl(30 86% 95%));
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
}

#root {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  position: relative;
}

.app-content {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 28px;
}

.card-shell {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px;
  margin-bottom: 18px;
}

.topbar-left {
  display: flex;
  flex-direction: column;
}

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

.name-input {
  background: hsl(var(--muted) / 0.5);
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.85rem;
  width: 120px;
  color: hsl(var(--foreground));
  outline: none;
  transition: all var(--transition-fast);
}

.name-input:focus {
  width: 160px;
  background: hsl(var(--background));
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.2);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.82rem;
  opacity: 0.72;
}

.app-title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: hsl(var(--muted) / 0.55);
  border: 1px solid hsl(var(--border));
}

.mode-btn {
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: hsl(var(--foreground));
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.mode-btn:hover {
  transform: translateY(-1px);
}

.mode-btn.active {
  background: hsl(var(--secondary) / 0.6);
  box-shadow: var(--shadow-sm);
}

.soft-btn,
.primary-btn,
.secondary-btn,
.ghost-btn,
.delete-btn,
.check-btn {
  border-radius: 999px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.soft-btn,
.secondary-btn,
.ghost-btn {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  padding: 10px 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.soft-btn.active {
  background: hsl(var(--secondary) / 0.6);
  box-shadow: var(--shadow-sm);
}

.primary-btn {
  background: hsl(var(--primary));
  color: hsl(var(--foreground));
  padding: 12px 18px;
  box-shadow: var(--shadow-sm);
}

.secondary-btn {
  background: hsl(var(--secondary));
  padding: 12px 18px;
}

.ghost-btn {
  border: 1px solid hsl(var(--border));
  padding: 12px 18px;
}

.soft-btn:hover,
.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.delete-btn:hover,
.check-btn:hover {
  transform: translateY(-1px);
}

.timer-section {
  width: min(100%, 720px);
  margin: 0 auto 18px;
  padding: 24px 18px;
  text-align: center;
}

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

.timer-mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: hsl(var(--secondary) / 0.55);
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.timer-circle-wrap {
  display: grid;
  place-items: center;
  margin: 12px 0 10px;
}

.timer-progress {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 10px;
  box-shadow: var(--shadow-lg);
  animation: pulseGlow 4s ease-in-out infinite;
}

.timer-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(180deg, hsl(var(--card)), hsl(var(--muted) / 0.9));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid hsl(var(--border));
}

.timer-text {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.timer-caption {
  font-size: 0.95rem;
  opacity: 0.75;
}

.progress-meta {
  width: min(100%, 420px);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.92rem;
  margin: 8px 0 8px;
}

.progress-wrap {
  width: min(100%, 420px);
  position: relative;
}

.progress-track {
  width: min(100%, 420px);
  height: 12px;
  background: hsl(var(--secondary) / 0.35);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
}

.progress-wrap .progress-track {
  width: 100%;
}

.progress-track.small {
  width: 100%;
  height: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, hsl(var(--primary)), hsl(var(--secondary)));
  border-radius: 999px;
  transition: width var(--transition-smooth);
}

.progress-cat {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  filter: drop-shadow(0 14px 26px hsl(var(--foreground) / 0.14));
  transition: left var(--transition-smooth);
  z-index: 2;
  cursor: pointer;
}

.progress-cat:hover {
  transform: translate(-50%, -55%) scale(1.05);
}

.progress-cat:active {
  transform: translate(-50%, -45%) scale(0.95);
}

/* small contact shadow so the cat feels grounded on the bar */
.progress-cat::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 62%;
  width: 58px;
  height: 12px;
  transform: translateX(-50%);
  background: radial-gradient(circle, hsl(var(--foreground) / 0.18), transparent 70%);
  filter: blur(0.5px);
  opacity: 0.7;
}

.progress-cat .cat {
  width: 64px;
  height: 48px;
}

.timer-inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin: 18px 0;
}

.timer-inputs label,
.goal-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer-inputs label {
  justify-content: space-between;
  background: hsl(var(--muted) / 0.7);
  padding: 12px 14px;
  border-radius: var(--radius-md);
}

.timer-inputs input,
.goal-row input,
.task-form input,
.chat-form input {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.8);
  color: hsl(var(--foreground));
  border-radius: 999px;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.timer-inputs input:focus,
.goal-row input:focus,
.task-form input:focus,
.chat-form input:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 4px hsl(var(--primary) / 0.2);
}

.timer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: hsl(var(--background) / 0.45);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  padding: 16px;
}

.stat-label {
  font-size: 0.82rem;
  opacity: 0.72;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-hint,
.goal-progress {
  margin-top: 8px;
  opacity: 0.8;
  font-size: 0.94rem;
}

.quote-text {
  font-size: 1.02rem;
  line-height: 1.5;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.side-card {
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.section-head span {
  opacity: 0.72;
  font-size: 0.9rem;
}

.stats-page {
  padding: 16px;
  margin-bottom: 18px;
}

.stat-grid-compact {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

a.nav-btn {
  white-space: nowrap;
}

.task-form,
.chat-form {
  display: flex;
  gap: 10px;
}

.task-form input,
.chat-form input {
  flex: 1;
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  gap: 10px;
}

.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: hsl(var(--background) / 0.5);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  padding: 10px;
}

.task-item.done .task-text {
  text-decoration: line-through;
  opacity: 0.6;
}

.check-btn {
  width: 32px;
  height: 32px;
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  font-weight: 700;
}

.delete-btn {
  background: hsl(var(--destructive) / 0.65);
  color: hsl(var(--foreground));
  padding: 8px 12px;
}

.empty-state {
  padding: 18px;
  border-radius: var(--radius-md);
  background: hsl(var(--muted) / 0.7);
  border: 1px dashed hsl(var(--border));
  opacity: 0.85;
}

.assistant-card {
  display: flex;
  flex-direction: column;
}

.assistant-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.assistant-avatar-mini {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: hsl(var(--primary));
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: var(--shadow-sm);
}

.coach-avatar {
  background: hsl(var(--secondary));
  font-size: 1.2rem;
}

.chat-box {
  min-height: 320px;
  max-height: 420px;
  overflow: auto;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
  background: hsl(var(--muted) / 0.2);
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--border) / 0.5);
}

.coach-chat {
  background: hsl(var(--background) / 0.3);
}

.chat-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-row.user {
  justify-content: flex-end;
}

.chat-row.assistant {
  justify-content: flex-start;
}

.assistant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: hsl(var(--primary));
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  margin-bottom: 4px;
}

.chat-bubble {
  max-width: 84%;
  border-radius: 24px;
  padding: 12px 16px;
  background: hsl(var(--background) / 0.7);
  border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-sm);
  position: relative;
}

.coach-bubble {
  border-radius: 28px;
}

.chat-row.user .chat-bubble {
  background: hsl(var(--primary) / 0.35);
  border-bottom-right-radius: 4px;
}

.chat-row.assistant .chat-bubble {
  background: hsl(var(--secondary) / 0.35);
  border-bottom-left-radius: 4px;
}

.chat-role {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.6;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-text {
  line-height: 1.5;
  font-size: 0.95rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px;
  background: hsl(var(--muted) / 0.4);
  border-radius: var(--radius-md);
}

.action-btn {
  flex: 1;
  min-width: 100px;
  background: hsl(var(--background) / 0.8);
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.action-btn:hover {
  background: hsl(var(--primary) / 0.2);
  transform: translateY(-1px);
}

.action-btn.active {
  background: hsl(var(--secondary) / 0.4);
  border-color: hsl(var(--secondary));
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.suggestion-btn {
  background: hsl(var(--muted) / 0.8);
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.suggestion-btn:hover:not(:disabled) {
  background: hsl(var(--secondary) / 0.4);
  transform: translateY(-1px);
}

.clear-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.typing-status {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-bottom: 4px;
  font-style: italic;
}

.typing-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 16px;
  padding: 4px 0;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: hsl(var(--foreground) / 0.55);
  animation: bounce 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.sky-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 15%, hsl(var(--primary) / 0.25), transparent 18%),
    radial-gradient(circle at 80% 20%, hsl(var(--secondary) / 0.28), transparent 20%),
    radial-gradient(circle at 50% 70%, hsl(var(--muted) / 0.45), transparent 30%);
  opacity: 1;
  transition: opacity var(--transition-smooth), filter var(--transition-smooth);
  animation: glowDrift 12s ease-in-out infinite;
}

.stars {
  position: absolute;
  inset: -10% -10% 0 -10%;
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.stars::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 10% 20%, hsl(45 95% 88% / 0.9) 0 1px, transparent 2px),
    radial-gradient(circle at 25% 12%, hsl(45 95% 88% / 0.85) 0 1px, transparent 2px),
    radial-gradient(circle at 38% 24%, hsl(45 95% 88% / 0.75) 0 1px, transparent 2px),
    radial-gradient(circle at 60% 18%, hsl(45 95% 88% / 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 10%, hsl(45 95% 88% / 0.7) 0 1px, transparent 2px),
    radial-gradient(circle at 84% 22%, hsl(45 95% 88% / 0.75) 0 1px, transparent 2px),
    radial-gradient(circle at 16% 40%, hsl(45 95% 88% / 0.7) 0 1px, transparent 2px),
    radial-gradient(circle at 44% 48%, hsl(45 95% 88% / 0.62) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 42%, hsl(45 95% 88% / 0.66) 0 1px, transparent 2px),
    radial-gradient(circle at 90% 38%, hsl(45 95% 88% / 0.68) 0 1px, transparent 2px);
  opacity: 0.9;
  filter: drop-shadow(0 0 8px hsl(45 95% 88% / 0.25));
  animation: twinkle 3.8s ease-in-out infinite;
}

.cloud {
  position: absolute;
  background: hsl(var(--background) / 0.75);
  border-radius: 999px;
  filter: blur(1px);
  transition: opacity var(--transition-smooth), transform var(--transition-smooth);
}

.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: inherit;
}

.cloud-one {
  width: 100px;
  height: 36px;
  top: 80px;
  left: -20px;
  animation: drift 26s linear infinite;
}

.cloud-one::before {
  width: 42px;
  height: 42px;
  left: 14px;
  top: -14px;
}

.cloud-one::after {
  width: 54px;
  height: 54px;
  right: 12px;
  top: -22px;
}

.cloud-two {
  width: 138px;
  height: 44px;
  top: 140px;
  left: -40px;
  opacity: 0.8;
  animation: drift 34s linear infinite;
  animation-delay: -7s;
}

.cloud-two::before {
  width: 52px;
  height: 52px;
  left: 18px;
  top: -18px;
}

.cloud-two::after {
  width: 62px;
  height: 62px;
  right: 18px;
  top: -24px;
}

.rain-overlay {
  position: absolute;
  inset: -40% -30% 0 -30%;
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.rain-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      115deg,
      transparent 0,
      transparent 10px,
      hsl(210 65% 92% / 0.22) 11px,
      transparent 12px
    );
  animation: rainSlide 0.75s linear infinite;
}

html[data-rain='on'] .rain-overlay {
  opacity: 0.9;
}

.window-frame {
  position: absolute;
  top: 84px;
  right: 5vw;
  width: 170px;
  height: 220px;
  border-radius: 28px;
  border: 10px solid hsl(var(--muted) / 0.92);
  background: linear-gradient(180deg, hsl(var(--secondary) / 0.65), hsl(var(--background) / 0.95));
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: background var(--transition-smooth), border-color var(--transition-smooth);
}

/* window glass reflection for a slightly more "real" feel */
.window-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, hsl(var(--background) / 0.55), transparent 42%),
    radial-gradient(circle at 70% 22%, hsl(var(--background) / 0.35), transparent 58%);
  opacity: 0.6;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.window-pane {
  position: absolute;
  top: 0;
  left: 50%;
  width: 8px;
  height: 100%;
  transform: translateX(-50%);
  background: hsl(var(--muted));
}

.window-pane.right {
  top: 50%;
  left: 0;
  width: 100%;
  height: 8px;
  transform: translateY(-50%);
}

.sun {
  position: absolute;
  top: 26px;
  left: 28px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: hsl(42 100% 84%);
  box-shadow: 0 0 28px hsl(42 100% 84% / 0.7);
  transition: opacity var(--transition-smooth), transform var(--transition-smooth), filter var(--transition-smooth);
  animation: sunBreathe 6.4s ease-in-out infinite;
}

.window-rain {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.window-rain::before {
  content: '';
  position: absolute;
  inset: -40% -30% 0 -30%;
  background:
    repeating-linear-gradient(
      120deg,
      transparent 0,
      transparent 10px,
      hsl(210 65% 90% / 0.35) 11px,
      transparent 12px
    );
  transform: translateY(-20%);
  animation: rainSlide 0.9s linear infinite;
}

.desk {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 960px);
  height: 26px;
  border-radius: 20px;
  background: linear-gradient(90deg, hsl(28 57% 78%), hsl(24 60% 72%), hsl(28 57% 78%));
  box-shadow: var(--shadow-lg);
  transition: background var(--transition-smooth);
}

.desk::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 18px,
      hsl(24 30% 40% / 0.06) 19px,
      transparent 22px
    );
  opacity: 0.55;
  mix-blend-mode: multiply;
}

.books-stack {
  position: absolute;
  bottom: 108px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.books-stack.left {
  left: 8vw;
}

.books-stack.right {
  right: 15vw;
}

.books-stack span {
  display: block;
  width: 84px;
  height: 16px;
  border-radius: 10px;
  background: linear-gradient(90deg, hsl(var(--primary) / 0.85), hsl(var(--secondary) / 0.85));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 10px 18px hsl(var(--foreground) / 0.08);
  position: relative;
  overflow: hidden;
}

.books-stack span::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0 55%, hsl(var(--background) / 0.45) 70%, transparent 90%);
  opacity: 0.5;
}

/* Background scene cat (sits near the books) */
.scene-cat {
  position: absolute;
  left: calc(8vw + 86px);
  bottom: 98px;
  transform: rotate(-1.5deg);
  filter: drop-shadow(0 18px 32px hsl(var(--foreground) / 0.14));
  opacity: 0.9;
  transition: transform var(--transition-smooth), opacity var(--transition-smooth);
  pointer-events: auto;
  cursor: pointer;
}

.scene-cat:hover {
  transform: rotate(-1.5deg) scale(1.05);
}

.scene-cat .cat {
  width: 86px;
  height: 62px;
}

.scene-cat.cat-awake {
  transform: rotate(-1deg) translateY(-1px);
}

.scene-cat.cat-sleep {
  transform: rotate(-2deg) translateY(1px);
  opacity: 0.86;
}

.scene-cat.cat-idle .cat-zzz {
  opacity: 0;
}

.scene-cat.cat-celebrate .cat {
  animation: catJump 0.6s ease-in-out infinite;
}

.chair {
  position: absolute;
  bottom: 26px;
  left: 16vw;
  width: 90px;
  height: 120px;
  border-radius: 28px 28px 20px 20px;
  background: linear-gradient(180deg, hsl(var(--secondary) / 0.7), hsl(var(--primary) / 0.6));
  opacity: 0.8;
}

.lamp {
  position: absolute;
  bottom: 108px;
  right: 26vw;
  width: 80px;
  height: 130px;
}

.lamp-head {
  position: absolute;
  top: 0;
  right: 6px;
  width: 56px;
  height: 28px;
  border-radius: 20px 20px 14px 14px;
  background: hsl(var(--muted));
  transform: rotate(-12deg);
  box-shadow: 0 0 20px hsl(42 100% 84% / 0.18);
}

.lamp-stand {
  position: absolute;
  top: 18px;
  right: 30px;
  width: 8px;
  height: 88px;
  border-radius: 999px;
  background: hsl(var(--border));
}

.cafe-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.cafe-glow::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 62%, hsl(32 90% 78% / 0.22), transparent 46%),
    radial-gradient(circle at 78% 62%, hsl(12 90% 78% / 0.18), transparent 50%);
  filter: blur(0.5px);
}

/* Scene changes per environment */
html[data-env='night'] .sky-glow {
  opacity: 0.75;
  filter: saturate(0.85) brightness(0.82);
}

html[data-env='night'] .stars {
  opacity: 1;
}

html[data-env='night'] .sun {
  opacity: 0;
  transform: translateY(6px);
}

html[data-env='night'] .cloud {
  opacity: 0.25;
}

html[data-env='rain'] .cloud {
  opacity: 0.35;
}

html[data-env='rain'] .window-rain {
  opacity: 1;
}

html[data-env='rain'] .sun {
  opacity: 0.15;
  filter: blur(1px);
}

html[data-env='rain'] .window-frame {
  background: linear-gradient(180deg, hsl(215 38% 86% / 0.78), hsl(210 34% 96% / 0.9));
}

html[data-env='cafe'] .cafe-glow {
  opacity: 1;
}

html[data-env='cafe'] .desk {
  background: linear-gradient(90deg, hsl(26 64% 74%), hsl(22 62% 68%), hsl(26 64% 74%));
}

html[data-env='cafe'] .cloud {
  opacity: 0.22;
}

html[data-env='cafe'] .sun {
  filter: saturate(1.05) brightness(1.08);
}

/* Celebration Popup */
.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.celebration-card {
  background: hsl(var(--card));
  padding: 24px 40px;
  border-radius: var(--radius-lg);
  border: 2px solid hsl(var(--primary));
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: popupIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  backdrop-filter: blur(12px);
}

.celebration-card h2 {
  margin: 0;
  font-size: 2rem;
  color: hsl(var(--primary));
}

.celebration-card p {
  margin: 8px 0 0;
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Confetti */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: hsl(var(--primary));
  top: -10px;
  animation: confettiFall 3s linear forwards;
}

@keyframes popupIn {
  from { transform: scale(0.5) translateY(40px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes confettiFall {
  to {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

@keyframes drift {
  0% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(calc(50vw + 120px), -7px);
  }
  100% {
    transform: translate(calc(100vw + 220px), 0);
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    transform: scale(1);
    box-shadow: var(--shadow-lg);
  }
  50% {
    transform: scale(1.015);
    box-shadow: 0 26px 70px hsl(var(--primary) / 0.25);
  }
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes tailWag {
  0%,
  100% {
    transform: rotate(8deg);
  }
  50% {
    transform: rotate(-8deg);
  }
}

@keyframes tailWagFast {
  0%,
  100% {
    transform: rotate(15deg);
  }
  50% {
    transform: rotate(-15deg);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

@keyframes rainSlide {
  from {
    transform: translateY(-20%);
  }
  to {
    transform: translateY(20%);
  }
}

@keyframes blink {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  94% {
    transform: scaleY(0.12);
  }
  96% {
    transform: scaleY(1);
  }
}

@keyframes earTwitch {
  0%,
  92%,
  100% {
    transform: rotate(45deg);
  }
  94% {
    transform: rotate(56deg);
  }
  96% {
    transform: rotate(45deg);
  }
}

@keyframes catBob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes catJump {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-12px) scale(1.05);
  }
}

@keyframes glowDrift {
  0%,
  100% {
    filter: saturate(1) brightness(1);
    transform: translateY(0);
  }
  50% {
    filter: saturate(1.08) brightness(1.02);
    transform: translateY(-8px);
  }
}

@keyframes sunBreathe {
  0%,
  100% {
    box-shadow: 0 0 28px hsl(42 100% 84% / 0.6);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 0 34px hsl(42 100% 84% / 0.78);
    transform: translateY(-2px);
  }
}

@keyframes zzzFloat {
  0%,
  100% {
    transform: translateX(6px) translateY(0);
    opacity: 0.75;
  }
  50% {
    transform: translateX(6px) translateY(-10px);
    opacity: 0.95;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@media (min-width: 640px) {
  .app-content {
    width: min(1180px, calc(100% - 40px));
    padding-top: 22px;
  }

  .timer-inputs {
    grid-template-columns: 1fr 1fr;
    max-width: 520px;
  }

  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat-grid-compact {
    grid-template-columns: repeat(3, 1fr);
  }

  .bottom-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 639px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions > button,
  .topbar-actions > a {
    flex: 1;
  }

  .mode-group {
    width: 100%;
    justify-content: space-between;
  }

  .mode-btn {
    flex: 1;
    text-align: center;
  }

  .task-form,
  .chat-form {
    flex-direction: column;
  }

  .window-frame {
    top: 94px;
    right: 14px;
    width: 124px;
    height: 164px;
  }

  .chair,
  .lamp {
    display: none;
  }

  .books-stack.right {
    right: 22px;
  }

  .books-stack.left {
    left: 14px;
  }

  .books-stack span {
    width: 62px;
  }

  .scene-cat {
    left: 92px;
    bottom: 100px;
  }

  .scene-cat .cat {
    width: 76px;
    height: 56px;
  }

  .timer-progress {
    width: 210px;
    height: 210px;
  }

  .timer-text {
    font-size: 2.6rem;
  }

  .progress-cat .cat {
    width: 56px;
    height: 42px;
  }

  .progress-cat::after {
    width: 48px;
  }
}
