/* ── Clio Design System ───────────────────────────────────────────────────── */
:root {
  --bg:        #2e2619;
  --bg2:       #352d1f;
  --surface:   #3d3324;
  --surface2:  #463b2a;
  --border:    #5a4e3a;
  --border-md: #6b5e48;
  --text:      #f5ede0;
  --text2:     #d4c0a0;
  --text3:     #9a8a70;
  --terra:     #c2542a;
  --terra-lt:  rgba(194,84,42,.15);
  --terra-md:  rgba(194,84,42,.3);
  --amber:     #d4893a;
  --amber-lt:  rgba(212,137,58,.15);
  --amber-md:  rgba(212,137,58,.3);
  --teal:      #5a9e8f;
  --teal-lt:   rgba(90,158,143,.15);
  --teal-md:   rgba(90,158,143,.3);
  --purple:    #8b7ec8;
  --purple-lt: rgba(139,126,200,.15);
  --peach:     #d4845a;
  --peach-lt:  rgba(212,132,90,.15);
  --green:     #6a9e5a;
  --green-lt:  rgba(106,158,90,.15);
  --red:       #c25050;
  --red-lt:    rgba(194,80,80,.15);
  --blue:      #5a8fc2;
  --blue-lt:   rgba(90,143,194,.15);
  --blue-md:   rgba(90,143,194,.3);
  --r-sm:8px;--r-md:12px;--r-lg:16px;--r-xl:22px;
  --shadow-sm:0 1px 3px rgba(0,0,0,.4);
  --shadow-md:0 4px 16px rgba(0,0,0,.5);
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:16px;-webkit-text-size-adjust:100%}
body{font-family:"Plus Jakarta Sans",system-ui,sans-serif;background:var(--bg);color:var(--text);min-height:100vh;line-height:1.6}
.nav{background:var(--bg2);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:100;box-shadow:0 2px 12px rgba(0,0,0,.4)}
.nav-inner{max-width:860px;margin:0 auto;padding:0 20px;min-height:54px;height:auto;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding-top:10px;padding-bottom:10px}
.nav-brand{font-family:"Lora",serif;font-size:1.05rem;font-weight:600;color:var(--terra);letter-spacing:.02em}
.nav-right{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.nav-user{font-size:.78rem;color:var(--text3)}
.nav-logout{font-size:.78rem;color:var(--text3);text-decoration:none;font-weight:500;transition:color .15s}
.nav-logout:hover{color:var(--text)}
.main{max-width:860px;margin:0 auto;padding:0 20px 60px}
.page-header{padding:32px 0 24px}
.clio-eyebrow{font-size:.7rem;color:var(--terra);text-transform:uppercase;letter-spacing:.14em;font-weight:700;margin-bottom:8px}
.greeting{font-family:"Lora",serif;font-size:1.45rem;font-weight:400;color:var(--text);line-height:1.35;letter-spacing:-.01em;font-style:italic}
.date-line{font-size:.78rem;color:var(--text3);margin-top:6px}
.progress-meta{display:flex;justify-content:space-between;font-size:.75rem;color:var(--text3);margin:18px 0 6px;font-weight:500}
.progress-label{color:var(--terra);font-weight:600}
.progress-track{height:20px;background:var(--surface2);border-radius:99px;overflow:hidden}
.progress-fill{height:100%;background:linear-gradient(90deg,var(--teal-lt),var(--teal));border-radius:99px;transition:width .6s ease}
.btn-suggest{margin-top:18px;background:var(--terra);border:1px solid var(--terra);color:#fff;padding:11px 20px;border-radius:var(--r-md);font-size:.85rem;font-weight:600;cursor:pointer;transition:filter .15s;font-family:inherit;letter-spacing:.01em}
.btn-suggest:hover{filter:brightness(1.1)}
.tabs{display:flex;gap:2px;overflow-x:auto;-webkit-overflow-scrolling:touch;border-bottom:1px solid var(--border);margin-bottom:24px;scrollbar-width:none}
.tabs::-webkit-scrollbar{display:none}
.tab{background:none;border:none;padding:10px 16px;font-size:.82rem;font-weight:500;color:var(--text3);cursor:pointer;border-bottom:2px solid transparent;white-space:nowrap;transition:all .15s;font-family:inherit;position:relative}
.tab:hover{color:var(--text2)}
.tab.active{color:var(--terra);border-bottom-color:var(--terra)}
.tab-content{display:none}
.tab-content.active{display:block}
.admin-tab-content{display:none}
.admin-tab-content.active{display:block}
.badge{display:inline-flex;align-items:center;justify-content:center;background:var(--terra);color:#fff;font-size:.65rem;font-weight:700;min-width:17px;height:17px;border-radius:99px;padding:0 4px;margin-left:5px;vertical-align:middle}
.section-title{font-family:"Lora",serif;font-size:1.1rem;font-weight:600;color:var(--text);margin-bottom:4px}
.section-sub{font-size:.82rem;color:var(--text3);margin-bottom:20px;line-height:1.6}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);padding:18px 20px;box-shadow:var(--shadow-sm)}
.card-label{font-size:.72rem;text-transform:uppercase;letter-spacing:.1em;font-weight:700;color:var(--text3);margin-bottom:14px}
.stat-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;margin-bottom:16px}
.stat-box{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-md);padding:14px 16px;text-align:center}
.stat-num{font-family:"Lora",serif;font-size:1.6rem;font-weight:600;line-height:1.1;margin-bottom:4px}
.stat-num.teal{color:var(--teal)}
.stat-num.purple{color:var(--purple)}
.stat-num.peach{color:var(--peach)}
.stat-lbl{font-size:.72rem;color:var(--text3);text-transform:uppercase;letter-spacing:.07em}
.check-item{display:flex;flex-direction:row;align-items:stretch;padding:0;background:var(--surface);border:1px solid var(--border);border-radius:var(--r-md);margin-bottom:8px;cursor:pointer;transition:border-color .15s,background .15s;overflow:hidden}
.check-item:hover{border-color:var(--border-md);background:var(--surface2)}
/* Inside the card: .item-body holds all the content that used to live
   directly in .check-item. Having a single wrapper means the card itself
   doesn't need flex-wrap — .item-body handles its own wrapping. Handle
   is a simple flex sibling that stretches to full card height. */
.check-item > .item-body{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;gap:12px;padding:12px 14px}

/* ── Unified drag-handle column (routine, promises, idle, kanban) ─────────── */
/* Simple in-flow flex handle. align-self:stretch fills the card height.
   This works uniformly across check-item, activity-card, and kb-card because
   all three are display:flex;flex-direction:row at the top level and the
   handle is a direct flex child.
   touch-action:none keeps mobile from scrolling while starting a drag. */
.check-item > .drag-handle,
.activity-card > .drag-handle,
.kb-card > .kb-drag-handle{
  align-self:stretch;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:grab;
  color:var(--text3);
  font-size:1.15rem;
  line-height:1;
  width:32px;
  user-select:none;
  -webkit-user-select:none;
  touch-action:none;
  flex-shrink:0;
  background:rgba(0,0,0,.035);
  border-right:1px solid var(--border);
  transition:color .15s, background .15s;
}
.check-item > .drag-handle:hover,
.activity-card > .drag-handle:hover,
.kb-card > .kb-drag-handle:hover{ color:var(--terra); background:rgba(0,0,0,.08); }
.check-item > .drag-handle:active,
.activity-card > .drag-handle:active,
.kb-card > .kb-drag-handle:active{ cursor:grabbing; }

/* SortableJS visuals for routine list */
.check-item.routine-dragging{opacity:.4}
.check-item.routine-ghost{opacity:.5;background:var(--terra-lt,rgba(194,84,42,.08));border-color:var(--terra)}

/* ── Notes (shared across routine, promises, work, free-time) ─────────── */
/* Notes icon in the meta row — shown only when the item has a note */
.note-icon-btn{background:none;border:none;padding:0 2px;cursor:pointer;font-size:.95rem;line-height:1;color:var(--text3);flex-shrink:0;transition:opacity .15s,transform .15s}
.note-icon-btn:hover{opacity:.75;transform:scale(1.15)}
/* Notes drawer — full-width block that appears below an item when the icon is clicked */
.note-drawer{flex-basis:100%;width:100%;margin-top:8px;padding:10px 14px;background:var(--surface2);border:1px solid var(--border);border-left:3px solid var(--amber);border-radius:var(--r-sm);font-size:.84rem;color:var(--text2);line-height:1.5;white-space:pre-wrap;word-break:break-word;font-family:'Lora',Georgia,serif;font-style:italic}
.note-drawer[hidden]{display:none}
/* Links inside notes stand out against the muted italic note text. */
.note-drawer .note-link{color:var(--terra);text-decoration:underline;font-style:normal;word-break:break-all}
.note-drawer .note-link:hover{opacity:.75}
/* Notes textarea inside edit forms */
.notes-field{width:100%;min-height:60px;max-height:200px;padding:8px 10px;font-size:.84rem;line-height:1.5;resize:vertical;font-family:inherit}
@keyframes doneFlash {
  0%   { background:#3d8a7a; border-color:#2d6b5e; color:#fff; }
  100% { background:var(--teal-lt); border-color:var(--teal-md); color:var(--text); }
}
.check-item.done-item{background:var(--teal-lt);border-color:var(--teal-md);animation:doneFlash .6s ease forwards;}
body:not(.theme-light) .check-item.done-item{background:rgba(90,158,143,.25);border-color:#5a9e8f;animation:none;}
.checkbox{width:22px;height:22px;border-radius:6px;border:2px solid var(--border-md);flex-shrink:0;display:flex;align-items:center;justify-content:center;transition:all .15s;background:var(--surface2)}
.checkbox.checked{background:#27ae60;border-color:#1e8449}
.check-mark{color:#fff;font-size:.8rem;font-weight:700}
.item-emoji{font-size:1.1rem;flex-shrink:0;width:24px;text-align:center}
.item-text-wrap{flex:1;min-width:0}
.item-text{font-size:.88rem;color:var(--text);line-height:1.4}
.item-cat{font-size:.72rem;color:var(--text3);margin-top:2px;text-transform:uppercase;letter-spacing:.06em}
.activity-card{display:flex;flex-direction:row;align-items:stretch;padding:0;background:var(--surface);border:1px solid var(--border);border-radius:var(--r-md);margin-bottom:8px;transition:border-color .15s;overflow:hidden}
.activity-card:hover{border-color:var(--border-md)}
.activity-card > .item-body{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:flex-start;gap:12px;padding:12px 14px}
.act-emoji{font-size:1.2rem;flex-shrink:0;width:28px;text-align:center;margin-top:1px}
.act-text{font-size:.88rem;color:var(--text);line-height:1.4}
.cat-label{font-size:.68rem;text-transform:uppercase;letter-spacing:.1em;font-weight:700;color:var(--text3);margin-bottom:8px;margin-top:4px}
.suggestion-box{display:flex;align-items:flex-start;gap:16px;background:linear-gradient(135deg,var(--surface2),var(--surface));border:1px solid var(--amber-md);border-radius:var(--r-lg);padding:20px;margin-bottom:20px}
.sugg-label{font-size:.68rem;text-transform:uppercase;letter-spacing:.12em;color:var(--amber);font-weight:700;margin-bottom:6px}
.sugg-text{font-family:"Lora",serif;font-size:1.05rem;color:var(--text);font-style:italic;line-height:1.4}
.btn{display:inline-flex;align-items:center;gap:6px;padding:8px 16px;border-radius:var(--r-md);font-size:.82rem;font-weight:600;cursor:pointer;border:1px solid transparent;transition:all .15s;font-family:inherit;white-space:nowrap}
.btn-teal{background:var(--terra);color:#fff;border-color:var(--terra)}
.btn-teal:hover{filter:brightness(1.1)}
.btn-peach{background:var(--peach);color:#fff;border-color:var(--peach)}
.btn-peach:hover{filter:brightness(1.1)}
.btn-amber{background:var(--amber);color:#fff;border-color:var(--amber)}
.btn-amber:hover{filter:brightness(1.1)}
.btn-ghost{background:transparent;color:var(--text2);border-color:var(--border-md)}
.btn-ghost:hover{background:var(--surface2);color:var(--text)}
.btn-dashed{background:transparent;color:var(--text3);border:1.5px dashed var(--border-md);padding:10px 16px;border-radius:var(--r-md);font-size:.82rem;font-weight:500;cursor:pointer;width:100%;transition:all .15s;font-family:inherit;margin-top:8px}
.btn-dashed:hover{border-color:var(--amber-md);color:var(--text2);background:var(--amber-lt)}
.del-btn{background:transparent;border:none;color:var(--text3);font-size:1.1rem;cursor:pointer;padding:2px 6px;border-radius:6px;transition:all .15s;line-height:1;flex-shrink:0}
.del-btn:hover{background:var(--red-lt);color:var(--red)}
.add-form{display:flex;gap:8px;align-items:center;flex-wrap:wrap;background:var(--surface2);border:1px solid var(--border-md);border-radius:var(--r-md);padding:12px 14px;margin-bottom:8px}
.form-group{margin-bottom:14px}
.form-label{display:block;font-size:.78rem;font-weight:600;color:var(--text2);margin-bottom:5px;text-transform:uppercase;letter-spacing:.06em}
.form-input{width:100%;padding:9px 12px;background:var(--bg2);border:1px solid var(--border-md);border-radius:var(--r-sm);font-size:16px;color:var(--text);font-family:inherit;transition:border-color .15s}
.form-input:focus{outline:none;border-color:var(--terra-md)}
.form-input::placeholder{color:var(--text3)}
select.form-input{cursor:pointer}
select.form-input option{background:var(--surface)}
.hist-row{display:flex;align-items:center;gap:12px;padding:7px 0;border-bottom:1px solid var(--border)}
.hist-row:last-child{border-bottom:none}
.hist-date{font-size:.74rem;color:var(--text3);width:100px;flex-shrink:0}
.hist-track{flex:1;height:5px;background:var(--surface2);border-radius:99px;overflow:hidden}
.hist-fill{height:100%;border-radius:99px}
.hist-pct{font-size:.78rem;font-weight:700;width:36px;text-align:right;flex-shrink:0}
.empty-msg{font-size:.84rem;color:var(--text3);padding:16px 0;text-align:center;font-style:italic}
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.grid-2-sm{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.grid-3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px}
.grid-panels{display:grid;grid-template-columns:1fr 1fr;gap:16px}
.accordion-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);overflow:hidden;margin-bottom:10px}
.accordion-header{width:100%;background:transparent;border:none;padding:16px 20px;display:flex;justify-content:space-between;align-items:center;cursor:pointer;font-family:"Plus Jakarta Sans",sans-serif;font-size:.9rem;font-weight:600;color:var(--text);text-align:left;transition:background .15s;box-sizing:border-box}
.accordion-header:hover{background:var(--surface2)}
.accordion-arrow{font-size:.85rem;color:var(--text3);transition:transform .2s;display:inline-block}
.accordion-card.open .accordion-arrow{transform:rotate(180deg)}
.accordion-body{padding:0 20px 20px;border-top:1px solid var(--border)}
::-webkit-scrollbar{width:4px;height:4px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border-md);border-radius:2px}
@media(max-width:640px){
  .nav-inner{flex-direction:column;align-items:flex-start;gap:6px;padding:10px 20px}
  .nav-right{width:100%;gap:8px;flex-wrap:wrap}
  .grid-panels{grid-template-columns:1fr}
  .grid-2-sm{grid-template-columns:1fr}
  .check-item{overflow:hidden}
  a{word-break:break-all}
  /* Free Time cards: on narrow screens the title wrapper gets squeezed by
     the button group into a tiny cell, wrapping word-by-word vertically.
     Fix: let the text wrapper grow large (wide min-width) so when wrapping
     happens it takes the full row, and actions flex-wrap to the row below. */
  .activity-card{overflow:hidden}
  .activity-card .act-text-wrap{min-width:60%}
  .activity-card .act-actions{flex-basis:100%;justify-content:flex-start;margin-left:40px}
  .act-text{overflow-wrap:anywhere;word-break:normal}
}
@media(max-width:520px){
  .greeting{font-size:1.2rem}
  .stat-num{font-size:1.3rem}
  .card{padding:14px 16px}
}

/* ── Light theme ─────────────────────────────────────────────────────────── */
body.theme-light {
  --bg:        #f5f0eb;
  --bg2:       #ffffff;
  --surface:   #ffffff;
  --surface2:  #faf7f4;
  --border:    #e8e0d6;
  --border-md: #d4c8ba;
  --text:      #1e1510;
  --text2:     #4a3a2a;
  --text3:     #8a7868;
  --terra:     #b84a22;
  --terra-lt:  rgba(184,74,34,.1);
  --terra-md:  rgba(184,74,34,.25);
  --amber:     #c47828;
  --amber-lt:  rgba(196,120,40,.1);
  --amber-md:  rgba(196,120,40,.25);
  --teal:      #3d8a7a;
  --teal-lt:   rgba(61,138,122,.1);
  --teal-md:   rgba(61,138,122,.25);
  --purple:    #6b5eb0;
  --purple-lt: rgba(107,94,176,.1);
  --peach:     #c2643a;
  --peach-lt:  rgba(194,100,58,.1);
  --green:     #4a8c3a;
  --green-lt:  rgba(74,140,58,.1);
  --red:       #a83030;
  --red-lt:    rgba(168,48,48,.1);
  --blue:      #3a72a8;
  --blue-lt:   rgba(58,114,168,.1);
  --blue-md:   rgba(58,114,168,.25);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,.12);
}
body.theme-light .nav {
  box-shadow: 0 1px 6px rgba(0,0,0,.1);
}
body.theme-light select.form-input option {
  background: #fff;
}

/* ── Theme toggle button ──────────────────────────────────────────────────── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-md);
  color: var(--text3);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: .75rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.theme-toggle:hover {
  border-color: var(--amber-md);
  color: var(--text2);
}

/* ── Celebrations & animations ────────────────────────────────────────────── */
@keyframes checkPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(.9); }
  100% { transform: scale(1); }
}
@keyframes slideComplete {
  from { opacity:1; transform:translateX(0); }
  to   { opacity:.45; transform:translateX(4px); }
}
@keyframes floatUp {
  0%   { opacity:1; transform:translateY(0) scale(1); }
  100% { opacity:0; transform:translateY(-36px) scale(1.4); }
}
@keyframes milestoneSlide {
  0%   { opacity:0; transform:translateY(-12px); }
  15%  { opacity:1; transform:translateY(0); }
  80%  { opacity:1; transform:translateY(0); }
  100% { opacity:0; transform:translateY(-12px); }
}
@keyframes sparkle {
  0%   { opacity:1; transform:scale(0) rotate(0deg); }
  60%  { opacity:1; transform:scale(1.2) rotate(180deg); }
  100% { opacity:0; transform:scale(.6) rotate(360deg); }
}
.checkbox.pop { animation: checkPop .3s ease forwards; }
.done-item    { animation: slideComplete .25s ease forwards; }
.float-up {
  position:fixed; pointer-events:none; z-index:9999;
  font-size:1.1rem; font-weight:700; color:var(--teal);
  animation: floatUp .7s ease forwards;
}
.milestone-toast {
  position:fixed; top:16px; left:50%; transform:translateX(-50%);
  background:var(--surface); border:1px solid var(--border-md);
  border-radius:var(--r-lg); padding:12px 24px;
  font-family:'Lora',serif; font-size:.95rem; font-style:italic;
  color:var(--text); box-shadow:0 8px 32px rgba(0,0,0,.15);
  z-index:9999; white-space:nowrap; pointer-events:none;
  animation: milestoneSlide 3s ease forwards;
}
.sparkle-burst {
  position:fixed; pointer-events:none; z-index:9999;
  font-size:1.3rem;
  animation: sparkle .6s ease forwards;
}
.streak-badge {
  display:inline-flex; align-items:center; gap:4px;
  font-size:.72rem; font-weight:700; color:var(--amber);
  background:var(--amber-lt); border:1px solid var(--amber);
  border-radius:99px; padding:2px 8px; margin-left:8px;
  vertical-align:middle;
}

/* ── Task form controls row ───────────────────────────────────────────────── */
.task-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.task-controls .ctrl-group {
  display: flex;
  gap: 6px;
  align-items: center;
}
.task-controls .ctrl-label {
  font-size: .78rem;
  color: var(--text2);
  font-weight: 600;
  white-space: nowrap;
}
.task-controls .remind-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
}
@media(max-width: 600px){
  .task-controls { gap: 10px; }
  .task-controls .form-input[type="date"] { width: 100%; }
  .task-controls .freq-select { width: 100%; }
}

/* ── iOS keyboard bounce fix ─────────────────────────────────────────────── */
@supports (-webkit-touch-callout: none) {
  body { min-height: -webkit-fill-available; }
}
html { height: -webkit-fill-available; }

/* ── Mobile routine task card ────────────────────────────────────────────── */
.item-cat-row { display:none; }
@media(max-width:600px){
  .routine-edit-btn { display:none !important; }
  .check-item .tod-icons { display:none !important; }
  .check-item .item-emoji { display:none; }
  .check-item .item-cat { display:none; }
  .check-item > .drag-handle,
  .activity-card > .drag-handle,
  .kb-card > .kb-drag-handle{ font-size:1.3rem; }
  .check-item > .drag-handle,
  .activity-card > .drag-handle{ width:36px; }
  .item-cat-row { display:flex; align-items:center; gap:6px; width:100%; margin-top:4px; flex-wrap:wrap; padding-left:42px; }
  .item-cat-row .tod-icons-mobile { display:flex; gap:3px; margin-left:auto; }
}
@media(max-width:600px){
  .tod-icons { display:none !important; }
  .tod-icons-mobile { display:flex !important; }
  .check-item { flex-wrap:wrap; }
}

/* ── Group completion inline message ─────────────────────────────────────── */
@keyframes groupMsgIn {
  0%   { opacity:0; transform:translateX(-8px); }
  60%  { opacity:1; transform:translateX(2px); }
  100% { opacity:1; transform:translateX(0); }
}
.group-complete-animate {
  animation: groupMsgIn .5s ease forwards;
}

/* ── TOD icon tooltips ───────────────────────────────────────────────────── */
.tod-btn { position:relative; }



/* ── JS tooltip ──────────────────────────────────────────────────────────── */
#clio-tooltip {
  position:fixed;
  background:var(--text);
  color:var(--surface);
  font-size:.72rem;
  font-weight:500;
  padding:4px 10px;
  border-radius:var(--r-sm);
  pointer-events:none;
  z-index:99999;
  max-width:220px;
  text-align:center;
  line-height:1.4;
  white-space:normal;
  opacity:0;
  transition:opacity .15s;
}

/* ── iOS input-zoom prevention ──────────────────────────────────────────── */
/* iOS Safari auto-zooms on focus when input font-size < 16px. This rule   */
/* catches inputs with inline styles (e.g. the Ask Clio chat textarea)     */
/* that bypass .form-input. Desktop is unaffected.                         */
@media screen and (max-width: 768px) {
  input, textarea, select { font-size: 16px !important; }
}

/* ── Kanban board ───────────────────────────────────────────────────────── */
.kb-board{display:grid;grid-template-columns:1fr 1fr 1fr;gap:14px;align-items:start}
.kb-col{display:flex;flex-direction:column;min-height:120px}
.kb-col-header{display:flex;align-items:center;justify-content:space-between;padding:8px 10px;margin-bottom:8px;border-radius:var(--r-sm)}
.kb-col-label{font-size:.78rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:var(--text2);cursor:pointer}
.kb-col-label:hover{opacity:.7}
.kb-col-count{font-size:.68rem;color:var(--text3);font-weight:600;background:var(--surface2);border-radius:99px;padding:1px 7px;min-width:18px;text-align:center;line-height:1.6}
.kb-col-body{flex:1;min-height:60px;padding:8px;background:var(--surface2);border:1.5px dashed var(--border);border-radius:var(--r-md);display:flex;flex-direction:column;gap:8px;transition:background .15s,border-color .15s}
.kb-drop-target{background:var(--terra-lt,rgba(194,84,42,.08));border-color:var(--terra)}
.kb-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--r-sm);padding:0;transition:box-shadow .15s,opacity .15s;display:flex;flex-direction:row;overflow:hidden}
.kb-card:hover{box-shadow:0 2px 8px rgba(0,0,0,.08)}
.kb-card-done{opacity:.6}
.kb-card-done .kb-card-text{text-decoration:line-through;color:var(--text3)}
.kb-card-overdue{border-left:3px solid var(--red)}
/* Kanban card body — sits to the right of the drag handle column.
   Padding moved from .kb-card to here so the handle stripe can go
   edge-to-edge. */
.kb-card-content{flex:1;min-width:0;padding:10px 12px}
.kb-dragging{opacity:.3}
/* SortableJS visual: placeholder slot where the dragged card will land */
.kb-ghost{opacity:.4;background:var(--terra-lt,rgba(194,84,42,.08));border-color:var(--terra)}
.kb-card-top{display:flex;align-items:flex-start;gap:8px}
.kb-card-text{flex:1;font-size:.84rem;line-height:1.4;color:var(--text);cursor:pointer;min-width:0;word-break:break-word}
.kb-card-meta{font-size:.72rem;margin-top:6px;line-height:1.6;display:flex;flex-wrap:wrap;gap:4px}
.kb-card-actions{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}
.kb-action-btn{background:none;border:1px solid var(--border-md);border-radius:var(--r-sm);color:var(--terra);font-size:.68rem;padding:3px 8px;cursor:pointer;font-weight:600;font-family:inherit;white-space:nowrap}
.kb-action-btn:hover{background:var(--terra-lt)}
.kb-del{font-size:.9rem;flex-shrink:0;margin-left:auto}
.kb-add-btn{width:100%;padding:10px;background:transparent;border:1.5px dashed var(--border-md);border-radius:var(--r-md);color:var(--text3);font-size:.82rem;font-weight:500;cursor:pointer;font-family:inherit;transition:all .15s}
.kb-add-btn:hover{border-color:var(--terra);color:var(--terra)}
.kb-add-form{padding:12px;background:var(--surface);border:1px solid var(--border);border-radius:var(--r-sm)}
.kb-add-form .task-controls{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-end}
.kb-add-form .ctrl-group{display:flex;flex-direction:column;gap:3px}
.kb-add-form .ctrl-label{font-size:.68rem;font-weight:600;color:var(--text3);text-transform:uppercase;letter-spacing:.04em}
.kb-add-form .remind-label{font-size:.78rem;color:var(--text2);display:flex;align-items:center;gap:4px;white-space:nowrap}
.kb-empty{padding:20px;text-align:center;font-size:.8rem;color:var(--text3);font-style:italic}
.kb-label-input{font-size:.78rem !important;padding:4px 8px !important;width:120px}
.kb-move-row{display:none;gap:6px;margin-top:8px;flex-wrap:wrap}
.kb-move-btn{background:var(--surface2);border:1px solid var(--border-md);border-radius:var(--r-sm);color:var(--text2);font-size:.68rem;padding:3px 8px;cursor:pointer;font-weight:600;font-family:inherit;white-space:nowrap}
.kb-move-btn:hover{background:var(--terra-lt);color:var(--terra);border-color:var(--terra)}

/* Mobile: stack columns, show move buttons as a tap-fallback alongside drag */
@media(max-width:768px){
  .kb-board{grid-template-columns:1fr;gap:20px}
  .kb-col-body{min-height:40px}
  .kb-move-row{display:flex}
}

/* ── Mobile bottom tabbar ──────────────────────────────────────────────── */
/* Chess.com-style fixed bottom navigation. Visible only on mobile; desktop
   uses the existing .tabs at the top of the page. Five buttons: four direct
   sections plus a "More" button that opens a full-screen overlay for the
   remaining sections. */
.mobile-tabbar { display:none; }
.more-overlay  { display:none; }
@media(max-width:768px){
  /* Hide the top tabs on mobile — the bottom bar replaces them entirely. */
  .tabs { display:none !important; }

  .mobile-tabbar{
    display:flex;
    position:fixed;
    left:0; right:0; bottom:0;
    z-index:90;
    background:var(--surface);
    border-top:1px solid var(--border);
    /* iOS home-indicator safe area — prevents tap targets from being
       crowded by the system gesture area on newer iPhones. */
    padding-bottom:env(safe-area-inset-bottom);
    /* Subtle elevation so content scrolling underneath is visibly separated */
    box-shadow:0 -2px 10px rgba(0,0,0,.04);
  }
  .mtb-btn{
    flex:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:3px;
    background:none;
    border:none;
    padding:8px 4px 6px;
    cursor:pointer;
    /* Darker, bolder default so inactive icons read as intentional rather
       than faded — matches the heavier look of the "More" overlay rows. */
    color:var(--text2);
    font-family:inherit;
    font-size:.64rem;
    font-weight:600;
    line-height:1.1;
    min-height:52px;
    position:relative;
    transition:color .15s;
    -webkit-tap-highlight-color:transparent;
  }
  .mtb-btn.active{ color:var(--terra); }
  .mtb-btn:active{ opacity:.6; }
  /* Thicker stroke gives the icons a bolder, more present feel — matches
     the visual weight of labels and the More-overlay row icons. */
  .mtb-icon{ width:22px; height:22px; display:block; flex-shrink:0; stroke-width:2.5; }
  .mtb-label{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:100%;
  }
  /* Badge (pending-count indicator) inside the bar — small red dot upper-right of icon */
  .mtb-badge{
    position:absolute;
    top:4px;
    right:50%;
    margin-right:-18px;
    min-width:16px;
    height:16px;
    padding:0 4px;
    border-radius:8px;
    background:var(--red,#c2542a);
    color:#fff;
    font-size:.62rem;
    font-weight:700;
    line-height:16px;
    text-align:center;
  }

  /* Push main page content up off the bar so the last list item isn't
     hidden under it. 64px bar + safe-area — estimated conservatively. */
  body{ padding-bottom:calc(72px + env(safe-area-inset-bottom)) !important; }

  /* Mobile only: compact the header depending on which tab is active.
     Two independent toggles driven by body classes set in activateTopTab:
       body.non-routine-tab       → hide the greeting block (routine-specific).
       body.hide-header-actions   → hide the two Clio action buttons (Account/Admin).
     Routine tab:    both visible.
     Work/FreeTime/
     Promises/
     Progress:       greeting hidden, action buttons visible (Clio still reachable).
     Account/Admin:  both hidden (no relevant context).
     Desktop keeps the whole header on every tab — these rules live inside
     the <=768px media block only. */
  body.non-routine-tab .page-header-greeting{ display:none !important; }
  body.hide-header-actions .page-header-actions{ display:none !important; }
  /* When both children are hidden, collapse the empty .page-header so it
     doesn't leave residual margin/padding above the tab content. */
  body.non-routine-tab.hide-header-actions .page-header{ display:none !important; }

  /* Mobile: tighten the page-header's own padding. Desktop default of
     32px top / 24px bottom leaves too much dead space on a phone,
     especially on non-routine tabs where the greeting is hidden. */
  .page-header{ padding:12px 0 16px !important; }
  /* And on non-routine tabs where the greeting block is gone, kill the
     btn-suggest's own 18px top margin — the only thing above it is the
     .clio-eyebrow which already has margin-bottom for breathing room. */
  body.non-routine-tab .page-header-actions .btn-suggest{ margin-top:4px; }

  /* ── "More" overlay ──────────────────────────────────────────────────── */
  .more-overlay{
    display:block;
    position:fixed;
    inset:0;
    z-index:95;           /* above the tabbar (90) so the backdrop covers it */
    pointer-events:none;
    opacity:0;
    transition:opacity .2s;
  }
  .more-overlay.open{
    pointer-events:auto;
    opacity:1;
  }
  .more-overlay-backdrop{
    position:absolute;
    inset:0;
    background:rgba(0,0,0,.45);
  }
  .more-overlay-sheet{
    position:absolute;
    left:0; right:0; bottom:0;
    background:var(--surface);
    border-top-left-radius:16px;
    border-top-right-radius:16px;
    padding:8px 0 env(safe-area-inset-bottom);
    max-height:80vh;
    overflow-y:auto;
    transform:translateY(100%);
    transition:transform .25s ease-out;
    box-shadow:0 -8px 30px rgba(0,0,0,.25);
  }
  .more-overlay.open .more-overlay-sheet{ transform:translateY(0); }
  .more-overlay-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:12px 20px 8px;
    border-bottom:1px solid var(--border);
    margin-bottom:4px;
  }
  .more-overlay-title{
    font-family:'Lora',serif;
    font-size:1.05rem;
    font-weight:600;
    color:var(--text);
  }
  .more-overlay-close{
    background:none;
    border:none;
    font-size:1.6rem;
    line-height:1;
    color:var(--text3);
    cursor:pointer;
    padding:4px 8px;
    -webkit-tap-highlight-color:transparent;
  }
  .more-overlay-list{ padding:8px 0; }
  .more-row{
    display:grid;
    grid-template-columns:36px 1fr;
    grid-template-rows:auto auto;
    column-gap:14px;
    align-items:center;
    width:100%;
    padding:14px 20px;
    background:none;
    border:none;
    border-bottom:1px solid var(--border);
    cursor:pointer;
    text-align:left;
    font-family:inherit;
    -webkit-tap-highlight-color:transparent;
  }
  .more-row:last-child{ border-bottom:none; }
  .more-row:active{ background:var(--surface2); }
  .more-row-icon{
    grid-row:1 / 3;
    width:28px;
    height:28px;
    color:var(--text2);
  }
  .more-row-label{
    grid-column:2;
    grid-row:1;
    font-size:.95rem;
    font-weight:600;
    color:var(--text);
    line-height:1.2;
  }
  .more-row-hint{
    grid-column:2;
    grid-row:2;
    font-size:.78rem;
    color:var(--text3);
    line-height:1.3;
    margin-top:2px;
  }
}
