:root {
  --bg-main: #061a33;
  --bg-panel: #0b2545;
  --bg-card: #102f57;
  --bg-input: #061427;
  --text-main: #ffffff;
  --text-muted: #b6c7dc;
  --accent: #38bdf8;
  --danger: #ef4444;
  --success: #22c55e;
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg-main); color: var(--text-main); }
button, input { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 14px; padding: 10px 14px; background: var(--accent); color: #03111f; font-weight: 700; }
button:disabled { opacity: .65; cursor: not-allowed; }
.ghost { background: rgba(255,255,255,.08); color: var(--text-main); }
.login-page { min-height: 100%; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #123b6a, var(--bg-main)); }
.login-card { width: min(460px, 100%); background: rgba(11,37,69,.92); padding: 28px; border: 1px solid rgba(255,255,255,.12); border-radius: 28px; box-shadow: 0 24px 80px rgba(0,0,0,.36); }
.login-card h1 { margin: 0 0 8px; }
.login-card p, .login-card small { color: var(--text-muted); }
.login-card label { display: grid; gap: 8px; margin: 16px 0; color: var(--text-muted); }
.login-card input, .composer input { width: 100%; border: 1px solid rgba(255,255,255,.12); background: var(--bg-input); color: var(--text-main); border-radius: 16px; padding: 13px 15px; outline: none; }
.login-card button { width: 100%; margin-top: 8px; }
.error, .success { padding: 12px 14px; border-radius: 16px; margin: 12px 0; }
.error { background: rgba(239,68,68,.16); color: #fecaca; border: 1px solid rgba(239,68,68,.25); }
.success { background: rgba(34,197,94,.16); color: #bbf7d0; border: 1px solid rgba(34,197,94,.25); }
.inline { margin: 8px 16px; }
.chat-shell { height: 100%; display: grid; grid-template-columns: 290px 1fr; background: var(--bg-main); }
.side-panel { background: var(--bg-panel); border-right: 1px solid rgba(255,255,255,.1); padding: 22px; }
.side-panel h2 { margin-top: 0; }
.side-panel p, .bubble-meta { color: var(--text-muted); }
.chat-panel { min-width: 0; height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.chat-header { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: rgba(11,37,69,.85); border-bottom: 1px solid rgba(255,255,255,.1); }
.chat-header span { margin-left: auto; color: var(--text-muted); font-size: 14px; }
.icon { width: 42px; height: 42px; padding: 0; display: inline-grid; place-items: center; background: rgba(255,255,255,.09); color: var(--text-main); border-radius: 14px; flex: 0 0 auto; }
.messages { overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.bubble { width: min(680px, 86%); background: var(--bg-card); border: 1px solid rgba(255,255,255,.1); padding: 13px 15px; border-radius: 20px 20px 20px 6px; box-shadow: 0 8px 30px rgba(0,0,0,.18); }
.bubble.mine { align-self: flex-end; background: #123f72; border-radius: 20px 20px 6px 20px; }
.bubble-meta { font-size: 12px; margin-bottom: 6px; }
.bubble-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--text-muted); font-size: 12px; }
.bubble-actions button { padding: 5px 8px; background: rgba(255,255,255,.08); color: var(--text-muted); font-weight: 500; border-radius: 10px; }
.file-card { width: 100%; text-align: left; background: rgba(255,255,255,.09); color: var(--text-main); }
.upload-progress { padding: 8px 16px; color: var(--text-muted); }
.composer { position: relative; display: flex; gap: 8px; align-items: center; padding: 12px; background: rgba(11,37,69,.96); border-top: 1px solid rgba(255,255,255,.1); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.attach { cursor: pointer; }
.send { width: 46px; height: 42px; padding: 0; }
.emoji-box { position: absolute; bottom: 68px; left: 112px; width: min(310px, calc(100vw - 24px)); display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 10px; background: #081d38; border: 1px solid rgba(255,255,255,.16); border-radius: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.emoji-box button { background: rgba(255,255,255,.08); color: white; padding: 8px; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,.72); z-index: 20; }
.modal-body { position: relative; max-width: min(1100px, 96vw); max-height: 92vh; background: var(--bg-panel); padding: 18px; border-radius: 24px; overflow: auto; }
.modal-body img, .modal-body video { max-width: 100%; max-height: 76vh; border-radius: 18px; }
.modal-body audio { width: min(620px, 80vw); }
.close { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; padding: 0; border-radius: 50%; background: rgba(255,255,255,.12); color: white; font-size: 24px; }
@media (max-width: 860px) {
  .chat-shell { grid-template-columns: 1fr; height: 100dvh; }
  .side-panel { display: none; }
  .chat-header { min-height: 56px; }
  .messages { padding: 10px; }
  .bubble { width: 92%; }
  .composer { gap: 6px; }
  .composer input { padding: 12px; }
  .icon { width: 40px; height: 40px; }
}
.fingerprint { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }

.error-details { white-space: pre-wrap; word-break: break-word; font-size: 12px; overflow:auto; max-height: 180px; }

.new-chat { display: grid; gap: 8px; margin: 22px 0; padding: 14px; border-radius: 18px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); }
.new-chat label { color: var(--text-main); font-weight: 700; }
.new-chat small { color: var(--text-muted); line-height: 1.35; }
.new-chat-row { display: flex; gap: 8px; }
.new-chat-row input { min-width: 0; width: 100%; border: 1px solid rgba(255,255,255,.12); background: var(--bg-input); color: var(--text-main); border-radius: 14px; padding: 11px 12px; outline: none; }
.new-chat-row button { width: 44px; height: 42px; padding: 0; }
.chat-list { display: grid; gap: 8px; margin: 12px 0 20px; }
.chat-list-item { display: grid; gap: 4px; width: 100%; text-align: left; background: rgba(255,255,255,.06); color: var(--text-main); border: 1px solid rgba(255,255,255,.1); }
.chat-list-item.active { background: rgba(56,189,248,.22); border-color: rgba(56,189,248,.45); }
.chat-list-item small, .empty-side { color: var(--text-muted); font-size: 13px; }
.empty-side { padding: 12px; border: 1px dashed rgba(255,255,255,.14); border-radius: 16px; }
.empty-chat { margin: auto; max-width: 520px; text-align: center; color: var(--text-muted); padding: 28px; border: 1px dashed rgba(255,255,255,.14); border-radius: 24px; }
.empty-chat h2 { color: var(--text-main); margin: 0 0 8px; }
.disabled { opacity: .5; pointer-events: none; }
.voice-panel { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: rgba(11,37,69,.98); border-top: 1px solid rgba(255,255,255,.1); color: var(--text-main); flex-wrap: wrap; }
.voice-panel audio { width: min(380px, 52vw); height: 36px; }
.record-dot { width: 12px; height: 12px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 rgba(239,68,68,.55); animation: pulse 1.2s infinite; }
.wave { display: flex; align-items: center; gap: 3px; height: 32px; padding: 0 6px; }
.wave i { display: block; width: 4px; height: 10px; border-radius: 99px; background: rgba(255,255,255,.65); animation: wave 950ms ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: 80ms; height: 17px; }
.wave i:nth-child(3) { animation-delay: 160ms; height: 25px; }
.wave i:nth-child(4) { animation-delay: 240ms; height: 14px; }
.wave i:nth-child(5) { animation-delay: 320ms; height: 22px; }
.wave i:nth-child(6) { animation-delay: 400ms; height: 12px; }
.wave i:nth-child(7) { animation-delay: 480ms; height: 20px; }
.wave i:nth-child(8) { animation-delay: 560ms; height: 16px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.55); } 70% { box-shadow: 0 0 0 12px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
@keyframes wave { 0%, 100% { transform: scaleY(.55); } 50% { transform: scaleY(1.15); } }
.file-card.voice-card { display: flex; align-items: center; gap: 10px; }
.sidebar-backdrop { display: none; }
@media (max-width: 860px) {
  .side-panel { position: fixed; display: block; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 31; transform: translateX(-105%); transition: transform .18s ease; box-shadow: 24px 0 70px rgba(0,0,0,.4); }
  .side-panel.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.42); border-radius: 0; padding: 0; }
  .voice-panel { gap: 8px; }
  .voice-panel audio { width: 100%; }
  .emoji-box { left: 12px; bottom: 72px; }
}
