@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&family=Caveat:wght@600;700&display=swap');

:root{
  --sage:        #8BA177;
  --sage-dark:    #6E8861;
  --sage-deep:    #566B4B;
  --cream:        #F6F1E3;
  --cream-soft:   #EFE7D2;
  --ink:          #2E3324;
  --ink-soft:     #5B5F4C;
  --coral:        #E2725B;
  --coral-soft:   #F0A98D;
  --gold:         #E0AC4C;
  --line:         rgba(46,51,36,.12);
  --shadow:       0 14px 30px -12px rgba(46,51,36,.35);
  --shadow-sm:    0 6px 16px -8px rgba(46,51,36,.3);
  --radius-lg:    28px;
  --radius-md:    20px;
  --radius-sm:    14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{height:100%;}
body{
  margin:0;
  font-family:'Nunito',system-ui,sans-serif;
  background:var(--cream);
  color:var(--ink);
  overscroll-behavior-y:none;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;}
textarea,input{font-family:inherit;}
.hidden{display:none !important;}
.tag{font-family:'Caveat',cursive;}

::-webkit-scrollbar{display:none;}

/* ---------- layout shells ---------- */
#app{position:relative; min-height:100vh; display:flex; flex-direction:column;}
.screen{
  flex:1; display:flex; flex-direction:column;
  padding: calc(var(--safe-top) + 16px) 18px calc(86px + var(--safe-bottom)) 18px;
  animation: screenIn .32s cubic-bezier(.22,.9,.32,1);
}
@keyframes screenIn{ from{opacity:0; transform:translateY(10px);} to{opacity:1; transform:none;} }

/* ---------- splash ---------- */
#screen-splash{
  position:fixed; inset:0; z-index:50;
  display:flex; align-items:center; justify-content:center;
  padding:24px;
  background:
    radial-gradient(circle at 14% 18%, rgba(255,255,255,.16), transparent 38%),
    radial-gradient(circle at 86% 82%, rgba(0,0,0,.10), transparent 45%),
    linear-gradient(160deg, var(--sage) 0%, var(--sage-dark) 60%, var(--sage-deep) 100%);
  overflow:hidden;
  transition:opacity .5s ease, visibility .5s ease;
}
#screen-splash.fade-out{opacity:0; visibility:hidden; pointer-events:none;}
.splash-spatter{position:absolute; inset:0; opacity:.5; mix-blend-mode:soft-light;}
.splash-card{
  position:relative; z-index:2;
  background:var(--cream);
  border-radius:32px;
  padding:38px 28px 32px;
  width:100%; max-width:340px;
  text-align:center;
  filter:url(#roughPaper);
  box-shadow:0 30px 60px -20px rgba(0,0,0,.45);
}
.splash-eyebrow{
  font-family:'Caveat',cursive; font-size:22px; color:var(--coral);
  transform:rotate(-3deg); display:inline-block; margin-bottom:2px; font-weight:700;
}
.splash-title{
  font-size:34px; line-height:1.08; font-weight:900; margin:4px 0 10px;
  color:var(--ink);
}
.splash-title span{display:block; position:relative;}
.splash-underline{position:absolute; left:-4px; right:-4px; bottom:-6px; height:14px; z-index:-1;}
.splash-sub{font-size:15.5px; color:var(--ink-soft); line-height:1.5; margin:0 6px 26px;}
.splash-dots{display:flex; gap:8px; justify-content:center; margin-bottom:22px; height:10px;}
.splash-dots span{width:9px; height:9px; border-radius:50%; background:var(--sage); opacity:.35; animation:dotPulse 1.1s infinite ease-in-out;}
.splash-dots span:nth-child(2){animation-delay:.15s;}
.splash-dots span:nth-child(3){animation-delay:.3s;}
@keyframes dotPulse{0%,80%,100%{opacity:.3; transform:scale(.85);} 40%{opacity:1; transform:scale(1.15);}}
.splash-go{display:none;}
.splash-go.ready{display:inline-flex;}

/* ---------- buttons ---------- */
.btn{
  appearance:none; border:none; cursor:pointer;
  font-weight:800; font-size:16px; letter-spacing:.2px;
  border-radius:999px; padding:15px 26px;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  transition:transform .15s ease, box-shadow .15s ease, opacity .15s ease;
  -webkit-user-select:none; user-select:none;
}
.btn:active{transform:scale(.96);}
.btn-primary{background:var(--coral); color:var(--cream); box-shadow:0 10px 22px -8px rgba(226,114,91,.55);}
.btn-primary:active{box-shadow:0 4px 10px -4px rgba(226,114,91,.55);}
.btn-ghost{background:var(--cream-soft); color:var(--ink); border:2px solid var(--line);}
.btn-dark{background:var(--ink); color:var(--cream);}
.btn-block{width:100%;}
.btn-sm{padding:10px 18px; font-size:14px;}
.btn:disabled{opacity:.45; pointer-events:none;}
.btn-icon{width:42px; height:42px; padding:0; border-radius:50%; background:var(--cream-soft); flex:0 0 auto;}

/* ---------- topbar ---------- */
.topbar{display:flex; align-items:center; justify-content:space-between; margin-bottom:18px;}
.hello{display:flex; align-items:center; gap:11px;}
.avatar{
  width:46px; height:46px; border-radius:50%; background:var(--sage);
  color:var(--cream); display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:18px; overflow:hidden; flex:0 0 auto;
  box-shadow:var(--shadow-sm);
}
.avatar img{width:100%; height:100%; object-fit:cover;}
.hello-text .greet{font-size:13.5px; color:var(--ink-soft); font-weight:700;}
.hello-text .name{font-size:19px; font-weight:900; line-height:1.15;}
.admin-entry{
  width:42px; height:42px; border-radius:50%; background:var(--cream-soft); border:none;
  display:flex; align-items:center; justify-content:center; color:var(--ink-soft); cursor:pointer; flex:0 0 auto;
}
.admin-entry svg{width:20px; height:20px;}

/* ---------- cards ---------- */
.card{
  background:#fff; border-radius:var(--radius-lg); padding:20px;
  box-shadow:var(--shadow-sm); position:relative; overflow:hidden;
}
.hero{
  background:linear-gradient(150deg, var(--sage) 0%, var(--sage-dark) 100%);
  color:var(--cream); border-radius:var(--radius-lg);
  padding:24px 22px 22px; margin-bottom:16px; position:relative; overflow:hidden;
  box-shadow:var(--shadow);
}
.hero::after{
  content:''; position:absolute; right:-30px; top:-30px; width:140px; height:140px;
  background:radial-gradient(circle, rgba(255,255,255,.16), transparent 70%);
}
.hero-tag{font-family:'Caveat',cursive; font-size:20px; font-weight:700; opacity:.92; transform:rotate(-2deg); display:inline-block;}
.hero h2{font-size:23px; margin:2px 0 8px; font-weight:900;}
.hero p{margin:0 0 18px; font-size:14.5px; opacity:.92; line-height:1.45; max-width:30ch;}

.mood-row{display:flex; gap:6px; margin-top:14px;}
.mood-chip{
  flex:1; background:rgba(255,255,255,.14); border:1.5px solid rgba(255,255,255,.28);
  border-radius:14px; padding:11px 2px; text-align:center; cursor:pointer;
  font-size:11px; font-weight:800; line-height:1.25; letter-spacing:.1px;
  min-height:44px; display:flex; align-items:center; justify-content:center;
  transition:transform .15s ease, background .15s ease;
}
.mood-chip:active{transform:scale(.92);}
.mood-chip[data-mood="great"]{background:rgba(255,255,255,.30);}
.mood-chip[data-mood="good"]{background:rgba(255,255,255,.20);}
.mood-chip[data-mood="meh"]{background:rgba(255,255,255,.12);}
.mood-chip[data-mood="bad"]{background:rgba(226,114,91,.28);}
.mood-chip[data-mood="awful"]{background:rgba(226,114,91,.48);}

.section-title{font-size:17px; font-weight:900; margin:22px 0 12px; display:flex; align-items:center; gap:8px;}
.section-title .scribble{flex:0 0 auto;}

.grid-nav{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.nav-card{
  background:#fff; border-radius:var(--radius-md); padding:16px 14px;
  box-shadow:var(--shadow-sm); cursor:pointer; text-align:left;
  border:2px solid transparent; transition:transform .15s ease, border-color .15s ease;
  display:flex; flex-direction:column; gap:10px;
}
.nav-card:active{transform:scale(.96);}
.nav-card .ic{
  width:42px; height:42px; border-radius:13px; display:flex; align-items:center; justify-content:center;
}
.nav-card .ic svg{width:24px; height:24px;}
.nav-card .label{font-weight:800; font-size:14.5px; line-height:1.25;}
.nav-card .sub{font-size:12px; color:var(--ink-soft); font-weight:600;}
.ic-sage{background:#E7EEE0; color:var(--sage-deep);}
.ic-coral{background:#FBE3DB; color:var(--coral);}
.ic-gold{background:#FBEAD0; color:var(--gold);}
.ic-ink{background:var(--cream-soft); color:var(--ink);}

.mini-list{display:flex; flex-direction:column; gap:10px; margin-top:8px;}
.mini-empty{
  text-align:center; padding:26px 16px; color:var(--ink-soft); font-size:14px; font-weight:600;
  background:var(--cream-soft); border-radius:var(--radius-md);
}

/* ---------- bottom nav ---------- */
.tabbar{
  position:fixed; left:0; right:0; bottom:0; z-index:40;
  display:flex; justify-content:space-around; align-items:center;
  background:rgba(246,241,227,.92); backdrop-filter:blur(14px);
  border-top:1px solid var(--line);
  padding:9px 6px calc(9px + var(--safe-bottom));
}
.tab{
  display:flex; flex-direction:column; align-items:center; gap:3px;
  background:none; border:none; color:var(--ink-soft); cursor:pointer;
  padding:4px 10px; border-radius:14px; transition:color .15s ease;
  flex:1; max-width:78px;
}
.tab svg{width:23px; height:23px;}
.tab span{font-size:10.5px; font-weight:800;}
.tab.active{color:var(--sage-deep);}
.tab.active .tab-dot{opacity:1; transform:scale(1);}
.tab-dot{width:4px; height:4px; border-radius:50%; background:var(--coral); opacity:0; transform:scale(0); transition:.15s ease;}

/* ---------- diary wizard ---------- */
.wizard-head{display:flex; align-items:center; gap:12px; margin-bottom:18px;}
.steps{display:flex; gap:6px; flex:1;}
.step-dot{height:7px; flex:1; border-radius:99px; background:var(--line);}
.step-dot.done{background:var(--sage);}
.step-dot.now{background:var(--coral);}

.step-card{background:#fff; border-radius:var(--radius-lg); padding:22px; box-shadow:var(--shadow-sm); flex:1; display:flex; flex-direction:column;}
.step-kicker{font-family:'Caveat',cursive; color:var(--coral); font-size:19px; font-weight:700; margin-bottom:2px;}
.step-q{font-size:20px; font-weight:900; margin:0 0 6px; line-height:1.25;}
.step-hint{font-size:13.5px; color:var(--ink-soft); margin:0 0 16px; line-height:1.45;}

.field{
  width:100%; border:2px solid var(--line); border-radius:16px;
  padding:13px 14px; font-size:15px; line-height:1.45; background:var(--cream-soft); color:var(--ink);
}
textarea.field{min-height:108px; resize:vertical;}
.field:focus{outline:none; border-color:var(--sage);}

.chips{display:flex; flex-wrap:wrap; gap:8px; margin:4px 0 6px;}
.chip{
  border:2px solid var(--line); background:#fff; border-radius:999px; padding:9px 14px;
  font-size:13.5px; font-weight:700; cursor:pointer; color:var(--ink-soft);
  transition:all .15s ease;
}
.chip.selected{background:var(--sage); border-color:var(--sage); color:#fff;}
.chip.coral.selected{background:var(--coral); border-color:var(--coral);}
.chip-info{font-size:11px; opacity:.7; font-weight:600; display:block; margin-top:1px;}

.slider-wrap{margin:18px 0 6px;}
.slider-labels{display:flex; justify-content:space-between; font-size:12px; color:var(--ink-soft); font-weight:700; margin-bottom:6px;}
input[type=range]{
  -webkit-appearance:none; width:100%; height:10px; border-radius:99px;
  background:linear-gradient(90deg, var(--sage), var(--coral));
  outline:none;
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; width:26px; height:26px; border-radius:50%; background:#fff;
  border:4px solid var(--ink); cursor:pointer; box-shadow:0 4px 10px rgba(0,0,0,.25);
}
.slider-val{text-align:center; font-size:30px; font-weight:900; margin-top:8px; color:var(--ink);}

.hint-card{background:var(--cream-soft); border-radius:16px; padding:14px 15px; margin-bottom:14px;}
.hint-card .h-title{font-size:12.5px; font-weight:800; color:var(--sage-deep); margin:0 0 6px; text-transform:uppercase; letter-spacing:.4px;}
.hint-card ul{margin:0; padding-left:18px; font-size:13.5px; line-height:1.6; color:var(--ink-soft);}

.compare-bars{display:flex; gap:18px; margin:16px 0 4px; align-items:flex-end;}
.compare-col{flex:1; text-align:center;}
.compare-track{height:90px; width:100%; background:var(--cream-soft); border-radius:12px; display:flex; align-items:flex-end; overflow:hidden;}
.compare-fill{width:100%; border-radius:12px;}
.compare-col .cv-num{font-weight:900; font-size:19px; margin-top:6px;}
.compare-col .cv-lbl{font-size:11.5px; color:var(--ink-soft); font-weight:700;}

.wizard-actions{display:flex; gap:10px; margin-top:18px;}
.wizard-actions .btn{flex:1;}

/* ---------- diary history ---------- */
.spark-card{background:#fff; border-radius:var(--radius-lg); padding:18px; box-shadow:var(--shadow-sm); margin-bottom:18px;}
.spark-card .spark-top{display:flex; justify-content:space-between; align-items:baseline; margin-bottom:8px;}
.spark-card .spark-top b{font-size:15px;}
.spark-card .spark-top span{font-size:12px; color:var(--ink-soft); font-weight:700;}

.entry{background:#fff; border-radius:var(--radius-md); padding:16px; box-shadow:var(--shadow-sm); margin-bottom:10px; cursor:pointer;}
.entry-top{display:flex; justify-content:space-between; align-items:center; margin-bottom:6px;}
.entry-date{font-size:12px; font-weight:800; color:var(--ink-soft);}
.entry-mode{font-size:10.5px; font-weight:800; background:var(--cream-soft); padding:3px 9px; border-radius:99px; color:var(--sage-deep);}
.entry-sit{font-size:14.5px; font-weight:700; margin:0 0 8px; line-height:1.4;}
.entry-emo{display:flex; align-items:center; gap:8px; font-size:12.5px; font-weight:700; color:var(--ink-soft);}
.emo-pill{padding:4px 10px; border-radius:99px; font-weight:800; font-size:11.5px;}
.emo-before{background:#FBE3DB; color:var(--coral);}
.emo-after{background:#E7EEE0; color:var(--sage-deep);}
.entry-detail{margin-top:12px; padding-top:12px; border-top:1px dashed var(--line); font-size:13.5px; line-height:1.55; color:var(--ink-soft); display:none;}
.entry.open .entry-detail{display:block;}
.entry-detail b{color:var(--ink);}

/* ---------- materials ---------- */
.mat-card{background:#fff; border-radius:var(--radius-md); padding:16px; box-shadow:var(--shadow-sm); margin-bottom:12px; cursor:pointer;}
.mat-cat{font-size:11px; font-weight:800; color:var(--coral); text-transform:uppercase; letter-spacing:.4px;}
.mat-title{font-size:16px; font-weight:900; margin:4px 0 6px;}
.mat-teaser{font-size:13.5px; color:var(--ink-soft); line-height:1.5;}
.mat-body{display:none; margin-top:10px; padding-top:10px; border-top:1px dashed var(--line); font-size:13.5px; line-height:1.6; color:var(--ink-soft);}
.mat-card.open .mat-body{display:block;}
.mat-card.open .mat-teaser{display:none;}

/* ---------- emergency ---------- */
.breath-wrap{display:flex; flex-direction:column; align-items:center; padding:18px 0 8px;}
.breath-circle{
  width:150px; height:150px; border-radius:50%;
  background:radial-gradient(circle at 35% 30%, var(--sage), var(--sage-deep));
  display:flex; align-items:center; justify-content:center; color:var(--cream);
  font-weight:800; font-size:16px; box-shadow:var(--shadow);
  transition:transform 4s ease-in-out;
}
.breath-circle.in{transform:scale(1.32);}
.breath-circle.hold{transform:scale(1.32);}
.breath-circle.out{transform:scale(.85);}
.sos-tel{
  display:flex; align-items:center; justify-content:space-between;
  background:var(--cream-soft); border-radius:16px; padding:13px 15px; margin-bottom:10px;
}
.sos-tel b{font-size:15px;}
.sos-tel span{font-size:12px; color:var(--ink-soft); display:block; font-weight:600;}
.sos-tel a{color:var(--coral); font-weight:900; font-size:15px; text-decoration:none;}
.disclaimer{font-size:12px; color:var(--ink-soft); line-height:1.5; background:var(--cream-soft); padding:12px 14px; border-radius:14px; margin-top:8px;}

/* ---------- schedule ---------- */
.week-row{display:flex; gap:6px; margin:14px 0;}
.day-pill{flex:1; text-align:center; background:#fff; border-radius:14px; padding:10px 4px; box-shadow:var(--shadow-sm);}
.day-pill .dn{font-size:11px; font-weight:800; color:var(--ink-soft); display:block;}
.day-pill .dd{font-size:15px; font-weight:900; margin-top:2px;}
.day-pill.off{opacity:.4;}
.slot-row{display:flex; flex-wrap:wrap; gap:8px; margin-top:6px;}
.slot{background:#fff; border:2px solid var(--line); border-radius:12px; padding:9px 14px; font-weight:800; font-size:13.5px;}

/* ---------- toast ---------- */
#toast{
  position:fixed; left:50%; bottom:104px; transform:translate(-50%,18px); z-index:60;
  background:var(--ink); color:var(--cream); padding:13px 20px; border-radius:99px;
  font-size:13.5px; font-weight:800; box-shadow:var(--shadow); opacity:0; pointer-events:none;
  transition:all .28s cubic-bezier(.22,.9,.32,1); white-space:nowrap; display:flex; align-items:center; gap:8px;
}
#toast.show{opacity:1; transform:translate(-50%,0);}

/* ---------- celebration overlay ---------- */
#celebrate{
  position:fixed; inset:0; z-index:55; display:flex; align-items:center; justify-content:center;
  background:rgba(46,51,36,.55); opacity:0; pointer-events:none; transition:opacity .25s ease;
}
#celebrate.show{opacity:1; pointer-events:auto;}
.celebrate-card{background:var(--cream); border-radius:28px; padding:34px 26px; text-align:center; max-width:300px; filter:url(#roughPaper);}
.celebrate-card .mark{width:46px; height:46px; margin:0 auto 14px; border-radius:50%; background:var(--sage); color:var(--cream); display:flex; align-items:center; justify-content:center;}
.celebrate-card .mark svg{width:24px; height:24px;}
.celebrate-card h3{margin:0 0 8px; font-size:21px; font-weight:900;}
.celebrate-card p{margin:0 0 20px; font-size:14px; color:var(--ink-soft); line-height:1.5;}

/* ---------- admin ---------- */
.seg{display:flex; background:var(--cream-soft); border-radius:14px; padding:4px; gap:4px; margin-bottom:18px;}
.seg-btn{flex:1; border:none; background:none; padding:9px 4px; border-radius:11px; font-weight:800; font-size:12.5px; color:var(--ink-soft); cursor:pointer;}
.seg-btn.active{background:#fff; color:var(--ink); box-shadow:var(--shadow-sm);}

.form-group{margin-bottom:14px;}
.form-label{display:block; font-size:12px; font-weight:800; color:var(--ink-soft); text-transform:uppercase; letter-spacing:.4px; margin-bottom:6px;}
.form-row{display:flex; gap:8px;}
.form-row .field{flex:1;}

.admin-item{background:#fff; border-radius:var(--radius-md); padding:15px; box-shadow:var(--shadow-sm); margin-bottom:10px;}
.admin-item-top{display:flex; justify-content:space-between; align-items:flex-start; gap:8px; margin-bottom:4px;}
.admin-item-title{font-weight:800; font-size:14.5px;}
.admin-item-sub{font-size:12px; color:var(--ink-soft); margin-top:2px;}
.admin-item-actions{display:flex; gap:6px; flex:0 0 auto;}
.icon-btn{width:34px; height:34px; border-radius:10px; border:none; background:var(--cream-soft); color:var(--ink-soft); display:flex; align-items:center; justify-content:center; cursor:pointer;}
.icon-btn svg{width:16px; height:16px;}
.icon-btn.danger{color:var(--coral);}
.pill-toggle{display:inline-flex; align-items:center; gap:7px; font-size:12.5px; font-weight:700; color:var(--ink-soft); cursor:pointer; user-select:none;}
.pill-toggle input{accent-color:var(--sage); width:16px; height:16px;}

.repeat-row{display:flex; gap:8px; margin-bottom:8px; align-items:center;}
.repeat-row .field{margin:0;}
.admin-card{background:#fff; border-radius:var(--radius-lg); padding:18px; box-shadow:var(--shadow-sm); margin-bottom:16px;}
.admin-card-title{font-size:13px; font-weight:800; color:var(--sage-deep); text-transform:uppercase; letter-spacing:.4px; margin-bottom:12px;}
.admin-add{width:100%; border:2px dashed var(--line); background:none; border-radius:16px; padding:13px; font-weight:800; color:var(--ink-soft); cursor:pointer; margin-top:4px;}

@media (min-width:480px){
  .screen{max-width:480px; margin:0 auto; width:100%;}
  .tabbar{max-width:480px; margin:0 auto; left:0; right:0;}
}
