/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; touch-action: manipulation; }

:root {
  --bg:           #0A0A0F;
  --surface:      #13131A;
  --surface2:     #1A1A24;
  --primary:      #6C63FF;
  --primary-dim:  rgba(108,99,255,0.15);
  --primary-glow: rgba(108,99,255,0.35);
  --text:         #F0F0F5;
  --text-sec:     #9090A8;
  --text-muted:   #55556A;
  --border:       rgba(255,255,255,0.07);
  --error:        #FF5757;
  --gold:         #FFD700;
  --orange:       #FF8C42;
  --radius:       16px;
  --font:         'Inter', system-ui, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

#app {
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ─── Screens ───────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 20px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  -webkit-overflow-scrolling: touch;
}

/* Calendar screen must NOT scroll — only the sessions panel inside scrolls */
#screen-history {
  overflow: hidden;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}
.screen.slide-up {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.safe-top    { height: max(env(safe-area-inset-top), 20px); }
.safe-bottom { height: max(env(safe-area-inset-bottom), 32px); }

/* ─── Home Header ───────────────────────────────────────────── */
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 24px;
  gap: 16px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-panda {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(255,140,50,0.4));
  animation: panda-bounce 3s ease-in-out infinite;
}
@keyframes panda-bounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%       { transform: translateY(-3px) rotate(3deg); }
}
.logo {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -1px;
}

.date {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: capitalize;
}

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.btn-icon:active { transform: scale(0.9); }

/* ─── Streak Badge ──────────────────────────────────────────── */
.streak-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.streak-flame {
  font-size: 20px;
  animation: pulse-flame 2s ease-in-out infinite;
}
@keyframes pulse-flame {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50%       { transform: scale(1.15); opacity: 1; }
}
.streak-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--orange);
  min-width: 22px;
}
.streak-meta { display: flex; flex-direction: column; gap: 3px; }
.streak-progress-bar {
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.streak-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--primary);
  width: 0%;
  transition: width 0.6s ease;
}
.streak-label {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
}

/* ─── Hero ──────────────────────────────────────────────────── */
.hero { margin-bottom: 28px; }
.hero-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.7px;
  line-height: 1.25;
  margin-bottom: 8px;
}
.hero-sub {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Input ─────────────────────────────────────────────────── */
.input-group { margin-bottom: 14px; }
.task-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 17px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.task-input::placeholder { color: var(--text-muted); }
.task-input:focus { border-color: var(--primary); }

/* ─── Chips ─────────────────────────────────────────────────── */
.chips-wrapper { margin-bottom: 28px; }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.chip {
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-sec);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}
.btn-edit-chips {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}

/* ─── Paused Session Card ───────────────────────────────────── */
.paused-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(135deg, rgba(108,99,255,0.18) 0%, rgba(255,140,50,0.1) 100%);
  border: 1.5px solid rgba(108,99,255,0.35);
  border-radius: 20px;
  padding: 18px 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.paused-card::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(108,99,255,0.15) 0%, transparent 70%);
  pointer-events: none;
}
.paused-card-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.paused-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(108,99,255,0.15);
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: 20px;
  padding: 3px 10px;
  width: fit-content;
}
.paused-task-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.paused-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.paused-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.paused-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--orange));
  transition: width 0.4s ease;
  width: 0%;
}
.paused-time-label {
  font-size: 12px;
  color: var(--text-muted);
}
.paused-actions {
  display: flex;
  gap: 10px;
}
.btn-end-paused {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  color: var(--text-sec);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-end-paused:active { background: rgba(255,255,255,0.05); }
.btn-resume {
  flex: 2;
  padding: 12px;
  background: var(--primary);
  border: none;
  border-radius: 14px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 4px 16px var(--primary-glow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-resume:active { transform: scale(0.97); }

/* ─── Start Button ──────────────────────────────────────────── */
.btn-start {
  width: 100%;
  padding: 18px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px var(--primary-glow);
  margin-bottom: 24px;
}
.btn-start:disabled {
  background: var(--surface);
  box-shadow: none;
  color: var(--text-muted);
  cursor: not-allowed;
}
.btn-start:not(:disabled):active { transform: scale(0.97); }

/* ─── Stats Row ─────────────────────────────────────────────── */
.stats-row {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 0;
  margin-bottom: 24px;
}
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-muted); text-align: center; line-height: 1.3; }
.stat-divider { width: 1px; background: var(--border); margin: 4px 0; }

/* ─── Focus Screen ──────────────────────────────────────────── */
.btn-back {
  background: none;
  border: none;
  color: var(--text-sec);
  font-size: 22px;
  font-family: var(--font);
  cursor: pointer;
  padding: 8px 4px;
  margin-bottom: 16px;
  display: block;
  transition: color 0.15s;
}
.btn-back:hover { color: var(--text); }

.task-header { text-align: center; margin-bottom: 32px; }
.focusing-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}
.task-name {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
}

/* ─── Timer Ring ────────────────────────────────────────────── */
.timer-container {
  position: relative;
  width: min(260px, 70vw);
  height: min(260px, 70vw);
  margin: 0 auto 28px;
}

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

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

.ring-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 678.6;   /* 2π × 108 */
  stroke-dashoffset: 678.6;
  transition: stroke-dashoffset 0.8s ease, stroke 0.5s ease;
}
.ring-progress.completed { stroke: var(--gold); }

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

.timer-time {
  font-size: clamp(40px, 12vw, 56px);
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

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

/* ─── Streak Pill ───────────────────────────────────────────── */
.streak-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ─── Stop Button ───────────────────────────────────────────── */
.btn-stop {
  display: block;
  margin: 0 auto;
  background: none;
  border: none;
  color: var(--error);
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  padding: 16px;
  transition: opacity 0.15s;
}
.btn-stop:active { opacity: 0.7; }

/* ─── Completion Card ───────────────────────────────────────── */
.completion-card {
  background: var(--surface);
  border-radius: 20px;
  border: 1px solid rgba(255,215,0,0.2);
  padding: 24px;
  text-align: center;
  margin: 16px 0 24px;
  animation: pop-in 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.completion-emoji { font-size: 48px; margin-bottom: 12px; }
.completion-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.completion-text  { font-size: 14px; color: var(--text-sec); line-height: 1.5; margin-bottom: 20px; }

.btn-done {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 6px 20px var(--primary-glow);
  transition: transform 0.15s;
}
.btn-done:active { transform: scale(0.97); }

/* ─── Pulse animation on timer ──────────────────────────────── */
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.02); }
}
.timer-container.running { animation: breathe 3s ease-in-out infinite; }

/* ─── History Screen ────────────────────────────────────────── */
.history-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding-top: 8px;
}
.history-header .btn-back { margin-bottom: 0; }
.history-title { font-size: 24px; font-weight: 700; }

/* Month navigation */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-nav-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: var(--font);
}
.cal-nav-btn:active { opacity: 0.6; }
.cal-month-label {
  font-size: 17px;
  font-weight: 600;
  text-transform: capitalize;
}

/* Weekday labels */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 6px;
  gap: 4px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0;
}

/* Day grid */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  padding: 2px;
  overflow: hidden;
}
.cal-day:active { transform: scale(0.92); }
.cal-day--empty {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}
.cal-day--future {
  opacity: 0.25;
  cursor: default;
}
.cal-day--today {
  border-color: var(--primary);
}
.cal-day--partial {
  background: rgba(108,99,255,0.12);
}
.cal-day--selected {
  border-color: var(--primary) !important;
  background: var(--primary-dim) !important;
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Fire (goal met) day */
.cal-day--fire {
  background: rgba(255,100,20,0.15);
  border-color: rgba(255,140,50,0.4);
}
.cal-day--fire .cal-day-num {
  color: #FF8C42;
  font-weight: 700;
}
.cal-fire {
  font-size: 11px;
  line-height: 1;
}
.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
  display: block;
}
.cal-day-num {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}

/* Day detail slide-up panel */
.day-detail {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px max(env(safe-area-inset-bottom), 24px);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34,1.3,0.64,1);
  z-index: 100;
  min-height: 80px;
  /* No margin hack needed — absolute pos ignores parent padding */
}
.day-detail.open {
  transform: translateY(0);
}
.day-detail-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.day-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.day-detail-date {
  font-size: 16px;
  font-weight: 600;
  text-transform: capitalize;
}
.day-detail-total {
  font-size: 14px;
  font-weight: 600;
  color: var(--orange);
}
.day-detail-sessions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}
.day-detail-empty {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}

/* Session rows (reused in day detail) */
.history-session {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.05);
}
.history-session:last-child { border-bottom: none; }
.history-session-left { display: flex; flex-direction: column; gap: 3px; }
.history-session-task { font-size: 14px; font-weight: 500; }
.history-session-time { font-size: 12px; color: var(--text-muted); }
.session-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.btn-edit-session {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
}
.btn-delete-session {
  background: rgba(255,87,87,0.12);
  border: 1px solid rgba(255,87,87,0.25);
  color: var(--error);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.btn-delete-session:active { background: rgba(255,87,87,0.25); }

/* ─── Scrollbar hide ────────────────────────────────────────── */
.screen::-webkit-scrollbar { display: none; }
.day-detail-sessions::-webkit-scrollbar { display: none; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }

.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.modal-subtitle { font-size: 14px; color: var(--text-sec); margin-bottom: 16px; }

.modal-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  margin-bottom: 16px;
}
.modal-input:focus { outline: none; border-color: var(--primary); }

/* Edit Chips modal specifics */
.add-chip-row { display: flex; gap: 8px; margin-bottom: 16px; }
.add-chip-row .modal-input { margin-bottom: 0; flex: 1; }
.btn-add-chip {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
}

.chip-edit-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.chip-edit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface2);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.btn-delete-chip {
  background: none;
  border: none;
  color: var(--error);
  font-size: 18px;
  cursor: pointer;
}

.btn-close-modal {
  width: 100%;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
}

/* Edit session modal specifics */
.modal-actions {
  display: flex;
  gap: 12px;
}
.btn-cancel, .btn-save {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: none;
}
.btn-cancel { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-save   { background: var(--primary); color: white; }

.confirm-icon {
  font-size: 40px;
  text-align: center;
  margin-bottom: 8px;
}
.btn-delete-confirm {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: var(--error);
  color: white;
}
.btn-delete-confirm:active { opacity: 0.85; }

/* ─── Scrollbar hide ────────────────────────────────────────── */
.screen::-webkit-scrollbar { display: none; }
