:root {
  --bg: #04040a;
  --surface: rgba(255,255,255,0.04);
  --surface-2: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.08);
  --border-glow: rgba(120,80,255,0.28);
  --text: #f0f0ff;
  --muted: rgba(240,240,255,0.45);
  --accent-1: #7c4dff;
  --accent-2: #2979ff;
  --accent-3: #00e5ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

.bg-blur {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  pointer-events: none;
}
.blur-1 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, var(--accent-1), transparent 70%);
  top: -120px; left: -80px;
}
.blur-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, var(--accent-3), transparent 70%);
  right: -140px; bottom: -140px;
}

/* ─── Expired ────────────────────────────────────────────────────────────── */
.expired-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(4,4,10,0.96);
  backdrop-filter: blur(16px);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.expired-overlay.hidden { display: none; }
.expired-box { text-align: center; max-width: 400px; }
.expired-box h2 { font-size: 32px; margin: 12px 0; color: #ff4444; }
.expired-box p { color: var(--muted); font-size: 15px; line-height: 1.6; }

/* ─── Shell ──────────────────────────────────────────────────────────────── */
.chat-shell {
  position: relative; z-index: 1;
  max-width: 980px; height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto auto;
  gap: 14px;
  padding: 18px;
  overflow-y: auto;
}

.chat-header,
.deal-card,
.sponsor-slot,
.chat-inputbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(14px);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px 20px;
}

.eyebrow {
  color: #a78bff; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.12em;
  margin-bottom: 4px;
}
h1 { margin: 0; font-size: 28px; line-height: 1; }
.meta-row {
  display: flex; gap: 10px; align-items: center;
  margin-top: 10px; color: var(--muted); font-size: 14px;
}
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-3); }
.timer-box { min-width: 140px; text-align: right; }
.timer-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.timer-value { font-size: 28px; font-weight: 700; color: #a78bff; }

.deal-card {
  display: flex; justify-content: space-between;
  gap: 14px; align-items: center; padding: 16px 18px;
}
.section-kicker { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.deal-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.deal-sub { color: var(--muted); font-size: 14px; }
.deal-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  display: inline-flex; align-items: center;
  padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  font-size: 12px; color: var(--muted);
}
.badge-live { color: #00e5a0; border-color: rgba(0,229,160,0.28); }

/* ─── PGP ────────────────────────────────────────────────────────────────── */
.pgp-section { display: block !important; }
.pgp-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.pgp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.pgp-field:last-child { grid-column: 1 / -1; }
.pgp-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.pgp-hint { color: rgba(167,139,255,0.7); font-size: 11px; }
.pgp-section textarea,
.pgp-section input[type="password"] {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 12px;
  color: var(--text); font-size: 13px;
  font-family: monospace; resize: vertical; outline: none;
}
.pgp-section textarea { min-height: 90px; }
.pgp-section input[type="password"] { margin-top: 8px; font-family: inherit; }
.pgp-actions { display: flex; align-items: center; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.pgp-toggle { display: flex; align-items: center; gap: 8px; color: rgba(240,240,255,0.75); font-size: 14px; cursor: pointer; }
.btn-secondary {
  border: 1px solid var(--border-glow);
  background: rgba(124,77,255,0.12);
  border-radius: 12px; padding: 10px 16px;
  color: #a78bff; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary:hover { background: rgba(124,77,255,0.22); }

/* ─── Sponsor ────────────────────────────────────────────────────────────── */
.sponsor-slot { padding: 16px 18px; border-color: var(--border-glow); }
.hidden { display: none !important; }
.sponsor-top { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 8px; }
.sponsor-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.sponsor-text { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.sponsor-button {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; text-decoration: none; color: white;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer;
}

/* ─── Messages ───────────────────────────────────────────────────────────── */
.chat-messages {
  min-height: 0; overflow: auto;
  display: flex; flex-direction: column;
  gap: 10px; padding-right: 4px;
}

.message {
  max-width: 72%; padding: 12px 14px;
  border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface-2);
}
.message.me {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(124,77,255,0.18), rgba(41,121,255,0.14));
  border-color: rgba(124,77,255,0.25);
}
.message.system {
  align-self: center; max-width: 100%;
  color: var(--muted); font-size: 13px; padding: 10px 12px;
}
.message-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.message-body { line-height: 1.45; word-break: break-word; }

/* ─── Fil i meddelande ───────────────────────────────────────────────────── */
.message-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 10px;
  margin-top: 6px;
  cursor: pointer;
  display: block;
  transition: opacity 0.2s;
}
.message-image:hover { opacity: 0.85; }

.message-file {
  display: flex; align-items: center; gap: 10px;
  margin-top: 6px; padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px; text-decoration: none;
  color: #a78bff; font-size: 13px;
  transition: background 0.2s;
}
.message-file:hover { background: rgba(124,77,255,0.12); }
.message-file-icon { font-size: 20px; }
.message-file-name { flex: 1; word-break: break-all; }
.message-file-size { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ─── Fil-förhandsvisning ────────────────────────────────────────────────── */
.file-preview {
  background: var(--surface);
  border: 1px solid var(--border-glow);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.file-preview-img {
  max-height: 60px; max-width: 80px;
  border-radius: 8px; object-fit: cover;
}
.file-preview-info { flex: 1; }
.file-preview-name { font-size: 13px; font-weight: 600; }
.file-preview-size { font-size: 12px; color: var(--muted); margin-top: 2px; }
.file-cancel {
  border: none; background: rgba(255,68,68,0.12);
  color: #ff6b6b; border-radius: 8px;
  padding: 6px 10px; font-size: 12px; cursor: pointer;
}

/* ─── Upload progress ────────────────────────────────────────────────────── */
.upload-progress {
  height: 3px; background: var(--border);
  border-radius: 999px; overflow: hidden;
  margin-top: 4px;
}
.upload-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  border-radius: 999px;
  transition: width 0.3s;
}

/* ─── Input ──────────────────────────────────────────────────────────────── */
.chat-inputbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px; padding: 12px;
}
.chat-inputbar input[type="text"] {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
  color: var(--text); outline: none; font-size: 15px;
}
.chat-inputbar input[type="text"]::placeholder { color: var(--muted); }
.chat-inputbar button[type="submit"] {
  border: none; color: white;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-radius: 12px; padding: 12px 20px;
  font-weight: 700; cursor: pointer; white-space: nowrap;
}

/* Fil-knapp */
.file-btn {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer;
  font-size: 20px; line-height: 1;
  transition: background 0.2s; align-self: center;
}
.file-btn:hover { background: rgba(124,77,255,0.15); border-color: var(--border-glow); }
.file-btn input[type="file"] { display: none; }

/* ─── Lightbox ───────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(4,4,10,0.92);
  backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 12px; }

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  body { overflow: auto; }
  .chat-shell { padding: 12px; gap: 10px; height: auto; min-height: 100vh; }
  .chat-header, .deal-card { display: block; }
  .timer-box { margin-top: 14px; text-align: left; }
  .pgp-grid { grid-template-columns: 1fr; }
  .pgp-field:last-child { grid-column: auto; }
  .message { max-width: 88%; }
}
