/* ============================================================
   Licentium MiCA Assistant — NEW design, OLD layout
   Layout rules copied 1:1 from backup; only colours/visuals changed.
   ============================================================ */

:root{
  --bg:#f5f3ff;
  --ink:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --line-soft:#f1f5f9;
  --brand:#3730a3;
  --brand-600:#312e81;
  --brand-100:#ede9fe;
  --ok:#16a34a;
  --err:#ef4444;
  --card:#ffffff;
  --shadow:0 10px 30px rgba(17,24,39,.06);
  --tag-bg:#ede9fe;
  --tag-border:#c4b5fd;
  --tag-text:#5b21b6;
}

/* ---------- RESET (old) ---------- */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; font-family:Inter,system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  background:var(--bg); color:var(--ink); display:flex; flex-direction:column;
}

/* ---------- HEADER (old layout, new colours) ---------- */
header{
  padding:16px 22px; display:flex; justify-content:space-between; align-items:center;
  border-bottom:1px solid var(--line); background:#fff; position:sticky; top:0; z-index:5;
}
header h1{margin:0; font-size:20px; font-weight:700; letter-spacing:.2px; color:var(--brand)}
.badge{font-size:10px; padding:4px 10px; border-radius:999px; border:1.5px solid var(--brand); background:var(--brand-100); color:var(--brand); font-weight:600}

/* ---------- CARD / WRAP (old layout, 1:1) ---------- */
.wrap{flex:1; display:flex; justify-content:center; padding:24px}
.chat{
  width:100%; max-width:920px; background:var(--card); border-radius:16px; padding:18px;
  border:1px solid var(--line); display:grid; grid-template-rows:auto 1fr auto auto; gap:12px; box-shadow:var(--shadow);
}

/* ---------- MESSAGES (old layout, 1:1) ---------- */
.messages{
  overflow-y:auto; padding:4px 2px 12px; display:grid; gap:10px; align-content:start; font-size:15px; line-height:1.55;
  background:#fff; border-radius:12px;
}

/* ---------- MSG ROWS & AVATARS (new) ---------- */
.msg-row{
  display:flex; align-items:flex-end; gap:10px;
}
.msg-row.msg-me{
  justify-self:end; flex-direction:row-reverse;
}
.msg-row.msg-greeting{
  /* full width, no avatar */
}

.avatar{
  width:36px; height:36px; border-radius:50%; background:var(--brand); color:#fff;
  font-size:14px; font-weight:700; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; align-self:flex-start;
}

/* ---------- BUBBLES (new design) ---------- */
.bubble{word-wrap:break-word; overflow-wrap:break-word;}

.bubble-greeting{
  background:var(--brand-100); border-radius:14px; padding:14px 18px;
  font-size:15px; line-height:1.6; border:1px solid var(--line);
  box-shadow:0 1px 0 rgba(17,24,39,.03);
}
.bubble-greeting strong{color:var(--brand)}

.bubble-me{
  background:var(--brand); color:#fff;
  border-radius:18px 18px 4px 18px; padding:12px 16px;
  font-size:15px; line-height:1.6; max-width:88%;
}

.bubble-bot{
  background:#fff; border:1px solid var(--line);
  border-radius:4px 18px 18px 18px; padding:14px 16px;
  font-size:15px; line-height:1.6; flex:1; min-width:0;
  box-shadow:0 1px 0 rgba(17,24,39,.03);
}
.bubble-bot p{margin-bottom:10px}
.bubble-bot p:last-of-type{margin-bottom:0}
.bubble-bot ul{margin:6px 0 10px 18px}
.bubble-bot li{margin:4px 0}
.bubble-bot strong{font-weight:600}

/* ---------- META ROW (time · count · badge · copy) ---------- */
.meta-row{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; margin:0 0 6px; font-size:12px; color:var(--muted);
}
.meta-row > div:first-child{
  display:flex; flex-direction:column; align-items:flex-start; gap:2px;
}
.meta-time{opacity:.9}
.meta-count{margin-left:0; color:var(--muted); font-size:12px; opacity:.9}
.meta-count strong{color:var(--ink); font-weight:700}
.meta-right{display:flex; align-items:center; gap:6px}

.badge-mode{
  display:inline-block; padding:2px 8px; border-radius:999px;
  background:var(--brand-100); color:var(--brand); border:1px solid var(--tag-border);
  font-size:11px; font-weight:700; letter-spacing:.02em;
}
.copy-btn{
  border:1px solid var(--line); background:#fff; color:var(--ink);
  padding:6px 10px; border-radius:8px; font-size:12px; cursor:pointer;
  font-family:inherit;
}
.copy-btn:hover{background:var(--brand-100); border-color:var(--tag-border)}

/* ---------- SOURCE TAGS (new) ---------- */
.source-tags{
  display:flex; flex-wrap:wrap; gap:6px;
  margin-top:12px; padding-top:10px; border-top:1px solid var(--line);
}
.source-tag{
  display:inline-flex; align-items:center; gap:5px;
  background:var(--tag-bg); border:1px solid var(--tag-border); color:var(--tag-text);
  font-size:12px; font-weight:500; padding:4px 10px; border-radius:6px;
  text-decoration:none; cursor:default;
}
.source-icon{width:12px; height:12px; flex-shrink:0}

/* ---------- ANSWER ---------- */
.answer{white-space:pre-wrap}

/* ---------- DETAIL ---------- */
.detail{
  margin-top:8px; padding-top:6px;
  border-top:1px dashed rgba(148,163,253,.25);
  font-size:13px; line-height:1.55;
}
.detail ul{margin:6px 0 0; padding-left:18px}
.detail li{margin:4px 0}

/* ---------- HINT (old) ---------- */
.hint{font-size:12px; color:var(--muted); padding:0 2px}

/* ---------- SOURCES section (old, hidden) ---------- */
.sources{
  background:#fff; border:1px solid var(--line); border-radius:12px; padding:12px 14px;
}
.sources h3{margin:0 0 8px; font-size:13px; color:var(--ink); font-weight:700}
.sources ul{margin:0; padding-left:18px}
.sources li{margin:6px 0}
.sources a{color:var(--brand); text-decoration:none}
.sources a:hover{text-decoration:underline}

/* ---------- FORM (old layout, new colours) ---------- */
form{display:flex; gap:10px; position:sticky; bottom:0; background:#fff; padding-top:2px}
input[type="text"]{
  flex:1; padding:12px 16px; border-radius:999px; border:1px solid var(--line); background:#fff; color:var(--ink); font-size:15px; outline:none;
  font-family:inherit;
}
input[type="text"]:focus{border-color:#a5b4fc; box-shadow:0 0 0 3px rgba(99,102,241,.12)}
input::placeholder{color:#9aa1ac}
#send-btn{
  padding:12px 18px; border-radius:999px; border:0; background:var(--brand); color:#fff; font-size:14px; font-weight:700; cursor:pointer;
  box-shadow:0 2px 0 rgba(17,24,39,.06); transition:background .15s ease, transform .02s ease;
  font-family:inherit;
}
#send-btn:hover{background:var(--brand-600)}
#send-btn:active{transform:translateY(1px)}
#send-btn:disabled{opacity:.6; cursor:default}

/* ---------- LOADER (old) ---------- */
.loader{
  display:inline-block; width:1.05em; height:1.05em; border:2px solid var(--brand);
  border-top-color:transparent; border-radius:50%; animation:spin .7s linear infinite; vertical-align:-2px; margin-right:6px;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------- DISCLAIMER (old) ---------- */
.disclaimer{
  margin-top:10px; padding-top:10px;
  border-top:1px solid var(--line-soft);
  font-size:11px; line-height:1.45;
  color:var(--muted); white-space:normal;
}

/* ---------- RESPONSIVE (old) ---------- */
@media (max-width:520px){.bubble-me,.bubble-bot{max-width:96%}.wrap{padding:14px}}
