/* ========== Calm, Accessible UI ========== */
:root{
  /* Light (default) */
  --bg: #f7f9fb;
  --bg-accent: #eef3f7;
  --card: #ffffff;
  --border: #e5ebf0;
  --text: #1f2937;
  --muted: #6b7280;
  --muted-2: #9aa3ae;

  --accent: #6ea8fe;    /* calm blue */
  --accent-weak: #e8f1ff;
  --you: #8ed1c6;       /* mint */
  --you-weak: #e9f7f4;

  --shadow: 0 12px 30px rgba(16,24,40,.06);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;

  --focus-ring: 0 0 0 4px rgba(110,168,254,.25);
}

/* Dark theme */
[data-theme="dark"]{
  --bg: #0f1720;
  --bg-accent: #0e1b28;
  --card: #111827cc;       /* glassy card */
  --border: rgba(255,255,255,.08);
  --text: #e5e7eb;
  --muted: #a3a9b3;
  --muted-2: #94a3b8;

  --accent: #7ab0ff;
  --accent-weak: rgba(122,176,255,.08);
  --you: #9adacc;
  --you-weak: rgba(154,218,204,.10);

  --shadow: 0 18px 40px rgba(0,0,0,.45);
}

/* Base */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans";
  color:var(--text);
  background:
    radial-gradient(1200px 700px at 10% -10%, var(--bg-accent), transparent 60%),
    radial-gradient(1200px 700px at 90% 0%, var(--bg-accent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

/* Layout */
.page{
  min-height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.chat-card{
  width:100%;
  max-width: 920px;
  height: 80vh;
  min-height:560px;
  display:flex;
  flex-direction:column;
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  background: var(--card);
  border:1px solid var(--border);
  overflow:hidden;
  box-shadow: var(--shadow);
}

/* Header */
.chat-header{
  display:flex;align-items:center;gap:14px;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--card) 92%, transparent));
}
.avatar{position:relative;width:44px;height:44px}
.avatar img{
  width:44px;height:44px;border-radius:50%;
  border:2px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.status-dot{
  position:absolute;right:-2px;bottom:-2px;
  width:12px;height:12px;border-radius:50%;
  background:#16a34a;border:2px solid var(--card);
}
.hdr-text .title{font-weight:700;letter-spacing:.2px}
.hdr-text .subtitle{color:var(--muted);font-size:12px;margin-top:-2px}
.hdr-actions{display:flex;gap:8px}
.btn-icon{
  width:36px;height:36px;border-radius:10px;border:1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, white 8%);
  color:inherit;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;
  transition: box-shadow .15s, transform .05s;
}
.btn-icon:hover{box-shadow: var(--focus-ring)}
.btn-icon:active{transform: translateY(1px)}

/* Body */
.chat-body{
  flex:1;overflow:auto;padding:18px;
  display:flex;flex-direction:column;gap:14px;scroll-behavior:smooth;
}

/* Empty state */
.empty-state{
  margin:auto;text-align:center;max-width:520px;color:var(--muted);
}
.empty-state.hidden{display:none}
.empty-emoji{font-size:44px;margin-bottom:8px;opacity:.9}
.empty-title{font-size:18px;color:var(--text);margin-bottom:6px;font-weight:600}
.empty-hint{font-size:14px;margin-bottom:12px}
.empty-suggestions{display:flex;gap:8px;flex-wrap:wrap;justify-content:center}
.chip{
  border:1px solid var(--border);background:var(--accent-weak);color:#1e3a8a;
  padding:8px 10px;border-radius:999px;font-size:13px;cursor:pointer;
}
[data-theme="dark"] .chip{color:#cfe1ff}

/* Messages */
.msg{display:flex;gap:10px;align-items:flex-end}
.msg.user{justify-content:flex-end}
.msg-avatar img{
  width:36px;height:36px;border-radius:50%;
  border:1.5px solid var(--border);
}
.msg-bubble{
  max-width: 72%;
  padding:12px 14px;border-radius:16px;position:relative;line-height:1.5;word-wrap:anywhere;
  background: color-mix(in srgb, var(--card) 94%, var(--bg-accent) 6%);
  border:1px solid var(--border);
}
.msg.user .msg-bubble{
  background: var(--you-weak);
  border-color: color-mix(in srgb, var(--you) 38%, var(--border));
}
.msg.bot .msg-bubble{
  background: var(--accent-weak);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
}
.msg-text{font-size:15px}
.msg-time{margin-top:6px;font-size:11px;color:var(--muted-2)}

/* Typing dots */
.typing{display:flex;gap:6px;align-items:center;padding:0 18px 10px}
.typing.hidden{display:none}
.typing span{
  display:inline-block;width:8px;height:8px;border-radius:50%;background: var(--muted);
  opacity:.65;animation: bounce 1.4s infinite ease-in-out;
}
.typing span:nth-child(2){animation-delay:.15s}
.typing span:nth-child(3){animation-delay:.3s}
@keyframes bounce{0%,80%,100%{transform:scale(0)} 40%{transform:scale(1)}}

/* Footer */
.chat-footer{
  padding:12px;border-top:1px solid var(--border);
  background: color-mix(in srgb, var(--card) 94%, transparent);
}
.input{
  flex:1;resize:none;background: #ffffff; /* light */
  border:1px solid var(--border);color:var(--text);
  padding:12px 14px;border-radius: var(--radius-md);
  outline:none;height:48px;transition:border .2s, box-shadow .2s, background .2s;
}
[data-theme="dark"] .input{background: color-mix(in srgb, var(--card) 88%, #000 12%)}
.input:focus{box-shadow: var(--focus-ring);border-color: color-mix(in srgb, var(--accent) 60%, var(--border))}
.send-btn{
  margin-left:10px;width:48px;height:48px;border-radius: var(--radius-sm);
  display:inline-flex;align-items:center;justify-content:center;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 80%, #3b82f6));
  color:white;border:none;outline:none;cursor:pointer;transition: transform .05s, filter .2s, box-shadow .15s;
  box-shadow: 0 6px 16px rgba(110,168,254,.35);
}
.send-btn:hover{box-shadow: 0 8px 22px rgba(110,168,254,.45)}
.send-btn:active{ transform: translateY(1px) }
.send-btn:disabled{ filter: grayscale(.4) brightness(.9); cursor:not-allowed }

/* Scrollbar (subtle) */
.chat-body::-webkit-scrollbar{width:10px}
.chat-body::-webkit-scrollbar-thumb{
  background: color-mix(in srgb, var(--muted) 30%, transparent);
  border-radius:999px;border:2px solid transparent;background-clip:padding-box;
}
.chat-body{-ms-overflow-style:none;scrollbar-color: color-mix(in srgb, var(--muted) 30%, transparent) transparent}

/* Mobile tweaks */
@media (max-width: 576px){
  .chat-card{height: 90
  }
}