:root {
  --green: #21A038; --green-d: #1A8230; --green-l: #E8F5EB; --green-m: #4CB86A;
  --gray: #F7F8FA; --gray-2: #EBEDF0; --gray-3: #C4C8CC; --gray-t: #7E8389;
  --dark: #1C1C1E; --white: #FFFFFF;
  --border: rgba(0,0,0,0.08); --shadow: 0 2px 16px rgba(0,0,0,0.08); --shadow-sm: 0 1px 6px rgba(0,0,0,0.06);
  --r-sm: 8px; --r-md: 12px; --r-lg: 20px; --r-xl: 28px;
  --nav-h: 60px; --bot-h: 58px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--dark); background: var(--gray); }

/* ── SCREENS ── */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.screen.hidden { display: none !important; }
.hidden { display: none !important; }

/* ══ WELCOME ══ */
#welcome {
  background: linear-gradient(150deg, #F0F9F2 0%, #E8F5EB 50%, #fff 100%);
  align-items: center; justify-content: center;
  overflow-y: auto; padding: 32px 20px 48px; gap: 0;
}
.wl-logo {
  width: 220px; height: 220px;
  background: none; border-radius: 0; box-shadow: none;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.wl-logo img { width: 220px; height: 220px; object-fit: contain; border-radius: 32px; margin-top: 32px; }
.wl-title { font-size: 34px; font-weight: 800; margin-bottom: 10px; text-align: center; }
.wl-sub { font-size: 16px; color: var(--gray-t); text-align: center; max-width: 340px; line-height: 1.55; margin-bottom: 36px; }
.wl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 480px; width: 100%; margin-bottom: 36px; }
.wl-card { background: #fff; border-radius: var(--r-md); padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.wl-card-icon { font-size: 28px; margin-bottom: 8px; }
.wl-card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.wl-card-desc { font-size: 12px; color: var(--gray-t); line-height: 1.4; }
.wl-cta {
  width: 100%; max-width: 320px; padding: 16px; border-radius: var(--r-xl);
  background: var(--green); color: #fff; border: none;
  font-size: 17px; font-weight: 600; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 20px rgba(33,160,56,.35); transition: all .2s;
}
.wl-cta:hover { background: var(--green-d); transform: translateY(-1px); }
.wl-hint { margin-top: 20px; font-size: 12px; color: var(--gray-3); }

/* ══ APP ══ */
#app { flex-direction: column; }

/* top nav */
.topnav {
  height: var(--nav-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 14px; gap: 10px; flex-shrink: 0; z-index: 30;
}
.burger { width: 36px; height: 36px; border: none; background: transparent; cursor: pointer; font-size: 20px; display: none; align-items: center; justify-content: center; border-radius: var(--r-sm); }
.brand-icon { width: 46px; height: 46px; background: none; border-radius: 0; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-icon img { width: 46px; height: 46px; object-fit: contain; border-radius: 12px; }
.brand-name { font-size: 16px; font-weight: 700; }
.topnav-center { flex: 1; display: flex; justify-content: center; gap: 2px; }
.nav-btn { padding: 7px 13px; border-radius: var(--r-md); font-size: 14px; font-weight: 500; color: var(--gray-t); border: none; background: transparent; cursor: pointer; font-family: inherit; transition: all .15s; }
.nav-btn:hover { background: var(--gray); color: var(--dark); }
.nav-btn.active { background: var(--green-l); color: var(--green); }
.topnav-user { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.u-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#21A038,#4CB86A); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.u-name { font-size: 13px; font-weight: 500; }

/* app body */
.app-body { flex: 1; display: flex; overflow: hidden; position: relative; }

/* sidebar */
.sidebar {
  width: 272px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: transform .25s; z-index: 20;
}
.sidebar-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.4); z-index: 19; display: none; }
.sidebar-overlay.on { display: block; }
.pp-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.4); z-index: 17; display: none; }
.pp-overlay.on { display: block; }
.sb-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--border); }
.sb-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.sb-tabs { display: flex; background: var(--gray); border-radius: var(--r-md); padding: 3px; gap: 3px; }
.sb-tab { flex: 1; padding: 5px 4px; border-radius: 9px; font-size: 12px; font-weight: 500; text-align: center; border: none; background: transparent; color: var(--gray-t); cursor: pointer; font-family: inherit; transition: all .2s; }
.sb-tab.active { background: #fff; color: var(--green); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.sb-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.sb-list.fading { opacity: 0; transform: translateY(4px); }
.sb-list { transition: opacity .18s ease, transform .18s ease; }
.case-row { padding: 9px 14px; display: flex; align-items: flex-start; gap: 9px; cursor: pointer; transition: background .15s, opacity .2s, transform .2s; position: relative; }
@keyframes caseIn { from { opacity:0; transform:translateX(-8px); } to { opacity:1; transform:translateX(0); } }
.case-row.animating { animation: caseIn .22s ease-out both; }
.case-row:hover { background: var(--gray); }
.case-row.active { background: var(--green-l); }
.case-row.active::before { content:''; position:absolute; left:0; top:4px; bottom:4px; width:3px; background:var(--green); border-radius:0 3px 3px 0; }
.case-ico { width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--gray-2); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.case-row.active .case-ico { background: rgba(33,160,56,.12); }
.case-inf { flex: 1; min-width: 0; }
.case-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-meta { font-size: 11px; color: var(--gray-t); margin-top: 1px; }
.case-prev { font-size: 11px; color: var(--gray-t); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.case-prev .cp-who { font-weight: 600; }
.case-badge { font-size: 10px; padding: 2px 6px; border-radius: 20px; font-weight: 600; flex-shrink: 0; margin-top: 1px; }
.bt { background: #FFF3E0; color: #E65100; }
.bc { background: #E8EAF6; color: #3949AB; }
.sb-empty { padding: 28px 14px; text-align: center; font-size: 13px; color: var(--gray-t); line-height: 1.5; }
.sb-foot { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.new-btn { width: 100%; padding: 10px; border-radius: var(--r-md); background: var(--green); color: #fff; border: none; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .15s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.new-btn:hover { background: var(--green-d); }
.clear-btn { width: 100%; padding: 7px; border-radius: var(--r-md); background: transparent; color: #C62828; border: 1px solid #FFCDD2; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; transition: all .15s; }
.clear-btn:hover { background: #FFEBEE; }

/* pages */
.page { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.page.hidden { display: none !important; }

/* ── CHAT PAGE ── */
#p-chat { flex-direction: row; }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #F0F2F5; min-width: 0; }

.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.ce-icon { font-size: 64px; margin-bottom: 14px; }
.ce-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.ce-sub { font-size: 14px; color: var(--gray-t); margin-bottom: 22px; max-width: 280px; line-height: 1.5; }
.ce-btn { padding: 12px 28px; border-radius: var(--r-xl); background: var(--green); color: #fff; border: none; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }

.chat-active { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-hdr { height: 58px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 11px; padding: 0 14px; flex-shrink: 0; }
.p-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,#5C9BD6,#3776B8); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.p-info { flex: 1; min-width: 0; }
.p-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-status { font-size: 11px; color: var(--gray-t); display: flex; align-items: center; gap: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.hdr-btns { display: flex; gap: 4px; }
.hbtn { width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--gray-2); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--gray-t); transition: all .15s; font-family: inherit; }
.hbtn:hover { background: var(--gray); color: var(--dark); }
.hbtn.red:hover { background: #FFEBEE; color: #C62828; border-color: #FFCDD2; }

.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.msgs::-webkit-scrollbar { width: 4px; }
.msgs::-webkit-scrollbar-thumb { background: var(--gray-3); border-radius: 10px; }

.mrow { display: flex; gap: 7px; max-width: 76%; animation: mIn .2s ease-out; }
@keyframes mIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.mrow.user { align-self: flex-end; flex-direction: row-reverse; }
.mrow.bot { align-self: flex-start; }
.mrow.sys { align-self: center; max-width: 86%; }
.mav { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; margin-top: auto; }
.mav.b { background: linear-gradient(135deg,#5C9BD6,#3776B8); }
.mav.u { background: linear-gradient(135deg,#21A038,#4CB86A); color:#fff; font-size:10px; font-weight:700; }
.bbl { padding: 9px 13px; border-radius: 18px; font-size: 14px; line-height: 1.55; max-width: 100%; }
.bot .bbl { background: #fff; border-radius: 4px 18px 18px 18px; box-shadow: var(--shadow-sm); }
.user .bbl { background: var(--green); color: #fff; border-radius: 18px 4px 18px 18px; }
.sys .bbl { background: rgba(0,0,0,.05); color: var(--gray-t); border-radius: var(--r-md); font-size: 12px; text-align: center; padding: 5px 12px; }
.mtime { font-size: 10px; color: var(--gray-t); margin-top: 3px; padding: 0 3px; }
.user .mtime { text-align: right; }
.tick { color: var(--green-m); }

.typing-row { display: none; align-self: flex-start; gap: 7px; }
.typing-row.on { display: flex; }
.typing-bbl { background: #fff; border-radius: 4px 18px 18px 18px; padding: 11px 13px; box-shadow: var(--shadow-sm); display: flex; gap: 4px; align-items: center; }
.tdot { width: 7px; height: 7px; border-radius: 50%; background: var(--gray-3); animation: tp 1.2s infinite; }
.tdot:nth-child(2){animation-delay:.2s} .tdot:nth-child(3){animation-delay:.4s}
@keyframes tp { 0%,60%,100%{opacity:.3;transform:scale(.85)} 30%{opacity:1;transform:scale(1)} }

.input-area { background: #fff; border-top: 1px solid var(--border); padding: 9px 12px 11px; flex-shrink: 0; }
.qbtns { display: flex; gap: 5px; margin-bottom: 8px; flex-wrap: wrap; }
.qbtn { padding: 6px 11px; border-radius: 20px; font-size: 13px; font-weight: 500; border: 1.5px solid var(--green); color: var(--green); background: transparent; cursor: pointer; font-family: inherit; white-space: nowrap; transition: all .15s; }
.qbtn:hover { background: var(--green-l); }
.qbtn.fin { background: var(--green-l); }
.qbtn.red { border-color: #EF5350; color: #C62828; }
.qbtn.red:hover { background: #FFEBEE; }
.irow { display: flex; gap: 8px; align-items: flex-end; }
.iwrap { flex: 1; background: var(--gray); border-radius: var(--r-xl); border: 1.5px solid transparent; display: flex; align-items: flex-end; padding: 4px 4px 4px 13px; transition: border-color .15s; }
.iwrap:focus-within { border-color: var(--green); background: #fff; }
#msgInput { flex: 1; border: none; background: transparent; outline: none; font-size: 15px; line-height: 1.5; color: var(--dark); font-family: inherit; resize: none; max-height: 96px; min-height: 34px; padding: 5px 0; }
#msgInput::placeholder { color: var(--gray-3); }
.sbtn { width: 38px; height: 38px; border-radius: 50%; background: var(--green); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s; flex-shrink: 0; }
.sbtn:hover { background: var(--green-d); }
.sbtn:active { transform: scale(.95); }
.sbtn svg { width: 17px; height: 17px; fill: #fff; }
.sbtn:disabled { opacity: .5; cursor: default; }
.mbtn { width: 38px; height: 38px; border-radius: 50%; background: transparent; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--gray-t); transition: all .15s; }
.mbtn:hover { background: var(--gray-2); color: var(--dark); }
.mbtn svg { width: 18px; height: 18px; }
.mbtn.recording { color: #C62828; animation: micPulse 1s ease-in-out infinite; }
.mbtn:disabled { opacity: .4; cursor: default; pointer-events: none; }
@keyframes micPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(198,40,40,.35); background: #FFEBEE; }
  50%      { box-shadow: 0 0 0 7px rgba(198,40,40,0); background: #FFCDD2; }
}

/* patient panel */
.pat-panel { width: 272px; flex-shrink: 0; background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; transition: transform .25s; }
.pp-sec { padding: 13px 14px; border-bottom: 1px solid var(--border); }
.pp-sec:last-child { border-bottom: none; }
.pp-label { font-size: 10px; font-weight: 600; color: var(--gray-t); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 9px; }
.pp-avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg,#5C9BD6,#3776B8); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.pp-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--green-l); color: var(--green-d); margin-top: 8px; }
.pp-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.pp-key { color: var(--gray-t); }
.pp-val { font-weight: 500; text-align: right; }
.prg-lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--gray-t); margin-bottom: 4px; }
.prg-bar { height: 5px; background: var(--gray-2); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.prg-fill { height: 100%; background: linear-gradient(90deg,#21A038,#4CB86A); border-radius: 10px; transition: width .4s ease; }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.qa-btn { padding: 8px 6px; border-radius: var(--r-sm); border: 1px solid var(--gray-2); background: var(--gray); font-size: 12px; font-weight: 500; cursor: pointer; color: var(--dark); text-align: center; transition: all .15s; font-family: inherit; line-height: 1.3; }
.qa-btn:hover { background: var(--green-l); color: var(--green); border-color: var(--green-m); }
.qa-btn.s2 { grid-column: span 2; background: var(--green); color: #fff; border-color: var(--green); }
.qa-btn.s2:hover { background: var(--green-d); }
.qa-btn.s2r { grid-column: span 2; background: transparent; color: #C62828; border-color: #FFCDD2; }
.qa-btn.s2r:hover { background: #FFEBEE; }

/* ── STATS PAGE ── */
#p-stats { overflow-y: auto; padding: 22px 20px; gap: 16px; }
.pg-title { font-size: 22px; font-weight: 700; }
.pg-sub { font-size: 14px; color: var(--gray-t); }
.sg { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; }
.sc { background: #fff; border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.sc-num { font-size: 28px; font-weight: 700; color: var(--green); }
.sc-lbl { font-size: 13px; color: var(--gray-t); margin-top: 2px; }
.hl { display: flex; flex-direction: column; gap: 10px; }
.hi { background: #fff; border-radius: var(--r-md); padding: 12px 14px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); display: flex; align-items: center; gap: 11px; }
.hi-icon { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--green-l); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.hi-inf { flex: 1; }
.hi-name { font-size: 14px; font-weight: 600; }
.hi-meta { font-size: 12px; color: var(--gray-t); margin-top: 1px; }
.hi-sc { font-size: 18px; font-weight: 700; }
.sg-good{color:var(--green)} .sg-mid{color:#F59E0B} .sg-low{color:#EF5350}
.no-hist { text-align: center; padding: 40px 14px; color: var(--gray-t); }
.no-hist-icon { font-size: 44px; margin-bottom: 10px; }

/* ── KB PAGE ── */
#p-kb { overflow-y: auto; padding: 22px 20px; gap: 16px; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 12px; }
.kb-card { background: #fff; border-radius: var(--r-md); padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); cursor: pointer; transition: all .2s; }
.kb-card:hover { border-color: var(--green); box-shadow: 0 4px 20px rgba(33,160,56,.12); transform: translateY(-1px); }
.kb-hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.kb-icon { width: 46px; height: 46px; border-radius: var(--r-md); background: var(--green-l); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.kb-n { font-size: 15px; font-weight: 700; }
.kb-c { font-size: 12px; color: var(--gray-t); margin-top: 1px; }
.kb-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.kb-tag { padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; background: var(--gray); color: var(--gray-t); }
.kb-body { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; line-height: 1.6; color: #444; }
.kb-card.open .kb-body { display: block; }
.kb-arrow { margin-left: auto; color: var(--gray-t); font-size: 12px; transition: transform .2s; }
.kb-card.open .kb-arrow { transform: rotate(180deg); }

/* ── MODAL ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100; display: none; align-items: flex-end; justify-content: center; }
.overlay.on { display: flex; }
.modal { background: #fff; border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 20px; width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; animation: sUp .25s ease-out; }
@keyframes sUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.mhandle { width: 34px; height: 4px; background: var(--gray-2); border-radius: 2px; margin: 0 auto 16px; }
.m-title { font-size: 20px; font-weight: 700; margin-bottom: 3px; }
.m-sub { font-size: 14px; color: var(--gray-t); margin-bottom: 16px; }
.m-lbl { font-size: 11px; font-weight: 600; color: var(--gray-t); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.d-card { padding: 12px 8px; border-radius: var(--r-md); border: 2px solid var(--gray-2); cursor: pointer; text-align: center; transition: all .15s; }
.d-card:hover, .d-card.sel { border-color: var(--green); background: var(--green-l); }
.d-icon { font-size: 26px; margin-bottom: 4px; }
.d-name { font-size: 13px; font-weight: 600; }
.d-desc { font-size: 11px; color: var(--gray-t); margin-top: 2px; }
.mode-row { display: flex; gap: 8px; margin-bottom: 18px; }
.m-card { flex: 1; padding: 12px; border-radius: var(--r-md); border: 2px solid var(--gray-2); cursor: pointer; transition: all .15s; }
.m-card:hover { border-color: var(--green-m); }
.m-card.sel { border-color: var(--green); background: var(--green-l); }
.mc-n { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.mc-d { font-size: 11px; color: var(--gray-t); }
.m-btns { display: flex; gap: 10px; justify-content: flex-end; }
.btn-c { padding: 10px 18px; border-radius: var(--r-md); border: 1.5px solid var(--gray-2); background: transparent; font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit; }
.btn-s { padding: 10px 22px; border-radius: var(--r-md); border: none; background: var(--green); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .15s; }
.btn-s:hover { background: var(--green-d); }

/* report */
.rep-card { background: #fff; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); max-width: 100%; }
.rep-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--gray); }
.rep-tab { flex: 1; padding: 9px 5px; font-size: 12px; font-weight: 500; text-align: center; cursor: pointer; border: none; background: transparent; color: var(--gray-t); border-bottom: 2px solid transparent; font-family: inherit; }
.rep-tab.active { color: var(--green); border-bottom-color: var(--green); background: #fff; }
.rep-body { padding: 14px; min-height: 220px; }
.sc-circle { width: 68px; height: 68px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 12px; }
.sc-n { font-size: 19px; font-weight: 700; line-height: 1; }
.sc-l { font-size: 10px; color: var(--gray-t); }
.arow { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--gray-2); }
.arow:last-child { border-bottom: none; }
.ok { color: var(--green); font-weight: 700; } .no { color: #EF5350; font-weight: 700; }

/* bottom nav */
.bot-nav { display: none; background: #fff; border-top: 1px solid var(--border); height: var(--bot-h); flex-shrink: 0; }
.bot-inner { display: flex; height: 100%; }
.bnav { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: none; background: transparent; cursor: pointer; color: var(--gray-t); font-size: 10px; font-weight: 500; font-family: inherit; transition: color .15s; }
.bnav.active { color: var(--green); }
.bnav-icon { font-size: 21px; line-height: 1; }

/* spinner */
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to{transform:rotate(360deg)} }

/* ══════════════════════════════════════
   ANIMATIONS & EFFECTS
══════════════════════════════════════ */

/* ── Welcome ── */
@keyframes wlLogoFloat {
  0%,100% { transform: translateY(0) rotate(-1.5deg); }
  50%      { transform: translateY(-10px) rotate(1.5deg); }
}
@keyframes wlFadeUp {
  from { opacity:0; transform: translateY(22px); }
  to   { opacity:1; transform: translateY(0); }
}
@keyframes wlCardIn {
  from { opacity:0; transform: translateY(18px) scale(.96); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}
@keyframes shimmerBtn {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}
.wl-logo { animation: wlLogoFloat 3.6s ease-in-out infinite; }
.wl-title { animation: wlFadeUp .55s .1s both ease-out; }
.wl-sub   { animation: wlFadeUp .55s .22s both ease-out; }
.wl-grid  { animation: wlFadeUp .55s .34s both ease-out; }
.wl-card  { transition: transform .2s, box-shadow .2s; }
.wl-card:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 8px 24px rgba(33,160,56,.14); }
.wl-cta {
  animation: wlFadeUp .55s .46s both ease-out;
  background: linear-gradient(90deg, var(--green) 0%, #4CB86A 40%, var(--green) 80%);
  background-size: 200% auto;
  background-position: left center;
  transition: background-position .6s ease, transform .2s, filter .2s;
}
.wl-cta:hover { background-position: right center; transform: translateY(-2px) scale(1.01); filter: brightness(1.08); }
.wl-hint { animation: wlFadeUp .55s .6s both ease-out; }

/* Floating particles on welcome */
#wl-particles { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
.wl-dot {
  position: absolute; border-radius: 50%; background: rgba(33,160,56,.18);
  animation: wlDotFloat linear infinite;
}
@keyframes wlDotFloat {
  0%   { transform: translateY(0) scale(1);    opacity: .15; }
  50%  { transform: translateY(-60px) scale(1.15); opacity: .35; }
  100% { transform: translateY(0) scale(1);    opacity: .15; }
}

/* ── Status dot pulse ── */
@keyframes dotGlow {
  0%,100% { box-shadow: 0 0 0 0 rgba(33,160,56,.5); }
  50%      { box-shadow: 0 0 0 5px rgba(33,160,56,0); }
}
.dot { animation: dotGlow 2s ease-in-out infinite; }

/* ── Progress bar shine ── */
.prg-bar { position: relative; overflow: hidden; }
.prg-fill::after {
  content: '';
  position: absolute; top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: progShine 2.2s ease-in-out infinite;
}
.prg-fill { position: relative; overflow: hidden; }
@keyframes progShine {
  0%   { left: -80%; }
  100% { left: 160%; }
}

/* ── Message bubble spring ── */
@keyframes mIn {
  0%   { opacity:0; transform: translateY(10px) scale(.94); }
  60%  { transform: translateY(-3px) scale(1.015); }
  80%  { transform: translateY(1px) scale(.997); }
  100% { opacity:1; transform: translateY(0) scale(1); }
}
.mrow { animation: mIn .28s cubic-bezier(.34,1.56,.64,1) both; }

/* ── Avatar heartbeat when bot typing ── */
@keyframes avatarPulse {
  0%,100% { transform: scale(1); }
  30%      { transform: scale(1.14); }
  60%      { transform: scale(.96); }
}
.typing-row.on .mav { animation: avatarPulse 1.4s ease-in-out infinite; }

/* ── Typing dots enhanced ── */
@keyframes tp {
  0%,60%,100% { opacity:.25; transform: scale(.8) translateY(0); }
  30%          { opacity:1;   transform: scale(1) translateY(-4px); }
}

/* ── Send button ripple host ── */
.sbtn, .new-btn, .wl-cta, .btn-s, .ce-btn, .qa-btn, .hbtn, .nav-btn, .bnav, .qbtn {
  position: relative; overflow: hidden;
}
.ripple-fx {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.38);
  transform: scale(0); animation: rippleFx .5s linear;
  pointer-events: none;
}
.ripple-fx.dark { background: rgba(33,160,56,.22); }
@keyframes rippleFx {
  to { transform: scale(4); opacity: 0; }
}

/* ── New case button pulse ── */
@keyframes newBtnGlow {
  0%,100% { box-shadow: 0 0 0 0 rgba(33,160,56,.4); }
  50%      { box-shadow: 0 0 0 7px rgba(33,160,56,0); }
}
.new-btn { animation: newBtnGlow 2.8s ease-in-out infinite; }

/* ── Page transition ── */
@keyframes pgSlideIn {
  from { transform: translateX(6px); }
  to   { transform: translateX(0); }
}
.page:not(.hidden) { animation: pgSlideIn .2s ease-out; }

/* ── Stats card entrance ── */
@keyframes scIn {
  from { opacity:0; transform: translateY(12px) scale(.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}
.sc { animation: scIn .3s ease-out both; }
.sc:nth-child(1) { animation-delay: .04s; }
.sc:nth-child(2) { animation-delay: .10s; }
.sc:nth-child(3) { animation-delay: .16s; }
.sc:nth-child(4) { animation-delay: .22s; }
.sc:hover { transform: translateY(-2px); box-shadow: 0 4px 18px rgba(33,160,56,.13); transition: transform .18s, box-shadow .18s; }

/* History item stagger */
@keyframes hiIn {
  from { opacity:0; transform: translateX(-10px); }
  to   { opacity:1; transform: translateX(0); }
}
.hi { animation: hiIn .28s ease-out both; }

/* ── KB card stagger ── */
@keyframes kbIn {
  from { opacity:0; transform: translateY(10px) scale(.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}
.kb-card { animation: kbIn .3s ease-out both; }

/* ── Score circle SVG ring ── */
.sc-ring-wrap { position:relative; width:80px; height:80px; margin:0 auto 12px; display:flex; align-items:center; justify-content:center; }
.sc-ring-svg { position:absolute; inset:0; width:100%; height:100%; transform: rotate(-90deg); }
.sc-ring-bg  { fill:none; stroke: var(--gray-2); stroke-width:6; }
.sc-ring-fill{ fill:none; stroke-width:6; stroke-linecap:round; transition: stroke-dashoffset .9s cubic-bezier(.34,1.1,.64,1); }
.sc-ring-inner { position:relative; text-align:center; }

/* ── Confetti ── */
#confetti-container { position:fixed; inset:0; pointer-events:none; z-index:999; overflow:hidden; }
.cf-piece {
  position:absolute; top:-20px; border-radius:2px;
  animation: cfFall linear forwards;
}
@keyframes cfFall {
  0%   { transform: translateY(-20px) rotateZ(0deg) rotateX(0deg); opacity:1; }
  100% { transform: translateY(110vh) rotateZ(720deg) rotateX(360deg); opacity:0; }
}

/* ── Case ico bounce on active ── */
.case-row.active .case-ico {
  animation: caseIcoBounce .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes caseIcoBounce {
  from { transform: scale(.8); }
  to   { transform: scale(1); }
}

/* ── Send button send animation ── */
@keyframes sendPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(.88) rotate(-8deg); }
  70%  { transform: scale(1.12) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
.sbtn.sending { animation: sendPop .35s cubic-bezier(.34,1.56,.64,1); }

/* ── Input area focus glow ── */
.iwrap:focus-within {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(33,160,56,.1);
  transition: border-color .15s, box-shadow .2s;
}

/* ── Brand icon spin on hover ── */
@keyframes brandSpin {
  from { transform: rotate(0); }
  to   { transform: rotate(360deg); }
}
.brand-icon:hover { animation: brandSpin .5s ease-out; cursor: pointer; }

/* ── Toast notification ── */
#toast-wrap { position:fixed; bottom:80px; left:50%; transform:translateX(-50%); z-index:200; display:flex; flex-direction:column; gap:6px; align-items:center; pointer-events:none; }
.toast {
  background: rgba(28,28,30,.88); color:#fff; padding:8px 16px; border-radius:20px;
  font-size:13px; font-weight:500; backdrop-filter:blur(8px);
  animation: toastIn .25s ease-out, toastOut .3s ease-in 1.9s forwards;
  white-space: nowrap;
}
@keyframes toastIn  { from{opacity:0;transform:translateY(10px) scale(.92)} to{opacity:1;transform:translateY(0) scale(1)} }
@keyframes toastOut { from{opacity:1;transform:translateY(0) scale(1)} to{opacity:0;transform:translateY(-8px) scale(.92)} }

/* ── App screen entrance ── */
@keyframes appIn {
  from { transform: scale(.97); filter: blur(2px); }
  to   { transform: scale(1);   filter: blur(0); }
}
#app:not(.hidden) { animation: appIn .28s ease-out; }

/* ── d-card select bounce ── */
@keyframes dCardSel {
  0%   { transform: scale(.96); }
  60%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.d-card.sel { animation: dCardSel .25s cubic-bezier(.34,1.56,.64,1); }

/* ── ── MOBILE ── */
@media (max-width: 768px) {
  .burger { display: flex; }
  .topnav-center { display: none; }
  .u-name { display: none; }
  .sidebar { position: absolute; top: 0; left: 0; bottom: 0; transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.on { transform: translateX(0); }
  .pat-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(320px, 92%); transform: translateX(100%); box-shadow: var(--shadow); z-index: 18; }
  .pat-panel.on { transform: translateX(0); }
  .bot-nav { display: block; }
  .mrow { max-width: 88%; }
  #p-stats { padding: 16px; }
  #p-kb { padding: 16px; }
  .sg { grid-template-columns: 1fr 1fr; }
  .kb-grid { grid-template-columns: 1fr; }
  .mode-row { flex-direction: column; }
  .wl-title { font-size: 28px; }
  .wl-grid { grid-template-columns: 1fr 1fr; }
  .wl-logo { width: 240px; height: 240px; }
  .wl-logo img { width: 240px; height: 240px; margin-top: 36px; }
}
@media (max-width: 400px) {
  .wl-grid { grid-template-columns: 1fr; }
  .sg { grid-template-columns: 1fr; }
  .d-grid { grid-template-columns: 1fr 1fr; }
}
