/* =============================================
   CSS VARIABLES
   ============================================= */
:root {
  --bg:         #F8F7F4;
  --surface:    #FFFFFF;
  --border:     #EFEFEC;
  --text:       #1A1A1A;
  --muted:      #8A8A8A;
  --dark-btn:   #1A1A1A;
  --chip-sand:  #EEE0B8;
  --chip-rose:  #EDD5C5;
  --chip-sky:   #C5D9E8;
  --chip-sage:  #C8E0C8;
  --chip-def:   #EFEFEC;
  --radius:     16px;
  --nav-h:      68px;
  --max-w:      430px;
  --font:       'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: #D8D5CF;
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-tap-highlight-color: transparent;
}

/* =============================================
   VIEWS
   ============================================= */
.view {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: var(--max-w);
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.view.active { display: flex; }

.screen {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + 20px);
}

/* =============================================
   WELCOME SCREEN
   ============================================= */
#view-welcome {
  position: relative;
  background: linear-gradient(160deg,
    #FDE8C0 0%,
    #F8DCA8 25%,
    #F5D090 50%,
    #F8E4B8 75%,
    #FFF6E8 100%
  );
  justify-content: flex-end;
  overflow: hidden;
}

/* Sun glow */
.wlc-sun {
  position: absolute;
  top: 20%; left: 50%;
  transform: translateX(-50%);
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,220,150,0.7) 0%, rgba(255,190,110,0.35) 50%, transparent 72%);
  pointer-events: none;
}

/* Horizon glow */
.wlc-horizon {
  position: absolute;
  bottom: 26%; left: -10%;
  width: 120%; height: 90px;
  background: linear-gradient(to top, rgba(255,200,140,0.4) 0%, transparent 100%);
  border-radius: 50%;
  pointer-events: none;
}

/* Floating orbs */
.wlc-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.55;
}
.wlc-orb1 { width: 140px; height: 140px; top: 6%;  right: 6%;  background: radial-gradient(circle, #F8D898, #F0C068); opacity: 0.45; }
.wlc-orb2 { width: 90px;  height: 90px;  top: 42%; left: 5%;   background: radial-gradient(circle, #F8E8B8, #F0D080); opacity: 0.40; }
.wlc-orb3 { width: 65px;  height: 65px;  top: 20%; left: 24%;  background: radial-gradient(circle, #FDECC0, #F8D898); opacity: 0.50; }

/* Sparkles */
.wlc-sparkle {
  position: absolute;
  font-size: 16px;
  pointer-events: none;
  opacity: 0.6;
  animation: twinkle 3s ease-in-out infinite;
}
.sp1 { top: 12%; left: 15%; animation-delay: 0s;    color: #C89838; }
.sp2 { top: 30%; right: 12%; animation-delay: 0.8s; color: #C8A840; }
.sp3 { top: 8%;  right: 28%; animation-delay: 1.5s; color: #D4A830; font-size: 12px; }
.sp4 { top: 50%; left: 10%; animation-delay: 2.2s;  color: #B88820; }

@keyframes twinkle {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 0.9; transform: scale(1.25); }
}

/* Right panel — desktop only */
.wlc-panel { display: none; }

/* Main content */
.welcome-content {
  position: relative;
  z-index: 2;
  margin: 16px 16px 32px;
  padding: 30px 28px 36px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 28px;
  box-shadow: 0 8px 40px rgba(180, 140, 60, 0.14);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Welcome tagline badge */
.wlc-tagline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(200, 158, 60, 0.12);
  border: 1.5px solid rgba(200, 158, 60, 0.32);
  padding: 6px 14px;
  border-radius: 20px;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 600;
  color: #7A5010;
  letter-spacing: 0.02em;
}
/* Auth screen brand */
.auth-logo {
  width: 120px;
  height: 49px;
  object-fit: contain;
  border-radius: 4px;
}
/* Sidebar / bottom nav logo */
.nav-logo {
  width: 90px;
  height: 37px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

.welcome-content h1 {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.2;
  color: #1A1008;
  letter-spacing: -0.6px;
}

.wlc-sub {
  font-size: 15px;
  color: #3A2810;
  line-height: 1.7;
  max-width: 320px;
}

.wlc-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.wlc-pill {
  background: rgba(255, 248, 230, 0.9);
  border: 1.5px solid rgba(200, 158, 60, 0.28);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #2A1808;
}

/* Streak widget (inside right panel) */
.wlc-streak      { background: rgba(255,255,255,0.88); border-radius: 14px; padding: 14px 18px; }
.streak-label    { font-size: 11px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.streak-dots     { display: flex; gap: 6px; margin-bottom: 6px; }
.s-dot           { width: 28px; height: 28px; border-radius: 8px; background: var(--chip-def); }
.s-filled        { background: linear-gradient(135deg, #C8A860, #E8C880); }
.streak-count    { font-size: 12px; font-weight: 600; color: var(--text); }
.wlc-journal-icon { font-size: 52px; text-align: center; }
.wlc-quote {
  font-size: 13px; color: var(--muted); line-height: 1.65;
  font-style: italic;
  border-left: 3px solid var(--chip-sand); padding-left: 12px;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  transition: opacity 0.15s, transform 0.12s;
  outline: none;
  text-decoration: none;
}
.btn:active { transform: scale(0.96); opacity: 0.82; }

.btn-dark  { background: var(--dark-btn); color: #fff; padding: 16px 28px; font-size: 15px; }
.btn-lg    { padding: 20px 40px; font-size: 16px; }
.btn-sm    { padding: 9px 18px; font-size: 13px; }
.btn-full  { width: 100%; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--dark-btn);
  color: var(--dark-btn);
  padding: 13px 24px;
  font-size: 14px;
  margin-top: 4px;
}

/* Spinner for loading state */
.spinner {
  width: 17px; height: 17px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   AUTH SCREEN
   ============================================= */
.auth-container {
  padding: 56px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100dvh;
}
.auth-header h2  { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.auth-header p   { font-size: 14px; }

.back-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  width: 32px;
  align-self: flex-start;
  line-height: 1;
}

.auth-tabs {
  display: flex;
  background: var(--chip-def);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.tab-active { background: var(--dark-btn); color: #fff; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form.hidden { display: none; }

/* =============================================
   FORM ELEMENTS
   ============================================= */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--muted); }

.form-group input,
.form-group textarea {
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.form-group input:focus,
.form-group textarea:focus  { border-color: #999; }
.form-group textarea        { resize: vertical; }

input[type="date"] { cursor: pointer; }

.error-msg {
  background: #fde8e8;
  color: #c0392b;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}

/* Home streak card */
.home-streak-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 14px 18px;
  margin: 0 20px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.hstreak-left  { display: flex; flex-direction: column; gap: 6px; }
.hstreak-dots  { display: flex; gap: 7px; }
.hstreak-dot-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hstreak-dot {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--chip-def);
  transition: background 0.2s;
}
.hstreak-dot-filled {
  background: linear-gradient(135deg, #C8A860, #E8C048);
  box-shadow: 0 2px 6px rgba(200, 160, 60, 0.35);
}
.hstreak-dot-lbl { font-size: 9px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.hstreak-days { font-size: 11px; color: var(--muted); font-weight: 500; }
.hstreak-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.hstreak-count { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1; }
.hstreak-label { font-size: 12px; font-weight: 500; color: var(--muted); }

/* =============================================
   HOME SCREEN
   ============================================= */
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 52px 20px 14px;
}
.home-header h2 { font-size: 24px; font-weight: 700; }
.home-sub       { font-size: 13px; margin-top: 2px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--chip-def);
  border-radius: 14px;
  padding: 12px 16px;
  margin: 0 20px 14px;
}
.search-bar input {
  border: none; background: transparent;
  font-family: var(--font); font-size: 14px;
  color: var(--text); outline: none; width: 100%;
}
.search-ico { font-size: 15px; opacity: 0.45; flex-shrink: 0; }

/* =============================================
   CHIPS
   ============================================= */
.chips-row {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.chips-row::-webkit-scrollbar { display: none; }

.chip {
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  background: var(--chip-def);
  color: var(--muted);
  transition: background 0.18s, color 0.18s;
}
.chip-active { background: var(--chip-sand); color: #5a4818; }
.chip-blue   { background: var(--chip-sky);  color: #1e4060; }
.chip-sage   { background: var(--chip-sage); color: #2a4a2a; }
.chip-rose   { background: var(--chip-rose); color: #5a2a1a; }

/* =============================================
   ENTRY GRID
   ============================================= */
.entries-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 20px;
}

.entry-card {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  transition: transform 0.18s, box-shadow 0.18s;
}
.entry-card:hover  { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
.entry-card:active { transform: scale(0.97); }

.card-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}
.card-no-img {
  width: 100%;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}
.card-body { padding: 10px 12px 12px; }
.card-date { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.card-desc {
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Pastel gradient pairs for entries without photo */
.grad-0 { background: linear-gradient(140deg, #EEE0B8, #EDD5C5); }
.grad-1 { background: linear-gradient(140deg, #C5D9E8, #C8E0C8); }
.grad-2 { background: linear-gradient(140deg, #EDD5C5, #C5D9E8); }
.grad-3 { background: linear-gradient(140deg, #C8E0C8, #EEE0B8); }
.grad-4 { background: linear-gradient(140deg, #D8C8E8, #C5D9E8); }

.empty-state   { text-align: center; padding: 56px 32px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.empty-icon    { font-size: 52px; margin-bottom: 14px; }

/* =============================================
   DETAIL SCREEN
   ============================================= */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 52px 20px 14px;
}
.top-bar h2 { font-size: 20px; font-weight: 700; }

.icon-btn {
  width: 36px; height: 36px;
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  transition: background 0.15s;
  color: var(--text);
}
.icon-btn:hover { background: var(--chip-def); }
.icon-btn svg   { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.detail-img-wrap {
  margin: 0 20px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.detail-img {
  width: 100%; height: 260px;
  object-fit: cover; display: block;
}
.detail-no-img {
  width: 100%; height: 180px;
  display: flex; align-items: center; justify-content: center;
  font-size: 56px;
  background: linear-gradient(135deg, var(--chip-sand), var(--chip-sky));
}

.detail-body { padding: 20px 20px 12px; }
.detail-top-row {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.detail-top-row h3 { font-size: 16px; font-weight: 600; }
.detail-eye {
  width: 34px; height: 34px;
  background: var(--chip-def); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.detail-eye svg { width: 17px; height: 17px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.detail-desc {
  font-size: 14px; color: var(--muted);
  line-height: 1.75; margin-bottom: 16px;
  white-space: pre-wrap;
}

/* =============================================
   CREATE SCREEN
   ============================================= */
.create-form { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 16px; }

.img-upload-wrap {
  aspect-ratio: 16/9;
  border-radius: var(--radius);
  background: var(--chip-def);
  border: 2px dashed #C8C5C0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.2s;
}
.img-upload-wrap:hover { border-color: #888; }
.img-placeholder { text-align: center; color: var(--muted); user-select: none; }
.upload-icon     { font-size: 38px; display: block; margin-bottom: 8px; }
.img-placeholder p { font-size: 13px; }
.img-preview     { width: 100%; height: 100%; object-fit: cover; }

/* =============================================
   OAUTH BUTTONS
   ============================================= */
.oauth-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.btn-oauth:hover    { background: var(--chip-def); border-color: #ccc; }
.btn-google   {}
.btn-facebook {}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* =============================================
   WELCOME TOPBAR
   ============================================= */
.wlc-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px;
  padding-top: max(20px, env(safe-area-inset-top));
}
.wlc-topbar-logo {
  width: 90px;
  height: 37px;
  object-fit: contain;
}
.wlc-signin-btn {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid rgba(0,0,0,0.18);
  padding: 9px 20px;
  font-size: 13px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.wlc-signin-btn:hover { background: #f5f5f2; }

/* =============================================
   AUTH SHEET
   ============================================= */
.auth-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.auth-sheet-overlay.hidden { display: none; }

.auth-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20,14,7,0.32);
  backdrop-filter: blur(2px);
}

.auth-sheet {
  position: relative;
  z-index: 1;
  background: var(--surface);
  width: 100%;
  max-width: var(--max-w);
  border-radius: 28px 28px 0 0;
  padding: 16px 28px 52px;
  max-height: 90dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: slideUp 0.3s ease;
}

.auth-sheet-grip {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  align-self: center;
  flex-shrink: 0;
}

.auth-sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-sheet-close {
  width: 32px; height: 32px;
  background: var(--chip-def);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s;
}
.auth-sheet-close:hover { background: var(--border); }

/* =============================================
   BOTTOM NAV
   ============================================= */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  z-index: 100;
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  padding: 8px 6px;
  color: var(--muted);
  font-family: var(--font); font-size: 10px; font-weight: 500;
  border-radius: 12px;
  transition: color 0.18s;
}
.nav-btn svg    { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-active     { color: var(--text); }
.nav-icon-wrap  { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.nav-notif-badge {
  position: absolute;
  top: -4px; right: -6px;
  min-width: 16px; height: 16px;
  background: #E53935; color: #fff;
  border-radius: 8px;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--surface);
  padding: 0 3px;
  line-height: 1;
}

/* =============================================
   PROFILE MODAL (BOTTOM SHEET)
   ============================================= */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(2px);
}
.modal-sheet {
  position: relative; z-index: 1;
  background: var(--surface);
  width: 100%; max-width: var(--max-w);
  border-radius: 26px 26px 0 0;
  padding: 16px 28px 52px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: slideUp 0.28s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin-bottom: 18px; align-self: center;
}
.profile-avatar {
  width: 68px; height: 68px; border-radius: 50%;
  background: linear-gradient(135deg, var(--chip-sand), var(--chip-rose));
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #5a4030;
  margin-bottom: 6px;
}
.modal-sheet h3     { font-size: 20px; font-weight: 700; }
.profile-stat {
  background: var(--chip-def); border-radius: 10px;
  padding: 10px 20px; font-size: 13px; color: var(--muted);
  margin: 8px 0 4px;
}

/* =============================================
   PROFILE VIEW
   ============================================= */
.profile-banner {
  background: linear-gradient(140deg, #D8C8E8 0%, #EDD5C5 55%, #EEE0B8 100%);
  padding: 52px 28px 72px;
  display: flex;
  justify-content: center;
  position: relative;
}

.profile-avatar-wrap {
  position: relative;
  width: 96px;
  height: 96px;
}

.profile-page-avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C8A860, #E8C880);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 700; color: #5a4030;
  border: 4px solid rgba(255,255,255,0.85);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.profile-page-avatar-img {
  width: 96px; height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,0.85);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  position: absolute; top: 0; left: 0;
}

.profile-avatar-edit {
  position: absolute; bottom: 0; right: 0;
  width: 32px; height: 32px;
  background: var(--dark-btn); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: opacity 0.15s;
}
.profile-avatar-edit:hover { opacity: 0.82; }

.profile-info-section {
  padding: 24px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-disp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.profile-disp-header h2 { font-size: 22px; font-weight: 700; }

.profile-badge {
  display: inline-block;
  background: var(--chip-sand);
  color: #5a4818;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  align-self: flex-start;
}

.profile-meta {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.profile-stats-row {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.pstat-box {
  flex: 1;
  background: var(--chip-def);
  border-radius: 14px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.pstat-num   { font-size: 24px; font-weight: 700; }
.pstat-label { font-size: 11px; color: var(--muted); font-weight: 500; }

.form-select {
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9' fill='none' stroke='%238A8A8A' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.form-select:focus { border-color: #999; }

.profile-edit-btns {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.profile-edit-btns .btn { flex: 1; }

/* =============================================
   DETAIL SHARE ROW
   ============================================= */
.detail-share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--chip-def);
  border-radius: 12px;
}
.detail-share-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.detail-share-row .chip { cursor: pointer; }
.share-public { background: var(--chip-sage); color: #2a4a2a; }

/* =============================================
   CREATE PUBLIC TOGGLE
   ============================================= */
.public-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--chip-def);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}
.public-toggle-label { flex: 1; font-size: 14px; font-weight: 500; }
.public-toggle-check { display: none; }
.public-toggle-knob {
  width: 44px; height: 26px;
  background: #C8C5C0;
  border-radius: 13px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.public-toggle-knob::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.public-toggle-check:checked + .public-toggle-knob { background: #4CAF50; }
.public-toggle-check:checked + .public-toggle-knob::after { transform: translateX(18px); }

/* =============================================
   TIMELINE
   ============================================= */
.timeline-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tl-loading {
  text-align: center;
  padding: 32px;
}

.tl-card {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 8px;
  border-radius: 0;
}

.tl-author-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
}

.tl-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.tl-avatar-img      { width: 100%; height: 100%; object-fit: cover; }
.tl-avatar-letter   {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--chip-sand), var(--chip-rose));
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; color: #5a4030;
}

.tl-author-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.tl-author-name { font-size: 14px; font-weight: 600; }
.tl-author-streak { font-size: 12px; font-weight: 600; color: #9a6c14; }
.tl-author-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tl-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.tl-own-badge {
  background: var(--chip-sky);
  color: #1e4060;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

.tl-post-img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
}

.tl-body      { padding: 10px 16px 6px; }
.tl-desc {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}

.tl-reactions {
  display: flex;
  gap: 4px;
  padding: 6px 16px 6px;
  flex-wrap: wrap;
}

.tl-react-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--chip-def);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  font-family: var(--font);
}
.tl-react-btn:active   { transform: scale(0.94); }
.tl-react-btn:hover    { border-color: #bbb; }
.tl-react-active       { background: var(--chip-sand); border-color: #c8a850; }
.tl-react-count        { font-size: 12px; font-weight: 600; color: var(--muted); }
.tl-react-active .tl-react-count { color: #5a4818; }

.tl-comments-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 16px 12px;
  transition: color 0.15s;
}
.tl-comments-toggle:hover { color: var(--text); }

.tl-comments-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px 0;
}

.tl-comments-list { display: flex; flex-direction: column; gap: 0; }

.tl-comment {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.tl-comment:last-child { border-bottom: none; }

.tl-reply {
  display: flex;
  gap: 8px;
  padding: 8px 0 8px 20px;
  margin-top: 6px;
}

.tl-comment-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.tl-comment-avatar-img    { width: 100%; height: 100%; object-fit: cover; }
.tl-comment-avatar-letter {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--chip-sky), var(--chip-sage));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #2a4a2a;
}

.tl-comment-body { flex: 1; min-width: 0; }
.tl-comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.tl-comment-name { font-size: 13px; font-weight: 600; }
.tl-comment-time { font-size: 11px; color: var(--muted); flex: 1; }
.tl-comment-del  {
  background: none; border: none; cursor: pointer;
  font-size: 10px; color: var(--muted);
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.tl-comment-del:hover { background: #fde8e8; color: #c0392b; }
.tl-comment-text { font-size: 13px; line-height: 1.5; }

.tl-reply-btn {
  background: none; border: none; cursor: pointer;
  font-size: 11px; font-weight: 600; color: var(--muted);
  padding: 4px 0; margin-top: 2px;
  font-family: var(--font);
  transition: color 0.15s;
}
.tl-reply-btn:hover { color: var(--text); }

.tl-reply-input-row,
.tl-comment-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.tl-reply-input-row { border-top: none; margin-top: 6px; padding-top: 6px; }

.tl-comment-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.tl-comment-input:focus { border-color: #999; }

.tl-comment-send {
  width: 34px; height: 34px;
  background: var(--dark-btn); color: #fff;
  border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.tl-comment-send:hover { opacity: 0.82; }

.tl-no-comments { font-size: 13px; color: var(--muted); padding: 8px 0 12px; }
.tl-load-msg    { font-size: 13px; color: var(--muted); padding: 8px 0; }

/* =============================================
   DESKTOP OVERRIDES FOR NEW VIEWS
   ============================================= */
@media (min-width: 768px) {
  .tl-card { border-radius: var(--radius); border: 1px solid var(--border); }
  .timeline-feed { gap: 16px; padding: 0 0 24px; }
}

.fullscreen {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.fullscreen.hidden { display: none; }
.fullscreen img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* =============================================
   TOAST
   ============================================= */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 14px);
  left: 50%; transform: translateX(-50%) translateY(12px);
  background: #1a1a1a; color: #fff;
  padding: 11px 20px; border-radius: 22px;
  font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity 0.28s, transform 0.28s;
  z-index: 400; pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =============================================
   UTILITIES
   ============================================= */
.hidden       { display: none !important; }
.text-muted   { color: var(--muted); font-size: 14px; }
.nav-brand    { display: none; }

/* =============================================
   MOBILE: subtle outer shadow
   ============================================= */
@media (min-width: 500px) and (max-width: 767px) {
  body { background: #D0CCBF; align-items: flex-start; }
  .view { box-shadow: 0 0 60px rgba(0,0,0,0.16); }
}

/* =============================================
   DESKTOP LAYOUT  (≥ 768px)
   ============================================= */
@media (min-width: 768px) {
  :root { --sidebar-w: 230px; }

  body { background: #E8E3DC; display: block; }

  /* Views fill full browser width */
  .view         { max-width: none; width: 100%; box-shadow: none; overflow: visible; }
  .view.active  { display: block; }

  /* Welcome needs flex for two-column layout */
  #view-welcome.active { display: flex; }

  /* ── Sidebar navigation ── */
  .bottom-nav {
    position: fixed;
    left: 0; top: 0; bottom: auto;
    width: var(--sidebar-w);
    height: 100dvh;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 0 16px 28px;
    border-top: none;
    border-right: 1px solid var(--border);
    gap: 4px;
    transform: none;
    max-width: var(--sidebar-w);
    overflow-y: auto;
  }

  .nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 26px 12px 18px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    width: 100%;
    flex-shrink: 0;
  }
  .nav-brand .nav-logo { width: 100px; height: 41px; border-radius: 4px; }

  .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 500;
    gap: 12px;
    border-radius: 12px;
  }
  .nav-btn:hover { background: var(--chip-def); color: var(--text); }
  .nav-active    { background: var(--chip-sand); color: #5a4818; }
  .nav-btn svg   { width: 20px; height: 20px; flex-shrink: 0; }

  /* ── Content area ── */
  .screen {
    margin-left: var(--sidebar-w);
    padding: 0 52px 52px;
    overflow-y: visible;
    min-height: 100dvh;
  }

  .home-header     { padding-top: 44px; padding-left: 0; padding-right: 0; }
  .home-streak-card { margin-left: 0; margin-right: 0; }
  .search-bar      { margin-left: 0; margin-right: 0; }
  .chips-row       { padding-left: 0; padding-right: 0; }
  .entries-grid    { padding-left: 0; padding-right: 0; grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .top-bar         { padding-top: 44px; padding-left: 0; padding-right: 0; }
  .detail-img-wrap { margin-left: 0; margin-right: 0; }
  .detail-img      { height: 380px; }
  .detail-body     { padding-left: 0; padding-right: 0; }
  .create-form     { padding-left: 0; padding-right: 0; max-width: 640px; }

  /* ── Welcome — two column ── */
  #view-welcome { flex-direction: row; align-items: stretch; max-width: none; }

  .welcome-content {
    flex: 0 0 50%;
    padding: 0 64px;
    justify-content: center;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    gap: 26px;
  }
  .welcome-content h1 { font-size: 50px; }
  .wlc-sub   { font-size: 15px; max-width: 400px; }
  .wlc-brand-pill { padding: 8px 12px; }
  .wlc-logo        { width: 120px; height: 49px; }
  .btn-lg    { padding: 18px 44px; font-size: 17px; align-self: flex-start; }
  .wlc-sun   { left: 25%; width: 220px; height: 220px; }

  .wlc-panel {
    flex: 0 0 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 52px;
    background: rgba(255, 244, 215, 0.35);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1.5px solid rgba(255,255,255,0.65);
  }
  .wlc-panel-inner {
    display: flex;
    flex-direction: column;
    gap: 22px;
    max-width: 300px;
    width: 100%;
    background: rgba(255, 255, 255, 0.78);
    border: 1.5px solid rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    padding: 28px 24px;
    box-shadow: 0 8px 36px rgba(180, 140, 60, 0.14);
  }

  /* ── Auth sheet — centered modal ── */
  .auth-sheet-overlay { align-items: center; }
  .auth-sheet {
    border-radius: 24px;
    max-width: 480px;
    padding: 44px 48px 52px;
    box-shadow: 0 20px 70px rgba(0,0,0,0.13);
    max-height: 90dvh;
  }
  .auth-sheet-grip { display: none; }

  /* ── Profile modal — centered ── */
  .modal       { align-items: center; }
  .modal-sheet { border-radius: 24px; max-width: 420px; padding-bottom: 36px; }

  .toast { bottom: 28px; }
}

@media (min-width: 1100px) {
  :root { --sidebar-w: 252px; }
  .entries-grid { grid-template-columns: repeat(4, 1fr); }
  .screen { padding: 0 68px 68px; }
}

@media (max-width: 360px) {
  .welcome-content h1 { font-size: 26px; }
  .entries-grid       { grid-template-columns: 1fr; }
}

/* =============================================
   NOTIFICATION BELL + BADGE
   ============================================= */
.notif-bell {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 150;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: box-shadow 0.15s;
  padding: 0;
}
.notif-bell:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.notif-bell svg   { stroke: var(--text); }

.notif-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 18px; height: 18px;
  background: #E53935;
  color: #fff;
  border-radius: 9px;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  padding: 0 4px;
  line-height: 1;
}

/* =============================================
   NOTIFICATION OVERLAY + SHEET
   ============================================= */
.notif-overlay {
  position: fixed; inset: 0;
  z-index: 300;
  display: flex; align-items: flex-end; justify-content: center;
}
.notif-overlay-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.notif-sheet {
  position: relative; z-index: 1;
  background: var(--surface);
  width: 100%; max-width: var(--max-w);
  border-radius: 28px 28px 0 0;
  max-height: 75dvh;
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideUp 0.3s ease;
}
.notif-grip {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 14px auto 0;
  flex-shrink: 0;
}
.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-header h3 { font-size: 17px; font-weight: 700; }
.notif-mark-btn  {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--muted);
  font-family: var(--font);
  transition: color 0.15s;
}
.notif-mark-btn:hover { color: var(--text); }
.notif-list { flex: 1; overflow-y: auto; padding-bottom: 40px; }
.notif-item {
  display: flex; gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.notif-unread { background: #fafaf5; }
.notif-item-body { flex: 1; font-size: 13px; line-height: 1.5; }
.notif-item-body p { margin-bottom: 3px; }
.notif-item-time  { font-size: 11px; color: var(--muted); }
.notif-empty { padding: 40px 20px; text-align: center; font-size: 14px; color: var(--muted); }

/* =============================================
   HOME CARD PUBLIC INDICATOR
   ============================================= */
.card-public-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
}
.card-pub-badge   { font-size: 12px; }
.card-social-count { font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }

@media (min-width: 768px) {
  .notif-bell { right: 24px; top: 20px; }
  .notif-sheet { border-radius: 20px; margin-bottom: 24px; }
  .notif-overlay { align-items: center; }
}
