:root {
  --bg: #0f0e17;
  --surface: #1a1930;
  --surface2: #252440;
  --accent: #e8c07d;
  --accent2: #a78bfa;
  --text: #fffffe;
  --text-muted: #8888aa;
  --danger: #ff6b6b;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background stars */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(
      1px 1px at 20% 30%,
      rgba(255, 255, 255, 0.3) 0%,
      transparent 100%
    ),
    radial-gradient(
      1px 1px at 80% 10%,
      rgba(255, 255, 255, 0.2) 0%,
      transparent 100%
    ),
    radial-gradient(
      1px 1px at 50% 80%,
      rgba(255, 255, 255, 0.15) 0%,
      transparent 100%
    ),
    radial-gradient(
      1px 1px at 10% 60%,
      rgba(255, 255, 255, 0.25) 0%,
      transparent 100%
    ),
    radial-gradient(
      1px 1px at 90% 50%,
      rgba(255, 255, 255, 0.2) 0%,
      transparent 100%
    ),
    radial-gradient(
      2px 2px at 40% 15%,
      rgba(232, 192, 125, 0.2) 0%,
      transparent 100%
    ),
    radial-gradient(
      2px 2px at 70% 70%,
      rgba(167, 139, 250, 0.15) 0%,
      transparent 100%
    );
  pointer-events: none;
  z-index: 0;
}

/* ===== HEADER ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 14, 23, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: "Playfair Display", serif;
  font-size: 22px;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.logo span {
  color: var(--accent2);
  font-style: italic;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
}
.btn-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

/* ===== NAV TABS ===== */
.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 20px;
  overflow-x: auto;
  scrollbar-width: none;
  position: relative;
  z-index: 1;
}
.nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: var(--text-muted);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.tab.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 500;
}
.tab:hover:not(.active) {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ===== MAIN ===== */
main {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

/* ===== VIEWS ===== */
.view {
  display: none;
}
.view.active {
  display: block;
  animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== DATE BANNER ===== */
.date-banner {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.date-big {
  font-family: "Playfair Display", serif;
  font-size: 42px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.date-info {
  text-align: right;
}
.date-weekday {
  font-size: 13px;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.date-month {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 4px;
}

.mood-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.mood-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.mood-btn:hover,
.mood-btn.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(232, 192, 125, 0.1);
}

/* ===== EDITOR ===== */
.editor-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.editor-toolbar {
  display: flex;
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
}

.tool-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.tool-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

textarea#diary-content {
  width: 100%;
  min-height: 200px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  line-height: 1.8;
  padding: 20px;
  resize: vertical;
  outline: none;
}
textarea#diary-content::placeholder {
  color: var(--text-muted);
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.char-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 11px 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(232, 192, 125, 0.3);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
  padding: 8px 14px;
  font-size: 12px;
}
.btn-danger:hover {
  background: rgba(255, 107, 107, 0.1);
}

/* ===== ENTRY LIST ===== */
.section-title {
  font-family: "Playfair Display", serif;
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.entry-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.entry-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent2);
  border-radius: 0 2px 2px 0;
}
.entry-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateX(4px);
  box-shadow: var(--shadow);
}

.entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.entry-date {
  font-size: 12px;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.entry-mood {
  font-size: 16px;
}

.entry-preview {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  opacity: 0;
  transition: opacity 0.2s;
}
.entry-card:hover .entry-actions {
  opacity: 1;
}

/* ===== SEARCH ===== */
.search-wrap {
  position: relative;
  margin-bottom: 20px;
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  padding: 12px 16px 12px 44px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus {
  border-color: rgba(232, 192, 125, 0.4);
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

/* ===== CALENDAR ===== */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-title {
  font-family: "Playfair Display", serif;
  font-size: 18px;
  color: var(--accent);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-header {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 8px 0;
  letter-spacing: 1px;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  position: relative;
}
.cal-day:hover {
  background: var(--surface2);
  color: var(--text);
}
.cal-day.today {
  color: var(--accent);
  font-weight: 600;
}
.cal-day.today::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-day.has-entry {
  color: var(--accent2);
}
.cal-day.has-entry::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent2);
}
.cal-day.empty {
  cursor: default;
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.stat-num {
  font-family: "Playfair Display", serif;
  font-size: 36px;
  color: var(--accent);
  display: block;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px 24px 16px 16px;
  padding: 24px;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title {
  font-family: "Playfair Display", serif;
  font-size: 20px;
  color: var(--accent);
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.modal-content {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 14, 23, 0.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  font-size: 11px;
  border: none;
  background: transparent;
}
.nav-item .nav-icon {
  font-size: 22px;
  transition: transform 0.2s;
}
.nav-item.active {
  color: var(--accent);
}
.nav-item.active .nav-icon {
  transform: scale(1.15);
}
.nav-item:hover {
  color: var(--text);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.empty-title {
  font-family: "Playfair Display", serif;
  font-size: 20px;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-desc {
  font-size: 14px;
  line-height: 1.6;
}

/* ===== DRIVE STATUS ===== */
.drive-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.drive-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
  box-shadow: 0 0 6px #4ade80;
}
.drive-dot.offline {
  background: var(--text-muted);
  box-shadow: none;
}

/* Responsive */
@media (min-width: 640px) {
  main {
    padding: 24px 20px 100px;
  }
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
