:root{
  --bg:#0b1020;
  --bg-2:#0f172a;
  --panel:rgba(13,18,34,.75);
  --panel-solid:#11182c;
  --line:rgba(255,255,255,.08);
  --text:#e5ecff;
  --muted:#96a2c6;
  --accent:#6ea8ff;
  --accent-2:#8b5cf6;
  --user:#1c4ed8;
  --ok:#10b981;
  --warn:#f59e0b;
  --danger:#ef4444;
  --shadow:0 18px 60px rgba(0,0,0,.28);
}

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

body{
  margin:0;
  font-family:'Inter',system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  color:var(--text);
  background:#09111f;
  overflow:hidden;
  position:relative;
}
.app-bg{
  position:fixed;
  inset:0;
  z-index:0;
  overflow:hidden;
  pointer-events:none;
  background:
    radial-gradient(circle at top left, rgba(110,168,255,.18), transparent 24%),
    radial-gradient(circle at top right, rgba(139,92,246,.18), transparent 22%),
    linear-gradient(180deg, #0a0f1d 0%, #09111f 100%);
}

.app-bg-video{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:contain;
  object-position:center center;
  transform:none;
  filter:none;
  opacity:.72;
}

.app-bg-blur-layer{
  position:absolute;
  inset:0;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}

.app-bg-overlay{
  position:absolute;
  inset:0;
  background:
    linear-gradient(
      90deg,
      rgba(7,12,24,.36) 0%,
      rgba(7,12,24,.08) 20%,
      rgba(7,12,24,.08) 80%,
      rgba(7,12,24,.36) 100%
    ),
    linear-gradient(
      180deg,
      rgba(4,8,18,.08) 0%,
      rgba(5,10,20,.22) 100%
    );
}

button,textarea,select{font:inherit}

.shell{
  position:relative;
  z-index:1;
  display:grid;
  grid-template-columns:320px minmax(0,1fr);
  height:100dvh;
  min-height:100dvh;
  overflow:hidden;
}

.sidebar{
  border-right:1px solid var(--line);
  background:rgba(8,11,24,.58);
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
  padding:20px 16px;
  display:flex;
  flex-direction:column;
  gap:18px;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  scrollbar-width:none;
  -ms-overflow-style:none;
}

.sidebar::-webkit-scrollbar{
  width:0;
  height:0;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:8px 8px 14px;
}

.brand-mark{
  width:44px;height:44px;border-radius:16px;
  display:grid;place-items:center;
  font-weight:900;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  color:#fff;
  box-shadow:0 12px 30px rgba(110,168,255,.35);
}

.brand-title{font-weight:900;font-size:18px}
.brand-sub{font-size:12px;color:var(--muted)}

.side-section{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:20px;
  padding:14px;
  box-shadow:var(--shadow);
}

.side-label{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--muted);
  font-weight:800;
  margin-bottom:10px;
}

.primary-side-btn,.side-btn,.task-btn,.ghost-btn,.quality-btn,.icon-btn,.send-btn,.live-toggle-btn{
  border:none;
  cursor:pointer;
  transition:.2s ease;
}

.primary-side-btn{
  border-radius:16px;
  padding:14px 16px;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  color:#fff;
  font-weight:800;
  box-shadow:0 14px 30px rgba(110,168,255,.24);
}

.primary-side-btn:hover{transform:translateY(-1px)}

.mode-list,.task-grid{display:grid;gap:8px}
.mode-list{grid-template-columns:1fr}
.task-grid{grid-template-columns:repeat(2,1fr)}

.side-btn,.task-btn,.ghost-btn,.quality-btn{
  border-radius:14px;
  padding:10px 12px;
  background:rgba(255,255,255,.03);
  color:var(--text);
  border:1px solid transparent;
  font-weight:700;
}

.side-btn:hover,.task-btn:hover,.ghost-btn:hover,.quality-btn:hover{background:rgba(255,255,255,.06)}
.side-btn.active,.task-btn.active,.quality-btn.active{
  background:rgba(110,168,255,.12);
  border-color:rgba(110,168,255,.45);
  color:#dcebff;
}

.task-btn.disabled-task,
.task-btn:disabled{
  opacity:.4;
  cursor:not-allowed;
  background:rgba(255,255,255,.02);
  border-color:rgba(255,255,255,.04);
  color:rgba(229,236,255,.55);
  box-shadow:none;
}
.task-btn.disabled-task:hover,
.task-btn:disabled:hover{
  background:rgba(255,255,255,.02);
  transform:none;
}

.manual-model-wrap,.quality-wrap{margin-top:10px}
.hidden{display:none !important}
.mini-label{display:block;font-size:12px;color:var(--muted);margin-bottom:8px;font-weight:700}
.select{
  width:100%;
  border-radius:14px;
  background:#0c1326;
  color:var(--text);
  border:1px solid var(--line);
  padding:12px;
  outline:none;
}

.tool-row{display:flex;gap:8px}

.history-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:260px;
  overflow:auto;
  scrollbar-width:none;
  -ms-overflow-style:none;
}

.history-list::-webkit-scrollbar{width:0;height:0}

.history-item{
  padding:10px 12px;
  border-radius:14px;
  background:rgba(255,255,255,.03);
  border:1px solid transparent;
  color:var(--text);
  text-align:left;
  cursor:pointer;
}
.history-item:hover{background:rgba(255,255,255,.06)}
.history-item.active{
  border-color:rgba(110,168,255,.45);
  background:rgba(110,168,255,.12);
}
.history-item-title{
  font-weight:700;
  font-size:14px;
  margin-bottom:4px;
}
.history-item-sub{
  font-size:12px;
  color:var(--muted);
}

.main-panel{
  display:flex;
  flex-direction:column;
  min-width:0;
  min-height:0;
  height:100dvh;
  overflow:hidden;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:20px 24px 16px;
  border-bottom:1px solid var(--line);
  background:rgba(9,14,27,.42);
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
  flex-shrink:0;
}
.mobile-menu-btn{
  display:none;
  width:42px;height:42px;border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--text);
  font-size:18px;
}

.topbar-title{font-size:20px;font-weight:900}
.topbar-subtitle{font-size:13px;color:var(--muted);margin-top:4px}
.live-toggle-btn{
  border-radius:999px;
  padding:12px 16px;
  font-weight:800;
  color:#ffe6e6;
  background:rgba(239,68,68,.18);
  border:1px solid rgba(239,68,68,.35);
  display:inline-flex;
  align-items:center;
  gap:10px;
}
.live-dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background:currentColor;
  display:inline-block;
  box-shadow:0 0 10px rgba(255,255,255,.18);
  flex:0 0 auto;
}
.live-toggle-btn.active{
  background:rgba(16,185,129,.18);
  color:#d9fff0;
  border-color:rgba(16,185,129,.4);
}

.messages{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:28px 24px 18px;
  display:flex;
  flex-direction:column;
  gap:18px;
  scroll-behavior:smooth;
  scrollbar-gutter:stable;
  scrollbar-width:thin;
  scrollbar-color:rgba(255,255,255,.12) transparent;
}

.message-row{
  display:flex;
  gap:10px;
  max-width:min(920px, 86%);
}
.message-row.user{align-self:flex-end;flex-direction:row-reverse}
.message-row.ai{align-self:flex-start}
.avatar{
  width:36px;height:36px;border-radius:999px;
  display:grid;place-items:center;
  flex-shrink:0;
  font-size:12px;
  font-weight:900;
  border:1px solid var(--line);
}
.avatar.ai{background:rgba(255,255,255,.06)}
.avatar.user{background:linear-gradient(135deg,var(--user),#3b82f6)}
.bubble{
  width:100%;
  border-radius:22px;
  padding:16px 18px;
  border:1px solid var(--line);
  background:var(--panel);
  box-shadow:var(--shadow);
}
.message-row.user .bubble{
  background:linear-gradient(135deg, rgba(30,64,175,.95), rgba(37,99,235,.95));
  border-color:rgba(147,197,253,.18);
}
.system-pill{
  align-self:center;
  padding:10px 14px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  background:rgba(245,158,11,.15);
  color:#ffe4ab;
  border:1px solid rgba(245,158,11,.25);
}

.bubble p{margin:0 0 10px}
.bubble p:last-child{margin-bottom:0}
.bubble code{
  background:rgba(255,255,255,.08);
  padding:2px 6px;
  border-radius:8px;
  font-size:.95em;
}
.bubble pre{
  margin-top:10px;
  border-radius:16px;
  padding:14px;
  overflow:auto;
  border:1px solid rgba(255,255,255,.08);
  background:#0c1221;
}
.bubble img{
  max-width:100%;
  display:block;
  border-radius:18px;
  border:1px solid var(--line);
  margin-top:10px;
}
.bubble audio,.bubble video{
  width:100%;
  margin-top:10px;
  border-radius:14px;
}

.thought-block{
  margin:0 0 12px;
  border:1px solid rgba(110,168,255,.18);
  background:rgba(255,255,255,.03);
  border-radius:16px;
  overflow:hidden;
}
.thought-block summary{
  list-style:none;
  cursor:pointer;
  padding:10px 14px;
  font-size:13px;
  font-weight:800;
  color:#cfe0ff;
  display:flex;
  align-items:center;
  gap:8px;
  user-select:none;
}
.thought-block summary::-webkit-details-marker{display:none}
.thought-block summary::before{
  content:"?";
  display:inline-block;
  transition:transform .18s ease;
  color:#a5c7ff;
}
.thought-block[open] summary::before{
  transform:rotate(90deg);
}
.thought-content{
  padding:0 14px 12px;
  color:#c4d4f8;
  font-size:14px;
  border-top:1px solid rgba(255,255,255,.06);
  background:rgba(10,16,31,.28);
}
.thought-content p:first-child{margin-top:10px}

.media-card{
  margin-top:10px;
  padding:10px;
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
}
.media-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:8px;
}
.media-link{
  color:#cfe0ff;
  font-weight:800;
  text-decoration:none;
}
.attach-inline{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:10px;
}
.attach-inline img,.attach-inline video{
  width:76px;height:76px;object-fit:cover;border-radius:14px;border:1px solid var(--line);margin:0;
}
.attach-inline .attach-label{
  width:76px;height:76px;border-radius:14px;border:1px solid var(--line);display:grid;place-items:center;
  background:rgba(255,255,255,.04);font-size:12px;font-weight:800;color:var(--muted);
}

.debug-panel{
  margin:0 24px 12px;
  border:1px solid var(--line);
  border-radius:18px;
  background:rgba(255,255,255,.03);
  padding:14px;
}
.debug-title{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:var(--muted);
  font-weight:800;
  margin-bottom:8px;
}
#debug-output{
  margin:0;
  white-space:pre-wrap;
  color:#dbeafe;
  font-size:12px;
  line-height:1.5;
}

.composer{
  padding:0 24px 24px;
  flex-shrink:0;
}

.dropzone-row{margin-bottom:10px}
.dropzone{
  border:1px dashed rgba(110,168,255,.35);
  border-radius:18px;
  padding:14px 16px;
  background:rgba(255,255,255,.03);
}
.dropzone.dragover{
  background:rgba(110,168,255,.08);
  border-color:rgba(110,168,255,.65);
}
.dropzone-title{font-weight:800}
.dropzone-sub{font-size:12px;color:var(--muted);margin-top:3px}

.attachments{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-bottom:12px;
}
.attach-chip{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius:16px;
  background:rgba(255,255,255,.04);
  border:1px solid var(--line);
}
.attach-preview{
  width:44px;height:44px;border-radius:12px;overflow:hidden;display:grid;place-items:center;background:#0d1324;color:var(--muted);font-weight:800;font-size:12px;
}
.attach-preview img,.attach-preview video{width:100%;height:100%;object-fit:cover}
.attach-meta{display:flex;flex-direction:column;gap:2px}
.attach-name{font-size:13px;font-weight:700;max-width:240px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.attach-state{font-size:11px;color:var(--muted)}
.attach-remove{
  width:28px;height:28px;border-radius:999px;border:none;background:rgba(255,255,255,.08);color:#fff;cursor:pointer;
}
.attach-remove:hover{background:rgba(239,68,68,.3)}

.composer-box{
  display:flex;
  align-items:flex-end;
  gap:12px;
  border:1px solid var(--line);
  border-radius:24px;
  background:rgba(14,20,38,.68);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
  padding:12px;
  box-shadow:var(--shadow);
}

.icon-btn,.send-btn{
  width:48px;height:48px;border-radius:16px;
  display:grid;place-items:center;
  background:rgba(255,255,255,.06);
  color:#fff;
  padding:0;
}

.icon-svg{
  width:22px;
  height:22px;
  display:block;
  pointer-events:none;
}

.icon-btn:hover{background:rgba(255,255,255,.1)}
.send-btn{
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  font-weight:900;
  box-shadow:0 12px 26px rgba(110,168,255,.24);
}
.send-btn:disabled{opacity:.55;cursor:not-allowed}
#chat-input{
  flex:1;
  min-height:48px;
  max-height:220px;
  resize:none;
  border:none;
  outline:none;
  background:transparent;
  color:var(--text);
  padding:12px 2px;
  line-height:1.55;
}

.live-overlay{
  position:fixed;
  inset:0;
  background:rgba(2,6,18,.72);
  backdrop-filter:blur(14px);
  display:grid;
  place-items:center;
  z-index:30;
}
.live-card{
  width:min(720px, calc(100vw - 32px));
  background:rgba(10,14,28,.94);
  border:1px solid var(--line);
  border-radius:28px;
  box-shadow:0 30px 90px rgba(0,0,0,.45);
  padding:20px;
}
.live-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-bottom:12px;
}
.live-title{font-weight:900;font-size:20px}
.live-sub{font-size:13px;color:var(--muted)}
.live-profile-switch{display:flex;gap:8px;margin:8px 0 14px}
.live-profile-switch .quality-btn{flex:1}
.live-visualizer{
  min-height:360px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  border-radius:24px;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.04) 0%, rgba(255,255,255,.01) 60%, transparent 100%);
  cursor:pointer;
  overflow:hidden;
  position:relative;
}
.live-blob{
  width:170px;height:170px;
  border-radius:60% 40% 30% 70% / 60% 30% 70% 40%;
  background:linear-gradient(135deg,#8b5cf6 0%, #3b82f6 100%);
  box-shadow:0 24px 65px rgba(59,130,246,.35);
  animation:morph-idle 6s ease-in-out infinite;
  transition:.35s ease;
}
.live-status{
  margin-top:34px;
  font-weight:800;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.12em;
  font-size:12px;
}
.live-visualizer.connecting .live-blob{
  background:linear-gradient(135deg,#f59e0b,#fbbf24);
  animation:pulse 1s infinite alternate;
}
.live-visualizer.listening .live-blob{
  background:linear-gradient(135deg,#f43f5e,#f97316);
  animation:morph-listen 3s linear infinite;
  transform:scale(1.06);
}
.live-visualizer.speaking .live-blob{
  background:linear-gradient(135deg,#06b6d4,#3b82f6,#8b5cf6);
  animation:morph-speak 1s ease-in-out infinite alternate;
}
.live-visualizer.error .live-blob{
  background:linear-gradient(135deg,#ef4444,#dc2626);
  animation:pulse 1s infinite alternate;
}

.live-debug-wrap{margin-top:12px}
.live-debug{
  width:100%;
  min-height:120px;
  max-height:200px;
  resize:vertical;
  border-radius:16px;
  border:1px solid var(--line);
  background:#09101f;
  color:#dbeafe;
  padding:12px;
}
.messages::-webkit-scrollbar,
.live-debug::-webkit-scrollbar{
  width:8px;
  height:8px;
}

.messages::-webkit-scrollbar-track,
.live-debug::-webkit-scrollbar-track{
  background:transparent;
}

.messages::-webkit-scrollbar-thumb,
.live-debug::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.08);
  border-radius:999px;
  border:2px solid transparent;
  background-clip:padding-box;
}

.messages:hover::-webkit-scrollbar-thumb,
.live-debug:hover::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.16);
  background-clip:padding-box;
}

.messages::-webkit-scrollbar-corner,
.live-debug::-webkit-scrollbar-corner{
  background:transparent;
}

.tts-hint{
  margin:0 24px 10px;
  padding:9px 12px;
  border-radius:999px;
  border:1px solid rgba(110,168,255,.25);
  background:rgba(110,168,255,.11);
  color:#cfe0ff;
  font-size:12px;
  font-weight:700;
  align-self:flex-start;
}

.typing-cursor::after{
  content:"";
  width:8px;
  height:1.1em;
  background:rgba(255,255,255,.6);
  display:inline-block;
  margin-left:2px;
  vertical-align:middle;
  animation:cursor-blink .9s steps(2, start) infinite;
}

@keyframes cursor-blink{
  to{opacity:0}
}

.mobile-drawer-backdrop{
  position:fixed;
  inset:0;
  z-index:18;
  background:rgba(3,7,16,.55);
  backdrop-filter:blur(4px);
}

@keyframes morph-idle{
  0%,100%{border-radius:60% 40% 30% 70% / 60% 30% 70% 40%}
  50%{border-radius:30% 60% 70% 40% / 50% 60% 30% 60%}
}
@keyframes morph-listen{
  0%{transform:rotate(0deg) scale(1.03)}
  100%{transform:rotate(360deg) scale(1.08)}
}
@keyframes morph-speak{
  from{transform:scale(1)}
  to{transform:scale(1.14)}
}
@keyframes pulse{
  from{transform:scale(.92)}
  to{transform:scale(1.03)}
}

@media (max-width: 980px){
  .shell{grid-template-columns:1fr}
  .mobile-menu-btn{display:grid;place-items:center}
  .topbar{padding:14px 16px 12px}
  .messages{padding:18px 16px 12px}
  .composer{padding:0 16px 16px}
  .tts-hint{margin:0 16px 8px}
  .sidebar{
    display:flex;
    position:fixed;
    left:0;
    top:0;
    bottom:0;
    width:min(88vw,340px);
    z-index:20;
    transform:translateX(-104%);
    transition:transform .24s ease;
  }
  .sidebar.open{transform:translateX(0)}
  .message-row{max-width:92%}
}