:root{
  --ink:#07070b;
  --ink2:#0c0b12;
  --panel:#12101a;
  --panel2:#17131f;
  --line:#2b2536;
  --text:#f5f1f7;
  --muted:#aaa0b5;
  --purple:#6334d7;
  --purple2:#3d1c8a;
  --magenta:#d11a9b;
  --pink:#f147ba;
  --warm:#d8c9a8;
  --danger:#ff6a8b;
  --shadow:0 18px 60px rgba(0,0,0,.35);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:
    radial-gradient(circle at 72% 10%,rgba(209,26,155,.16),transparent 34%),
    radial-gradient(circle at 28% 12%,rgba(99,52,215,.19),transparent 32%),
    linear-gradient(135deg,#08070c 0%,#0b0910 45%,#09070c 100%);
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  overflow:hidden;
}
button,input,textarea{font:inherit}
button{cursor:pointer}
.hide{display:none!important}

.app-shell{height:100vh;display:grid;grid-template-columns:292px 1fr}
.sidebar{
  min-width:0;
  background:rgba(8,7,12,.92);
  border-right:1px solid var(--line);
  display:flex;
  flex-direction:column;
  backdrop-filter:blur(20px);
}
.sidebar-top{padding:18px 16px 14px;border-bottom:1px solid rgba(255,255,255,.05)}
.brand{display:flex;align-items:center;gap:11px;margin-bottom:16px}
.brand img{width:42px;height:42px;object-fit:contain;background:#030305;border-radius:9px}
.brand b{display:block;font-size:14px}
.brand span{display:block;color:var(--muted);font-size:11px;margin-top:3px}
.new-chat{
  width:100%;border:1px solid #46355a;background:linear-gradient(135deg,#1c1527,#21162d);
  color:#fff;border-radius:12px;padding:11px 13px;text-align:left;font-weight:720
}
.new-chat:hover{border-color:#8b54e6}
.sidebar-label{padding:17px 16px 7px;color:#776d82;font-size:11px;text-transform:uppercase;letter-spacing:.12em}
.chat-list{padding:0 9px;overflow:auto;flex:1}
.empty-side{padding:14px 10px;color:#70677a;font-size:12px}
.chat-row{display:flex;align-items:stretch;border-radius:10px;margin:3px 0}
.chat-row:hover,.chat-row.active{background:#17121f}
.chat-row.active{box-shadow:inset 2px 0 0 var(--magenta)}
.chat-open{flex:1;min-width:0;background:none;border:0;color:#ddd3e3;padding:10px 9px;text-align:left}
.chat-title{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:13px}
.chat-meta{display:block;color:#6f6677;font-size:10px;margin-top:3px}
.chat-menu{width:34px;background:none;border:0;color:#655c6d;font-size:18px}
.chat-menu:hover{color:var(--danger)}
.sidebar-bottom{padding:13px;border-top:1px solid var(--line)}
.status-pill{font-size:12px;color:#d6c9df;margin-bottom:9px}
.sidebar-actions{display:flex;gap:6px;flex-wrap:wrap}
.ghost,.icon-btn{
  color:#d8d1dd;background:#17131e;border:1px solid #31283c;border-radius:9px;padding:8px 10px
}
.ghost:hover,.icon-btn:hover{border-color:#6b477d}

.workspace{min-width:0;height:100vh;display:grid;grid-template-rows:68px 1fr auto}
.topbar{
  display:flex;align-items:center;gap:13px;padding:0 22px;border-bottom:1px solid var(--line);
  background:rgba(9,8,13,.7);backdrop-filter:blur(18px)
}
.icon-btn{font-size:18px;padding:7px 10px}
.top-title{font-weight:760;font-size:14px;max-width:60vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top-subtitle{font-size:10px;color:#746c7d;margin-top:3px}
.top-right{margin-left:auto}
.plan-badge{font-size:10px;letter-spacing:.08em;color:#e6c9f2;border:1px solid #432956;background:#1d1026;border-radius:999px;padding:7px 10px}

.conversation{overflow:auto;padding:0 max(24px,calc((100% - 980px)/2)) 40px;scroll-behavior:smooth}
.welcome{padding:11vh 0 6vh}
.eyebrow{color:#d68ad2;font-size:11px;letter-spacing:.13em;margin-bottom:14px}
.welcome h1{font-size:clamp(42px,6vw,76px);line-height:.98;letter-spacing:-.045em;margin:0 0 22px;max-width:950px}
.welcome p{max-width:820px;color:#b3a9b9;font-size:18px;line-height:1.6}
.capability-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:34px}
.capability-grid>div{padding:16px;border:1px solid #30273a;background:linear-gradient(145deg,#15111b,#100d15);border-radius:15px}
.capability-grid b{display:block;margin-bottom:6px}
.capability-grid span{font-size:12px;color:#897f91}

.messages{padding:28px 0}
.message{margin:0 0 30px}
.message-head{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:#8e8299;margin-bottom:8px}
.message.user{margin-left:18%}
.message.user .message-body{background:linear-gradient(135deg,#241632,#191222);border-color:#4a2c5d}
.message-body{
  background:#121018;border:1px solid #2c2435;border-radius:17px;padding:18px 20px;line-height:1.68;
  font-size:15px;box-shadow:0 8px 24px rgba(0,0,0,.14)
}
.message.assistant .message-body{border-left:2px solid var(--magenta)}
.source-stack{display:grid;gap:8px;margin-top:10px}
.source-card{display:flex;gap:10px;padding:12px 14px;background:#0e0c13;border:1px solid #2b2432;border-radius:12px}
.source-num{
  width:24px;height:24px;display:grid;place-items:center;flex:0 0 auto;border-radius:8px;
  background:linear-gradient(135deg,var(--purple),var(--magenta));font-size:11px;font-weight:800
}
.source-card b{font-size:12px}
.source-meta{font-size:11px;color:#817689;margin-top:4px}
.source-card a{font-size:11px;color:#d88de2;text-decoration:none}

.composer-wrap{padding:10px max(24px,calc((100% - 980px)/2)) 20px;background:linear-gradient(180deg,transparent,#09080d 22%);}
.scope-row{display:flex;gap:6px;overflow-x:auto;padding-bottom:8px}
.scope{
  white-space:nowrap;border:1px solid #30273a;background:#121019;color:#94899d;border-radius:999px;
  padding:6px 10px;font-size:11px
}
.scope.active{color:#fff;border-color:#a73e9d;background:linear-gradient(135deg,#332054,#35162e)}
.composer{
  display:grid;grid-template-columns:auto 1fr auto;align-items:end;gap:8px;padding:10px;border-radius:18px;
  background:linear-gradient(135deg,#15111d,#0f0d14);border:1px solid #3a2d46;box-shadow:var(--shadow)
}
.attach-btn{width:40px;height:40px;display:grid;place-items:center;border-radius:11px;background:#21172b;border:1px solid #40304d;cursor:pointer}
.attach-btn:hover{border-color:#9553a0}
.attach-btn input{display:none}
.composer textarea{
  resize:none;max-height:180px;min-height:40px;padding:10px 6px;border:0;outline:0;background:transparent;color:#fff;
  line-height:1.45
}
.send-btn{
  height:40px;border:0;border-radius:11px;padding:0 16px;font-weight:800;color:#fff;
  background:linear-gradient(135deg,var(--purple),var(--magenta))
}
.send-btn:disabled{opacity:.5;cursor:wait}
.composer-note{font-size:10px;color:#766d7d;padding:7px 3px 0}

.attachment-tray{display:flex;gap:7px;overflow-x:auto;padding-bottom:8px}
.attachment-chip{
  display:grid;grid-template-columns:1fr auto;grid-template-rows:auto auto;gap:0 9px;min-width:190px;max-width:280px;
  background:#17121e;border:1px solid #382a45;border-radius:11px;padding:8px 9px
}
.attachment-chip span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:11px}
.attachment-chip small{font-size:9px;color:#7d7287}
.attachment-chip button{grid-column:2;grid-row:1/3;border:0;background:none;color:#867b90}
.attachment-chip.error{border-color:#7a3047}

.modal{position:fixed;inset:0;background:rgba(2,1,4,.78);display:grid;place-items:center;z-index:30;backdrop-filter:blur(8px)}
.card{position:relative;width:min(430px,92vw);padding:30px;background:#15111c;border:1px solid #3d3048;border-radius:20px;box-shadow:var(--shadow);text-align:center}
.auth-card:before{
  content:"";position:absolute;inset:-1px;border-radius:20px;padding:1px;background:linear-gradient(135deg,var(--purple),transparent 45%,var(--magenta));
  -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;pointer-events:none
}
.auth-card img{max-width:160px;max-height:70px;margin-bottom:8px}
.auth-card h2{margin:8px 0 5px}
.auth-card p{color:#92869d;font-size:12px}
.auth-card input{width:100%;padding:12px 13px;border-radius:10px;border:1px solid #40324b;background:#0d0b11;color:#fff;margin:10px 0}
.primary{width:100%;border:0;border-radius:10px;padding:12px;font-weight:800;color:#fff;background:linear-gradient(135deg,var(--purple),var(--magenta))}
.close-btn{position:absolute;right:12px;top:10px;border:0;background:none;color:#a89eaf;font-size:22px}
.auth-msg{min-height:18px}
.toast{
  position:fixed;right:22px;bottom:22px;z-index:50;max-width:420px;background:#1b1422;border:1px solid #633d6a;color:#fff;
  border-radius:12px;padding:12px 15px;box-shadow:var(--shadow);font-size:12px
}

body.sidebar-collapsed .app-shell{grid-template-columns:0 1fr}
body.sidebar-collapsed .sidebar{overflow:hidden;border:0}

@media(max-width:850px){
  .app-shell{grid-template-columns:1fr}
  .sidebar{position:fixed;z-index:20;width:280px;height:100vh;transform:translateX(-100%);transition:.2s}
  body:not(.sidebar-collapsed) .sidebar{transform:translateX(0)}
  body.sidebar-collapsed .sidebar{transform:translateX(-100%)}
  .capability-grid{grid-template-columns:1fr}
  .message.user{margin-left:7%}
  .top-subtitle{display:none}
  .conversation,.composer-wrap{padding-left:16px;padding-right:16px}
}

.pricing-card{width:min(920px,94vw);text-align:left}
.pricing-card h2{margin:7px 0 20px}
.pricing-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
.price-plan{display:flex;flex-direction:column;gap:11px;padding:18px;border:1px solid #362b42;border-radius:16px;background:#100d15}
.price-plan.featured{border-color:#8b3d91;background:linear-gradient(145deg,#171021,#180e1d)}
.price-plan strong{font-size:34px}
.price-plan strong small{font-size:12px;color:#8f8498}
.price-plan span{min-height:38px;color:#91869a;font-size:12px}
@media(max-width:760px){.pricing-grid{grid-template-columns:1fr}}


/* v3: folder/ZIP uploads, stable attachment tray, chat rename, Drive browser */
.workspace,
.conversation,
.composer-wrap,
.composer,
.messages,
.message,
.message-body,
.source-stack,
.source-card {
  min-width: 0;
  max-width: 100%;
}

.upload-actions{
  display:flex;
  flex:0 0 auto;
  gap:6px;
  min-width:0;
}

.attachment-tray{
  width:100%;
  max-width:100%;
  min-width:0;
  display:flex;
  gap:7px;
  overflow-x:auto;
  overflow-y:hidden;
  padding-bottom:8px;
  scrollbar-width:thin;
  overscroll-behavior-x:contain;
}

.attachment-chip{
  flex:0 0 230px;
  width:230px;
  min-width:0;
  max-width:230px;
  overflow:hidden;
}

.attachment-chip span{
  min-width:0;
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.message-body,
.source-card,
.source-meta{
  overflow-wrap:anywhere;
  word-break:break-word;
}

.chat-actions{
  display:flex;
  align-items:center;
  gap:2px;
  flex:0 0 auto;
}

.chat-rename{font-size:13px}
.message{scroll-margin-top:18px}

.drive-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  font-family:Arial,sans-serif;
  color:#fff;
  background:linear-gradient(135deg,#6f2cff,#d621b7);
  border:1px solid rgba(255,255,255,.12);
}

.drive-panel{
  width:min(760px,94vw);
  max-height:82vh;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  padding:20px;
}

.drive-headline{padding-right:36px}
.drive-headline h2{margin:4px 0 4px}
.drive-headline p{margin:0;color:#aaa0b7}

.drive-tools{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top:16px;
}

.drive-tools input{
  min-width:0;
  flex:1;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:10px;
  color:#fff;
  background:#120d18;
}

.drive-files{
  min-height:180px;
  max-height:50vh;
  overflow:auto;
  margin-top:12px;
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px;
}

.drive-file{
  width:100%;
  display:grid;
  grid-template-columns:34px minmax(0,1fr) auto;
  align-items:center;
  gap:9px;
  padding:11px 12px;
  border:0;
  border-bottom:1px solid rgba(255,255,255,.06);
  color:#eee8f5;
  background:transparent;
  text-align:left;
  cursor:pointer;
}

.drive-file:hover{background:rgba(154,46,205,.11)}
.drive-file-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.drive-file-action{font-size:12px;color:#ef81db}
.drive-empty{padding:28px 18px;color:#b8afc2;text-align:center}

.drive-footer{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:12px;
}

@media(max-width:650px){
  .attachment-chip{
    flex-basis:190px;
    width:190px;
    max-width:190px;
  }
  .drive-tools{flex-wrap:wrap}
  .drive-tools input{flex-basis:100%}
}
