:root{
  --bg:#0f172a;
  --surface:#1e293b;
  --accent:#2563eb;
  --text-main:#f8fafc;
  --border:#334155;
  --msg-user:#2563eb;
  --msg-user-border:#94a3b8;
  --msg-ai:#1e293b;
  --msg-ai-border:#1d4ed8;
  --study-bg:#64748b;
  --study-color:#ef4444;
  --study-dot:#38bdf8;
  --portal-title-color:#94a3b8;
}

/* White Theme 🤍 */
body.theme-white{
  --bg:#f8fafc;
  --surface:#ffffff;
  --accent:#2563eb;
  --text-main:#0f172a;
  --border:#cbd5e1;
  --msg-user:#374151;
  --msg-user-border:#000000;
  --msg-ai:#374151;
  --msg-ai-border:#38bdf8;
  --study-bg:#4b5563;
  --study-color:#ef4444;
  --study-dot:#ef4444;
  --portal-title-color:#334155;
}

/* Grey Theme ✒️ */
body.theme-grey{
  --bg:#111827;
  --surface:#1f2937;
  --accent:#4b5563;
  --text-main:#f9fafb;
  --border:#374151;
  --msg-user:#374151;
  --msg-user-border:#000000;
  --msg-ai:#374151;
  --msg-ai-border:#38bdf8;
  --study-bg:#64748b;
  --study-color:#ef4444;
  --study-dot:#38bdf8;
  --portal-title-color:#94a3b8;
}

/* Brown Theme 🟤 */
body.theme-brown{
  --bg:#292524;
  --surface:#44403c;
  --accent:#78716c;
  --text-main:#fafaf9;
  --border:#57534e;
  --msg-user:#78716c;
  --msg-user-border:#d6d3d1;
  --msg-ai:#44403c;
  --msg-ai-border:#a8a29e;
  --study-bg:#64748b;
  --study-color:#ef4444;
  --study-dot:#38bdf8;
  --portal-title-color:#94a3b8;
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{width:100%;max-width:100vw;overflow-x:hidden;height:100%;font-family:system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text-main);transition:background 0.2s ease,color 0.2s ease}
header{background:var(--surface);border-bottom:1px solid var(--border);padding:10px 14px;display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:20}
.header-title{font-size:1.1rem;font-weight:bold}
.menu-btn{background:none;border:none;color:var(--text-main);font-size:1.4rem;cursor:pointer;padding:4px}
.sub-bar{background:rgba(30,41,59,0.5);border-bottom:1px solid var(--border);padding:6px 14px;display:flex;justify-content:space-between;align-items:center;font-size:0.85rem}
.try-hint{display:flex;align-items:center;gap:6px;cursor:pointer}
.blue-dot{width:8px;height:8px;background:var(--accent);border-radius:50%;display:inline-block}
.pi-btn{background:var(--surface);border:1px solid var(--border);color:var(--text-main);border-radius:4px;padding:2px 8px;cursor:pointer;font-weight:bold}
.study-btn{position:relative;background:var(--study-bg);color:var(--study-color)!important;border:1px solid var(--border);border-radius:5px;padding:3px 8px;font-weight:bold;font-size:0.82rem;display:inline-flex;align-items:center;gap:3px}
.study-dot{position:absolute;top:-3px;right:-3px;width:6px;height:6px;background:var(--study-dot);border-radius:50%;border:1px solid var(--bg)}
#menu-dropdown{display:none;position:absolute;top:50px;right:14px;background:var(--surface);border:1px solid var(--border);border-radius:8px;box-shadow:0 10px 25px rgba(0,0,0,0.5);z-index:30;min-width:170px;overflow:hidden}
.menu-item{width:100%;padding:10px 14px;background:none;border:none;color:var(--text-main);text-align:left;cursor:pointer;font-size:0.9rem;border-bottom:1px solid var(--border);display:block}
.menu-item:last-child{border-bottom:none}
.view-section{display:none;padding:12px;width:100%;max-width:600px;margin:0 auto}

/* PORTAL STYLES */
.home-container{padding-top:10px}
.home-top-row{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-bottom:20px}
.portal-close-btn{background:rgba(239,68,68,0.15);border:1px solid rgba(239,68,68,0.4);color:#ef4444;border-radius:8px;padding:6px 12px;font-size:1.1rem;cursor:pointer;flex-shrink:0}
.portal-title{font-size:0.98rem;white-space:nowrap;font-weight:700;color:var(--portal-title-color);text-align:right;line-height:1.2;flex:1}
.portal-options{display:flex;flex-direction:column;gap:12px}
.portal-card-btn{display:flex;align-items:center;gap:14px;background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:16px;color:var(--text-main);cursor:pointer;text-align:left;transition:transform 0.15s ease,border-color 0.15s ease}
.portal-card-btn:active{transform:scale(0.98);border-color:var(--accent)}
.portal-btn-icon{font-size:1.8rem}
.portal-card-btn strong{display:block;font-size:1.02rem;margin-bottom:3px}
.portal-card-btn p{font-size:0.82rem;color:#94a3b8}

/* CHAT AREA & CUSTOM BUBBLES WITH OUTLINES */
#chat-view{height:calc(100vh - 86px);flex-direction:column;justify-content:space-between;padding:10px;box-sizing:border-box}
#chat-box{flex:1;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;gap:10px;padding-bottom:10px;word-break:break-word}
.msg{max-width:82%;padding:9px 13px;border-radius:12px;font-size:0.92rem;line-height:1.4}
.msg.user{
  align-self:flex-end;
  background:var(--msg-user);
  color:#fff;
  border:1.5px solid var(--msg-user-border);
  border-bottom-right-radius:2px;
}
.msg.ai{
  align-self:flex-start;
  background:var(--msg-ai);
  color:var(--text-main);
  border:1.5px solid var(--msg-ai-border);
  border-bottom-left-radius:2px;
}
body.theme-white .msg.ai, body.theme-grey .msg.ai{
  color:#f8fafc;
}

#pro-modal{display:none;background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:12px;margin-bottom:8px}
.tier-badge{display:inline-block;padding:3px 8px;font-size:0.75rem;border-radius:6px;font-weight:bold;margin-right:6px}
#input-area{display:flex;align-items:center;gap:6px;background:var(--surface);border:1px solid var(--border);border-radius:24px;padding:4px 8px;width:100%;box-sizing:border-box}
#input-area input{flex:1;min-width:0;background:none;border:none;color:var(--text-main);padding:8px 6px;font-size:0.92rem;outline:none}
.plus-btn{width:34px;height:34px;min-width:34px;border-radius:50%;background:rgba(255,255,255,0.08);border:1px solid var(--border);color:var(--text-main);font-size:1.1rem;display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0;box-sizing:border-box}
.primary-btn{background:var(--accent);color:#fff;border:none;border-radius:18px;padding:7px 14px;font-weight:bold;cursor:pointer;font-size:0.88rem;white-space:nowrap;flex-shrink:0}
.card{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:16px;box-sizing:border-box;word-break:break-word}
.input-row{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.input-row input,.input-row select{flex:1;min-width:110px;padding:8px;border-radius:8px;border:1px solid var(--border);background:var(--bg);color:var(--text-main)}
.calc-result-box{margin-top:12px;padding:10px;background:var(--bg);border-radius:8px;border:1px solid var(--border);font-family:monospace;font-size:1rem;word-break:break-all}
.prompt-tag{display:inline-block;background:rgba(255,255,255,0.08);border:1px solid var(--border);padding:4px 8px;border-radius:6px;font-size:0.8rem;margin:3px 2px}
.theme-btn{display:block;width:100%;padding:10px;margin-top:8px;background:var(--bg);color:var(--text-main);border:1px solid var(--border);border-radius:8px;font-weight:bold;cursor:pointer;text-align:left}
/* buffer line 1 🛡️ */
/* buffer line 2 🛡️ */
/* buffer line 3 🛡️ */
/* buffer line 4 🛡️ */
/* buffer line 5 🛡️ */
/* buffer line 6 🛡️ */
/* buffer line 7 🛡️ */
/* buffer line 8 🛡️ */
