* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --ios-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --bg: #0b0f1a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-soft: rgba(255, 255, 255, 0.02);
  --text-primary: #e5e7eb;
  --text-secondary: rgba(229, 231, 235, 0.6);
  --text-tertiary: rgba(229, 231, 235, 0.4);
  --accent: #2563eb;
  --radius: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
}
body {
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  padding: var(--space-4);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
  letter-spacing: -0.1px;
  overflow-x: hidden;
  max-width: 100%;
}
html {
  overflow-x: hidden;
}
.app {
  margin: auto;
  width: 100%;
  max-width: 900px;
}
.card {
  background: var(--surface-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: var(--space-4);
  width: 100%;
  max-width: 100%;
}
.card.primary {
  background: rgba(255, 255, 255, 0.02);
  position: relative;
}
#streakChartTop {
  flex-shrink: 0;
  isolation: isolate;
}
#streakChartTop::before {
  content: "";
  position: absolute;
  inset: -20px;
  background: radial-gradient(circle, rgba(255, 0, 0, 0.15), transparent 70%);
  filter: blur(20px);
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#streakChartTop.aura-on::before {
  opacity: 1;
}
.card.primary > * + * {
  margin-top: 12px;
}
input,
textarea,
select {
  width: 100%;
  padding: var(--space-3);
  margin-top: var(--space-2);
  border-radius: var(--radius);
  border: none;
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  resize: none;
  transition: transform 0.08s var(--ios-ease);
  font-size: 16px;
}

input:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

input::placeholder,
textarea::placeholder {
  font-family: inherit;
}
button {
  margin-top: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-primary);
  opacity: 0.7;
  min-height: 44px;
  transition: opacity 0.2s var(--ios-ease);
}
button:hover {
  opacity: 0.85;
}
button:active {
  transform: scale(0.97);
}
.card.primary button {
  background: var(--accent);
  color: white;
  opacity: 1;
}
.history-item {
  padding: 12px 4px;
  margin-bottom: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  transition:
    background 0.2s var(--ios-ease),
    transform 0.2s var(--ios-ease);
  line-height: 1.6;
  will-change: transform;
  font-size: 14px;
  color: rgba(229, 231, 235, 0.9);
  overflow: hidden;
  transition:
    background 0.2s,
    transform 0.2s,
    opacity 0.2s;
}
.history-item + .history-item {
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}
.history-item.removing {
  opacity: 0;
  transform: translateY(-10px);
}
.history-item .inner {
  transition: transform 0.2s var(--ios-ease);
}
.history-item:hover .inner {
  transform: translateY(-2px);
}

.history-item.active .inner {
  transform: translateY(-2px) scale(1.01);
}

.history-item.active {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
}
.small {
  font-size: 12px;
  color: var(--text-tertiary);
}
.actions button {
  margin-right: 5px;
}
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 10px);
  background: var(--surface);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.button-success {
  background: #22c55e !important;
  color: #022c22 !important;
  animation: successPop 0.4s var(--ios-ease);
}

.button-success::after {
  content: "✓";
  margin-left: 6px;
}

#onboarding {
  transition: opacity 0.4s var(--ios-ease);
}

#onboarding.hide {
  opacity: 0;
}

.primary {
  outline: 1px solid #38bdf8;
}
.secondary {
  opacity: 1;
}
#search {
  margin-top: 8px;
  font-size: 16px;
}
#dateFilters button {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  padding: 10px 8px;
  font-size: clamp(10px, 2.8vw, 13px);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  text-align: center;
}
#dateFilters button.active {
  background: var(--accent);
  color: white;
  opacity: 1;
}
input[type="date"] {
  position: relative;
  padding-right: 44px;
  font-size: 16px;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  width: 24px;
  height: 24px;
}
/* make entire field feel clickable */
#filterDate {
  height: 48px;
}
#filterDate:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

.btn-loading {
  opacity: 0.6;
  pointer-events: none;
}

.badge {
  font-size: 13px;
  margin-left: 0;
  color: var(--text-secondary);
  background: transparent;
}
.mood-💡,
.mood-🇯🇵,
.mood-🔥 {
  background: transparent;
  color: inherit;
}

.truncate {
  white-space: pre-wrap;
  word-break: break-word;
}

.status {
  font-size: 11px;
  margin-top: 0;
  opacity: 0.6;
}
#stats {
  font-size: 13px;
  color: var(--text-secondary);
}
#moodButtons {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

#moodButtons .mood-item {
  flex: 1;
  text-align: center;
}

#moodButtons button {
  width: 100%;
  padding: var(--space-3);
  font-size: 18px;
  border-radius: var(--radius);
  background: var(--surface);
}

.mood-label {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

#moodButtons button.active {
  background: var(--accent);
  color: white;
}
.history-item b {
  display: block;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
  margin-bottom: 4px;

  /* 🔥 ini penting */
  line-height: 1.2;
}
.history-item .small {
  font-size: 11px;
  opacity: 0.65;
}
@keyframes successPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}
/* actions button style */
.actions button {
  background: transparent;
  border: none;
  color: var(--text-primary);
  opacity: 0.75;
  padding: 6px 4px;
  flex: 1;
  text-align: center;
  border-radius: 8px;
}

.actions button:hover {
  opacity: 1;
}

.actions button:last-child {
  color: #f87171;
  background: transparent;
}

.actions {
  margin-top: 8px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  opacity: 0.6;
}
.history-item:hover .actions {
  opacity: 1;
}

#loading {
  opacity: 0.6;
}

/* subtle background by mood */
.mood-bg-💡,
.mood-bg-🇯🇵,
.mood-bg-🔥 {
  background: transparent;
}
.history-item.mood-bg-💡,
.history-item.mood-bg-🇯🇵,
.history-item.mood-bg-🔥 {
}

.highlight {
  background: rgba(253, 224, 71, 0.3);
  color: #fde047;
  padding: 0 2px;
  border-radius: 3px;
}
#moodButtons button:active {
  transform: scale(0.95);
}

/* skeleton loading */
/* 🔥 advanced flame streak animation */
.streak-glow {
  animation: flameFlicker 1.2s ease-in-out infinite;
}

@keyframes flameFlicker {
  0% {
    transform: scale(1) rotate(0deg);
    text-shadow:
      0 0 6px rgba(255, 140, 0, 0.6),
      0 0 12px rgba(255, 69, 0, 0.5),
      0 0 20px rgba(255, 0, 0, 0.4);
  }
  25% {
    transform: scale(1.05) rotate(-1deg);
    text-shadow:
      0 0 8px rgba(255, 165, 0, 0.8),
      0 0 16px rgba(255, 69, 0, 0.7),
      0 0 26px rgba(255, 0, 0, 0.5);
  }
  50% {
    transform: scale(1.1) rotate(1deg);
    text-shadow:
      0 0 10px rgba(255, 200, 0, 0.9),
      0 0 20px rgba(255, 100, 0, 0.8),
      0 0 32px rgba(255, 0, 0, 0.6);
  }
  75% {
    transform: scale(1.04) rotate(-1deg);
    text-shadow:
      0 0 8px rgba(255, 165, 0, 0.8),
      0 0 16px rgba(255, 69, 0, 0.7),
      0 0 26px rgba(255, 0, 0, 0.5);
  }
  100% {
    transform: scale(1) rotate(0deg);
    text-shadow:
      0 0 6px rgba(255, 140, 0, 0.6),
      0 0 12px rgba(255, 69, 0, 0.5),
      0 0 20px rgba(255, 0, 0, 0.4);
  }
}
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 12px;
}

.skeleton-item {
  height: 80px;
  margin-bottom: 10px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.history-header {
  display: none;
}

.history-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
#topStats {
  font-size: 12px;
  opacity: 0.6;
}
.card.secondary h2 {
  margin-bottom: 4px;
}

.history-title-row h2 {
  margin: 0;
}

.history-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-info .status {
  white-space: normal;
  line-height: 1.4;
}

.history-chart {
  width: 120px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible; /* 🔥 allow glow to spread */
}
.card.secondary {
  background: transparent;
  border: none;
  opacity: 0.85;
}

.history-chart canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#streakChartText {
  display: inline-flex; /* 🔥 prevent emoji collapse */
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  line-height: 1;
  overflow: visible;
  white-space: nowrap; /* 🔥 keep fire visible */
}

#streakChartTop,
#streakChartTop * {
  overflow: visible !important;
}

@media (max-width: 600px) {
  .history-header {
    flex-direction: column;
    align-items: stretch;
  }
  .history-title-row {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .history-chart {
    width: 90px;
    height: 36px;
  }
}
#modal > div {
  transform: scale(0.95);
  opacity: 0;
  animation: modalIn 0.2s var(--ios-ease) forwards;

  width: 100%;
  max-width: calc(100% - 32px); /* padding compensation */
  margin: 0 auto;
}

@keyframes modalIn {
  to {
    transform: scale(1);
    opacity: 1;
  }
}

body.typing .card.secondary {
  opacity: 0.4;
}
h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
/* .history-header::after removed, replaced by border-bottom */
input::placeholder,
textarea::placeholder {
  opacity: 0.4;
}
#sortBtn:hover {
  opacity: 0.8;
}
#editMoodButtons .edit-mood-btn {
  flex: 1;
  padding: 12px;
  font-size: 18px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ios-ease);
}
#editMoodButtons .edit-mood-btn.active {
  background: var(--accent);
  color: white;
  transform: scale(1.03);
}
#editMoodButtons .edit-mood-btn:active {
  transform: scale(0.95);
}
#dateFilters {
  overflow-x: hidden;
  flex-wrap: wrap;
}
#sortBtn {
  flex: 1 1 100%;
  text-align: center;
  margin-top: 6px;
}

* {
  max-width: 100%;
}

body,
html {
  position: relative;
  overflow-x: hidden;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.chip {
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  opacity: 0.7;
  transition:
    background 0.2s var(--ios-ease),
    opacity 0.2s var(--ios-ease);
  display: flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-width: 80px;
  justify-content: center;
  flex: 1 1 auto;
}
#yearChips .chip {
  flex: 0 0 auto;
  min-width: auto;
  padding: 12px 22px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.04);
  opacity: 0.7;
}
#yearChips .chip.active {
  background: rgba(37, 99, 235, 0.28);
  color: #ffffff;
  opacity: 1;
}
.chip:hover {
  opacity: 0.9;
}
.chip.active {
  background: var(--accent);
  color: white;
  opacity: 1;
  transform: none;
}
.chip:active {
  transform: scale(0.95);
}
.chip-group:not(#monthChips) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
#monthChips {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 8px;
  padding-bottom: 4px;
  margin-top: 8px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
#monthChips .chip {
  flex: 0 0 auto;
  white-space: nowrap;
  scroll-snap-align: start;
  max-width: max-content;
  padding: 4px 10px;
  min-width: 80px;
  font-size: 11px;
}
#monthChips::-webkit-scrollbar {
  display: none;
}
#monthChips .chip.active {
  background: rgba(37, 99, 235, 0.22);
  color: #e0e7ff;
}
.btn-primary {
  background: var(--accent);
  color: white;
  opacity: 1;
  width: 100%;
}

.btn-primary:hover {
  opacity: 0.9;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  width: 100%;
  margin-top: 8px;
  opacity: 0.9;
}

.btn-secondary:hover {
  opacity: 1;
}
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: transparent; /* removed background */
  backdrop-filter: none; /* remove blur */
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0.7;
  transition: all 0.2s var(--ios-ease);
  pointer-events: auto;
  font-size: 10px;
}

#prevBtn {
  left: calc(50% - 260px);
}
#nextBtn {
  right: calc(50% - 260px);
}

.nav-btn:hover {
  opacity: 1;
}

.nav-btn:active {
  transform: translateY(-50%) scale(0.9);
}

@media (max-width: 600px) {
  #prevBtn {
    left: 6px;
  }
  #nextBtn {
    right: 6px;
  }
  .nav-btn {
    width: 34px;
    height: 34px;
    opacity: 0.5;
  }
}
.preview-animate {
  transition:
    transform 0.25s var(--ios-ease),
    opacity 0.25s var(--ios-ease);
}

.slide-left {
  transform: translateX(-40px);
  opacity: 0;
}

.slide-right {
  transform: translateX(40px);
  opacity: 0;
}
.history-item.done {
  opacity: 0.8;
}

.history-item.done b,
.history-item.done .truncate {
  text-decoration: line-through;
  opacity: 0.7;
}

.check-btn {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  padding: 0;

  /* 🔥 ini yang ngangkat */
  margin-top: -1px;

  transition: all 0.2s var(--ios-ease);
  background: transparent;
  transition:
    all 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}
.check-btn.done {
  background: #2563eb !important;
  border-color: #60a5fa !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.9);
}
.check-btn:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.check-btn:active {
  transform: scale(0.9);
}
.streak-char {
  display: inline-block;
  animation: none; /* default off */
}

.streak-char:first-child {
  animation: none;
}
.chars-on .streak-char {
  animation: charFlicker var(--dur, 1.2s) ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.08s);
}

.chars-on .streak-char:first-child {
  animation: charStable calc(var(--dur, 1.2s) * 1.4) ease-in-out infinite;
}

.streak-fire {
  display: inline-block;
  margin-left: 4px;
  flex-shrink: 0; /* 🔥 prevent disappearing */
  transform-origin: center;
  will-change: transform;
  animation: none;
}
.streak-number {
  display: inline-flex;
}

.flame-on .streak-fire {
  animation: flameFlicker var(--dur, 1.2s) ease-in-out infinite;
}

@keyframes charFlicker {
  0% {
    transform: translateY(0px) scale(1);
  }
  50% {
    transform: translateY(-1.2px) scale(1.03);
  }
  100% {
    transform: translateY(0px) scale(1);
  }
}

@keyframes charStable {
  0% {
    transform: translateY(0px) scale(1);
  }
  50% {
    transform: translateY(-0.3px) scale(1.01);
  }
  100% {
    transform: translateY(0px) scale(1);
  }
}
.streak-shake {
  animation: shake 0.4s infinite;
}

.heat-on {
  position: relative;
}

.heat-on::after {
  content: "";
  position: absolute;
  inset: -6px;
  pointer-events: none;
  border-radius: 8px;
  backdrop-filter: blur(1.2px);
  -webkit-backdrop-filter: blur(1.2px);
  opacity: 0.35;
  mix-blend-mode: screen;
}

@keyframes shake {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(1px, -1px);
  }
  50% {
    transform: translate(-1px, 1px);
  }
  75% {
    transform: translate(1px, 1px);
  }
  100% {
    transform: translate(0, 0);
  }
}
.revive {
  animation: revivePop 0.6s ease;
}

@keyframes revivePop {
  0% {
    transform: scale(0.9);
    filter: brightness(0.8);
  }
  40% {
    transform: scale(1.25);
    filter: brightness(1.8);
  }
  70% {
    transform: scale(0.95);
    filter: brightness(1.2);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}
.milestone {
  animation: milestoneBurst 0.7s ease;
}

@keyframes milestoneBurst {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  30% {
    transform: scale(1.4);
    filter: brightness(2);
  }
  60% {
    transform: scale(0.95);
    filter: brightness(1.4);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.preview-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background: #1e293b;
  padding: 20px 48px;
  border-radius: 12px;
  height: min(85vh, 100dvh);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 1.65;
}
.preview-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.preview-card:not(.active) {
  pointer-events: none;
  z-index: 1;
}

.preview-card.active {
  z-index: 2;
}

.preview-card .truncate {
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-card br {
  display: block;
  margin-bottom: 6px;
}

.preview-card.active {
  transform: translateX(0);
}
#previewCardWrapper {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: auto;
  min-height: 200px;
  overflow: hidden;
  display: flex;
}
#previewModal {
  overscroll-behavior: none;
  touch-action: pan-y;
}
.btn-primary.success {
  background: #22c55e !important;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
  transform: scale(1.02);
}
.preview-card .check-btn.done {
  transform: scale(1.15);
}
