/* ============ TOKENS ============ */
:root{
  --bg:#f6f6f4;
  --paper:#ffffff;
  --ink:#121212;
  --ink-soft:#4a4a4a;
  --gray:#8d8d8d;
  --gray-line:#d8d8d4;
  --gray-fill:#ececea;
  --track:#e4e4e0;
  --radius-a: 22px 10px 20px 12px;
  --radius-b: 12px 20px 10px 22px;
  --shadow: 0 1px 0 rgba(0,0,0,.02);
  --font-display:'Oswald','Vazirmatn',sans-serif;
  --font-body:'Vazirmatn','Inter',sans-serif;
  --safe-bottom: 84px;
  --transition: .28s cubic-bezier(.4,0,.2,1);
  --accent: #121212;
  --accent-soft: rgba(18,18,18,.12);
}
body.dark{
  --bg:#0e0e0e;
  --paper:#161616;
  --ink:#f2f2f0;
  --ink-soft:#c7c7c2;
  --gray:#8a8a86;
  --gray-line:#2c2c2a;
  --gray-fill:#1f1f1d;
  --track:#242422;
  --accent: #f2f2f0;
  --accent-soft: rgba(242,242,240,.14);
}
/* ---- theme accent colors (structure stays mono, only key actions tint) ---- */
body.theme-blue{ --accent:#2b5fd9; --accent-soft:rgba(43,95,217,.15); }
body.theme-red{ --accent:#c23b3b; --accent-soft:rgba(194,59,59,.15); }
body.theme-green{ --accent:#2f8f5b; --accent-soft:rgba(47,143,91,.15); }
body.theme-yellow{ --accent:#c9971f; --accent-soft:rgba(201,151,31,.15); }
body.theme-purple{ --accent:#7c4fd0; --accent-soft:rgba(124,79,208,.15); }
body.theme-pink{ --accent:#d9679b; --accent-soft:rgba(217,103,155,.15); }
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg);
  font-family:var(--font-body);
  color:var(--ink);
  min-height:100vh;
  display:flex; justify-content:center;
  transition:background var(--transition), color var(--transition);
}
.app{
  width:100%; max-width:430px; min-height:100vh;
  background:var(--bg);
  position:relative;
  overflow-x:hidden;
  padding-bottom:var(--safe-bottom);
}
h1,h2,h3,.disp{font-family:var(--font-display),var(--font-body); letter-spacing:.2px;}
::selection{background:var(--ink); color:var(--paper);}

/* ============ TOP BAR ============ */
.topbar{display:flex; align-items:center; justify-content:space-between; padding:18px 18px 10px;}
.brand{display:flex; align-items:center; gap:10px;}
.brand-mark{
  width:38px; height:38px; border-radius:11px; background:var(--ink); color:var(--paper);
  display:flex; align-items:center; justify-content:center;
  font-family:var(--font-display); font-weight:700; font-size:15px; overflow:hidden; flex-shrink:0;
}
.brand-mark img{width:100%; height:100%; object-fit:cover; display:none;}
.brand-name{font-family:var(--font-display); font-weight:600; font-size:15px; letter-spacing:1px;}
.brand-sub{font-size:10px; color:var(--gray); margin-top:1px;}
.topbar-actions{display:flex; gap:8px;}
.icon-btn{
  width:38px; height:38px; border-radius:12px; border:1.6px solid var(--ink); background:var(--paper);
  display:flex; align-items:center; justify-content:center; cursor:pointer; color:var(--ink);
  transition:transform .15s, background var(--transition);
}
.icon-btn:active{transform:scale(.9);}

/* ============ PAGES ============ */
.page{ padding:6px 16px 20px; display:none; animation:pageIn .32s ease; }
.page.active{display:block;}
@keyframes pageIn{ from{opacity:0; transform:translateY(10px);} to{opacity:1; transform:translateY(0);} }

/* ============ CARD ============ */
.card{
  background:var(--paper); border:2px solid var(--ink); border-radius:var(--radius-a);
  padding:16px; margin-bottom:16px; position:relative; box-shadow:var(--shadow);
  transition:background var(--transition), border-color var(--transition);
}
.card.tilt{transform:rotate(-.35deg);}
.card.tilt2{transform:rotate(.35deg); border-radius:var(--radius-b);}
.card-title{
  font-family:var(--font-display); font-weight:600; font-size:13px; text-transform:uppercase;
  letter-spacing:1.2px; color:var(--gray); margin:0 0 12px 0; display:flex; align-items:center; justify-content:space-between;
}
.small-note{font-size:10px; text-transform:none; letter-spacing:0; color:var(--gray); font-family:var(--font-body); font-weight:400;}
.dotted-divider{border:none; border-top:2px dotted var(--gray-line); margin:12px 0;}

/* ============ HOME TASK LINES ============ */
.task-line{
  display:flex; align-items:center; gap:10px; padding:9px 2px; border-bottom:1.4px dashed var(--gray-line);
  cursor:grab; transition:opacity .2s;
}
.task-line.dragging{opacity:.35;}
.task-line:last-child{border-bottom:none;}
.task-line .handle{color:var(--gray); font-size:13px; letter-spacing:2px;}
.checkbox{
  width:21px; height:21px; border-radius:7px; border:2px solid var(--ink); flex-shrink:0; cursor:pointer;
  position:relative; transition:background .2s, transform .15s;
}
.checkbox.done{background:var(--accent);}
.checkbox.done::after{
  content:''; position:absolute; left:5px; top:1px; width:6px; height:11px;
  border:solid var(--paper); border-width:0 2.4px 2.4px 0; transform:rotate(38deg);
}
.checkbox:active{transform:scale(.85);}
.task-text{flex:1; font-size:14px;}
.task-text.done{color:var(--gray); text-decoration:line-through;}
.task-del{color:var(--gray); cursor:pointer; font-size:15px; padding:2px 6px;}
.task-input-row{display:flex; gap:8px; margin-top:10px;}
.task-input{
  flex:1; border:1.6px solid var(--gray-line); border-radius:10px; padding:9px 12px;
  font-size:13.5px; background:var(--bg); color:var(--ink); font-family:inherit;
}
.task-input:focus{outline:none; border-color:var(--ink);}
.add-btn{
  width:38px; height:38px; border-radius:10px; border:1.6px solid var(--accent); background:var(--accent);
  color:var(--paper); font-size:18px; cursor:pointer; display:flex; align-items:center; justify-content:center;
  transition:transform .15s;
}
.add-btn:active{transform:scale(.88);}

.big-add-card{
  border:2px dashed var(--gray-line); background:transparent; border-radius:18px;
  display:flex; align-items:center; justify-content:center; padding:14px; cursor:pointer;
  margin-bottom:16px; color:var(--gray); font-size:26px; font-weight:300; transition:border-color .2s, color .2s;
}
.big-add-card:hover{border-color:var(--ink); color:var(--ink);}

.cycle-item{
  display:flex; align-items:center; gap:10px; border:2px solid var(--ink); border-radius:16px;
  padding:12px 12px; margin-bottom:10px; background:var(--paper); cursor:grab; transition:opacity .2s, transform .2s;
}
.cycle-item.dragging{opacity:.35;}
.cycle-item .handle{color:var(--gray); font-size:14px; letter-spacing:2px; cursor:grab; padding:0 2px;}
.cycle-item .checkbox{margin-inline-start:2px;}
.cycle-item .task-text{font-size:14px; font-weight:500;}

textarea.scratchpad{
  width:100%; border:1.6px dashed var(--gray-line); border-radius:14px; padding:12px;
  background:var(--bg); color:var(--ink); font-family:inherit; font-size:13.5px; resize:vertical; min-height:110px;
}
textarea.scratchpad:focus{outline:none; border-color:var(--ink);}

/* progress dock — HOME ONLY */
.progress-dock{
  position:fixed; left:0; right:0; bottom:78px; display:none; justify-content:center;
  pointer-events:none; z-index:40;
}
.progress-dock.show{display:flex;}
.progress-dock-inner{
  width:100%; max-width:430px; margin:0 16px; padding:10px 14px;
  background:rgba(140,140,140,.16);
  -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px);
  border:1.4px solid var(--gray-line); border-radius:16px;
  box-shadow:0 4px 18px rgba(0,0,0,.10);
}
.progress-track{height:9px; border-radius:6px; background:var(--track); overflow:hidden; border:1.4px solid var(--gray-line);}
.progress-fill{height:100%; width:0%; background:var(--accent); border-radius:6px; transition:width .5s cubic-bezier(.4,0,.2,1);}
.progress-msg{font-size:11.5px; text-align:center; margin-top:6px; color:var(--ink-soft); font-weight:500; min-height:14px;}
.streak-badge{
  display:inline-flex; align-items:center; gap:4px; font-size:10.5px; color:var(--ink-soft);
  border:1.2px solid var(--gray-line); border-radius:10px; padding:2px 8px; margin-inline-start:6px;
}

.quote-banner{
  border:2px solid var(--ink); border-radius:18px; padding:16px; margin-bottom:16px;
  background:repeating-linear-gradient(135deg, var(--paper) 0 12px, var(--gray-fill) 12px 13px);
  position:relative; overflow:hidden;
  min-height:104px; display:flex; flex-direction:column; justify-content:center;
}
.quote-text{font-size:13px; font-weight:600; line-height:1.7; font-family:var(--font-display);}
.quote-author{font-size:10.5px; color:var(--gray); margin-top:8px;}

/* confetti burst on 100% completion */
.confetti-piece{
  position:fixed; top:40%; z-index:300; font-size:20px; pointer-events:none;
  animation:confettiFall 1.1s ease-in forwards;
}
@keyframes confettiFall{
  0%{transform:translateY(0) rotate(0); opacity:1;}
  100%{transform:translateY(220px) rotate(300deg); opacity:0;}
}

/* ============ BOTTOM NAV ============ */
.bottomnav{position:fixed; left:0; right:0; bottom:0; display:flex; justify-content:center; z-index:50;}
.bottomnav-inner{
  width:100%; max-width:430px; background:var(--paper); border-top:2px solid var(--ink);
  display:flex; align-items:center; justify-content:space-between; padding:10px 14px 14px;
}
.nav-btn{
  background:none; border:none; display:flex; flex-direction:column; align-items:center; gap:4px;
  color:var(--gray); cursor:pointer; font-family:var(--font-body); font-size:9.5px; flex:1; transition:color .2s;
}
.nav-btn svg{width:21px; height:21px; stroke:var(--gray); fill:none; stroke-width:1.8; transition:stroke .2s;}
.nav-btn.active{color:var(--ink);}
.nav-btn.active svg{stroke:var(--ink);}
.nav-btn.home-btn{margin-top:-26px;}
.nav-btn.home-btn .home-circle{
  width:52px; height:52px; border-radius:50%; background:var(--accent); border:3px solid var(--paper);
  display:flex; align-items:center; justify-content:center; box-shadow:0 3px 10px rgba(0,0,0,.25); transition:transform .2s;
}
.nav-btn.home-btn:active .home-circle{transform:scale(.9);}
.nav-btn.home-btn svg{stroke:var(--paper); width:23px; height:23px;}

/* ============ ANALYSIS ============ */
.seg-row{display:flex; gap:8px; margin-bottom:16px;}
.seg{
  border:1.6px solid var(--ink); border-radius:20px; padding:8px 14px; font-size:12.5px;
  background:var(--paper); color:var(--ink); cursor:pointer; flex:1; text-align:center;
}
.seg.active{background:var(--accent); color:var(--paper); font-weight:600;}
.grid-cycle{display:grid; grid-template-columns:repeat(6,1fr); gap:6px;}
.day-cell{
  border:1.6px solid var(--ink); border-radius:8px; aspect-ratio:1/1; position:relative;
  cursor:pointer; overflow:hidden; background:var(--paper); transition:transform .15s;
}
.day-cell:active{transform:scale(.9);}
.day-cell .fill{position:absolute; left:0; right:0; bottom:0; background:var(--gray-fill); transition:height .4s;}
.day-cell .fill.strong{background:var(--accent); opacity:.9;}
.day-cell .fill.mid{background:var(--gray); opacity:.55;}
.day-cell .num{position:absolute; top:2px; right:3px; font-size:7.5px; color:var(--gray); font-family:var(--font-display);}
.day-cell.empty{border-style:dashed; border-color:var(--gray-line);}
.day-cell.today::before{
  content:''; position:absolute; inset:-2px; border:1.6px solid var(--ink); border-radius:9px; animation:pulseRing 1.8s infinite;
}
@keyframes pulseRing{0%{opacity:.9;}50%{opacity:.15;}100%{opacity:.9;}}
.timeline-row{display:flex; align-items:flex-end; gap:10px; padding:6px 2px 2px; height:110px;}
.tl-bar-wrap{flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; height:100%; justify-content:flex-end;}
.tl-bar{width:100%; max-width:26px; border-radius:8px 8px 4px 4px; background:var(--gray-fill); position:relative; transition:height .5s;}
.tl-bar.filled{background:var(--accent);}
.tl-label{font-size:9.5px; color:var(--gray);}

.stat-row{display:flex; justify-content:space-between; gap:10px; margin-top:8px;}
.stat-box{flex:1; text-align:center; padding:12px 4px; border:1.6px solid var(--gray-line); border-radius:14px;}
.stat-num{font-family:var(--font-display); font-size:20px; font-weight:700;}
.stat-lbl{font-size:9.5px; color:var(--gray); margin-top:2px;}

.day-progress-label{display:flex; justify-content:space-between; font-size:11.5px; color:var(--gray); margin-bottom:8px;}

/* seg row now supports 4 scrollable segments */
.seg-row.wide{overflow-x:auto; -ms-overflow-style:none; scrollbar-width:none;}
.seg-row.wide::-webkit-scrollbar{display:none;}
.seg-row.wide .seg{flex:0 0 auto; padding:8px 12px; white-space:nowrap;}

/* list view (Notion-style rows) */
.list-view-wrap{display:flex; flex-direction:column; gap:8px;}
.list-row{
  display:flex; align-items:center; gap:10px; border:1.6px solid var(--gray-line); border-radius:12px; padding:9px 12px;
}
.list-row .ld{font-size:11.5px; color:var(--ink-soft); width:44px; flex-shrink:0; font-family:var(--font-display);}
.list-row .list-bar{flex:1; height:8px; border-radius:5px; background:var(--track); overflow:hidden;}
.list-row .list-bar .f{height:100%; background:var(--accent); border-radius:5px; transition:width .4s;}
.list-row .lp{font-size:11px; color:var(--gray); width:34px; text-align:left; flex-shrink:0;}

/* calendar view (Notion-style calendar/heatmap) */
.cal-weekhead{display:grid; grid-template-columns:repeat(7,1fr); gap:6px; margin-bottom:6px;}
.cal-weekhead span{font-size:9px; color:var(--gray); text-align:center;}
.cal-grid{display:grid; grid-template-columns:repeat(7,1fr); gap:6px;}
.cal-cell{
  border:1.6px solid var(--gray-line); border-radius:10px; aspect-ratio:1/1; position:relative;
  display:flex; align-items:center; justify-content:center; cursor:pointer; background:var(--paper);
}
.cal-cell.blank{border:none; background:transparent; cursor:default;}
.cal-cell .cn{font-size:9.5px; color:var(--gray); font-family:var(--font-display);}
.cal-cell.has .cn{color:var(--paper); font-weight:600;}
.cal-cell.lvl1{background:var(--gray-fill);}
.cal-cell.lvl2{background:var(--accent); opacity:.55;}
.cal-cell.lvl3{background:var(--accent); opacity:.9;}
.cal-cell.lvl3 .cn, .cal-cell.lvl2 .cn{color:var(--paper);}
.cal-cell.today{border-color:var(--ink); border-width:2px;}

/* color swatches for theme picker */
.swatch-row{display:flex; flex-wrap:wrap; gap:10px; margin-bottom:6px;}
.swatch{
  width:34px; height:34px; border-radius:50%; cursor:pointer; border:2.4px solid transparent;
  display:flex; align-items:center; justify-content:center; position:relative;
}
.swatch.selected{border-color:var(--ink);}
.swatch.selected::after{content:'✓'; color:#fff; font-size:13px; font-weight:700; text-shadow:0 0 2px rgba(0,0,0,.5);}
.swatch-mono{background:linear-gradient(135deg,#111 50%,#eee 50%);}
.swatch-blue{background:#2b5fd9;} .swatch-red{background:#c23b3b;} .swatch-green{background:#2f8f5b;}
.swatch-yellow{background:#c9971f;} .swatch-purple{background:#7c4fd0;} .swatch-pink{background:#d9679b;}

/* home block reorder list (used inside Customize modal) */
.order-row{
  display:flex; align-items:center; gap:10px; border:1.6px solid var(--gray-line); border-radius:12px;
  padding:10px 12px; margin-bottom:8px; cursor:grab; background:var(--paper);
}
.order-row.dragging{opacity:.35;}
.order-row .handle{color:var(--gray); font-size:14px; letter-spacing:2px;}
.order-row span.lbl{flex:1; font-size:13px;}

/* finished challenges — clickable summary row (opens full list) */
.finished-summary{
  display:flex; align-items:center; justify-content:space-between; border:2px dashed var(--gray-line);
  border-radius:18px; padding:14px 16px; cursor:pointer; margin-top:8px;
}
.fs-left{display:flex; align-items:center; gap:10px;}
.fs-count{
  width:30px; height:30px; border-radius:50%; background:var(--gray-fill); display:flex; align-items:center;
  justify-content:center; font-family:var(--font-display); font-weight:700; font-size:12.5px; flex-shrink:0;
}
.folder-row .fs-count{ background:transparent; font-size:20px; }

/* journal search */
.journal-search{
  width:100%; border:1.6px solid var(--gray-line); border-radius:12px; padding:10px 12px; margin-bottom:14px;
  background:var(--paper); color:var(--ink); font-family:inherit; font-size:13px;
}
.journal-search:focus{outline:none; border-color:var(--ink);}

/* ============ MODAL ============ */
.modal-bg{
  position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:100; display:none;
  align-items:flex-end; justify-content:center; backdrop-filter:blur(2px);
}
.modal-bg.show{display:flex; animation:fadeBg .2s ease;}
@keyframes fadeBg{from{opacity:0;} to{opacity:1;}}
.modal-sheet{
  width:100%; max-width:430px; background:var(--paper); border-radius:24px 24px 0 0;
  border:2px solid var(--ink); border-bottom:none; padding:20px; max-height:82vh; overflow-y:auto;
  animation:sheetUp .3s cubic-bezier(.4,0,.2,1); position:relative;
}
@keyframes sheetUp{from{transform:translateY(100%);} to{transform:translateY(0);}}
.modal-handle{width:40px; height:4px; background:var(--gray-line); border-radius:3px; margin:0 auto 16px;}
.modal-title{font-family:var(--font-display); font-size:17px; font-weight:600; margin-bottom:4px;}
.modal-sub{font-size:11.5px; color:var(--gray); margin-bottom:14px;}
.mini-task{display:flex; align-items:center; gap:8px; padding:6px 0; font-size:13px;}
.mini-dot{width:9px; height:9px; border-radius:50%; background:var(--ink); flex-shrink:0;}
.mini-dot.off{background:var(--gray-line);}
.field{margin-bottom:14px;}
.field label{font-size:11.5px; color:var(--gray); display:block; margin-bottom:6px;}
.field input, .field select, .field textarea{
  width:100%; border:1.6px solid var(--gray-line); border-radius:10px; padding:10px 12px;
  font-size:13.5px; background:var(--bg); color:var(--ink); font-family:inherit;
}
.field input:focus, .field select:focus, .field textarea:focus{outline:none; border-color:var(--ink);}
.btn-solid{
  width:100%; padding:13px; border-radius:12px; border:none; background:var(--accent); color:var(--paper);
  font-family:var(--font-display); font-weight:600; font-size:14px; cursor:pointer; margin-top:6px; transition:transform .15s;
}
.btn-solid:active{transform:scale(.97);}
.btn-outline{
  width:100%; padding:12px; border-radius:12px; border:1.6px solid var(--ink); background:transparent; color:var(--ink);
  font-family:var(--font-display); font-weight:600; font-size:13.5px; cursor:pointer; margin-top:8px;
}
.btn-danger{border-color:#8a3a3a; color:#8a3a3a;}
.two-col{display:flex; gap:10px;}
.two-col .btn-solid, .two-col .btn-outline{flex:1;}
.goal-row-list{margin-bottom:8px;}
.goal-row{display:flex; align-items:center; gap:8px; padding:7px 0; border-bottom:1.2px dashed var(--gray-line); font-size:13px;}
.goal-row span{flex:1;}
.goal-row .x{color:var(--gray); cursor:pointer; font-size:14px;}
.list-select-row{
  display:flex; align-items:center; justify-content:space-between; padding:12px 4px;
  border-bottom:1.4px dashed var(--gray-line); cursor:pointer;
}
.list-select-row:last-child{border-bottom:none;}
.list-select-name{font-size:13.5px; font-weight:600;}
.list-select-meta{font-size:10.5px; color:var(--gray); margin-top:2px;}

/* ============ SETTINGS ============ */
.set-row{display:flex; align-items:center; justify-content:space-between; padding:14px 4px; border-bottom:1.4px dashed var(--gray-line); cursor:pointer;}
.set-row:last-child{border-bottom:none;}
.set-left{display:flex; align-items:center; gap:12px;}
.set-ic{width:34px; height:34px; border-radius:10px; background:var(--gray-fill); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.set-ic svg{width:17px; height:17px; stroke:var(--ink); fill:none; stroke-width:1.8;}
.set-title{font-size:13.5px; font-weight:500;}
.set-sub{font-size:10.5px; color:var(--gray); margin-top:1px;}
.chev{color:var(--gray); font-size:14px;}
.switch{width:42px; height:24px; border-radius:14px; background:var(--track); position:relative; cursor:pointer; border:1.6px solid var(--gray-line); flex-shrink:0;}
.switch.on{background:var(--accent); border-color:var(--accent);}
.switch::after{content:''; position:absolute; top:2px; right:2px; width:17px; height:17px; border-radius:50%; background:var(--paper); transition:right .2s;}
.switch.on::after{right:20px;}
.seg2{display:flex; border:1.6px solid var(--ink); border-radius:12px; overflow:hidden;}
.seg2 button{flex:1; padding:8px; border:none; background:var(--paper); color:var(--ink); font-size:12px; cursor:pointer;}
.seg2 button.active{background:var(--accent); color:var(--paper);}

/* ============ CHALLENGES ============ */
.chal-card{border:2px solid var(--ink); border-radius:18px; padding:14px; margin-bottom:12px; position:relative; transition:opacity .2s, transform .2s, box-shadow .2s;}
.chal-card.just-activated{
  animation: chalPulse .7s ease;
}
@keyframes chalPulse{
  0%{ transform:scale(1); box-shadow:0 0 0 0 var(--accent-soft); }
  35%{ transform:scale(1.035); box-shadow:0 0 0 8px var(--accent-soft); border-color:var(--accent); }
  100%{ transform:scale(1); box-shadow:0 0 0 0 transparent; }
}
.icon-btn.spin-once{ animation: spinOnce .5s ease; }
@keyframes spinOnce{ from{ transform:rotate(0deg); } to{ transform:rotate(360deg); } }
.chal-card.pending{opacity:.5; border-style:dashed;}
.chal-card.finished{opacity:.7;}
.chal-top{display:flex; justify-content:space-between; align-items:center; margin-bottom:10px;}
.chal-name{font-family:var(--font-display); font-weight:600; font-size:15px;}
.badge{font-size:9.5px; border:1.2px solid var(--gray-line); border-radius:8px; padding:2px 7px; color:var(--gray);}
.badge.active-badge{background:var(--accent); color:var(--paper); border-color:var(--accent);}
.badge.pending-badge{border-color:var(--gray); color:var(--gray);}
.badge.finished-badge{border-color:var(--gray-line); color:var(--gray);}
.mini-progress{height:7px; border-radius:5px; background:var(--track); overflow:hidden; margin:8px 0;}
.mini-progress .f{height:100%; background:var(--accent); transition:width .5s;}
.chal-meta{display:flex; justify-content:space-between; font-size:10.5px; color:var(--gray);}
.chal-actions{display:flex; gap:8px; margin-top:10px;}
.chal-actions button{flex:1; font-size:11.5px; padding:8px; border-radius:9px; border:1.4px solid var(--ink); background:var(--paper); color:var(--ink); cursor:pointer;}
.chal-actions button.primary{background:var(--ink); color:var(--paper);}
.finished-box{border:2px dashed var(--gray-line); border-radius:20px; padding:14px; margin-top:8px;}
.section-label{font-size:11px; color:var(--gray); text-transform:uppercase; letter-spacing:1px; margin:4px 0 10px;}

/* ============ JOURNAL ============ */
.journal-grid{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.journal-add{
  border:2px dashed var(--gray-line); border-radius:16px; aspect-ratio:1/1.05;
  display:flex; align-items:center; justify-content:center; cursor:pointer; color:var(--gray); font-size:30px; font-weight:300;
}
.note-card{
  border:2px solid var(--ink); border-radius:14px; padding:12px; aspect-ratio:1/1.05; cursor:pointer;
  display:flex; flex-direction:column; background:var(--paper); overflow:hidden; transition:transform .15s;
}
.note-card:nth-child(3n+1){transform:rotate(-.6deg);}
.note-card:nth-child(3n+2){transform:rotate(.5deg);}
.note-card:active{transform:scale(.96);}
.note-card .pin{font-size:11px; align-self:flex-end; margin-bottom:2px;}
.note-title{font-family:var(--font-display); font-weight:600; font-size:13px; margin-bottom:6px;}
.note-snippet{font-size:11px; color:var(--ink-soft); line-height:1.6; flex:1; overflow:hidden;}
.note-date{font-size:9px; color:var(--gray); margin-top:6px;}
.editor-textarea{width:100%; min-height:220px; border:none; background:transparent; font-family:inherit; font-size:13.5px; color:var(--ink); resize:vertical;}
.editor-textarea:focus{outline:none;}
.editor-title-input{width:100%; border:none; background:transparent; font-family:var(--font-display); font-weight:600; font-size:17px; color:var(--ink); margin-bottom:6px;}
.editor-title-input:focus{outline:none;}
.editor-meta{font-size:10px; color:var(--gray); margin-bottom:10px;}

.toast{
  position:fixed; bottom:100px; left:50%; transform:translateX(-50%) translateY(20px); opacity:0;
  background:var(--ink); color:var(--paper); padding:10px 18px; border-radius:30px; font-size:12px;
  z-index:200; transition:all .3s; pointer-events:none; white-space:nowrap; max-width:90%; text-align:center;
}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

/* ============ AUTH OVERLAY ============ */
.auth-overlay{
  position:fixed; inset:0; background:var(--bg); z-index:1000;
  display:flex; align-items:center; justify-content:center; padding:24px;
}
.auth-card{width:100%; max-width:360px; position:relative;}
.auth-translate-btn{
  position:absolute; top:-6px; left:0;
  border:1.6px solid var(--ink); background:var(--paper); color:var(--ink);
  border-radius:20px; padding:6px 14px; font-size:11px; font-weight:600; cursor:pointer;
  font-family:var(--font-display); letter-spacing:.5px;
}
.auth-translate-btn:active{ transform:scale(.94); }
.auth-logo{display:flex; flex-direction:column; align-items:center; margin-bottom:26px;}
.auth-brand-name{font-family:var(--font-display); font-weight:700; font-size:20px; letter-spacing:1.5px; margin-top:12px;}
.auth-brand-sub{font-size:11px; color:var(--gray); margin-top:2px;}
.auth-screen{animation:pageIn .3s ease;}
.auth-lead{font-size:13px; color:var(--ink-soft); text-align:center; margin-bottom:22px; line-height:1.8;}
.auth-error{font-size:11.5px; color:#c23b3b; min-height:16px; margin:-6px 0 6px;}
.reveal-code{
  font-family:var(--font-display); font-size:26px; font-weight:700; letter-spacing:3px;
  margin:14px 0; padding:14px; border:2px dashed var(--ink); border-radius:14px;
}

/* ============================================================
   RESPONSIVE — TABLET & DESKTOP
   Everything above this line is the original mobile-first design
   and is left completely untouched. Everything below only ADDS
   rules inside media queries, so mobile (<600px) is 100% unchanged.
   Pure CSS — no JS or HTML structure changes required.

   Direction handling: the app dir="rtl" by default (Persian) and
   switches to dir="ltr" when the person picks English. Rather than
   relying on inline-start/end logical properties (easy to get
   backwards), each rule below is written explicitly for RTL first,
   with an html[dir="ltr"] override right after it — so the sidebar
   sits on the right in Persian and correctly flips to the left in
   English, unambiguously.
   ============================================================ */

/* ---------------- TABLET (600px – 1023px): breathing room, wider grids ---------------- */
@media (min-width:600px){
  .app{ max-width:640px; }
  .journal-grid{ grid-template-columns:repeat(3,1fr); }
  .grid-cycle{ grid-template-columns:repeat(9,1fr); }
  .cal-grid, .cal-weekhead{ grid-template-columns:repeat(9,1fr); }
  .modal-sheet{ max-width:460px; margin:0 auto; }
  .modal-bg{ justify-content:center; }
}

/* ---------------- DESKTOP (≥1024px): a real dashboard layout, not just "bigger mobile" ---------------- */
@media (min-width:1024px){
  body{ display:block; }               /* stop the mobile centering flexbox; .app now owns full width */
  .app{
    max-width:none; width:100%; min-height:100vh; padding-bottom:24px; position:relative;
    padding-right:92px;   /* reserve the sidebar's space once, here — everything inside can then
                              center freely at any breakpoint without ever needing to re-derive
                              sidebar clearance math (that's what caused the earlier overlap bug) */
  }
  html[dir="ltr"] .app{ padding-right:0; padding-left:92px; }

  /* topbar & pages: centered content column, already clear of the sidebar via .app's padding above */
  .topbar{ max-width:1180px; margin:0 auto; padding-inline:24px; }
  .page{ max-width:1180px; margin:0 auto; padding:10px 24px 40px; }

  /* ---- bottom nav becomes a persistent sidebar: right side in Persian, left in English ---- */
  .bottomnav{
    position:fixed; top:0; bottom:0; right:0; left:auto; width:92px;
    display:flex; align-items:stretch; justify-content:center; z-index:50;
  }
  html[dir="ltr"] .bottomnav{ right:auto; left:0; }
  .bottomnav-inner{
    flex-direction:column; width:100%; height:100%;
    border-top:none; border-right:none; border-left:2px solid var(--ink);
    justify-content:flex-start; align-items:center; gap:30px; padding:32px 0 24px;
  }
  html[dir="ltr"] .bottomnav-inner{ border-left:none; border-right:2px solid var(--ink); }
  .nav-btn{ flex:none; width:100%; font-size:9.5px; }
  .nav-btn.home-btn{ margin-top:0; order:-1; margin-bottom:6px; }
  .nav-btn.home-btn .home-circle{ box-shadow:none; }

  /* progress dock stays compact and centered within the content area, not under the sidebar */
  .progress-dock{ right:92px; left:0; }
  html[dir="ltr"] .progress-dock{ right:0; left:92px; }

  /* modal becomes a centered dialog instead of a bottom sheet */
  .modal-bg{ align-items:center; }
  .modal-sheet{
    max-width:480px; border-radius:22px; border-bottom:2px solid var(--ink);
    animation:modalFadeIn .22s ease;
  }
  @keyframes modalFadeIn{ from{opacity:0; transform:translateY(10px);} to{opacity:1; transform:translateY(0);} }

  /* ---- HOME: two-column dashboard instead of one long stacked column ----
     Plain grid auto-flow (no hardcoded block assignment) so it still
     respects whatever order the user picked in Customize — it just flows
     that same order left-to-right / top-to-bottom across 2 columns. */
  #homeBlocksWrapper{ display:grid; grid-template-columns:1.05fr 1fr; gap:22px; align-items:start; }
  #homeBlocksWrapper > div:last-child{ grid-column:1/-1; }

  /* ---- ANALYSIS: big view card + stacked stat cards side by side ---- */
  .grid-cycle{ grid-template-columns:repeat(12,1fr); }
  .cal-grid, .cal-weekhead{ grid-template-columns:repeat(12,1fr); }
  #page-analysis.active{ display:grid; grid-template-columns:1.3fr 1fr; gap:20px; align-items:start; }
  #page-analysis > .card:first-child{ grid-column:1; grid-row:1/3; }
  #page-analysis > .card:has(#statsLbl){ grid-column:2; grid-row:1; }
  #page-analysis > .card:has(#challengeDaysLbl){ grid-column:2; grid-row:2; }

  /* ---- CHALLENGES: cards flow into a responsive multi-column grid ---- */
  #runningChallenges, #pendingChallenges{
    display:grid; grid-template-columns:repeat(auto-fill, minmax(300px,1fr)); gap:14px;
  }
  #runningChallenges .chal-card, #pendingChallenges .chal-card{ margin-bottom:0; }

  /* ---- JOURNAL: more columns for the note grid ---- */
  .journal-grid{ grid-template-columns:repeat(4,1fr); }

  /* ---- SETTINGS: the two settings cards sit side by side ---- */
  #page-settings.active{ display:grid; grid-template-columns:1fr 1fr; gap:20px; align-items:start; }
  #page-settings > .card-title{ grid-column:1/-1; }

  /* ---- AUTH SCREEN: centered pill buttons instead of full-width bars — desktop only, mobile stays as-is ---- */
  .auth-screen .btn-solid, .auth-screen .btn-outline{
    width:auto; min-width:230px; max-width:100%; display:block; margin:0 auto 10px;
  }
}

/* ---------------- LARGE DESKTOP (≥1440px): a bit more room, cap growth ---------------- */
@media (min-width:1440px){
  .topbar, .page{ max-width:1320px; }
}
