:root{
  --bg: #0b1020;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.08);
  --border: rgba(255,255,255,.12);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.60);
  --accent: #7c5cff;
  --accent2: #19c37d;
  --danger: #ff4d6d;
  --shadow: 0 12px 30px rgba(0,0,0,.35);
  --radius: 14px;
  --radius2: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 20% 0%, rgba(124,92,255,.25), transparent 55%),
    radial-gradient(900px 600px at 95% 20%, rgba(25,195,125,.14), transparent 55%),
    radial-gradient(900px 600px at 20% 95%, rgba(255,77,109,.10), transparent 55%),
    var(--bg);
}

code{ font-family: var(--mono); }

.app{
  height:100%;
  display:flex;
  flex-direction:column;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:16px 18px;
  border-bottom:1px solid var(--border);
  background: rgba(0,0,0,.18);
  backdrop-filter: blur(10px);
}

.brand__title{
  font-weight:700;
  letter-spacing:.2px;
  font-size:16px;
}
.brand__sub{
  font-size:12px;
  color: var(--muted);
  margin-top:2px;
}

.topbar__right{
  display:flex;
  align-items:center;
  gap:12px;
}

.status{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.05);
}
.status__dot{
  width:10px; height:10px;
  border-radius:999px;
  background: rgba(255,255,255,.35);
  box-shadow: 0 0 0 3px rgba(255,255,255,.08);
}
.status--ok .status__dot{ background: var(--accent2); box-shadow: 0 0 0 3px rgba(25,195,125,.18); }
.status--bad .status__dot{ background: var(--danger); box-shadow: 0 0 0 3px rgba(255,77,109,.18); }
.status__text{ font-size:12px; color: var(--muted); }

.main{
  flex:1;
  display:grid;
  grid-template-columns: 360px 1fr;
  gap:16px;
  padding:16px;
  min-height:0;
}

.panel{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.05);
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:0;
}
.panel__section{
  padding:14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.panel__footer{
  padding:12px 14px;
  color: var(--muted);
}

.label{
  font-size:12px;
  color: var(--muted);
  margin-bottom:8px;
}

.hint{
  margin-top:8px;
  color: var(--muted);
  font-size:12px;
  line-height:1.4;
}

.input,.select,.textarea{
  width:100%;
  border:1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding:10px 10px;
  color: var(--text);
  background: rgba(0,0,0,.25);
  outline:none;
}
.input:focus,.select:focus,.textarea:focus{ border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 4px rgba(124,92,255,.14); }
.textarea{ resize: vertical; min-height: 96px; font-family: var(--sans); }

.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}

.btn{
  appearance:none;
  border:1px solid rgba(124,92,255,.45);
  background: linear-gradient(180deg, rgba(124,92,255,.95), rgba(124,92,255,.80));
  color: white;
  padding:10px 12px;
  border-radius: 12px;
  font-weight: 650;
  cursor:pointer;
  box-shadow: 0 10px 20px rgba(124,92,255,.18);
}
.btn:hover{ filter: brightness(1.05); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; transform:none; }

.btn--ghost{
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: none;
}
.btn--ghost:hover{ background: rgba(255,255,255,.08); }

.chat{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.04);
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}

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

.msg{
  display:flex;
  gap:10px;
}
.msg__role{
  flex:0 0 auto;
  width: 84px;
  font-size: 12px;
  color: var(--muted);
  padding-top: 10px;
}
.msg__bubble{
  flex: 1 1 auto;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--radius2);
  padding: 10px 12px;
  background: rgba(0,0,0,.25);
}
.msg--user .msg__bubble{
  background: rgba(124,92,255,.12);
  border-color: rgba(124,92,255,.22);
}
.msg--assistant .msg__bubble{
  background: rgba(0,0,0,.22);
}

.msg__text{
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 14px;
}

.msg__meta{
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255,255,255,.45);
}

.composer{
  border-top: 1px solid rgba(255,255,255,.10);
  padding: 12px;
  display:flex;
  gap:12px;
  align-items:flex-end;
}

.composer__input{
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 200px;
  resize: vertical;
  border:1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(0,0,0,.25);
  color: var(--text);
  outline:none;
  font-family: var(--sans);
}
.composer__input:focus{ border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 4px rgba(124,92,255,.14); }

.composer__actions{
  display:flex;
  gap:10px;
}

.switch{
  display:flex;
  align-items:center;
  gap:10px;
  user-select:none;
}
.switch input{ display:none; }
.switch__track{
  position: relative;
  width: 44px;
  height: 26px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
}
.switch__track::after{
  content: "";
  position:absolute;
  top:3px; left:3px;
  width: 20px; height: 20px;
  border-radius: 999px;
  background: rgba(255,255,255,.88);
  transition: transform .18s ease, background .18s ease;
}
.switch input:checked + .switch__track{
  background: rgba(25,195,125,.22);
  border-color: rgba(25,195,125,.35);
}
.switch input:checked + .switch__track::after{
  transform: translateX(18px);
  background: rgba(25,195,125,.95);
}
.switch__label{
  font-size: 12px;
  color: var(--muted);
}

.toast{
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 720px;
  width: calc(100% - 24px);
  border: 1px solid rgba(255,77,109,.35);
  background: rgba(20,10,14,.92);
  color: rgba(255,255,255,.92);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  padding: 12px 14px;
}
.toast__body{ font-size: 13px; line-height: 1.45; }

@media (max-width: 960px){
  .main{ grid-template-columns: 1fr; }
}
