:root{
  --navy:         #16324F;
  --navy-700:     #1E3A5F;
  --teal:         #2E86AB;
  --teal-100:     #E4F1F6;
  --teal-200:     #C7E3ED;
  --bg:           #F4F6F8;
  --paper:        #FFFFFF;
  --ink:          #212B36;
  --ink-soft:     #637083;
  --ink-faint:    #9AA5B1;
  --line:         #E3E8EE;
  --amber:        #C9862A;
  --amber-100:    #FBF0DE;
  --red:          #C25450;
  --red-100:      #FBEAE9;
  --shadow:       0 10px 30px -12px rgba(22,50,79,0.25);
  --shadow-soft:  0 4px 14px -6px rgba(22,50,79,0.14);
  --radius-lg:    22px;
  --radius-md:    16px;
  --radius-sm:    12px;
  --radius-pill:  999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; background:var(--bg); }
body{ font-family:var(--font); color:var(--ink); -webkit-tap-highlight-color:transparent; }
button, input, textarea, select{ font-family:inherit; }
img{ max-width:100%; }
.icon{ width:20px; height:20px; stroke:currentColor; stroke-width:2; fill:none; stroke-linecap:round; stroke-linejoin:round; }

.app-shell{
  max-width:460px; margin:0 auto; min-height:100vh; background:var(--bg);
  position:relative; display:flex; flex-direction:column; overflow:hidden;
}
@media (min-width:461px){
  body{ display:flex; justify-content:center; padding:0; background:#E7EBEF; }
}

.screen{ display:none; flex-direction:column; flex:1; min-height:0; animation:fadeIn .3s ease; }
.screen.active{ display:flex; }
@keyframes fadeIn{ from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:none;} }
.screen-scroll{ flex:1; overflow-y:auto; padding:0 20px 100px; -webkit-overflow-scrolling:touch; }

/* ============ SPLASH ============ */
#screen-splash{ align-items:center; justify-content:center; background:var(--navy); }
.splash-hero{ text-align:center; color:#fff; padding:0 30px; }
.splash-mark{ display:flex; justify-content:center; margin-bottom:16px; }
.splash-hero h1{ font-size:26px; margin:0 0 6px; }
.splash-hero p{ font-size:14px; opacity:.8; margin:0; }

/* ============ AUTH ============ */
.auth-wrap{ padding:calc(40px + env(safe-area-inset-top)) 28px 40px; display:flex; flex-direction:column; align-items:center; text-align:center; }
.auth-wrap h2{ font-size:22px; margin:0 0 4px; color:var(--navy); }
.auth-sub{ font-size:13.5px; color:var(--ink-soft); margin:0 0 20px; }
.auth-wrap > *{ width:100%; }
.form-field-label{ font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.4px; color:var(--ink-faint); display:block; margin-bottom:5px; text-align:left; }
.text-input{
  width:100%; border:1.5px solid var(--line); border-radius:var(--radius-sm); padding:12px 14px;
  font-size:14.5px; background:var(--paper); color:var(--ink);
}
.text-input:focus{ outline:none; border-color:var(--teal); }
select.text-input{ appearance:none; -webkit-appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23637083' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; background-size:16px; }
.remember-row{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--ink-soft); justify-content:flex-start; }
.auth-row-between{ display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.auth-row-between a{ font-size:12.5px; color:var(--teal); font-weight:700; text-decoration:none; margin-top:14px; }
.auth-error{ background:var(--red-100); color:var(--red); border-radius:var(--radius-sm); padding:10px 12px; font-size:13px; margin-top:12px; text-align:left; }
.auth-switch{ margin-top:16px; font-size:13.5px; color:var(--ink-soft); }
.auth-switch a{ color:var(--teal); font-weight:700; text-decoration:none; margin-left:4px; }

.btn{ border:none; border-radius:var(--radius-pill); padding:13px 22px; font-size:15px; font-weight:700; cursor:pointer; width:100%; }
.btn-primary{ background:var(--navy); color:#fff; }
.btn-secondary{ background:var(--paper); color:var(--navy); border:1.5px solid var(--line); }
.btn-sm{ padding:9px 16px; font-size:13.5px; width:auto; }
.btn-icon{ background:none; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; padding:6px; color:var(--navy); }

/* ============ TOPBAR / NAV ============ */
.topbar{ padding:calc(18px + env(safe-area-inset-top)) 20px 6px; }
.topbar h1{ font-size:22px; margin:0; color:var(--navy); }
.seg-tabs{ display:flex; gap:8px; padding:12px 20px 4px; }
.seg-tab{
  flex:1; background:var(--paper); border:1.5px solid var(--line); border-radius:var(--radius-pill);
  padding:9px 10px; font-size:13px; font-weight:700; color:var(--ink-soft); cursor:pointer;
}
.seg-tab.active{ background:var(--navy); border-color:var(--navy); color:#fff; }

.bottom-nav{
  position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:460px;
  display:flex; background:var(--paper); border-top:1px solid var(--line);
  padding:9px 2px calc(9px + env(safe-area-inset-bottom)); z-index:20;
}
.nav-item{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:3px;
  background:none; border:none; cursor:pointer; color:var(--ink-faint); font-size:10.5px; font-weight:700;
  padding:4px 1px;
}
.nav-item.active{ color:var(--teal); }
.nav-item .icon{ width:21px; height:21px; }

/* ============ SHARE BOX / POSTS ============ */
.share-box{ margin:0 20px 14px; background:var(--paper); border-radius:var(--radius-md); box-shadow:var(--shadow-soft); padding:14px; }
.share-footer{ display:flex; align-items:center; gap:8px; margin-top:10px; }
.share-fab-wrap{
  position:fixed; left:50%; transform:translateX(-50%); width:100%; max-width:460px;
  bottom:calc(78px + env(safe-area-inset-bottom)); pointer-events:none; z-index:15;
}
.share-fab{
  position:absolute; right:20px; bottom:0; pointer-events:auto; width:52px; height:52px; border-radius:50%;
  background:var(--teal); border:none; box-shadow:var(--shadow); cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.media-preview-box{ position:relative; border-radius:var(--radius-sm); overflow:hidden; margin-top:10px; aspect-ratio:16/10; background:var(--bg); }
.media-preview-box img{ width:100%; height:100%; object-fit:cover; display:block; }
.media-remove-btn{
  position:absolute; top:16px; right:16px; width:26px; height:26px; border-radius:50%;
  background:rgba(20,30,45,0.65); border:none; cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.media-preview-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:10px; }
.media-preview-item{ position:relative; border-radius:var(--radius-sm); overflow:hidden; aspect-ratio:1; background:var(--bg); }
.media-preview-item img{ width:100%; height:100%; object-fit:cover; display:block; }
.media-preview-item .media-remove-btn{ top:6px; right:6px; width:22px; height:22px; }

/* Multi-photo grid on a post — 1 photo is a single tall image; 2+ share a
   compact square grid, with a "+N" overlay if there are more than 4. */
.post-photos{ display:grid; gap:4px; border-radius:var(--radius-sm); overflow:hidden; margin-top:10px; }
.post-photos.count-1{ grid-template-columns:1fr; }
.post-photos.count-2,
.post-photos.count-3,
.post-photos.count-4{ grid-template-columns:1fr 1fr; }
.post-photo-tile{ position:relative; cursor:pointer; overflow:hidden; background:var(--bg); aspect-ratio:1; }
.post-photos.count-1 .post-photo-tile{ aspect-ratio:16/10; max-height:340px; }
.post-photo-tile img{ width:100%; height:100%; object-fit:cover; display:block; }
.post-photo-more{
  position:absolute; inset:0; background:rgba(10,18,28,0.55); color:#fff; font-size:20px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
}

.post-card{ background:var(--paper); border-radius:var(--radius-md); box-shadow:var(--shadow-soft); padding:16px; margin-bottom:14px; }
.post-head{ display:flex; align-items:center; gap:10px; }
.avatar{ width:38px; height:38px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; color:#fff; font-size:14px; flex-shrink:0; overflow:hidden; background:var(--navy); }
.avatar.avatar-photo img{ width:100%; height:100%; object-fit:cover; }
.post-head-name{ font-weight:700; font-size:14px; color:var(--ink); }
.post-head-meta{ font-size:11.5px; color:var(--ink-faint); }
.dept-badge{ display:inline-block; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.3px; background:var(--teal-100); color:var(--navy-700); padding:2px 9px; border-radius:var(--radius-pill); margin-left:6px; }
.post-text{ font-size:14.5px; line-height:1.5; margin-top:10px; white-space:pre-wrap; }
.post-photo{ margin-top:10px; border-radius:var(--radius-sm); overflow:hidden; cursor:pointer; }
.post-photo img{ width:100%; display:block; max-height:340px; object-fit:cover; }
.post-actions{ display:flex; align-items:center; gap:18px; margin-top:12px; padding-top:10px; border-top:1px solid var(--line); }
.post-actions button{ background:none; border:none; display:flex; align-items:center; gap:6px; color:var(--ink-soft); font-size:13px; font-weight:600; cursor:pointer; padding:2px; }
.post-actions button.liked{ color:var(--red); }
.post-actions .icon{ width:18px; height:18px; }
.comment-thread{ margin-top:10px; }
.comment-item{ font-size:13px; margin-top:6px; line-height:1.4; }
.comment-item b{ color:var(--ink); }
.comment-input-row{ display:flex; gap:8px; margin-top:10px; }
.comment-input-row input{ flex:1; }
.empty-state{ text-align:center; color:var(--ink-faint); font-size:13.5px; padding:50px 20px; }
.delete-post-btn{ margin-left:auto; background:none; border:none; color:var(--ink-faint); cursor:pointer; padding:4px; }

/* ============ PROFILE ============ */
.profile-head{ display:flex; align-items:center; gap:14px; padding:calc(22px + env(safe-area-inset-top)) 20px 6px; }
.profile-avatar-wrap{ position:relative; flex-shrink:0; }
.profile-avatar{ width:76px; height:76px; border-radius:50%; background:var(--teal-100); display:flex; align-items:center; justify-content:center; overflow:hidden; }
.profile-avatar img{ width:100%; height:100%; object-fit:cover; display:block; }
.avatar-edit-btn{
  position:absolute; bottom:-2px; right:-2px; width:26px; height:26px; border-radius:50%;
  background:var(--navy); border:2px solid var(--bg); display:flex; align-items:center; justify-content:center; cursor:pointer; padding:0;
}
.profile-head h2{ font-size:19px; margin:0; color:var(--navy); }
.profile-name-row{ display:flex; align-items:center; gap:7px; }
.profile-edit-btn{ background:none; border:none; color:var(--ink-faint); cursor:pointer; padding:2px; display:inline-flex; }
.profile-meta{ font-size:13px; color:var(--ink-soft); margin:2px 0 0; }
.profile-email-hint{ display:block; font-size:12px; color:var(--teal); font-weight:700; text-decoration:none; margin-top:4px; }
.prompt-card{ background:var(--paper); border-radius:var(--radius-md); box-shadow:var(--shadow-soft); padding:16px; }
.prompt-footer{ display:flex; gap:10px; margin-top:14px; }

.section-label{ font-size:11.5px; text-transform:uppercase; letter-spacing:1.2px; color:var(--ink-faint); font-weight:700; margin:20px 0 10px; }
.mood-card{ background:var(--paper); border-radius:var(--radius-lg); box-shadow:var(--shadow-soft); padding:18px; text-align:center; }
.mood-question{ font-size:14.5px; font-weight:700; color:var(--navy); margin:0 0 14px; }
.mood-options{ display:flex; justify-content:space-between; }
.mood-btn{ border:none; background:var(--bg); font-size:22px; width:44px; height:44px; border-radius:50%; cursor:pointer; transition:transform .15s; }
.mood-btn.active{ background:var(--teal-200); transform:scale(1.12); }
.mood-logged-note{ font-size:12px; color:var(--teal); font-weight:700; margin:12px 0 0; }

.mood-chart-card{ background:var(--paper); border-radius:var(--radius-lg); padding:18px; box-shadow:var(--shadow-soft); }
.mood-chart{ display:flex; align-items:flex-end; gap:4px; height:110px; }
.mood-bar{ flex:1; border-radius:4px 4px 2px 2px; min-height:4px; }
.mgr-chart-hint{ font-size:11.5px; color:var(--ink-faint); margin:10px 0 0; line-height:1.4; }

.settings-card{ background:var(--paper); border-radius:var(--radius-md); box-shadow:var(--shadow-soft); padding:15px 16px; }
.settings-row{ display:flex; align-items:center; gap:14px; }
.settings-row span{ font-size:14px; font-weight:600; color:var(--ink); }
.settings-hint{ font-size:12px; color:var(--ink-faint); margin:3px 0 0; line-height:1.4; }

.named-mood-row{ display:flex; align-items:center; justify-content:space-between; background:var(--paper); border-radius:var(--radius-sm); padding:11px 14px; margin-bottom:8px; box-shadow:var(--shadow-soft); }
.named-mood-row .who{ font-size:13.5px; font-weight:600; }
.named-mood-row .when{ font-size:11.5px; color:var(--ink-faint); }
.named-mood-row .emoji{ font-size:19px; }

.list-row{ display:flex; align-items:center; gap:12px; background:var(--paper); border-radius:var(--radius-md); padding:14px 16px; margin-bottom:10px; box-shadow:var(--shadow-soft); cursor:pointer; }
.list-row .icon{ color:var(--navy); }
.list-row span{ flex:1; font-size:14px; font-weight:600; }

.switch{ width:46px; height:26px; border-radius:var(--radius-pill); background:var(--line); border:none; position:relative; cursor:pointer; flex-shrink:0; padding:0; }
.switch-knob{ position:absolute; top:2px; left:2px; width:22px; height:22px; border-radius:50%; background:#fff; transition:left .18s; box-shadow:0 1px 3px rgba(0,0,0,.2); }
.switch.on{ background:var(--teal); }
.switch.on .switch-knob{ left:22px; }

/* ============ LIGHTBOX ============ */
.lightbox-overlay{ position:fixed; inset:0; background:rgba(10,18,28,0.94); z-index:200; display:flex; align-items:center; justify-content:center; }
.lightbox-image{ max-width:92vw; max-height:88vh; object-fit:contain; border-radius:6px; }
.lightbox-close{ position:absolute; top:calc(18px + env(safe-area-inset-top)); right:18px; background:rgba(255,255,255,0.15); border:none; width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.lightbox-nav{
  position:absolute; top:50%; transform:translateY(-50%); background:rgba(255,255,255,0.15); border:none;
  width:42px; height:42px; border-radius:50%; display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.lightbox-nav.lightbox-prev{ left:10px; }
.lightbox-nav.lightbox-next{ right:10px; }
.lightbox-counter{
  position:absolute; bottom:calc(22px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%);
  background:rgba(255,255,255,0.15); color:#fff; font-size:12.5px; font-weight:700; padding:5px 14px; border-radius:var(--radius-pill);
}

/* ============ TOAST ============ */
.toast{
  position:fixed; left:50%; bottom:100px; transform:translateX(-50%) translateY(20px);
  background:var(--navy); color:#fff; padding:11px 20px; border-radius:var(--radius-pill);
  font-size:13.5px; font-weight:600; opacity:0; pointer-events:none; transition:opacity .25s, transform .25s; z-index:300; max-width:85%; text-align:center;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
