/* ========================
FULL CORRECTED styles.css
Matched to corrected script.js + index.html
======================== */
:root{
  --bg:#FFF6E8;
  --panel:#FFFFFF;
  --panel2:#FFF1D6;
  --text:#1F2937;
  --muted:#6B7280;
  --line:rgba(31,41,55,.10);

  --accent:#FF7A00;
  --cta:#F2A67B;

  --spark:#00B894;
  --shadow: 0 10px 30px rgba(31,41,55,.10);
  --radius:16px;

  --chat-bg: rgba(255,255,255,.55);
  --chat-border: rgba(31,41,55,.10);
  --bubble-bot: rgba(255,255,255,.92);
  --bubble-user: rgba(255,122,0,.14);
  --bubble-radius: 18px;
  --bubble-shadow: 0 10px 24px rgba(31,41,55,.08);

  --overlay-z: 99990;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(900px 600px at 12% 10%, rgba(255,122,0,.16), transparent 60%),
    radial-gradient(900px 600px at 90% 18%, rgba(0,184,148,.14), transparent 60%),
    radial-gradient(900px 600px at 40% 95%, rgba(255,214,102,.20), transparent 65%),
  var(--bg);
  color:var(--text);
  overflow:hidden;
  overscroll-behavior-y:none;
}

a{ color:inherit; }

.app{
  height:100vh;
  display:flex;
}

@supports (height: 100dvh){
  .app{ height:100dvh; }
}

.sidebar{
  width:280px;
  padding:18px;
  border-right:1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,122,0,.06), transparent 40%);
  display:flex;
  flex-direction:column;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 10px 14px;
  border-bottom:1px solid var(--line);
  margin-bottom:14px;
}

.brand-mark{
  width:40px;
  height:40px;
  border-radius:14px;
  display:grid;
  place-items:center;
  background: rgba(255,122,0,.12);
  border:1px solid rgba(255,122,0,.28);
  font-weight:800;
}

.brand-name{ font-weight:800; }
.brand-sub{ color:var(--muted); font-size:12px; margin-top:2px; }

.nav{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding-top:10px;
}

.nav-item{
  width:100%;
  border:1px solid transparent;
  background:transparent;
  color:var(--text);
  padding:10px 10px;
  border-radius:12px;
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;
  text-align:left;
}

.nav-item:hover{
  background: rgba(31,41,55,.04);
  border-color: rgba(31,41,55,.08);
}

.nav-item.active{
  background: rgba(255,122,0,.12);
  border-color: rgba(255,122,0,.28);
}

.nav-dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background: rgba(31,41,55,.28);
}

.nav-item.active .nav-dot{ background: var(--accent); }

.nav-divider{
  height:1px;
  background: var(--line);
  margin:10px 0;
}

.sidebar-footer{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding-top:12px;
  border-top:1px solid var(--line);
}

.pill{
  border:1px solid var(--line);
  border-radius:999px;
  padding:8px 10px;
  color:var(--muted);
  font-size:12px;
  width:max-content;
}

.mini-links{
  display:flex;
  gap:12px;
  font-size:12px;
  color:var(--muted);
}

.mini-links a{
  text-decoration:none;
  border-bottom:1px dashed rgba(31,41,55,.25);
}

.mini-links a:hover{
  color:var(--text);
  border-bottom-color: rgba(31,41,55,.40);
}

.ghost{
  border:1px solid var(--line);
  background:transparent;
  color:var(--text);
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
}

.ghost:hover{ background:rgba(31,41,55,.04); }

.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 200;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:18px 22px;
  border-bottom:1px solid var(--line);
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  overflow: visible;
  isolation: isolate;
}

.page-title{
  margin:0;
  font-size:22px;
  letter-spacing:-.2px;
}

.page-subtitle{
  margin:6px 0 0;
  color:var(--muted);
  font-size:13px;
}

.topbar-right{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  position: relative;
  z-index: var(--overlay-z);
}

.content{
  padding:18px 22px;
  overflow:auto;
  height:100%;
  min-height:0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: 120px;
  position: relative;
  z-index: 1;
}

.grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:14px;
}

.grid.two{
  grid-template-columns: repeat(2, minmax(0,1fr));
}

@media (max-width: 980px){
  .sidebar{ display:none; }
  .grid{ grid-template-columns: 1fr; }
  .grid.two{ grid-template-columns: 1fr; }
  .topbar{ padding:14px 14px; }
  .content{ padding:14px 14px; }

  #portalBtn, #checkoutBtn, #loginBtn{ display:none !important; }
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.74));
  border:1px solid var(--line);
  border-radius: var(--radius);
  padding:16px;
  box-shadow: var(--shadow);
}

.card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}

.card h2{
  margin:0;
  font-size:16px;
}

.tag{
  font-size:12px;
  color:var(--muted);
  border:1px solid var(--line);
  border-radius:999px;
  padding:4px 10px;
  background: rgba(255,241,214,.55);
}

.btn{
  border:1px solid transparent;
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
  font-weight:700;
  transition: transform .06s ease, filter .12s ease, background .12s ease, border-color .12s ease;
}

.btn:active{ transform: translateY(1px); }

.btn.primary{
  background: var(--cta);
  color: #ffffff;
}

.btn.primary:hover{ filter: brightness(1.03); }

.btn.secondary{
  background: rgba(255,122,0,.08);
  border-color: rgba(255,122,0,.18);
  color: var(--text);
}

.btn.secondary:hover{ background: rgba(255,122,0,.11); }

.btn.full{ width:100%; }

.card-actions{
  display:flex;
  gap:10px;
  margin-top:12px;
  flex-wrap:wrap;
}

.list{
  margin:0;
  padding-left:18px;
  color:var(--text);
}

.muted{ color:var(--muted); }
.tiny{ font-size:12px; }

.stack{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.queue-item{
  border:1px solid var(--line);
  background: rgba(255,255,255,.62);
  border-radius:14px;
  padding:12px;
}

.callout{
  margin-top:12px;
  border:1px solid rgba(0,184,148,.25);
  background: rgba(0,184,148,.10);
  border-radius:14px;
  padding:12px;
}

.label{
  font-size:12px;
  color:var(--muted);
  margin-top:6px;
}

.input{
  width:100%;
  background: rgba(255,255,255,.80);
  border:1px solid rgba(31,41,55,.14);
  border-radius:12px;
  padding:10px 12px;
  color: var(--text);
  outline:none;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}

.input:focus{
  border-color: rgba(255,122,0,.45);
  box-shadow: 0 0 0 4px rgba(255,122,0,.12);
  background: rgba(255,255,255,.92);
}

.view.hidden{ display:none; }

.split{
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap:14px;
}

.thread-sidebar{
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height: 280px;
}

.thread-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height: 420px;
  overflow:auto;
  padding-right:4px;
}

.thread-item{
  border:1px solid var(--line);
  background: rgba(255,255,255,.78);
  border-radius:14px;
  padding:10px;
  cursor:pointer;
  transition: border-color .12s ease, transform .12s ease, background .12s ease;
}

.thread-item:hover{
  border-color: rgba(255,122,0,.24);
  transform: translateY(-1px);
}

.thread-item.active{
  border-color: rgba(255,122,0,.34);
  background: rgba(255,122,0,.10);
}

.thread-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}

.thread-title{
  font-weight:700;
  font-size:13px;
}

.thread-meta{
  font-size:11px;
  color:var(--muted);
  margin-top:6px;
}

.thread-preview{
  font-size:12px;
  color:var(--muted);
  margin-top:6px;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

.thread-actions{
  display:flex;
  gap:6px;
}

.mini-btn{
  border:1px solid rgba(31,41,55,.10);
  background: rgba(255,255,255,.72);
  color:var(--muted);
  border-radius:10px;
  padding:4px 8px;
  font-size:11px;
  cursor:pointer;
}

.mini-btn:hover{
  color:var(--text);
  border-color: rgba(255,122,0,.26);
}

.memory-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  border:1px solid rgba(31,41,55,.10);
  background: rgba(255,255,255,.76);
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
}

.memory-chip{
  border:1px solid rgba(31,41,55,.10);
  background: rgba(255,255,255,.84);
  border-radius:12px;
  padding:10px;
}

.memory-chip-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:6px;
}

.memory-chip-key{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:var(--muted);
}

.calendar-status-good{
  color: var(--spark);
}

.calendar-status-warn{
  color: var(--accent);
}

#view-assistant .split > .card:first-child{
  display:grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height:520px;
  height: calc(100dvh - 124px);
  min-height: 0;
  overflow: hidden;
}
@media (max-width: 980px){
  .split{ grid-template-columns: 1fr; }
  #view-assistant .split > .card:last-child{ display:none !important; }
  #view-assistant p.muted.tiny{ display:none !important; }

  #view-assistant .split > .card:first-child{
    display:grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: calc(100dvh - 92px - env(safe-area-inset-bottom));
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0;
  }
}
/* Premium Chat UI */
.chat{
  min-height:0;
  height:100%;
  border:1px solid var(--chat-border);
  border-radius:18px;
  padding:14px 12px calc(28px + var(--kb, 0px)) 12px;
  overflow-y:auto;
  overflow-x:hidden;
  background: var(--chat-bg);
  display:flex;
  flex-direction:column;
  gap:10px;
  scroll-behavior:smooth;
  overscroll-behavior: contain;
  scroll-padding-bottom: calc(112px + var(--kb, 0px));
  scrollbar-gutter: stable both-edges;
  touch-action: pan-y;
}

@media (max-width: 980px){
  .chat{
    min-height:0;
    height:100%;
    -webkit-overflow-scrolling: touch;
    padding:14px 10px 168px 10px;
    border-radius: 20px;
  }
}

.msg{
  padding:10px 12px;
  border-radius: var(--bubble-radius);
  border:1px solid var(--line);
  max-width: min(560px, 88%);
  white-space: pre-wrap;
  line-height: 1.35;
  box-shadow: var(--bubble-shadow);
  transform-origin: bottom left;
  scroll-margin-bottom: calc(160px + var(--kb, 0px));
  word-break: break-word;
}

.msg.is-new{ animation: msgIn .16s ease-out both; }

@keyframes msgIn{
  from { opacity: 0; transform: translateY(6px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.msg.user{
  margin-left:auto;
  background: var(--bubble-user);
  border-color: rgba(255,122,0,.30);
  transform-origin: bottom right;
}

.msg.bot{
  background: var(--bubble-bot);
}

/* Composer */
.chatbox{
  display:flex;
  gap:10px;
  margin-top:12px;
  align-items:flex-end;
  position: relative;
  border: 1px solid rgba(31,41,55,.10);
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 30px rgba(31,41,55,.10);
  padding: 8px;
}

#chatInput{
  flex: 1 1 auto;
  resize:none;
  overflow:hidden;
  line-height:1.25;
  padding:12px 14px;
  min-height:48px;
  border-radius:18px;
  max-height:132px;
  border: 0;
  box-shadow: none;
  background: transparent;
}

#view-assistant .chatbox .btn.primary{
  border-radius:18px;
  min-height:48px;
  min-width:76px;
  padding:10px 16px;
  flex: 0 0 auto;
}

#chatInput:focus{
  border: 0;
  box-shadow: none;
  background: rgba(255,255,255,.98);
}

@media (max-width: 980px){
  #view-assistant .chatbox{
    position: fixed;
    left: 14px;
    right: 14px;
    top: auto;
    z-index: 320;
    margin-top: 0;
    padding: 8px;
    border-radius: 24px;
    border-color: rgba(255,122,0,.16);
    box-shadow: 0 18px 50px rgba(31,41,55,.16);
    background: linear-gradient(
      180deg,
      rgba(255,255,255,.96) 0%,
      rgba(255,250,244,.98) 100%
    );
    backdrop-filter: blur(10px);
  }

  .mobile-composer #view-assistant .chat{
    scroll-padding-bottom: 220px;
  }

  .keyboard-open #view-assistant .chat{
    padding-bottom: 260px;
  }

  #chatInput{
    font-size: 16px;
    min-height: 50px;
    padding: 13px 14px;
    max-height: 240px;
    line-height: 1.35;
  }

  #view-assistant .chatbox .btn.primary{
    min-height: 50px;
    align-self: flex-end;
  }
}

/* Modal */
.modal.hidden{ display:none; }
.hidden{ display:none !important; }

.modal{
  position:fixed;
  inset:0;
  z-index:9999;
}

.modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(31,41,55,.45);
}

.modal-card{
  position:relative;
  max-width:420px;
  margin:10vh auto;
  background: rgba(255,255,255,.96);
  border:1px solid rgba(31,41,55,.12);
  border-radius:16px;
  box-shadow: 0 30px 90px rgba(31,41,55,.22);
  padding:16px;
}

.sr-only{
  position:absolute !important;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}

.modal-actions{
  display:flex;
  gap:10px;
  margin-top:12px;
  justify-content:flex-end;
  flex-wrap:wrap;
}

#pageSubtitle { display: none !important; }

/* Toast */
.toast{
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 100000;
  border: 1px solid rgba(31,41,55,.14);
  background: rgba(255,255,255,.96);
  box-shadow: 0 16px 50px rgba(31,41,55,.18);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
}

.toast.good{ border-color: rgba(0,184,148,.26); }
.toast.bad{ border-color: rgba(255,122,0,.28); }

/* Mobile menu */
.mobile-menu{
  display:none;
  position: relative;
  z-index: var(--overlay-z);
}

.mobile-menu summary{ list-style:none; }
.mobile-menu summary::-webkit-details-marker{ display:none; }
.mobile-menu-btn{ white-space: nowrap; }

.mobile-menu-panel{
  position: fixed;
  top: var(--mm-top, 72px);
  right: var(--mm-right, 14px);
  min-width: 240px;
  max-width: calc(100vw - 28px);
  border:1px solid rgba(31,41,55,.12);
  background: rgba(255,255,255,.98);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(31,41,55,.18);
  padding: 10px;
  z-index: 100000;
  pointer-events: auto;
  isolation: isolate;
}

.mobile-menu-panel .nav-item{
  width:100%;
  border-radius: 12px;
  padding: 10px 10px;
}

@media (max-width: 980px){
  .mobile-menu{ display:block; }
  .topbar-right{ align-items:center; }
}

@media (min-width: 981px){
  .mobile-menu{ display:none; }
}

.mobile-menu[open] .mobile-menu-btn{
  border-color: rgba(255,122,0,.28);
  background: rgba(255,122,0,.12);
}

/* Content Calendar */
.calendar-head-actions{
  display:flex;
  align-items:center;
  gap:10px;
}

.segmented{
  display:inline-flex;
  background: rgba(255,122,0,.08);
  border: 1px solid rgba(255,122,0,.18);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.seg-btn{
  border:0;
  background:transparent;
  color:var(--muted);
  padding:8px 12px;
  border-radius:999px;
  cursor:pointer;
  font-size:13px;
  font-weight:800;
}

.seg-btn.active{
  background: rgba(255,255,255,.78);
  color: var(--text);
}

.calendar-toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.cal-nav{
  display:flex;
  gap:8px;
  align-items:center;
}

.cal-title{
  flex:1;
  min-width:220px;
  text-align:center;
}

.cal-title-main{
  font-weight:900;
  letter-spacing:-.2px;
  font-size:16px;
}

.cal-jump{
  display:flex;
  gap:8px;
  align-items:center;
}

.cal-jump .input{ max-width:170px; }

.cal-quick-actions{
  display:flex;
  gap:8px;
  align-items:center;
}

.calendar-dow{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 14px;
  margin-bottom: 6px;
}

.dow{
  font-size:12px;
  color:var(--muted);
  padding:0 6px;
}

.calendar-grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap:8px;
}

.cal-cell{
  text-align:left;
  border:1px solid var(--line);
  background: rgba(255,255,255,.72);
  border-radius: var(--radius);
  padding:10px;
  min-height:104px;
  cursor:pointer;
  transition: transform .08s ease, border-color .08s ease;
}

.cal-cell:hover{
  border-color: rgba(255,122,0,.22);
  transform: translateY(-1px);
}

.cal-cell.is-out{ opacity:.62; }

.cal-cell.is-today{
  outline: 2px solid rgba(255,122,0,.35);
  outline-offset: 2px;
}

.cal-cell-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
}

.cal-daynum{
  font-weight:900;
  font-size:14px;
  color:var(--text);
}

.cal-cell-items{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.cal-chip{
  display:flex;
  flex-direction:column;
  gap:6px;
  width:100%;
  border:1px solid rgba(31,41,55,.10);
  background: rgba(255,255,255,.82);
  border-radius:12px;
  padding:8px;
  cursor:pointer;
}

.cal-chip:hover{ border-color: rgba(0,184,148,.22); }

.cal-chip.is-done{
  opacity:.72;
  text-decoration: line-through;
}

.cal-chip-title{
  font-size:13px;
  font-weight:800;
  color:var(--text);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.cal-chip-badges{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}

.cal-badge{
  font-size:11px;
  color: rgba(31,41,55,.72);
  border:1px solid rgba(31,41,55,.12);
  background: rgba(255,241,214,.55);
  border-radius:999px;
  padding:3px 8px;
  width:fit-content;
}

.cal-more{ padding-left:2px; }

.week-grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap:10px;
  margin-top:14px;
}

.week-col{
  border:1px solid var(--line);
  background: rgba(255,255,255,.72);
  border-radius: var(--radius);
  overflow:hidden;
  min-height:240px;
}

.week-col.is-today{
  outline: 2px solid rgba(255,122,0,.35);
  outline-offset: 2px;
}

.week-head{
  width:100%;
  border:0;
  background: rgba(255,122,0,.08);
  padding:10px 10px 8px;
  cursor:pointer;
  text-align:left;
}

.week-dow{
  font-weight:900;
  letter-spacing:-.1px;
  font-size:13px;
  color:var(--text);
}

.week-body{
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.icon-btn{
  border:1px solid rgba(31,41,55,.12);
  background: rgba(255,255,255,.72);
  color:var(--text);
  border-radius:12px;
  padding:6px 10px;
  cursor:pointer;
}

.icon-btn:hover{ background: rgba(255,255,255,.88); }

/* Trends formatting */
.ti-section{
  border:1px solid rgba(31,41,55,.10);
  background: rgba(255,255,255,.70);
  border-radius:14px;
  padding:12px;
}

.ti-title{
  font-weight:900;
  font-size:13px;
  margin-bottom:8px;
}

.ti-list{
  margin:0;
  padding-left:18px;
  color:var(--text);
}

.ti-rawtext{
  margin-top:10px;
  white-space: pre-wrap;
  font-size:13px;
  line-height:1.4;
  color:var(--text);
}

@media (max-width: 900px){
  .calendar-toolbar{ justify-content:flex-start; }
  .cal-title{ text-align:left; flex:1 1 100%; }

  .week-grid{
    grid-template-columns: repeat(7, minmax(240px, 1fr));
    overflow-x:auto;
    padding-bottom:6px;
  }

  .calendar-grid{ gap:6px; }
  .cal-cell{ min-height:92px; padding:8px; }
}
