/* ============================================================
   FokusPomo — Sistem Desain Lengkap
   Berisi semua variabel CSS, komponen, animasi, dan layout
   ============================================================ */

/* ─── 1. GOOGLE FONTS ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ─── 2. CSS CUSTOM PROPERTIES (DESIGN TOKENS) ────────────── */
:root {
  /* Palet warna utama (Light Mode) */
  --color-bg:           #FFF8F0;   /* Krem muda — background */
  --color-surface:      #FFFFFF;
  --color-surface-2:    #FFF0E6;

  --color-accent-1:     #FFB3C6;   /* Merah muda — alarm, tombol primer */
  --color-accent-1-deep:#FF6E99;
  --color-accent-2:     #B5EAD7;   /* Hijau muda — sukses, istirahat */
  --color-accent-2-deep:#72CEB0;
  --color-accent-3:     #C7E8F3;   /* Biru muda — fokus, informatif */
  --color-accent-3-deep:#7DC8E8;

  --color-text:         #2D2D2D;
  --color-text-muted:   #8A8080;
  --color-text-light:   #FFFFFF;
  --color-border:       rgba(0, 0, 0, 0.08);
  --color-shadow:       rgba(0, 0, 0, 0.06);

  /* Gradien */
  --grad-focus:  linear-gradient(135deg, #C7E8F3 0%, #A0D8EF 100%);
  --grad-break:  linear-gradient(135deg, #B5EAD7 0%, #8EDCBF 100%);
  --grad-alarm:  linear-gradient(135deg, #FFB3C6 0%, #FF8FAD 100%);
  --grad-hero:   linear-gradient(160deg, #FFF8F0 0%, #FFE8F0 50%, #E8F4FF 100%);

  /* Tipografi */
  --font-body:    'Plus Jakarta Sans', sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
  --font-timer:   clamp(4.5rem, 18vw, 9rem);
  --font-label:   clamp(0.8rem, 2vw, 1rem);

  /* Spacing */
  --gap-xs: 0.375rem;
  --gap-sm: 0.75rem;
  --gap-md: 1.25rem;
  --gap-lg: 2rem;
  --gap-xl: 3rem;

  /* Border radius */
  --radius-sm:   0.5rem;
  --radius-md:   1rem;
  --radius-lg:   1.5rem;
  --radius-xl:   2rem;
  --radius-full: 9999px;

  /* Transisi */
  --transition-fast:   0.15s ease;
  --transition-base:   0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Bayangan */
  --shadow-sm:    0 2px 8px var(--color-shadow);
  --shadow-md:    0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg:    0 8px 40px rgba(0, 0, 0, 0.12);
  --shadow-focus: 0 0 0 3px rgba(199, 232, 243, 0.6);
  --shadow-alarm: 0 0 0 3px rgba(255, 179, 198, 0.6);

  /* Layout */
  --max-width: 940px;

  /* Z-index */
  --z-overlay: 100;
  --z-modal:   200;
  --z-toast:   300;
}

/* ─── Dark Mode ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --color-bg:           #1A1614;
  --color-surface:      #252220;
  --color-surface-2:    #2E2A28;

  --color-accent-1:     #C05070;
  --color-accent-1-deep:#DC607C;
  --color-accent-2:     #3A8A6A;
  --color-accent-2-deep:#4CAF8E;
  --color-accent-3:     #3A7A9A;
  --color-accent-3-deep:#50A0C0;

  --color-text:         #F0EAE5;
  --color-text-muted:   #9A8E8A;
  --color-border:       rgba(255, 255, 255, 0.08);
  --color-shadow:       rgba(0, 0, 0, 0.35);

  --grad-focus:  linear-gradient(135deg, #1E3A4A 0%, #162A36 100%);
  --grad-break:  linear-gradient(135deg, #1A3A2A 0%, #102A1E 100%);
  --grad-alarm:  linear-gradient(135deg, #4A1A28 0%, #3A1020 100%);
  --grad-hero:   linear-gradient(160deg, #1A1614 0%, #2A1820 50%, #181E2A 100%);

  --shadow-focus: 0 0 0 3px rgba(58, 122, 154, 0.45);
  --shadow-alarm: 0 0 0 3px rgba(192, 80, 112, 0.45);
}

/* ─── 3. RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  line-height: 1.6;
  transition: background var(--transition-base), color var(--transition-base);
  overflow-x: hidden;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--transition-base);
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font-family: var(--font-body);
  outline: none;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus {
  border-color: var(--color-accent-3-deep);
  box-shadow: var(--shadow-focus);
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
svg { display: block; }
ul, ol { list-style: none; }

/* ─── 4. LAYOUT UTAMA ─────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gap-md);
}

/* ─── 5. NAVBAR ───────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 248, 240, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-base);
}

[data-theme="dark"] .navbar {
  background: rgba(26, 22, 20, 0.88);
}

.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem var(--gap-md);
  max-width: var(--max-width);
  margin: 0 auto;
}

.navbar__logo {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  user-select: none;
}

.navbar__logo-icon {
  width: 34px;
  height: 34px;
  background: var(--grad-alarm);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.navbar__nav {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  color: var(--color-text-muted);
  transition: all var(--transition-base);
  white-space: nowrap;
}

.nav-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.nav-btn.active {
  background: var(--color-accent-1);
  color: var(--color-text);
  font-weight: 700;
}

[data-theme="dark"] .nav-btn.active {
  color: var(--color-text-light);
}

.nav-icon { font-size: 1rem; }

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-left: var(--gap-xs);
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--color-accent-3);
  transform: rotate(22deg) scale(1.08);
}

/* ─── 6. VIEW SYSTEM ──────────────────────────────────────── */
.view {
  display: none;
  flex: 1;
  animation: fadeInUp 0.35s ease both;
}

.view.active { display: block; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── 7. VIEW TIMER ───────────────────────────────────────── */
#view-timer {
  padding: var(--gap-lg) 0 var(--gap-xl);
}

/* Session badges */
.session-badges {
  display: flex;
  justify-content: center;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-lg);
  flex-wrap: wrap;
}

.session-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  user-select: none;
}

.session-badge.focus    { background: var(--color-accent-3); }
.session-badge.break    { background: var(--color-accent-2); }
.session-badge.longbreak{ background: var(--color-accent-2); opacity: 0.75; }

/* Timer card */
.timer-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--gap-lg) var(--gap-md) var(--gap-xl);
  box-shadow: var(--shadow-md);
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.timer-card:hover {
  box-shadow: var(--shadow-lg);
}

/* Garis warna atas kartu berubah sesuai state */
.timer-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: var(--color-accent-3);
  transition: background var(--transition-slow);
}

body.state-break .timer-card::before  { background: var(--color-accent-2); }
body.state-alarm .timer-card::before  { background: var(--color-accent-1); }

/* Session label */
.session-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--gap-md);
  transition: color var(--transition-base);
}

/* Progress ring */
.progress-ring-wrapper {
  position: relative;
  width: 270px;
  height: 270px;
  margin: 0 auto var(--gap-md);
}

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

.progress-ring__track {
  fill: none;
  stroke: var(--color-surface-2);
  stroke-width: 9;
}

.progress-ring__bar {
  fill: none;
  stroke: var(--color-accent-3);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke var(--transition-slow);
}

.timer-display {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
}

.timer-time {
  font-family: var(--font-display);
  font-size: var(--font-timer);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--color-text);
  transition: color var(--transition-base);
}

.timer-sublabel {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Pomodoro dots */
.pomodoro-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: var(--gap-lg);
  min-height: 20px;
}

.pomo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-border);
  transition: all var(--transition-spring);
  flex-shrink: 0;
}

.pomo-dot.done {
  background: var(--color-accent-1);
  transform: scale(1.2);
}

.pomo-dot.active {
  background: var(--color-accent-3);
  transform: scale(1.4);
  box-shadow: 0 0 0 3px rgba(199, 232, 243, 0.45);
}

body.state-break .pomo-dot.active {
  background: var(--color-accent-2);
  box-shadow: 0 0 0 3px rgba(181, 234, 215, 0.45);
}

/* Timer controls */
.timer-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}

/* Info hari ini */
.today-info {
  text-align: center;
  margin-top: var(--gap-lg);
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ─── 8. TOMBOL SISTEM ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all var(--transition-spring);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background var(--transition-fast);
  border-radius: inherit;
}

.btn:hover::after { background: rgba(255, 255, 255, 0.18); }
.btn:active { transform: scale(0.96); }

/* Primer — merah muda */
.btn-primary {
  background: var(--color-accent-1);
  color: var(--color-text);
  box-shadow: 0 4px 16px rgba(255, 179, 198, 0.45);
}
.btn-primary:hover {
  background: var(--color-accent-1-deep);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(255, 110, 153, 0.38);
  color: var(--color-text-light);
}

/* Sekunder — biru muda */
.btn-secondary {
  background: var(--color-accent-3);
  color: var(--color-text);
  box-shadow: 0 4px 16px rgba(199, 232, 243, 0.4);
}
.btn-secondary:hover {
  background: var(--color-accent-3-deep);
  transform: translateY(-2px);
}

/* Sukses — hijau muda */
.btn-success {
  background: var(--color-accent-2);
  color: var(--color-text);
  box-shadow: 0 4px 16px rgba(181, 234, 215, 0.4);
}
.btn-success:hover {
  background: var(--color-accent-2-deep);
  transform: translateY(-2px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 2px solid var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: transparent;
}

/* Besar */
.btn-lg {
  padding: 1rem 2.2rem;
  font-size: 1.05rem;
}

/* Ikon saja */
.btn-icon {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.btn-icon:hover {
  background: var(--color-accent-3);
  transform: scale(1.1);
}

/* Tombol swap di alarm */
.btn-swap {
  width: 100%;
  justify-content: center;
}

/* ─── 9. OVERLAY: ALARM & VERIFIKASI ──────────────────────── */
#overlay-alarm {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(255, 179, 198, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: var(--gap-md);
  overflow-y: auto;
  animation: alarmFadeIn 0.4s ease both;
}

#overlay-alarm.active {
  display: flex;
}

[data-theme="dark"] #overlay-alarm {
  background: rgba(90, 10, 30, 0.35);
}

@keyframes alarmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.alarm-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--gap-lg);
  max-width: 560px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(255, 110, 150, 0.22), var(--shadow-lg);
  border: 2px solid var(--color-accent-1);
  text-align: center;
  animation: cardBounceIn 0.5s var(--transition-spring) both;
  position: relative;
  margin: auto;
}

@keyframes cardBounceIn {
  from { opacity: 0; transform: scale(0.86) translateY(24px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Pulse ring animasi di tepi alarm card */
.alarm-pulse-ring {
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 2px solid var(--color-accent-1);
  animation: pulseRing 1.6s ease-out infinite;
  pointer-events: none;
}

@keyframes pulseRing {
  0%   { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.05); opacity: 0; }
}

.alarm-icon {
  font-size: 2.6rem;
  margin-bottom: var(--gap-sm);
  display: block;
  animation: bellShake 0.7s ease-in-out infinite alternate;
}

@keyframes bellShake {
  from { transform: rotate(-10deg); }
  to   { transform: rotate(10deg); }
}

.alarm-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  margin-bottom: var(--gap-xs);
}

.alarm-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: var(--gap-md);
}

/* Kotak instruksi barang */
.alarm-instruction {
  background: var(--grad-alarm);
  border-radius: var(--radius-md);
  padding: var(--gap-md) var(--gap-lg);
  margin-bottom: var(--gap-md);
  position: relative;
  overflow: hidden;
}

.alarm-instruction::before {
  content: '';
  position: absolute;
  top: -60%; left: -60%;
  width: 220%; height: 220%;
  background: radial-gradient(circle at center, rgba(255,255,255,0.28) 0%, transparent 65%);
  animation: shimmerSpin 3s linear infinite;
}

@keyframes shimmerSpin {
  to { transform: rotate(360deg); }
}

.instruction-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  position: relative;
  opacity: 0.85;
}

.instruction-item {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 5vw, 1.65rem);
  font-weight: 800;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: relative;
}

/* Camera wrapper */
.camera-wrapper {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #0a0a0a;
  position: relative;
  aspect-ratio: 4 / 3;
  margin-bottom: var(--gap-md);
  border: 2px solid var(--color-accent-1);
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  transform: scaleX(-1); /* Mirror — lebih intuitif */
}

/* State: loading kamera */
.camera-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  gap: var(--gap-sm);
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.camera-loading-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent-1);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* State: izin ditolak */
.camera-permission {
  position: absolute;
  inset: 0;
  display: none;            /* JS menampilkan saat error */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  border-radius: inherit;
  padding: var(--gap-lg);
  text-align: center;
  gap: var(--gap-sm);
}

.camera-permission-icon { font-size: 2.6rem; }

.camera-permission h3 {
  font-weight: 700;
  font-size: 1rem;
}

.camera-permission p {
  font-size: 0.83rem;
  color: var(--color-text-muted);
}

.camera-permission-hint {
  background: var(--color-accent-3);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem !important;
  color: var(--color-text) !important;
}

/* Scanner overlay */
.camera-scanner {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}

/* Sudut scanner */
.scanner-corners {
  position: absolute;
  inset: 12px;
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--color-accent-1);
  border-style: solid;
  opacity: 0.9;
}

.corner.tl { top: 0; left: 0;    border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.corner.tr { top: 0; right: 0;   border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.corner.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.corner.br { bottom: 0; right: 0;border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

/* Garis scanner bergerak */
.scanner-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--color-accent-1) 50%, transparent 100%);
  animation: scanLine 2.2s ease-in-out infinite;
}

@keyframes scanLine {
  0%   { top: 10%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 90%; opacity: 0; }
}

/* Prediction box */
.prediction-box {
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--gap-sm) var(--gap-md);
  margin-bottom: var(--gap-md);
  display: none; /* JS menampilkan saat kamera aktif */
}

.prediction-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.prediction-item {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-bottom: 0.4rem;
}

.prediction-item:last-child { margin-bottom: 0; }

.prediction-name {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 90px;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.prediction-bar-wrap {
  flex: 1;
  background: var(--color-border);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
}

.prediction-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-accent-3-deep);
  transition: width 0.18s ease;
  min-width: 2px;
}

.prediction-bar.target { background: var(--color-accent-2-deep); }
.prediction-bar.matched { background: #4CAF50; }

.prediction-pct {
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 42px;
  text-align: right;
}

/* Alarm actions */
.alarm-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-xs);
}

.swap-info {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* ─── 10. OVERLAY: SUKSES ─────────────────────────────────── */
#overlay-success {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(181, 234, 215, 0.25);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: successFadeIn 0.3s ease both;
}

#overlay-success.active { display: flex; }

@keyframes successFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.success-card {
  text-align: center;
  animation: successPop 0.5s var(--transition-spring) both;
  padding: var(--gap-lg);
}

@keyframes successPop {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

.success-icon {
  font-size: 5.5rem;
  display: block;
  margin-bottom: var(--gap-md);
  animation: successBounce 0.6s var(--transition-spring) 0.1s both;
}

@keyframes successBounce {
  from { transform: scale(0) rotate(-20deg); }
  to   { transform: scale(1) rotate(0deg); }
}

.success-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--gap-sm);
}

.success-subtitle {
  font-size: 1rem;
  color: var(--color-text-muted);
}

/* ─── 11. VIEW: STATISTIK ─────────────────────────────────── */
#view-stats {
  padding: var(--gap-lg) 0 var(--gap-xl);
}

.stats-header {
  text-align: center;
  margin-bottom: var(--gap-xl);
}

.stats-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.stats-header p { color: var(--color-text-muted); }

.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--gap-md);
  margin-bottom: var(--gap-xl);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--gap-md);
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-card__icon { font-size: 1.8rem; margin-bottom: 0.5rem; }

.stat-card__value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.3rem;
}

.stat-card__label {
  font-size: 0.77rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.chart-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--gap-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--gap-lg);
}

.chart-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: var(--gap-md);
}

.chart-wrap {
  position: relative;
  height: 220px;
}

.history-list {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--gap-md);
  box-shadow: var(--shadow-sm);
}

.history-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: var(--gap-md);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--color-border);
  gap: var(--gap-sm);
}

.history-item:last-child { border-bottom: none; }

.history-date { font-size: 0.875rem; font-weight: 600; }
.history-detail { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 0.12rem; }

.history-badge {
  background: var(--color-accent-3);
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: var(--gap-xl);
  color: var(--color-text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: var(--gap-sm); }

.stats-footer {
  text-align: center;
  margin-top: var(--gap-lg);
}

/* ─── 12. VIEW: PENGATURAN ────────────────────────────────── */
#view-settings {
  padding: var(--gap-lg) 0 var(--gap-xl);
}

.settings-header {
  text-align: center;
  margin-bottom: var(--gap-xl);
}

.settings-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.settings-header p { color: var(--color-text-muted); }

.settings-grid {
  display: grid;
  gap: var(--gap-lg);
}

@media (min-width: 768px) {
  .settings-grid { grid-template-columns: 1fr 1fr; }
}

.settings-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--gap-lg);
  box-shadow: var(--shadow-sm);
}

.settings-card__title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: var(--gap-md);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: var(--gap-sm);
  border-bottom: 2px solid var(--color-surface-2);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-md);
  margin-bottom: var(--gap-sm);
  padding: 0.25rem 0;
}

.setting-row:last-child { margin-bottom: 0; }

.setting-label {
  font-size: 0.875rem;
  font-weight: 500;
  flex: 1;
  cursor: default;
}

.setting-label small {
  display: block;
  font-size: 0.73rem;
  color: var(--color-text-muted);
  font-weight: 400;
  margin-top: 0.1rem;
}

.setting-input {
  width: 80px;
  text-align: center;
  flex-shrink: 0;
}

.setting-select {
  width: 140px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Range slider */
.range-wrap {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex: 1;
  min-width: 0;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  border: none;
  padding: 0;
  cursor: pointer;
  min-width: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent-1);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 179, 198, 0.55);
  transition: transform var(--transition-spring);
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.25); }

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent-1);
  cursor: pointer;
  border: none;
}

.range-value {
  font-size: 0.83rem;
  font-weight: 700;
  min-width: 38px;
  text-align: right;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 46px;
  height: 25px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-block;
}

.toggle input { display: none; }

.toggle__slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: var(--radius-full);
  transition: background var(--transition-base);
  cursor: pointer;
}

.toggle__slider::before {
  content: '';
  position: absolute;
  width: 19px;
  height: 19px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-spring);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
}

.toggle input:checked + .toggle__slider { background: var(--color-accent-2-deep); }
.toggle input:checked + .toggle__slider::before { transform: translateX(21px); }

/* Model labels section */
.model-labels-section {
  margin-top: var(--gap-md);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--color-border);
}

.model-labels-title {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.6rem;
}

.model-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 28px;
}

.model-labels-loading {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.model-label-tag {
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--color-accent-3);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
}

/* Model status section */
.model-status-section {
  margin-top: var(--gap-md);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--color-border);
}

.model-status-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 0.5rem;
}

.model-status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.model-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ccc;
  display: inline-block;
  flex-shrink: 0;
  transition: background var(--transition-base);
}

/* Settings save row */
.settings-save-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--gap-sm);
  margin-top: var(--gap-lg);
  padding-top: var(--gap-lg);
  flex-wrap: wrap;
}

/* ─── 13. TOAST NOTIFIKASI ────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--gap-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.toast {
  background: var(--color-surface);
  border-radius: var(--radius-full);
  padding: 0.65rem 1.2rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 600;
  animation: toastIn 0.4s var(--transition-spring) both;
  border: 1px solid var(--color-border);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(18px) scale(0.88); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.hiding {
  animation: toastOut 0.3s ease both;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px) scale(0.92); }
}

.toast.success { border-color: var(--color-accent-2-deep); background: color-mix(in srgb, var(--color-surface) 90%, var(--color-accent-2)); }
.toast.error   { border-color: var(--color-accent-1-deep); background: color-mix(in srgb, var(--color-surface) 90%, var(--color-accent-1)); }
.toast.info    { border-color: var(--color-accent-3-deep); background: color-mix(in srgb, var(--color-surface) 90%, var(--color-accent-3)); }

/* Fallback untuk browser tanpa color-mix */
@supports not (color: color-mix(in srgb, red 90%, blue)) {
  .toast.success { border-color: var(--color-accent-2-deep); }
  .toast.error   { border-color: var(--color-accent-1-deep); }
  .toast.info    { border-color: var(--color-accent-3-deep); }
}

/* ─── 14. PAGE LOADER ─────────────────────────────────────── */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.page-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-md);
}

.loader-tomato {
  font-size: 3rem;
  animation: loaderBounce 1s ease-in-out infinite alternate;
}

@keyframes loaderBounce {
  from { transform: translateY(-6px) scale(1.05); }
  to   { transform: translateY(6px) scale(0.95); }
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-surface-2);
  border-top-color: var(--color-accent-1);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loader-content p {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ─── 15. FOOTER ──────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: var(--gap-md);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

/* ─── 16. STATE CLASSES (body) ────────────────────────────── */
body.state-focus .timer-card::before { background: var(--color-accent-3); }
body.state-break .timer-card::before { background: var(--color-accent-2); }
body.state-alarm .timer-card::before { background: var(--color-accent-1); }
body.state-alarm .timer-time         { color: var(--color-accent-1-deep); }

/* ─── 17. SCROLLBAR ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ─── 18. AKSESIBILITAS ───────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent-3-deep);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ─── 19. RESPONSIF ───────────────────────────────────────── */

/* Mobile kecil (< 400px) */
@media (max-width: 399px) {
  .progress-ring-wrapper { width: 220px; height: 220px; }
  .navbar__logo-text { display: none; }
  .nav-label { display: none; }
  .nav-btn { padding: 0.45rem; }
  .timer-card { padding: var(--gap-md) var(--gap-sm) var(--gap-lg); }
  .alarm-card { padding: var(--gap-md) var(--gap-sm); }
  .instruction-item { font-size: 1.2rem; }
  .btn-lg { padding: 0.85rem 1.5rem; font-size: 0.95rem; }
}

/* Mobile (400px – 639px) */
@media (min-width: 400px) and (max-width: 639px) {
  .navbar__logo-text { display: none; }
  .nav-label { font-size: 0.8rem; }
}

/* Tablet (>= 768px) */
@media (min-width: 768px) {
  .stats-summary { grid-template-columns: repeat(4, 1fr); }
  .settings-grid { grid-template-columns: 1fr 1fr; }
}

/* Desktop (>= 1024px) */
@media (min-width: 1024px) {
  .progress-ring-wrapper { width: 300px; height: 300px; }
  .navbar__inner { padding: 1rem var(--gap-lg); }
}

/* Preferensi reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
