:root{
  /* Light, modern palette */
  --bg:#f6f7fb;
  --panel:#ffffff;
  --panel2:#f3f6ff;
  --text:#0f172a;      /* slate-900 */
  --muted:#64748b;     /* slate-500 */
  --border:#e6eaf2;

  --accent:#6366f1;    /* indigo-500 */
  --accent2:#06b6d4;   /* cyan-500 (subtle accents) */
  --danger:#ef4444;

  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
  --radius:14px;
  --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;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--sans);
  color:var(--text);
  background:
    radial-gradient(1000px 600px at 10% -10%, rgba(99,102,241,.18), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(6,182,212,.14), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 45%, #f3f6ff 100%);
}

.app{
  height:100%;
  display:grid;
  grid-template-columns: 320px 1fr;
}

/* Sidebar */
.sidebar{
  background:rgba(255,255,255,.78);
  border-right:1px solid var(--border);
  backdrop-filter: blur(12px);
  display:flex;
  flex-direction:column;
  min-width:260px;
}

.sidebar-header{
  padding:14px;
  border-bottom:1px solid var(--border);
}

.sidebar-section{
  padding:12px;
  overflow:auto;
  flex:1;
}

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

.chat-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.chat-item{
  border:1px solid var(--border);
  background: rgba(255,255,255,.9);
  border-radius:14px;
  padding:10px 10px;
  cursor:pointer;
  transition: .15s ease;
  box-shadow: 0 6px 18px rgba(15,23,42,.04);
}
.chat-item:hover{
  border-color: rgba(99,102,241,.35);
  transform: translateY(-1px);
}
.chat-item.active{
  border-color: rgba(99,102,241,.55);
  background:
    linear-gradient(180deg, rgba(99,102,241,.10), rgba(255,255,255,.85));
}

.chat-item-title{
  font-size:14px;
  line-height:1.2;
  margin-bottom:6px;
}
.chat-item-meta{
  color:var(--muted);
  font-size:12px;
}

.sidebar-footer{
  padding:12px 14px;
  border-top:1px solid var(--border);
  color:var(--muted);
  font-size:12px;
}

/* Main */
.main{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.topbar{
  height:58px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,.78);
  backdrop-filter: blur(12px);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 14px;
}

.topbar-left{
  display:flex;
  gap:10px;
  align-items:center;
  min-width:0;
}
.title-wrap{min-width:0}
.chat-title{
  font-weight:750;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.chat-subtitle{
  color:var(--muted);
  font-size:12px;
}

/* Messages */
.messages{
  padding:18px 16px 120px;
  overflow:auto;
  flex:1;
}

.msg{
  max-width: 920px;
  margin: 0 auto 14px;
  display:flex;
  gap:12px;
  align-items:flex-start;
}

/* Default layout: AI left, USER right */
.msg.ai{
  justify-content:flex-start; /* AI left */
}
.msg.user{
  justify-content:flex-end;   /* USER right */
}

/* Put avatar next to bubble with nice spacing */
.avatar{
  width:34px;height:34px;border-radius:12px;
  display:flex;align-items:center;justify-content:center;
  border:1px solid var(--border);
  background: rgba(255,255,255,.85);
  color: var(--muted);
  flex:0 0 auto;
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
}

/* Keep avatar near the edge of its side */
.msg.user .avatar{ order: 2; }
.msg.user .bubble{ order: 1; }
.msg.ai .avatar{ order: 1; }
.msg.ai .bubble{ order: 2; }

.bubble{
  border:1px solid var(--border);
  border-radius: 16px;
  padding:12px 14px;
  box-shadow: var(--shadow);
  min-width:0;
  width:fit-content;
  max-width: min(720px, 100%);
}

/* AI bubble (left) */
.msg.ai .bubble{
  background: rgba(255,255,255,.92);
}

/* USER bubble (right) */
.msg.user .bubble{
  background: linear-gradient(180deg, rgba(99,102,241,.14), rgba(99,102,241,.08));
  border-color: rgba(99,102,241,.30);
}

/* Meta + content */
.bubble .meta{
  color:var(--muted);
  font-size:12px;
  margin-bottom:8px;
}
.bubble .content{
  line-height:1.55;
  font-size:15px;
  overflow-wrap:anywhere;
}

/* Composer */
.composer{
  position:fixed;
  left:320px;
  right:0;
  bottom:0;
  padding:14px 16px 18px;
  background: linear-gradient(180deg, rgba(246,247,251,0) 0%, rgba(246,247,251,.82) 35%, rgba(246,247,251,1) 100%);
  border-top:1px solid rgba(230,234,242,.9);
}

.composer-inner{
  max-width: 920px;
  margin:0 auto;
  display:flex;
  gap:10px;
  align-items:flex-end;
}

textarea{
  width:100%;
  resize:none;
  border-radius:16px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.92);
  color:var(--text);
  padding:12px 12px;
  font-size:15px;
  outline:none;
  line-height:1.35;
  max-height: 220px;
  box-shadow: 0 10px 24px rgba(15,23,42,.06);
}
textarea:focus{
  border-color: rgba(99,102,241,.55);
  box-shadow: 0 0 0 4px rgba(99,102,241,.15), 0 10px 24px rgba(15,23,42,.08);
}

.composer-meta{
  max-width: 920px;
  margin:8px auto 0;
  color:var(--muted);
  font-size:12px;
  display:flex;
  justify-content:space-between;
}

/* Buttons */
.btn{
  border:1px solid var(--border);
  background: rgba(255,255,255,.9);
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
  transition:.15s ease;
  box-shadow: 0 10px 22px rgba(15,23,42,.06);
}
.btn:hover{
  border-color: rgba(99,102,241,.35);
  transform: translateY(-1px);
}
.btn:active{ transform: translateY(0); }

.btn-primary{
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-color: rgba(79,70,229,.65);
  color:white;
}
.btn-primary:hover{ filter: brightness(1.03); }

.w-100{width:100%}

.link{
  background:none;
  border:none;
  padding:0;
  color:var(--muted);
  cursor:pointer;
  text-decoration:underline;
}
.link:hover{color:var(--text)}
.link.danger{color: var(--danger)}

.icon-btn{
  border:1px solid var(--border);
  background:rgba(255,255,255,.9);
  color:var(--text);
  width:40px;height:40px;
  border-radius:14px;
  cursor:pointer;
  box-shadow: 0 10px 22px rgba(15,23,42,.06);
}

/* Code blocks */
pre{
  position:relative;
  border-radius:6px;
  border:1px solid #e7eaf3;
  overflow:auto;
  background: #0b1220; /* keep readable dark code */
  box-shadow: 0 10px 26px rgba(15,23,42,.10);
}

/* Jaśniejsza czcionka w bloku kodu */
pre code{
  color:#eaf2ff;
  font-family:var(--mono);
  font-size:13px;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
}

/* Jeśli highlight.js nadpisuje kolory tokenów, to ustaw bazowy kolor */
.hljs{
  color:#eaf2ff;
}

code, pre code{
  font-family:var(--mono);
  font-size:13px;
}

.copy-btn{
  position:absolute;
  top:10px;
  right:10px;
  padding:6px 10px;
  font-size:12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.10);
  color: #e5e7eb;
  cursor:pointer;
}

/* Inline code */
:not(pre) > code{
  color:#0f172a;
  background: rgba(99,102,241,.10);
  border:1px solid rgba(99,102,241,.18);
  padding:2px 6px;
  border-radius:10px;
}

/* Mobile */
.mobile-only{display:none}

@media (max-width: 900px){
  .app{grid-template-columns: 1fr}
  .sidebar{
    position:fixed;
    top:0; bottom:0; left:0;
    width: 86%;
    max-width: 340px;
    transform: translateX(-105%);
    transition: .2s ease;
    z-index:20;
    box-shadow: var(--shadow);
  }
  .sidebar.open{transform:translateX(0)}
  .composer{left:0}
  .mobile-only{display:inline-flex}
}