:root{
  --purple:#6b4ee6;
  --purple-dark:#5a3fd0;
  --purple-light:#f0ecff;
  --green:#16a34a;
  --green-light:#e8f8ee;
  --orange:#f97316;
  --orange-light:#fef1e6;
  --bg:#f4f5fa;
  --card-bg:#ffffff;
  --border:#eaebf2;
  --text-dark:#1f2233;
  --text-mid:#6b7086;
  --text-light:#9a9fb3;
  --radius-lg:18px;
  --radius-md:14px;
  --radius-sm:10px;
  --shadow-sm:0 1px 3px rgba(20,20,50,.04);
  --shadow-md:0 8px 24px rgba(30,30,70,.08);
  --shadow-lg:0 16px 40px rgba(30,30,70,.14);
}

*{box-sizing:border-box;}

body{
  margin:0;
  font-family:'Inter',system-ui,sans-serif;
  background:var(--bg);
  color:var(--text-dark);
  -webkit-font-smoothing:antialiased;
}

a{text-decoration:none;color:inherit;}
button{font-family:inherit;}

/* ================= APP SHELL ================= */
.app-shell{
  display:flex;
  min-height:100vh;
}

/* ================= SIDEBAR ================= */
.sidebar{
  width:250px;
  flex-shrink:0;
  background:var(--card, #ffffff);
  border-right:1px solid var(--border, #e2e8f0);
  padding:28px 20px;
  display:flex;
  flex-direction:column;
  position:sticky;
  top:0;
  height:100vh;
  z-index:100;
  transition:transform .3s ease;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 6px 32px;
}
.brand-icon{
  width:40px;height:40px;
  border-radius:12px;
  background:rgba(108,92,231,0.12);
  display:flex;align-items:center;justify-content:center;
  font-size:20px;
  flex-shrink:0;
}
.brand-icon i{color:#6C5CE7;}
.brand-name{font-family:'Plus Jakarta Sans', sans-serif;font-weight:800;font-size:17px;line-height:1.1;color:var(--text-dark, #1e293b);}
.brand-tag{font-size:11.5px;color:var(--text-light, #64748b);margin-top:2px;}
.sidebar-close {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--text-mid, #64748b);
  cursor: pointer;
}

.side-nav{
  display:flex;
  flex-direction:column;
  gap:4px;
  flex:1;
}
.side-link{
  display:flex;
  align-items:center;
  gap:12px;
  padding:11px 14px;
  border-radius:12px;
  color:var(--text-mid, #64748b);
  font-size:14.5px;
  font-weight:500;
  text-decoration:none;
  transition:background .15s ease, color .15s ease, transform .15s ease;
}
.side-link i{font-size:17px;width:20px;text-align:center;flex-shrink:0;}
.side-link:hover{background:var(--bg, #f8fafc);color:var(--text-dark, #1e293b);transform:translateX(2px);}
.side-link.active{
  background:#6C5CE7;
  color:#fff !important;
  font-weight:600;
  box-shadow:0 4px 12px rgba(108,92,231,.35);
}
.side-link.active i{color:#fff !important;}
.side-link.active:hover{transform:none;}

.sidebar-footer{
  border-top:1px solid var(--border, #e2e8f0);
  padding-top:16px;
  margin-top:auto;
}
.logout-btn, .logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 500;
  color: #E5484D;
  border: none;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.logout-btn i, .logout i { font-size: 17px; width: 20px; text-align: center; }
.logout-btn:hover, .logout:hover { background: #FEF2F2; color: #DC2626; transform: translateX(2px); }

/* ================= MAIN CONTENT ================= */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1020;
}
.hamburger-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-dark);
  display: flex;
  align-items: center;
}
.mobile-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mobile-logo-text {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 16px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1025;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* ================= TOPBAR ================= */
.topbar{
  display:flex;
  align-items:center;
  gap:18px;
  padding:20px 28px;
  flex-wrap:wrap;
}
.btn-burger{
  background:#fff;border:1px solid var(--border);border-radius:10px;
  width:40px;height:40px;font-size:18px;
}
.page-title-wrap{flex:1;min-width:180px;}
.page-title{
  font-size:26px;font-weight:800;margin:0;
  display:flex;align-items:center;gap:10px;
}
.page-title i{color:var(--purple);font-size:22px;}
.page-subtitle{margin:2px 0 0;color:var(--text-mid);font-size:13.5px;}

.topbar-right{
  display:flex;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
}

.date-pill{
  display:flex;align-items:center;gap:8px;
  background:#fff;border:1px solid var(--border);
  padding:10px 16px;border-radius:12px;
  font-size:13.5px;font-weight:600;color:var(--text-dark);
  white-space:nowrap;
}
.date-pill i{color:var(--purple);}

.search-wrap{
  position:relative;
  display:flex;align-items:center;
  background:#fff;border:1px solid var(--border);
  border-radius:12px;padding:10px 16px;
  min-width:230px;
}
.search-wrap i{color:var(--text-light);margin-right:8px;}
.search-wrap input{
  border:none;outline:none;font-size:13.5px;width:100%;background:transparent;
}
.search-results{
  position:absolute;top:calc(100% + 8px);left:0;right:0;
  background:#fff;border:1px solid var(--border);
  border-radius:12px;box-shadow:var(--shadow-lg);
  max-height:280px;overflow-y:auto;
  display:none;z-index:1050;
}
.search-results.show{display:block;}
.search-result-item{
  padding:10px 14px;font-size:13px;border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:10px;cursor:pointer;
}
.search-result-item:last-child{border-bottom:none;}
.search-result-item:hover{background:var(--bg);}
.search-result-item i{color:var(--purple);}
.search-result-empty{padding:14px;font-size:13px;color:var(--text-light);text-align:center;}

.notif-wrap{position:relative;}
.notif-btn{
  width:42px;height:42px;border-radius:12px;
  background:#fff;border:1px solid var(--border);
  font-size:18px;color:var(--text-mid);position:relative;
}
.notif-badge{
  position:absolute;top:-6px;right:-6px;
  background:#e5484d;color:#fff;font-size:10.5px;font-weight:700;
  min-width:18px;height:18px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  padding:0 4px;
}
.notif-badge.hide{display:none;}
.notif-dropdown{
  position:absolute;top:calc(100% + 10px);right:0;
  width:340px;max-width:90vw;
  background:#fff;border:1px solid var(--border);
  border-radius:14px;box-shadow:var(--shadow-lg);
  display:none;z-index:1060;overflow:hidden;
}
.notif-dropdown.show{display:block;}
.notif-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 16px;border-bottom:1px solid var(--border);
  font-weight:700;font-size:14px;
}
.notif-actions{display:flex;gap:6px;}
.notif-actions button{
  border:none;background:var(--bg);width:30px;height:30px;border-radius:8px;
  color:var(--text-mid);font-size:13px;
}
.notif-actions button:hover{background:var(--purple-light);color:var(--purple-dark);}
.notif-list{max-height:340px;overflow-y:auto;}
.notif-item{
  display:flex;gap:10px;padding:12px 16px;border-bottom:1px solid var(--border);
  position:relative;
}
.notif-item.unread{background:#faf9ff;}
.notif-item:last-child{border-bottom:none;}
.notif-icon{
  width:34px;height:34px;border-radius:9px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:15px;
}
.notif-icon.type-study{background:var(--purple-light);color:var(--purple);}
.notif-icon.type-workout{background:var(--green-light);color:var(--green);}
.notif-icon.type-meal{background:var(--orange-light);color:var(--orange);}
.notif-icon.type-deadline{background:#fdeceb;color:#e5484d;}
.notif-icon.type-reminder{background:#fff7e0;color:#c98a00;}
.notif-text{flex:1;}
.notif-text .n-title{font-size:13px;font-weight:600;margin:0;}
.notif-text .n-desc{font-size:12px;color:var(--text-mid);margin:2px 0 0;}
.notif-text .n-time{font-size:11px;color:var(--text-light);margin-top:4px;}
.notif-del{
  border:none;background:none;color:var(--text-light);font-size:13px;
  align-self:flex-start;
}
.notif-del:hover{color:#e5484d;}
.notif-empty{padding:30px 16px;text-align:center;color:var(--text-light);font-size:13px;}

/* ================= CONTENT GRID ================= */
.content-grid{
  display:grid;
  grid-template-columns:1fr 360px;
  gap:22px;
  padding:0 28px 28px;
  align-items:start;
}
.content-main{display:flex;flex-direction:column;gap:22px;min-width:0;}

.panel{
  background:var(--card-bg);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:24px;
  box-shadow:var(--shadow-sm);
}
.panel-title{font-size:18px;font-weight:800;margin:0 0 4px;}
.panel-sub{margin:0 0 18px;color:var(--text-mid);font-size:13.5px;}
.panel-head-row{
  display:flex;align-items:center;justify-content:space-between;margin-bottom:18px;
}

/* ================= CATEGORY CARDS ================= */
.category-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:18px;
}
.category-card{
  border:1.5px solid var(--border);
  border-radius:var(--radius-md);
  padding:26px 22px;
  cursor:pointer;
  transition:transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease, border-color .22s ease;
  position:relative;
  background:#fff;
}
.category-card:hover{
  transform:translateY(-6px);
  box-shadow:var(--shadow-md);
}
.category-card:active,
.category-card.clicked{
  transform:translateY(-2px) scale(.97);
}
.category-card h3{font-size:17px;font-weight:800;margin:0 0 6px;}
.category-card p{font-size:13px;color:var(--text-mid);margin:0 0 20px;line-height:1.5;min-height:40px;}

.cat-icon{
  width:56px;height:56px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  font-size:24px;margin-bottom:18px;
  transition:transform .25s ease;
}
.category-card:hover .cat-icon{transform:scale(1.08) rotate(-4deg);}

.cat-study{background:var(--purple-light);}
.cat-study .cat-icon{background:#e3dbff;color:var(--purple);}
.cat-fitness{background:var(--green-light);}
.cat-fitness .cat-icon{background:#d3f3df;color:var(--green);}
.cat-meal{background:var(--orange-light);}
.cat-meal .cat-icon{background:#fde2c8;color:var(--orange);}

.cat-arrow{
  width:38px;height:38px;border-radius:10px;border:none;
  background:#fff;color:var(--text-dark);font-size:15px;
  display:flex;align-items:center;justify-content:center;
  transition:background .2s ease, color .2s ease, transform .2s ease;
  box-shadow:0 2px 6px rgba(20,20,50,.08);
}
.cat-study .cat-arrow:hover{background:var(--purple);color:#fff;transform:translateX(4px);}
.cat-fitness .cat-arrow:hover{background:var(--green);color:#fff;transform:translateX(4px);}
.cat-meal .cat-arrow:hover{background:var(--orange);color:#fff;transform:translateX(4px);}

/* ================= CREATE PLAN BTN ================= */
.btn-create-plan{
  display:flex;align-items:center;gap:6px;
  background:var(--purple);color:#fff;border:none;
  padding:9px 16px;border-radius:10px;font-size:13.5px;font-weight:700;
  transition:background .2s ease, transform .2s ease;
}
.btn-create-plan:hover{background:var(--purple-dark);transform:translateY(-1px);}

/* ================= PLANS GRID ================= */
.plans-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(260px,1fr));
  gap:18px;
}
.plan-card{
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  padding:20px;
  position:relative;
  transition:box-shadow .2s ease, transform .2s ease;
}
.plan-card:hover{box-shadow:var(--shadow-md);transform:translateY(-3px);}
.plan-card.favorite{border-color:#ffd166;}
.plan-card .plan-top{display:flex;align-items:flex-start;gap:12px;}
.plan-icon{
  width:42px;height:42px;border-radius:11px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:19px;
}
.plan-icon.Study{background:var(--purple-light);color:var(--purple);}
.plan-icon.Fitness{background:var(--green-light);color:var(--green);}
.plan-icon.Meal{background:var(--orange-light);color:var(--orange);}
.plan-name-row{flex:1;min-width:0;}
.plan-name{font-weight:800;font-size:15px;margin:0;display:flex;align-items:center;gap:6px;}
.plan-name .fav-star{color:#ffb703;font-size:12px;}
.plan-meta{font-size:12px;color:var(--text-mid);margin-top:3px;display:flex;gap:8px;flex-wrap:wrap;}
.plan-status-badge{
  font-size:10.5px;font-weight:700;padding:2px 8px;border-radius:20px;
  text-transform:uppercase;letter-spacing:.3px;
}
.plan-status-badge.active{background:var(--green-light);color:var(--green);}
.plan-status-badge.archived{background:#eee;color:#888;}
.plan-status-badge.completed{background:var(--purple-light);color:var(--purple);}

.plan-menu-btn{
  border:none;background:none;color:var(--text-light);font-size:16px;
  padding:4px 6px;border-radius:6px;
}
.plan-menu-btn:hover{background:var(--bg);}

.plan-progress-row{margin:16px 0 4px;}
.progress-track{
  height:7px;border-radius:20px;background:#eef0f6;overflow:hidden;
}
.progress-fill{height:100%;border-radius:20px;transition:width .5s ease;}
.progress-fill.Study{background:linear-gradient(90deg,#8b6ff0,var(--purple));}
.progress-fill.Fitness{background:linear-gradient(90deg,#34d17a,var(--green));}
.progress-fill.Meal{background:linear-gradient(90deg,#fbaa4a,var(--orange));}
.plan-pct{font-size:11.5px;color:var(--text-mid);margin-top:6px;display:flex;justify-content:space-between;}

.plan-dates{font-size:11px;color:var(--text-light);margin-top:10px;}

.plan-footer-row{
  display:flex;align-items:center;justify-content:space-between;
  margin-top:14px;
}
.btn-view-plan{
  background:var(--purple-light);color:var(--purple-dark);
  border:none;padding:8px 16px;border-radius:9px;font-size:12.5px;font-weight:700;
  transition:background .2s ease;
}
.btn-view-plan.Fitness{background:var(--green-light);color:var(--green);}
.btn-view-plan.Meal{background:var(--orange-light);color:var(--orange);}
.btn-view-plan:hover{filter:brightness(.95);}

.plan-empty{
  grid-column:1/-1;text-align:center;padding:40px 10px;color:var(--text-light);font-size:13.5px;
}

/* dropdown menu for plan card */
.plan-dropdown-menu{
  position:absolute;top:44px;right:16px;
  background:#fff;border:1px solid var(--border);border-radius:12px;
  box-shadow:var(--shadow-lg);min-width:170px;overflow:hidden;
  display:none;z-index:20;
}
.plan-dropdown-menu.show{display:block;}
.plan-dropdown-menu button{
  width:100%;text-align:left;border:none;background:none;
  padding:10px 14px;font-size:13px;display:flex;align-items:center;gap:9px;color:var(--text-dark);
}
.plan-dropdown-menu button:hover{background:var(--bg);}
.plan-dropdown-menu button.danger{color:#e5484d;}
.plan-dropdown-menu hr{margin:4px 0;border-color:var(--border);}

/* ================= TODAY OVERVIEW ================= */
.overview-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:18px;
}
.overview-card{
  border:1px solid var(--border);border-radius:var(--radius-md);
  padding:18px;
}
.overview-top{display:flex;align-items:center;gap:10px;margin-bottom:14px;}
.overview-icon{
  width:38px;height:38px;border-radius:10px;
  display:flex;align-items:center;justify-content:center;font-size:17px;
}
.overview-icon.study{background:var(--purple-light);color:var(--purple);}
.overview-icon.workout{background:var(--green-light);color:var(--green);}
.overview-icon.meal{background:var(--orange-light);color:var(--orange);}
.overview-title{font-weight:700;font-size:14px;}
.overview-count{font-size:12.5px;color:var(--text-mid);margin-top:1px;}

/* ================= STATS ================= */
.stats-grid{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:16px;
  margin-bottom:22px;
}
.stat-card{
  border:1px solid var(--border);border-radius:var(--radius-md);
  padding:18px;text-align:center;
}
.stat-value{font-size:26px;font-weight:800;color:var(--purple);}
.stat-label{font-size:12px;color:var(--text-mid);margin-top:4px;}
.weekly-chart-wrap{padding:6px 4px 0;}

/* ================= AI COACH ================= */
.ai-coach-panel{position:sticky;top:20px;}
.ai-coach-card{
  background:#fff;border:1px solid var(--border);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
  display:flex;flex-direction:column;
  max-height:calc(100vh - 40px);
  overflow:hidden;
}
.ai-coach-head{
  display:flex;align-items:center;gap:12px;
  padding:18px 18px 14px;border-bottom:1px solid var(--border);
}
.ai-avatar{
  width:44px;height:44px;border-radius:50%;
  background:var(--purple-light);color:var(--purple);
  display:flex;align-items:center;justify-content:center;font-size:19px;
  position:relative;flex-shrink:0;
}
.ai-head-text{flex:1;}
.ai-name{font-weight:800;font-size:14.5px;}
.ai-status{font-size:12px;color:var(--text-mid);display:flex;align-items:center;gap:5px;}
.dot-online{width:7px;height:7px;border-radius:50%;background:var(--green);display:inline-block;}
.ai-head-actions{display:flex;gap:4px;}
.ai-head-actions button{
  border:none;background:none;color:var(--text-light);width:28px;height:28px;border-radius:7px;font-size:13px;
}
.ai-head-actions button:hover{background:var(--bg);color:var(--text-dark);}

.ai-chat-search-bar{
  display:flex;align-items:center;gap:8px;
  padding:10px 16px;border-bottom:1px solid var(--border);
  background:var(--bg);
}
.ai-chat-search-bar i{color:var(--text-light);}
.ai-chat-search-bar input{border:none;background:transparent;outline:none;font-size:13px;width:100%;}

.ai-chat-body{
  padding:18px;
  overflow-y:auto;
  flex:1;
  display:flex;flex-direction:column;gap:10px;
}
.ai-msg{
  padding:12px 14px;border-radius:14px;font-size:13.5px;line-height:1.5;
  max-width:90%;
}
.ai-msg p{margin:0 0 4px;}
.ai-msg p:last-child{margin-bottom:0;}
.ai-msg-bot{background:var(--bg);border-top-left-radius:4px;align-self:flex-start;}
.ai-msg-user{background:var(--purple);color:#fff;border-top-right-radius:4px;align-self:flex-end;}
.ai-msg-typing{background:var(--bg);align-self:flex-start;padding:14px 16px;border-top-left-radius:4px;}
.typing-dots span{
  width:6px;height:6px;background:var(--text-light);border-radius:50%;
  display:inline-block;margin-right:4px;
  animation:blink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2){animation-delay:.2s;}
.typing-dots span:nth-child(3){animation-delay:.4s;}
@keyframes blink{0%,80%,100%{opacity:.25;}40%{opacity:1;}}

.ai-suggestions{display:flex;flex-direction:column;gap:8px;margin-top:4px;}
.ai-suggestion{
  display:flex;align-items:center;gap:12px;
  border:1px solid var(--border);background:#fff;
  border-radius:12px;padding:11px 12px;text-align:left;
  transition:background .18s ease, transform .18s ease, border-color .18s ease;
}
.ai-suggestion i{font-size:17px;color:var(--purple);width:20px;}
.ai-suggestion strong{display:block;font-size:13px;color:var(--purple-dark);}
.ai-suggestion span{font-size:11.5px;color:var(--text-mid);}
.ai-suggestion:hover{background:var(--purple-light);border-color:var(--purple);transform:translateX(3px);}

#aiChatHistoryList{display:flex;flex-direction:column;gap:8px;}
.chat-history-item{
  display:flex;align-items:center;gap:8px;
  border:1px solid var(--border);border-radius:10px;padding:9px 10px;font-size:12.5px;
}
.chat-history-item span{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.chat-history-item button{border:none;background:none;color:var(--text-light);font-size:12px;padding:2px 4px;}
.chat-history-item button:hover{color:var(--purple);}

.ai-chat-input-row{
  display:flex;gap:8px;padding:14px 16px;border-top:1px solid var(--border);
}
.ai-chat-input-row input{
  flex:1;border:1px solid var(--border);border-radius:12px;padding:10px 14px;
  font-size:13px;outline:none;background:var(--bg);
}
.ai-chat-input-row input:focus{border-color:var(--purple);}
.ai-chat-input-row button{
  width:42px;height:42px;border-radius:12px;border:none;
  background:var(--purple);color:#fff;font-size:15px;flex-shrink:0;
  transition:background .2s ease;
}
.ai-chat-input-row button:hover{background:var(--purple-dark);}

/* ================= TOASTS ================= */
.toast-stack{
  position:fixed;bottom:24px;right:24px;z-index:2000;
  display:flex;flex-direction:column;gap:10px;
}
.app-toast{
  background:#1f2233;color:#fff;padding:12px 18px;border-radius:12px;
  font-size:13px;box-shadow:var(--shadow-lg);
  display:flex;align-items:center;gap:10px;
  animation:toastIn .25s ease;
}
.app-toast i{color:var(--green);}
.app-toast.error i{color:#ff6b6b;}
@keyframes toastIn{from{transform:translateY(10px);opacity:0;}to{transform:translateY(0);opacity:1;}}

/* modal button */
.btn-primary-plan{
  background:var(--purple);color:#fff;border:none;padding:8px 18px;border-radius:9px;font-weight:600;
}
.btn-primary-plan:hover{background:var(--purple-dark);color:#fff;}

/* ================= RESPONSIVE ================= */
@media (max-width:1200px){
  .content-grid{grid-template-columns:1fr;}
  .ai-coach-panel{position:static;}
  .stats-grid{grid-template-columns:repeat(2,1fr);}
}

@media (max-width:991px){
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1035;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100vh;
  }
  .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-close { display: block; }
  .main-content { padding: 20px 18px 32px; }
  .mobile-topbar { display: flex; }
  .category-grid{grid-template-columns:1fr;}
  .overview-grid{grid-template-columns:1fr;}
}

@media (max-width:767px){
  .topbar{padding:16px;}
  .content-grid{padding:0 16px 20px;}
  .search-wrap{min-width:150px;}
  .stats-grid{grid-template-columns:repeat(2,1fr);}
  .plans-grid{grid-template-columns:1fr;}
}

@media (max-width:480px){
  .topbar-right{width:100%;}
  .date-pill{order:3;width:100%;justify-content:center;}
  .search-wrap{flex:1;min-width:0;}
  .stats-grid{grid-template-columns:1fr 1fr;}
}

/* backdrop for mobile sidebar */
.sidebar-backdrop{
  display:none;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:1020;
}
.sidebar-backdrop.show{display:block;}

::-webkit-scrollbar{width:6px;height:6px;}
::-webkit-scrollbar-thumb{background:#d7d9e6;border-radius:10px;}

/* ================= WORKSPACE VIEW ================= */
.ws-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.22s ease-out;
}
.ws-modal-content {
  background: #f8fafc;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
  border: 1px solid #e2e8f0;
  width: 100%;
  max-width: 980px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.ws-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.ws-back-btn {
  background: none;
  border: none;
  color: var(--text-mid);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease, transform 0.15s ease;
}
.ws-back-btn:hover {
  color: var(--purple);
  transform: translateX(-3px);
}

.ws-top-info {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.ws-large-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.ws-large-icon.Study { background: #f5f3ff; color: #6C5CE7; }
.ws-large-icon.Fitness { background: #f0fdf4; color: #22C55E; }
.ws-large-icon.Meal { background: #fff7ed; color: #ea580c; }

.ws-title-group h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-dark);
}
.ws-title-group p {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-mid);
}

.ws-layout {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 24px;
}
@media (max-width: 991px) {
  .ws-layout { grid-template-columns: 1fr; }
}

.ws-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.ws-card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.ws-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ws-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.ws-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ws-input-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ws-input-group input, .ws-input-group select {
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  background: #ffffff;
  color: #1e293b;
  width: 100%;
  transition: all 0.2s ease;
}
.ws-input-group input:focus, .ws-input-group select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.ws-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.ws-item-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  transition: all 0.2s ease;
}
.ws-item-row:hover {
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.ws-item-row.completed {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.ws-item-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: transparent;
  font-size: 13px;
  transition: all 0.2s ease;
}
.ws-item-checkbox:hover {
  border-color: #64748b;
  transform: scale(1.05);
}
.ws-item-checkbox.checked {
  color: #ffffff;
}
.ws-item-checkbox.checked.Study { background: #6C5CE7; border-color: #6C5CE7; }
.ws-item-checkbox.checked.Fitness { background: #22C55E; border-color: #22C55E; }
.ws-item-checkbox.checked.Meal { background: #ea580c; border-color: #ea580c; }

.ws-item-body {
  flex: 1;
}
.ws-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}
.ws-item-row.completed .ws-item-title {
  text-decoration: line-through;
  color: var(--text-light);
}
.ws-item-desc {
  font-size: 12.5px;
  color: var(--text-mid);
  margin: 2px 0 0;
}

.ws-item-badge {
  font-size: 12px;
  font-weight: 600;
  color: #6366f1;
  padding: 4px 10px;
  border-radius: 20px;
  background: #f5f3ff;
  border: 1px solid #e0e7ff;
}
.ws-item-badge.Fitness {
  color: #10b981;
  background: #ecfdf5;
  border: 1px solid #d1fae5;
}
.ws-item-badge.Meal {
  color: #f97316;
  background: #fff7ed;
  border: 1px solid #ffedd5;
}

.ws-item-menu {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  transition: color 0.15s ease;
}
.ws-item-menu:hover { color: #EF4444; }

.ws-add-btn {
  background: none;
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.ws-add-btn:hover { opacity: 0.8; }
.ws-add-btn.Study { color: #6C5CE7; }
.ws-add-btn.Fitness { color: #22C55E; }
.ws-add-btn.Meal { color: #ea580c; }

.ws-add-task-btn-row {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}
.ws-add-task-btn {
  background: none;
  border: none;
  color: #6C5CE7;
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.ws-add-task-btn:hover { opacity: 0.8; }

.ws-sidebar-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ws-svg-progress {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin: 16px 0;
}

.ws-subject-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.ws-subject-pill {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 6px 12px;
  border-radius: 12px;
}

.ws-action-btn-full {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.ws-action-btn-full:hover { opacity: 0.9; }
.ws-action-btn-full.Study { background: #6C5CE7; }
.ws-action-btn-full.Fitness { background: #22C55E; }
.ws-action-btn-full.Meal { background: #ea580c; }

.ws-target-row {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.ws-target-row:last-child { border-bottom: none; }
.ws-target-label { color: var(--text-mid); }
.ws-target-val { font-weight: 600; color: var(--text-dark); }

.ws-nutrition-bar {
  margin-bottom: 16px;
}
.ws-nutrition-bar:last-child { margin-bottom: 0; }
.ws-nutrition-head {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 6px;
}
.ws-nutrition-label { font-weight: 600; color: var(--text-mid); }
.ws-nutrition-val { font-weight: 600; color: var(--text-dark); }
.ws-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.ws-progress-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.3s ease;
}
.ws-progress-fill.Calories { background: #ea580c; }
.ws-progress-fill.Protein { background: #22C55E; }
.ws-progress-fill.Carbs { background: #6C5CE7; }
.ws-progress-fill.Fats { background: #facc15; }
