@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg-deep: #0b0906;
  --bg-panel: #161310;
  --bg-panel-2: #1f1a15;
  --bg-input: #0e0c09;
  --border-subtle: #3a2f21;
  --gold: #d4af37;
  --gold-bright: #f4d67a;
  --gold-dim: #8a7128;
  --text-main: #efe7d8;
  --text-muted: #a89a80;
  --danger: #b3453a;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-main);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(212, 175, 55, 0.05), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(212, 175, 55, 0.04), transparent 40%);
}

::selection { background: var(--gold-dim); color: #000; }

.auth-box {
  max-width: 380px;
  margin: 100px auto;
  padding: 36px 32px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(212,175,55,0.06), 0 20px 60px rgba(0,0,0,0.5);
}
.auth-box h1 {
  margin-top: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 32px;
  color: var(--gold-bright);
  letter-spacing: 0.5px;
}
.auth-box input {
  display: block;
  width: 100%;
  padding: 11px 12px;
  margin: 10px 0;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-body);
}
.auth-box input:focus { outline: none; border-color: var(--gold-dim); }
.auth-box button {
  width: 100%;
  padding: 11px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--gold) 0%, #b8912c 100%);
  color: #16130d;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  letter-spacing: 0.3px;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.auth-box button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.error { color: #e07a6f; min-height: 20px; font-size: 13px; }
.hint { font-size: 12px; color: var(--text-muted); }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); text-decoration: underline; }

.chat-layout { display: flex; height: 100vh; }
.sidebar {
  width: 250px;
  background: var(--bg-panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  position: relative;
  padding-bottom: 64px;
}

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tab-btn {
  flex: 1;
  padding: 8px 4px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}
.tab-btn.active { background: var(--gold-dim); color: #16130d; border-color: var(--gold); font-weight: 600; }
.tab-btn:hover:not(.active) { border-color: var(--gold-dim); color: var(--text-main); }
.tab-panel { display: none; flex: 1; overflow-y: auto; }
.tab-panel.active { display: block; }

.add-friend-form { display: flex; gap: 6px; margin-bottom: 8px; }
.add-friend-form input {
  flex: 1;
  padding: 7px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-main);
  text-transform: uppercase;
  font-size: 12px;
}
.add-friend-form button {
  padding: 7px 12px;
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  background: var(--gold);
  color: #16130d;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
}

.friend-code-display {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--gold-bright);
  background: var(--bg-input);
  border: 1px dashed var(--gold-dim);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  margin: 6px 0;
}

#userList { list-style: none; padding: 0; margin: 0; overflow-y: auto; }
.user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  position: relative;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.user-item .avatar-wrap::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5a4d38;
  border: 2px solid var(--bg-panel);
}
.user-item.online .avatar-wrap::after { background: #6fae5a; box-shadow: 0 0 6px #6fae5a; }
.user-item:hover { background: var(--bg-panel-2); transform: translateX(2px); }
.user-item.active { background: var(--gold-dim); color: #16130d; font-weight: 600; }

/* ---- Corner profile bar ---- */
.profile-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 58px;
  background: var(--bg-panel-2);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-top: 1px solid var(--border-subtle);
}
.profile-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #8a7128);
  color: #16130d;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid var(--gold-dim);
}
.profile-name {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gear-btn {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 18px; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.gear-btn:hover { background: var(--bg-deep); color: var(--gold-bright); transform: rotate(45deg); }

/* ---- Settings overlay ---- */
.settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.settings-overlay.hidden { display: none; }
.settings-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  width: 90%; max-width: 420px; max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 0 1px rgba(212,175,55,0.08), 0 20px 60px rgba(0,0,0,0.6);
}
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.settings-header h3 { font-family: var(--font-display); color: var(--gold-bright); font-size: 24px; margin: 0; }
.close-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer; width: 28px; height: 28px; border-radius: 50%;
  transition: all 0.15s ease;
}
.close-btn:hover { background: var(--bg-panel-2); color: var(--gold-bright); }
.settings-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border-subtle); }
.settings-section h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); }
.settings-section select, #emailForm input {
  width: 100%; padding: 8px; border-radius: 6px;
  border: 1px solid var(--border-subtle); background: var(--bg-input); color: var(--text-main);
}
#emailForm { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
#emailForm button, .settings-section button {
  padding: 8px; border: 1px solid var(--gold-dim); border-radius: 6px;
  background: var(--gold); color: #16130d; cursor: pointer; font-weight: 600;
}
.logout-btn {
  width: 100%; padding: 10px; border: 1px solid #7a2e26; border-radius: 6px;
  background: var(--danger); color: #fff0ee; cursor: pointer; font-weight: 600;
}
.logout-btn:hover { filter: brightness(1.1); }
#avatarInput { font-size: 12px; color: var(--text-muted); }

/* ---- Font customization ---- */
body[data-font="serif"] .msg, body[data-font="serif"] .profile-name { font-family: Georgia, 'Times New Roman', serif; }
body[data-font="mono"] .msg, body[data-font="mono"] .profile-name { font-family: 'Courier New', monospace; }
body[data-font="rounded"] .msg, body[data-font="rounded"] .profile-name { font-family: 'Segoe UI Rounded', Verdana, sans-serif; }
body[data-font="cursive"] .msg, body[data-font="cursive"] .profile-name { font-family: 'Comic Sans MS', cursive; }

/* ---- Main chat area ---- */
.chat-main { flex: 1; display: flex; flex-direction: column; padding: 18px; }
.compose-wrap { position: relative; }
.chat-main h2 {
  font-family: var(--font-display);
  color: var(--gold-bright);
  font-weight: 600;
  margin: 0 0 12px;
}
.messages {
  flex: 1; overflow-y: auto; padding: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  margin-bottom: 12px;
  display: flex; flex-direction: column;
}
.msg {
  max-width: 100%; width: fit-content; padding: 9px 13px; border-radius: 14px;
  margin: 2px 0; word-wrap: break-word; line-height: 1.4;
}
.msg.mine {
  background: linear-gradient(135deg, var(--gold-dim), #6b571e);
  color: #fbf3d9;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.msg.theirs {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-image { max-width: 240px; max-height: 240px; border-radius: 8px; display: block; }

.msg-form { display: flex; gap: 8px; align-items: center; }
.msg-form input[type="text"] {
  flex: 1; padding: 11px; border-radius: 8px;
  border: 1px solid var(--border-subtle); background: var(--bg-input); color: var(--text-main);
}
.msg-form input[type="text"]:focus { outline: none; border-color: var(--gold-dim); }
.msg-form button[type="submit"] {
  padding: 10px 22px; border: 1px solid var(--gold-dim); border-radius: 8px;
  background: linear-gradient(180deg, var(--gold), #b8912c); color: #16130d; cursor: pointer; font-weight: 600;
}
.msg-form button:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn {
  background: var(--bg-panel-2); border: 1px solid var(--border-subtle);
  color: var(--text-main); border-radius: 8px; padding: 0 14px; height: 42px;
  cursor: pointer; font-size: 14px; transition: all 0.15s ease;
}
.icon-btn:hover { border-color: var(--gold-dim); color: var(--gold-bright); }

/* ---- GIF picker ---- */
.gif-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 10px;
  width: 420px;
  max-width: 90vw;
  height: 460px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 0 0 1px rgba(212,175,55,0.08), 0 20px 60px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.gif-picker.hidden { display: none; }
.gif-picker-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-shrink: 0; }
.gif-tab-btn { background: var(--bg-panel-2); border: 1px solid var(--border-subtle); color: var(--text-muted); padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.gif-tab-btn.active { background: var(--gold-dim); color: #16130d; }
#gifSearchInput { width: 100%; padding: 8px 10px; margin-bottom: 10px; border-radius: 6px; border: 1px solid var(--border-subtle); background: var(--bg-input); color: var(--text-main); flex-shrink: 0; }
.gif-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  overflow-y: auto; flex: 1;
}
.gif-cell { position: relative; cursor: pointer; }
.gif-cell img { width: 100%; height: 130px; object-fit: cover; border-radius: 8px; display: block; }
.gif-fav-btn { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.6); border: none; color: var(--gold-bright); border-radius: 4px; font-size: 13px; cursor: pointer; padding: 2px 6px; }

/* ---- Files tab ---- */
#uploadForm { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
#uploadForm input[type="file"] { font-size: 12px; color: var(--text-muted); }
#uploadForm button {
  padding: 8px; border: 1px solid var(--gold-dim); border-radius: 6px;
  background: var(--gold); color: #16130d; cursor: pointer; font-weight: 600;
}
#fileList { list-style: none; padding: 0; margin: 0; }
.file-item { background: var(--bg-panel-2); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 10px; margin-bottom: 8px; font-size: 13px; }
.file-item div:last-child { display: flex; gap: 6px; margin-top: 6px; }
.file-item button { font-size: 11px; padding: 4px 8px; border: 1px solid var(--border-subtle); border-radius: 4px; background: var(--bg-input); color: var(--text-main); cursor: pointer; }
.file-item button:hover { border-color: var(--gold-dim); color: var(--gold-bright); }

/* ---- Watermark ---- */
.watermark {
  position: fixed; bottom: 8px; right: 12px;
  font-family: var(--font-display);
  font-size: 12px; color: var(--gold-bright);
  opacity: 0.5; pointer-events: none; letter-spacing: 1px; z-index: 50;
}

button { transition: background-color 0.15s ease, transform 0.15s ease, opacity 0.15s ease, filter 0.15s ease; }

/* ---- Sidebar (friends-only, no tabs) ---- */
.sidebar-title {
  font-family: var(--font-display);
  color: var(--gold-bright);
  font-size: 20px;
  margin: 0 0 10px;
}
#userList { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; }
.list-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  object-fit: cover; margin-right: 8px; vertical-align: middle;
  border: 1px solid var(--border-subtle);
}

/* ---- Message avatars + smooth entry animation ---- */
.msg-row { display: flex; align-items: flex-end; gap: 8px; margin: 4px 0; }
.msg-row.mine { justify-content: flex-end; }
.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--border-subtle); flex-shrink: 0;
}
.msg {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.msg.msg-enter-active { opacity: 1; transform: translateY(0); }

.file-card {
  display: block;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-main);
  text-decoration: none;
}
.file-card:hover { border-color: var(--gold-dim); text-decoration: none; }

/* ---- Send button: dark by default, glows when there's something to send ---- */
.msg-form button[type="submit"] {
  background: var(--bg-panel-2);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  box-shadow: none;
}
.msg-form button[type="submit"].send-glow {
  background: linear-gradient(180deg, var(--gold), #b8912c);
  color: #16130d;
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}
.msg-form button[type="submit"]:disabled { opacity: 0.4; box-shadow: none; }

/* ---- Discord-style attachment preview before sending ---- */
.attach-preview { margin-bottom: 8px; }
.attach-preview.hidden { display: none; }
.attach-preview-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
}
.attach-thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
.attach-thumb.hidden { display: none; }
.attach-icon { font-size: 20px; }
.attach-icon.hidden { display: none; }
.attach-name { font-size: 13px; color: var(--text-main); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-remove {
  background: none; border: none; cursor: pointer; font-size: 14px;
  color: var(--text-muted); border-radius: 4px; padding: 2px 6px;
}
.attach-remove:hover { color: #e07a6f; }

/* ---- Avatar with letter-fallback (used in friend list + messages) ---- */
.avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar-fallback {
  width: 100%; height: 100%; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #8a7128);
  color: #16130d;
  display: none; align-items: center; justify-content: center;
  font-weight: 700;
  position: absolute; top: 0; left: 0;
}
.avatar-sm { width: 22px; height: 22px; }
.avatar-sm .avatar-fallback { font-size: 11px; }
.avatar-md { width: 36px; height: 36px; }
.avatar-md .avatar-fallback { font-size: 15px; }

/* ---- Message grouping (avatar + full name only on first message of a run) ---- */
.msg-row { display: flex; align-items: flex-start; gap: 10px; margin: 2px 0; }
.msg-row.mine { justify-content: flex-end; }
.msg-col { display: flex; flex-direction: column; max-width: 70%; }
.msg-sender-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-bright);
  margin-bottom: 3px;
  white-space: normal;
  overflow-wrap: break-word;
}
.msg-avatar-spacer { width: 36px; flex-shrink: 0; }

/* ================= THEMES ================= */
/* Default (no data-theme or "gold") uses the :root variables already defined above. */
body[data-theme="sapphire"] {
  --gold: #4a90d9; --gold-bright: #7fb8f0; --gold-dim: #2c5a85;
  --bg-deep: #060a12; --bg-panel: #0e1622; --bg-panel-2: #16212f; --bg-input: #0a121c;
  --border-subtle: #223347;
}
body[data-theme="emerald"] {
  --gold: #3fae6a; --gold-bright: #74d69a; --gold-dim: #256b41;
  --bg-deep: #060b08; --bg-panel: #0d1712; --bg-panel-2: #15231b; --bg-input: #0a130e;
  --border-subtle: #1f3327;
}
body[data-theme="crimson"] {
  --gold: #c9463f; --gold-bright: #ef7e77; --gold-dim: #7a2924;
  --bg-deep: #0d0605; --bg-panel: #1a0f0d; --bg-panel-2: #241613; --bg-input: #120908;
  --border-subtle: #3a201b;
}
body[data-theme="midnight"] {
  --gold: #8b7fd9; --gold-bright: #b4aaef; --gold-dim: #4c4485;
  --bg-deep: #07070d; --bg-panel: #0f0f1a; --bg-panel-2: #171727; --bg-input: #0b0b14;
  --border-subtle: #26263d;
}

.theme-grid { display: flex; gap: 10px; }
.theme-swatch {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform 0.15s ease, border-color 0.15s ease;
}
.theme-swatch:hover { transform: scale(1.15); }
.theme-swatch.active { border-color: var(--text-main); }
.theme-swatch[data-theme="gold"] { background: linear-gradient(135deg, #d4af37, #8a7128); }
.theme-swatch[data-theme="sapphire"] { background: linear-gradient(135deg, #4a90d9, #2c5a85); }
.theme-swatch[data-theme="emerald"] { background: linear-gradient(135deg, #3fae6a, #256b41); }
.theme-swatch[data-theme="crimson"] { background: linear-gradient(135deg, #c9463f, #7a2924); }
.theme-swatch[data-theme="midnight"] { background: linear-gradient(135deg, #8b7fd9, #4c4485); }

/* ================= Settings extras ================= */
.settings-label { display: block; font-size: 11px; color: var(--text-muted); margin: 10px 0 4px; }
#displayNameInput, #statusInput, #descriptionInput {
  width: 100%; padding: 8px; border-radius: 6px; border: 1px solid var(--border-subtle);
  background: var(--bg-input); color: var(--text-main); font-family: var(--font-body);
}
#descriptionInput { resize: vertical; }
#nameColorInput { width: 50px; height: 32px; border: none; background: none; cursor: pointer; }
#saveProfileBtn { margin-top: 10px; }

/* ================= Own-message color fix (dark text on gold for contrast) ================= */
.msg.mine { color: #1c1408; }
.msg-row.mine .msg-col { align-items: flex-end; }
.msg-row.mine .msg-sender-name { text-align: right; }

/* ================= Friend list: display name + status ================= */
.user-item-text { display: flex; flex-direction: column; overflow: hidden; }
.user-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-item-status { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================= Profile popup ================= */
.profile-popup {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 110;
}
.profile-popup.hidden { display: none; }
.profile-popup-card {
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: 12px;
  padding: 28px; width: 90%; max-width: 320px; text-align: center;
  box-shadow: 0 0 0 1px rgba(212,175,55,0.08), 0 20px 60px rgba(0,0,0,0.6);
  animation: popIn 0.2s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.avatar-lg { width: 72px; height: 72px; margin: 0 auto 12px; display: block; }
.avatar-lg .avatar-fallback { font-size: 28px; }
.profile-popup-card h3 { font-family: var(--font-display); font-size: 22px; margin: 4px 0 0; }
.popup-status { font-size: 13px; color: var(--gold); margin: 4px 0; }
.popup-description { font-size: 13px; color: var(--text-muted); margin: 10px 0 18px; }
#popupCloseBtn {
  padding: 8px 20px; border: 1px solid var(--gold-dim); border-radius: 6px;
  background: var(--gold); color: #16130d; cursor: pointer; font-weight: 600;
}

/* ================= Extra hover polish ================= */
.settings-swatch, .theme-swatch, .gear-btn, .icon-btn, .file-card, .gif-cell img {
  transition: transform 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
}
.gif-cell img:hover { transform: scale(1.05); filter: brightness(1.1); }
.file-card:hover { transform: translateY(-1px); }
.settings-panel, .profile-popup-card { animation: popIn 0.18s ease; }
.gif-picker:not(.hidden) { animation: popIn 0.15s ease; }

/* ================= Mobile responsiveness ================= */
.mobile-menu-btn { display: none; }
.sidebar-overlay { display: none; }
.mobile-hint { display: none; }

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 10px; left: 10px; z-index: 60;
    width: 40px; height: 40px; border-radius: 8px;
    background: var(--bg-panel-2); border: 1px solid var(--border-subtle);
    color: var(--gold-bright); font-size: 18px; cursor: pointer;
  }
  .mobile-hint { display: block; }
  .chat-layout { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 78vw; max-width: 300px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 55;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50;
  }
  .sidebar-overlay.hidden { display: none; }
  .chat-main { padding: 56px 10px 10px; }
  .msg-col { max-width: 82%; }
  .gif-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-panel { width: 94%; padding: 18px; }
  .icon-btn { padding: 0 10px; font-size: 13px; }
  .msg-form input[type="text"] { font-size: 16px; } /* prevents iOS zoom on focus */
}

.toggle-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.toggle-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--gold); cursor: pointer; }

/* ================= Landing page ================= */
.landing { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.landing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 0;
}
.landing-brand { font-family: var(--font-display); font-size: 22px; color: var(--gold-bright); font-weight: 700; }
.landing-nav nav { display: flex; align-items: center; gap: 16px; }
.landing-nav-link { color: var(--text-main); font-size: 14px; }
.landing-cta-small {
  padding: 8px 16px; border-radius: 6px; border: 1px solid var(--gold-dim);
  background: var(--gold); color: #16130d; font-weight: 600; font-size: 14px;
}
.landing-cta-small:hover { text-decoration: none; filter: brightness(1.1); }

.landing-hero { text-align: center; padding: 60px 0 40px; }
.landing-hero h1 {
  font-family: var(--font-display); font-size: 42px; color: var(--gold-bright);
  max-width: 700px; margin: 0 auto 16px; line-height: 1.2;
}
.landing-sub { color: var(--text-muted); font-size: 16px; max-width: 520px; margin: 0 auto 32px; }
.landing-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.landing-cta, .landing-cta-outline {
  padding: 12px 28px; border-radius: 8px; font-weight: 600; font-size: 15px; transition: all 0.15s ease;
}
.landing-cta { background: linear-gradient(180deg, var(--gold), #b8912c); color: #16130d; border: 1px solid var(--gold); }
.landing-cta:hover { filter: brightness(1.1); text-decoration: none; transform: translateY(-1px); }
.landing-cta-outline { border: 1px solid var(--border-subtle); color: var(--text-main); }
.landing-cta-outline:hover { border-color: var(--gold-dim); text-decoration: none; }

.landing-features {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px;
  padding: 40px 0 60px;
}
.landing-feature {
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 22px;
}
.landing-feature h3 { font-family: var(--font-display); color: var(--gold); margin: 0 0 8px; font-size: 19px; }
.landing-feature p { color: var(--text-muted); font-size: 14px; margin: 0; }

.landing-footer { text-align: center; padding: 20px 0 40px; color: var(--gold-dim); font-family: var(--font-display); font-size: 13px; }

@media (max-width: 640px) {
  .landing-hero h1 { font-size: 30px; }
  .landing-features { grid-template-columns: 1fr; }
}

/* ================= Landing hero: icon, badge, stats ================= */
body:has(.landing) {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(212, 175, 55, 0.05), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(212, 175, 55, 0.04), transparent 40%),
    repeating-linear-gradient(45deg, rgba(212,175,55,0.035) 0px, rgba(212,175,55,0.035) 1px, transparent 1px, transparent 22px),
    repeating-linear-gradient(-45deg, rgba(212,175,55,0.035) 0px, rgba(212,175,55,0.035) 1px, transparent 1px, transparent 22px);
}

.landing-icon-wrap { display: flex; justify-content: center; padding-top: 40px; }
.landing-icon {
  width: 64px; height: 64px;
  filter: drop-shadow(0 8px 24px rgba(212, 175, 55, 0.25));
}

.landing-badge {
  text-align: center;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.5px;
  margin: 18px 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
}

.landing-stats {
  display: flex;
  justify-content: center;
  gap: 60px;
  padding: 30px 0 10px;
  flex-wrap: wrap;
}
.landing-stat { text-align: center; }
.landing-stat span {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--gold-bright);
}
.landing-stat small { color: var(--text-muted); font-size: 12px; }

@media (max-width: 640px) {
  .landing-icon { width: 72px; height: 72px; }
  .landing-stats { gap: 34px; }
}

.back-to-landing {
  position: fixed;
  top: 20px; left: 20px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.back-to-landing:hover { border-color: var(--gold-dim); color: var(--gold-bright); text-decoration: none; }

.home-btn { color: var(--text-main); flex-shrink: 0; width: 32px; height: 32px; }
.home-btn:hover { text-decoration: none; border-color: var(--gold-dim); }

/* ================= Custom file input buttons ================= */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap;
}
.file-btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--gold-dim);
  background: var(--gold);
  color: #16130d;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.file-btn:hover { filter: brightness(1.1); }
.file-btn-name { display: inline-block; margin-left: 10px; }

/* ================= Circular icon button (matches gear button) ================= */
.circle-icon-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0;
}
.circle-icon-btn:hover { border-color: var(--gold-dim); color: var(--gold-bright); transform: rotate(-8deg); }

.hidden { display: none !important; }
#pwStep2 input, #delStep2 input {
  display: block; width: 100%; padding: 8px; margin-bottom: 8px;
  border-radius: 6px; border: 1px solid var(--border-subtle);
  background: var(--bg-input); color: var(--text-main);
}
#pwSubmitBtn, #pwRequestBtn { margin-top: 4px; }

/* ================= Custom scrollbars matching the gold theme ================= */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) var(--bg-panel);
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: var(--bg-panel); }
*::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ================= Step modal (Epic Games-style: one screen at a time) ================= */
.step-modal-card { text-align: left; }
.step-modal-card h3 {
  font-family: var(--font-display); color: var(--gold-bright);
  font-size: 22px; margin: 0 0 8px; text-align: center;
}
#stepModalInput {
  width: 100%; padding: 10px; margin: 14px 0;
  border-radius: 6px; border: 1px solid var(--border-subtle);
  background: var(--bg-input); color: var(--text-main);
  font-size: 15px; letter-spacing: 1px;
}
.step-modal-buttons { display: flex; gap: 10px; margin-top: 10px; }
.step-cancel-btn {
  flex: 1; padding: 10px; border-radius: 6px;
  border: 1px solid var(--border-subtle); background: var(--bg-panel-2);
  color: var(--text-main); cursor: pointer;
}
.step-cancel-btn:hover { border-color: var(--gold-dim); }
#stepModalSubmit {
  flex: 2; padding: 10px; border-radius: 6px; border: 1px solid var(--gold-dim);
  background: var(--gold); color: #16130d; font-weight: 600; cursor: pointer;
}
#stepModalSubmit.logout-btn { border-color: #7a2e26; }
