@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  transition: color .4s ease;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
code, .mono { font-family: 'JetBrains Mono', monospace; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(140,150,180,.35); border-radius: 8px; }

/* ---------- theme variables ---------- */
:root, [data-theme="light"] {
  --bg1: #F4F6FB; --bg2: #E7ECF6; --surface: #FFFFFF; --text: #161A22;
  --sub: #5B6472; --accent1: #3B5BFF; --accent2: #12B3A6; --border: #DFE4EE;
}
[data-theme="dark"] {
  --bg1: #0A0D14; --bg2: #111623; --surface: #151A27; --text: #E9EDF6;
  --sub: #8B93A7; --accent1: #7C9CFF; --accent2: #38E0C6; --border: #232A3B;
}

/* ---------- animated mesh background ---------- */
.mesh-bg { position: fixed; inset: 0; z-index: -1; background: var(--bg1); transition: background .4s ease; overflow: hidden; }
.mesh-bg::before { content:''; position:absolute; inset:0; background: linear-gradient(160deg, var(--bg1), var(--bg2)); transition: background .4s ease; }
.blob { position: absolute; border-radius: 50%; filter: blur(95px); opacity: .22; }
.blob1 { width: 520px; height: 520px; top: -8%; left: -6%; background: var(--accent1); animation: blobMove1 16s ease-in-out infinite; }
.blob2 { width: 460px; height: 460px; bottom: -10%; right: -6%; background: var(--accent2); opacity: .2; animation: blobMove2 18s ease-in-out infinite; }
.blob3 { width: 360px; height: 360px; top: 40%; left: 60%; background: var(--accent1); opacity: .12; animation: blobMove3 20s ease-in-out infinite; }
@keyframes blobMove1 { 0%,100%{ transform: translate(0,0) scale(1);} 50%{ transform: translate(6%,8%) scale(1.15);} }
@keyframes blobMove2 { 0%,100%{ transform: translate(0,0) scale(1);} 50%{ transform: translate(-8%,-4%) scale(1.1);} }
@keyframes blobMove3 { 0%,100%{ transform: translate(0,0) scale(1);} 50%{ transform: translate(4%,-9%) scale(1.2);} }
@keyframes fadeUp { from{opacity:0; transform: translateY(8px);} to{opacity:1; transform: translateY(0);} }
.fade-up { animation: fadeUp .35s ease both; }

/* ---------- auth page ---------- */
.auth-wrap { min-height: 100vh; display:flex; align-items:center; justify-content:center; padding:16px; }
.auth-card { width:100%; max-width:400px; background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:28px; box-shadow:0 20px 60px rgba(0,0,0,.25); }
.brand { display:flex; align-items:center; gap:10px; margin-bottom:4px; }
.brand-icon { width:34px; height:34px; border-radius:9px; background:linear-gradient(135deg,var(--accent1),var(--accent2)); display:flex; align-items:center; justify-content:center; color:#fff; font-weight:800; }
.brand-name { font-family:'JetBrains Mono',monospace; font-weight:700; font-size:17px; }
.subtext { font-size:13px; color:var(--sub); margin-bottom:18px; }
.tabs { display:flex; background:var(--bg2); border-radius:10px; padding:4px; margin-bottom:18px; }
.tabs a { flex:1; text-align:center; padding:8px 0; border-radius:8px; font-size:13px; font-weight:600; color:var(--sub); }
.tabs a.active { background:var(--surface); color:var(--text); box-shadow:0 2px 8px rgba(0,0,0,.12); }
.field { margin-bottom:12px; }
.field label { display:block; font-size:12px; color:var(--sub); margin-bottom:5px; font-weight:600; }
.field input, .field select { width:100%; padding:10px 12px; border-radius:9px; outline:none; border:1px solid var(--border); background:var(--bg2); color:var(--text); font-size:14px; }
.btn-primary { width:100%; padding:11px 0; border-radius:10px; border:none; background:linear-gradient(135deg,var(--accent1),var(--accent2)); color:#fff; font-weight:700; font-size:14px; }
.error-msg { color:#F26363; font-size:12.5px; margin:4px 0 6px; }
.hint { margin-top:16px; font-size:11.5px; color:var(--sub); display:flex; gap:6px; }

/* ---------- shell (editor chrome) ---------- */
.shell { position:relative; z-index:2; display:flex; min-height:100vh; }
.sidebar { width:230px; flex-shrink:0; border-right:1px solid var(--border); background:color-mix(in srgb, var(--surface) 80%, transparent); backdrop-filter:blur(10px); display:flex; flex-direction:column; padding:18px 14px; }
.sidebar .brand { padding:4px 6px 20px; }
.navlink { display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:9px; border:none; margin-bottom:4px; text-align:left; font-size:13.5px; font-weight:600; background:transparent; color:var(--text); width:100%; }
.navlink.active { background:color-mix(in srgb, var(--accent1) 12%, transparent); color:var(--accent1); }
.navlink svg { flex-shrink:0; }
.spacer { flex:1; }
.mode-switch { display:flex; background:var(--bg2); border-radius:10px; padding:3px; }
.mode-switch a { flex:1; padding:7px 0; border-radius:8px; display:flex; justify-content:center; color:var(--sub); }
.mode-switch a.active { background:var(--surface); color:var(--accent1); box-shadow:0 2px 6px rgba(0,0,0,.12); }
.who { margin-top:14px; padding:10px 12px; border-radius:10px; background:var(--bg2); display:flex; align-items:center; gap:8px; }
.avatar { width:26px; height:26px; border-radius:50%; background:linear-gradient(135deg,var(--accent2),var(--accent1)); display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; color:#fff; flex-shrink:0; }
.who-name { font-size:12.5px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.who-role { font-size:10.5px; color:var(--sub); }
.logout-btn { margin-left:auto; background:none; border:none; color:var(--sub); padding:4px; }

.main { flex:1; display:flex; flex-direction:column; min-width:0; }
.titlebar { height:44px; border-bottom:1px solid var(--border); display:flex; align-items:center; padding:0 16px; gap:8px; background:color-mix(in srgb, var(--surface) 60%, transparent); }
.dot { width:10px; height:10px; border-radius:50%; }
.dot.red{background:#F26363;} .dot.yellow{background:#F5B942;} .dot.green{background:#57C785;}
.filename { margin-left:14px; font-family:'JetBrains Mono',monospace; font-size:12px; color:var(--sub); }
.content { flex:1; overflow-y:auto; padding:28px; }
.statusbar { height:26px; border-top:1px solid var(--border); display:flex; align-items:center; padding:0 14px; font-size:11px; color:var(--sub); gap:14px; font-family:'JetBrains Mono',monospace; }
.statusbar .push { margin-left:auto; }

/* ---------- generic components ---------- */
h1.page-title { font-size:22px; font-weight:800; margin:0 0 4px; }
h2.page-title { font-size:20px; font-weight:800; margin:0 0 4px; }
.page-desc { color:var(--sub); font-size:14px; margin-bottom:22px; }
.card { background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:18px; }
.grid-cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:14px; }
.icon-box { width:34px; height:34px; border-radius:9px; background:color-mix(in srgb, var(--accent1) 12%, transparent); display:flex; align-items:center; justify-content:center; margin-bottom:12px; color:var(--accent1); }
.btn { padding:8px 13px; border-radius:9px; border:1px solid var(--border); background:var(--surface); color:var(--text); font-size:12.5px; font-weight:600; display:inline-flex; align-items:center; gap:6px; }
.btn-grad { border:none; background:linear-gradient(135deg,var(--accent1),var(--accent2)); color:#fff; }
.btn-danger { color:#F26363; }
.tab-row { display:flex; gap:6px; margin-bottom:18px; flex-wrap:wrap; }
.tab-btn { display:flex; align-items:center; gap:6px; padding:8px 13px; border-radius:9px; border:1px solid var(--border); background:var(--surface); color:var(--text); font-size:12.5px; font-weight:600; }
.tab-btn.active { border-color:transparent; background:linear-gradient(135deg,var(--accent1),var(--accent2)); color:#fff; }
textarea.tool-ta { width:100%; height:260px; padding:12px; border-radius:12px; border:1px solid var(--border); background:var(--surface); color:var(--text); font-family:'JetBrains Mono',monospace; font-size:12.5px; resize:vertical; outline:none; }
.tool-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.tool-label { font-size:11.5px; color:var(--sub); margin-bottom:6px; font-weight:700; }
.toast { position:fixed; top:16px; left:50%; transform:translateX(-50%); z-index:200; background:var(--surface); border:1px solid var(--border); color:var(--text); padding:10px 18px; border-radius:10px; font-size:13px; font-weight:500; box-shadow:0 8px 24px rgba(0,0,0,.18); display:none; }

/* chat */
.chat-wrap { display:flex; flex-direction:column; height:calc(100vh - 130px); max-width:780px; }
.chat-box { flex:1; overflow-y:auto; border:1px solid var(--border); border-radius:14px; background:var(--surface); padding:16px; margin-bottom:12px; }
.msg-row { display:flex; margin-bottom:10px; }
.msg-row.user { justify-content:flex-end; }
.bubble { max-width:80%; padding:9px 13px; border-radius:12px; font-size:13.5px; line-height:1.5; white-space:pre-wrap; }
.bubble.user { background:linear-gradient(135deg,var(--accent1),var(--accent2)); color:#fff; }
.bubble.ai { background:var(--bg2); color:var(--text); }
.chat-input-row { display:flex; gap:8px; }
.chat-input-row input { flex:1; padding:11px 14px; border-radius:11px; border:1px solid var(--border); background:var(--surface); color:var(--text); font-size:13.5px; }
.send-btn { padding:0 16px; border-radius:11px; border:none; background:linear-gradient(135deg,var(--accent1),var(--accent2)); color:#fff; }

/* admin */
.color-field { display:flex; gap:6px; align-items:center; }
.color-field input[type=color] { width:34px; height:34px; border-radius:8px; border:1px solid var(--border); padding:0; background:none; }
.color-field input[type=text] { width:90px; padding:7px 8px; border-radius:8px; border:1px solid var(--border); background:var(--surface); color:var(--text); font-size:12px; }
.theme-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.theme-fields { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.preview-strip { margin-top:12px; height:60px; border-radius:10px; }
.preset-btn { display:flex; align-items:center; gap:8px; padding:8px 12px; border-radius:10px; border:1px solid var(--border); background:var(--surface); color:var(--text); font-size:12.5px; }
.swatches { display:flex; border-radius:6px; overflow:hidden; }
.swatches span { width:14px; height:14px; display:block; }
.user-list { border:1px solid var(--border); border-radius:14px; overflow:hidden; background:var(--surface); }
.user-row { display:flex; align-items:center; gap:10px; padding:12px 16px; border-bottom:1px solid var(--border); }
.user-row:last-child { border-bottom:none; }
.badge-admin { font-size:10px; background:color-mix(in srgb, var(--accent1) 15%, transparent); color:var(--accent1); padding:2px 8px; border-radius:20px; font-weight:700; }

@media (max-width: 760px) {
  .sidebar { width: 76px; }
  .who-name, .who-role, .navlink span.label { display:none; }
  .brand-name { display:none; }
  .theme-grid, .tool-grid { grid-template-columns: 1fr; }
}

/* ---------- v2: modal ---------- */
.modal-overlay { position:fixed; inset:0; z-index:150; background:rgba(6,8,14,.6); backdrop-filter:blur(4px); display:flex; align-items:center; justify-content:center; padding:16px; }
.modal-box { width:100%; max-width:560px; max-height:88vh; overflow-y:auto; background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:22px; box-shadow:0 20px 60px rgba(0,0,0,.35); }
.modal-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.icon-btn { background:var(--bg2); border:none; color:var(--text); width:30px; height:30px; border-radius:8px; font-size:14px; display:inline-flex; align-items:center; justify-content:center; }

/* ---------- v2: notification / ad / code cards ---------- */
.notif-card { }
.notif-icon { width:38px; height:38px; border-radius:10px; background:var(--bg2); display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0; }
.code-card { display:flex; flex-direction:column; }
.code-card-noimg { width:100%; aspect-ratio:16/9; border-radius:10px; margin-bottom:10px; background:linear-gradient(135deg, var(--accent1), var(--accent2)); display:flex; align-items:center; justify-content:center; color:#fff; font-family:'JetBrains Mono',monospace; font-size:28px; font-weight:700; opacity:.85; }

/* ---------- v2: chat room extras ---------- */
.msg-actions { display:flex; gap:4px; opacity:.5; }
.msg-actions button { background:none; border:none; font-size:12px; padding:2px 4px; border-radius:6px; }
.msg-actions button:hover { opacity:1; background:var(--bg2); }
.voice-bubble { display:flex; align-items:center; gap:8px; min-width:130px; }
.voice-play { width:26px; height:26px; border-radius:50%; border:none; background:rgba(255,255,255,.25); color:inherit; flex-shrink:0; }
.bubble.ai .voice-play { background:var(--surface); }
.voice-wave { flex:1; opacity:.8; }
#recordBar .rec-dot { width:9px; height:9px; border-radius:50%; background:#F26363; animation:recPulse 1s ease-in-out infinite; }
@keyframes recPulse { 0%,100%{opacity:1;} 50%{opacity:.3;} }

/* ---------- v2: call ---------- */
.call-box { max-width:720px; }
.call-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:10px; min-height:120px; }
.call-tile { position:relative; background:#000; border-radius:12px; overflow:hidden; aspect-ratio:4/3; }
.call-tile video { width:100%; height:100%; object-fit:cover; }
.call-tile-label { position:absolute; bottom:6px; left:8px; font-size:11px; color:#fff; background:rgba(0,0,0,.5); padding:2px 8px; border-radius:20px; }

/* ---------- v2: admin gear / user modal ---------- */
.gear-btn { background:none; border:none; color:var(--sub); padding:6px; border-radius:7px; }
.gear-btn:hover { background:var(--bg2); color:var(--text); }
.token-toggle { display:flex; align-items:center; gap:8px; font-size:12.5px; }
.switch { position:relative; width:38px; height:22px; background:var(--border); border-radius:20px; border:none; flex-shrink:0; }
.switch.on { background:linear-gradient(135deg,var(--accent1),var(--accent2)); }
.switch::after { content:''; position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%; background:#fff; transition:left .2s ease; }
.switch.on::after { left:18px; }
