:root{
  --bg0:#070a10;
  --bg1:#0b1120;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.04);
  --border: rgba(255,255,255,.10);
  --text:#eaf1ff;
  --muted:#a7b4cf;
  --accent:#66aaff;
  --accent2:#8a6bff;
  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --radius: 18px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

body.theme-light{
  --bg0:#f6f8ff;
  --bg1:#eef3ff;
  --panel: rgba(255,255,255,.86);
  --panel2: rgba(255,255,255,.70);
  --border: rgba(10,20,40,.10);
  --text:#0c1324;
  --muted:#4b5b76;
  --shadow: 0 18px 60px rgba(10,20,40,.10);
}

body.theme-glass{
  --panel: rgba(255,255,255,.08);
  --panel2: rgba(255,255,255,.05);
}

body.font-mono { --font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
body.font-serif{ --font: ui-serif, Georgia, "Times New Roman", serif; }

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--font);
  color:var(--text);
  background:
    radial-gradient(1200px 800px at 15% 0%, rgba(102,170,255,.18), transparent 55%),
    radial-gradient(900px 700px at 90% 10%, rgba(138,107,255,.16), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  background: rgba(10,14,22,.55);
  backdrop-filter: blur(14px);
}

.brand{
  display:flex; align-items:center; gap:10px;
  font-weight:800; letter-spacing:.2px;
}
.brand::before{
  content:"";
  width:12px; height:12px; border-radius:999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 18px rgba(102,170,255,.35);
}

.controls{display:flex; gap:10px; align-items:center}
select,input{
  border:1px solid var(--border);
  background: rgba(0,0,0,.18);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  outline:none;
}
body.theme-light select, body.theme-light input{ background: rgba(255,255,255,.75); }

.btn{
  border:1px solid var(--border);
  background: linear-gradient(135deg, rgba(102,170,255,.22), rgba(138,107,255,.14));
  color:var(--text);
  padding:10px 14px;
  border-radius:12px;
  cursor:pointer;
  transition: transform .08s ease, filter .12s ease;
}
.btn:hover{ filter: brightness(1.05); }
.btn:active{ transform: translateY(1px); }
.btn.ghost{ background: transparent; }

.layout{
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
  display:grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
}
@media (max-width: 980px){
  .layout{ grid-template-columns: 1fr; }
}

.card{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  overflow:hidden;
  position:relative;
}
.card::after{
  content:"";
  position:absolute; inset:0;
  background: radial-gradient(800px 200px at 10% 0%, rgba(102,170,255,.10), transparent 55%);
  pointer-events:none;
}
.cardTitle{
  position:relative;
  font-weight:800;
  margin: 2px 0 10px 0;
  display:flex; align-items:center; gap:10px;
}
.cardTitle::before{
  content:"";
  width:8px; height:8px; border-radius:999px;
  background: rgba(102,170,255,.9);
  box-shadow: 0 0 14px rgba(102,170,255,.35);
}

.muted{color:var(--muted)}
.small{font-size:12px}

.chat{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display:grid;
  grid-template-rows: 1fr auto;
  overflow:hidden;
  min-height: calc(100vh - 110px);
}

.messages{
  padding: 16px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.msg{
  border:1px solid var(--border);
  border-radius: 16px;
  padding: 12px 12px;
  background: var(--panel2);
  backdrop-filter: blur(10px);
}
.msgHead{
  display:flex;
  gap:10px;
  align-items:baseline;
  justify-content:space-between;
}
.msgUser{font-weight:800}
.msgTime{font-size:12px; color:var(--muted)}
.msgBody{
  margin-top:8px;
  white-space:pre-wrap;
  word-break:break-word;
  line-height:1.35;
}

.composer{
  display:flex;
  gap: 10px;
  padding: 12px;
  border-top:1px solid var(--border);
  background: rgba(0,0,0,.14);
  backdrop-filter: blur(14px);
}
.composer input{ flex:1; border-radius: 14px; }

.radioTitle{
  position:relative;
  font-weight:800;
  margin-bottom: 10px;
}
audio{
  width:100%;
  border-radius: 12px;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.35));
}

.emojiGrid{
  position:relative;
  display:grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.emojiBtn{
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius: 12px;
  padding: 9px 0;
  cursor:pointer;
  transition: transform .08s ease, background .12s ease;
}
.emojiBtn:hover{ background: rgba(255,255,255,.06); }
.emojiBtn:active{ transform: translateY(1px); }

.sep{
  border:none;
  border-top:1px solid var(--border);
  margin:14px 0;
}

.toolBlock{
  margin-bottom:12px;
  display:flex;
  flex-direction:column;
  gap:6px;
  position:relative;
}

.toolSelect{
  border-radius:10px;
  padding:8px 10px;
}

.palette{
  display: grid;
  grid-template-columns: repeat(10, 18px);
  gap: 6px;
}
.swatch{
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.swatch.active{
  outline: 2px solid rgba(255,255,255,.55);
  outline-offset: 1px;
}

.modal{
  position:fixed; inset:0;
  display:none;
  align-items:center; justify-content:center;
  background: rgba(0,0,0,.62);
  z-index: 50;
}
.modal.show{ display:flex; }
.modalCard{
  width:min(560px, calc(100% - 24px));
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(18px);
}
.modalTitle{ font-weight:900; font-size:22px; margin: 0 0 12px 0; }
.row{ display:flex; gap:10px; margin-bottom: 10px; }
.row input{ flex:1; }
.error{ color:#ffb3b3; min-height: 18px; }
