/* ============================================================
   Farend AI — clean minimal light theme (ChatGPT / Gemini style).
   Solid white and very light grey surfaces, thin borders, plain
   buttons. No glass, no blur, no translucency anywhere.
   Inter throughout. Violet accent only for links and highlights.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --sidebar: #f7f7f8;
  --text: #171717;
  --muted: #6b7280;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --accent: #6d28d9;
  --accent-hover: #5b21b6;
  --accent-soft: #f3f0ff;
  --danger: #b3261e;
  --danger-soft: #fce8e6;
  --success: #137333;
  --success-soft: #e6f4ea;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --btn-dark: #171717;
  --btn-dark-hover: #000000;
  --radius: 12px;
  --radius-sm: 8px;
  --max: 1200px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.app-page { height: 100vh; height: 100dvh; overflow: hidden; }
img, svg { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }
main { flex: 1; min-height: 0; }
h1, h2, h3 { line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; margin-bottom: 14px; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin-bottom: 14px; }
.muted { color: var(--muted); font-size: .95rem; }

/* ---------- Loading spinner (shared) ---------- */
.spinner {
  width: 32px; height: 32px; margin: 0 auto 14px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* ---------- Header (plain white bar) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 14px; height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 12px; flex: none; overflow: hidden;
  display: grid; place-items: center; background: var(--bg-soft);
  border: 1px solid var(--border);
}
.logo-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo small { display: block; font-size: .6rem; font-weight: 700; color: var(--muted); letter-spacing: .12em; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.header-icon-btn {
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--border);
  border-radius: 50%; width: 38px; height: 38px;
  color: var(--text); cursor: pointer;
}
.header-icon-btn:hover { background: var(--bg-soft); }
.header-icon-btn.muted { color: var(--muted); }

/* ---------- User menu (plain dropdown) ---------- */
.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px 5px 5px;
  color: var(--text); font-family: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
  max-width: 220px;
}
.user-chip:hover { background: var(--bg-soft); }
.user-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .mini-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--accent); display: grid; place-items: center;
  font-size: .85rem; color: #fff; font-weight: 700; overflow: hidden;
}
.user-chip .mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .10); overflow: hidden; z-index: 60; padding: 6px;
}
.user-dropdown.open { display: block; }
.user-dropdown a, .user-dropdown button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  color: var(--text); background: none; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: .93rem; font-weight: 600; cursor: pointer; text-align: left;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg-soft); text-decoration: none; }
.user-dropdown a svg, .user-dropdown button svg { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: .95rem; line-height: 1.4;
  transition: background .15s;
}
.btn:hover { text-decoration: none; }
/* Primary button (legacy class name "btn-gold" — now solid dark). */
.btn-gold, .btn-purple { background: var(--btn-dark); color: #fff; }
.btn-gold:hover, .btn-purple:hover { background: var(--btn-dark-hover); }
.btn-outline { background: #fff; border: 1px solid var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--bg-soft); }
.btn-sm { padding: 8px 14px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Forms / auth ---------- */
.form-card {
  max-width: 480px; margin: 48px auto;
  background: #fff; border: 1px solid var(--border);
  border-radius: 20px; padding: 32px;
}
.form-card h1 { font-size: 1.5rem; margin-bottom: 8px; text-align: center; }
.form-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: .95rem; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: #fff;
  color: var(--text); font-family: inherit; font-size: 1rem; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 40, 217, .12);
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.field input:disabled, .field textarea:disabled { background: var(--bg-soft); opacity: .7; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 5px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .85rem; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-google {
  background: #fff; color: var(--text); border: 1px solid var(--border-strong);
  width: 100%; justify-content: center;
}
.btn-google:hover { background: var(--bg-soft); }
.btn-x, .btn-apple { background: #000; color: #fff; width: 100%; justify-content: center; margin-top: 10px; }
.btn-x:hover, .btn-apple:hover { background: #222; }
.alert { padding: 13px 15px; border-radius: var(--radius-sm); font-size: .92rem; margin-bottom: 16px; line-height: 1.6; }
.alert-error { background: var(--danger-soft); border: 1px solid #f5c6c2; color: var(--danger); }
.alert-info { background: var(--accent-soft); border: 1px solid #d8b4fe; color: var(--accent-hover); }
.alert-success { background: var(--success-soft); border: 1px solid #a8dab5; color: var(--success); }
.error-code { font-size: .75rem; opacity: .75; margin-top: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.form-footer { text-align: center; margin-top: 18px; color: var(--muted); font-size: .93rem; }

/* ---------- Static pages ---------- */
.page { padding: 40px 0 48px; }
.page .narrow { max-width: 780px; margin: 0 auto; }
.page h1 { margin-bottom: 20px; }
.page h2 { margin-top: 30px; }
.page ul { margin: 0 0 16px 22px; }
.page li { margin-bottom: 8px; line-height: 1.7; }

/* ---------- Profile (plain cards) ---------- */
.profile-head {
  display: flex; gap: 20px; align-items: center; margin-bottom: 28px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.avatar {
  width: 68px; height: 68px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-head-info { min-width: 0; flex: 1; }
.profile-head-info h1 { font-size: 1.4rem; margin-bottom: 4px; word-break: break-word; }
.profile-head-info p { margin: 0; color: var(--muted); font-size: .95rem; word-break: break-word; }
.profile-logout { margin-left: auto; }
.profile-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 20px; padding: 22px 24px; margin-bottom: 24px;
}
.profile-card h2 { font-size: 1.1rem; margin-bottom: 8px; }
.profile-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.profile-row:last-child { border-bottom: none; padding-bottom: 0; }
.profile-row:first-of-type { padding-top: 6px; }
.profile-label { color: var(--muted); font-size: .92rem; font-weight: 500; }
.profile-value { font-weight: 600; font-size: .95rem; text-align: right; word-break: break-word; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 0; }
.settings-row p { margin: 0; }
.settings-row .settings-label { font-weight: 600; }
.settings-row .settings-desc { color: var(--muted); font-size: .88rem; }

/* ---------- Footer (plain) ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; background: #fff; }
.footer-inner { padding: 28px 0; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-size: .9rem; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom {
  border-top: 1px solid var(--border); padding: 16px 0;
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  color: var(--muted); font-size: .85rem;
}

/* ---------- Toast (solid dark, bottom-centre) ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px);
  background: #171717; color: #fff;
  padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: .92rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); opacity: 0;
  transition: transform .25s, opacity .25s; z-index: 100; pointer-events: none;
  max-width: calc(100vw - 48px); text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- Ad slots ---------- */
.ad-slot {
  margin: 24px auto; max-width: 100%; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-soft); min-height: 90px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px; gap: 4px; overflow: hidden;
}
.ad-slot .ad-label { font-size: .68rem; letter-spacing: .18em; color: var(--muted); font-weight: 700; }
.ad-slot .ad-note { font-size: .85rem; color: var(--muted); }
.ad-slot.ad-live { border: none; background: none; padding: 0; min-height: 0; }

/* ---------- Modals (solid white cards) ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, .45);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-card {
  width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
  text-align: center; padding: 28px 26px 24px;
  background: #fff; border: 1px solid var(--border); border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .18);
  position: relative;
  animation: modal-in .2s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px;
  border-radius: 50%; border: 1px solid var(--border); background: #fff;
  color: var(--muted); cursor: pointer; display: grid; place-items: center;
  z-index: 2;
}
.modal-close:hover { color: var(--text); background: var(--bg-soft); }
.modal-card h2 { font-size: 1.3rem; margin-bottom: 8px; }
.modal-card p { color: var(--muted); font-size: .95rem; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.modal-note { font-size: .8rem; color: var(--muted); margin-top: 14px; }
.modal-card.modal-wide {
  max-width: 560px; text-align: left;
  max-height: 90vh; overflow-y: auto; padding: 26px 24px 22px;
}
.modal-card.modal-wide h2, .modal-card.modal-wide p { text-align: left; }
.modal-label { display: block; font-weight: 600; font-size: .9rem; color: var(--text); margin: 16px 0 6px; }
.modal-textarea {
  width: 100%; min-height: 88px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: #fff;
  color: var(--text); font-family: inherit; font-size: 1rem; outline: none; resize: vertical;
}
.modal-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 40, 217, .12); }
.modal-textarea::placeholder { color: var(--muted); }
.modal-textarea:disabled { background: var(--bg-soft); opacity: .7; }
.modal-input, .modal-select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: #fff;
  color: var(--text); font-family: inherit; font-size: .95rem; outline: none;
}
.modal-input:focus, .modal-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 40, 217, .12); }
.modal-input::placeholder { color: var(--muted); }
.style-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.style-chips button {
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--border-strong);
  color: var(--text); font-family: inherit; font-size: .85rem; font-weight: 600;
}
.style-chips button:hover { border-color: var(--accent); color: var(--accent); }
.style-chips button.selected { background: var(--btn-dark); color: #fff; border-color: var(--btn-dark); }
.modal-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.modal-row .modal-select { width: auto; min-width: 220px; }
.modal-usage { padding: 0; margin: 0 0 4px auto; }
.modal-card .modal-actions .btn { width: 100%; justify-content: center; }
.vid-elapsed { font-size: .82rem; text-align: center; }
.byok-saved-line { font-size: 1rem; }
.byok-saved-line b { font-family: ui-monospace, monospace; }

/* ---------- AI generation results ---------- */
.img-loading { text-align: center; padding: 32px 12px; color: var(--muted); }
.img-spinner {
  width: 36px; height: 36px; margin: 0 auto 14px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.img-result { margin-top: 20px; text-align: center; }
.img-result img, .img-result video {
  max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border);
  display: block; margin: 0 auto;
}
.img-result video { background: #000; }
.img-result .ai-download-btn { margin: 16px 4px 0; }
.ai-download-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--border-strong);
  color: var(--text); font-family: inherit; font-size: .9rem; font-weight: 600; text-decoration: none;
}
.ai-download-btn:hover { border-color: var(--accent); color: var(--accent); }
.ai-download-btn svg { width: 16px; height: 16px; }

/* ============================================================
   AI CHAT APP (index.html) — ChatGPT-style layout
   ============================================================ */
.app { flex: 1; min-height: 0; display: flex; }

/* ----- Sidebar ----- */
.sidebar {
  width: 264px; flex: none; background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.sidebar-logo:hover { text-decoration: none; }
.new-chat-btn {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin-top: 12px; padding: 10px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border-strong);
  color: var(--text); font-family: inherit; font-size: .92rem; font-weight: 600;
  cursor: pointer; text-align: left;
}
.new-chat-btn:hover { background: var(--bg-soft); }
.history-label {
  padding: 14px 16px 6px; font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; color: var(--muted); text-transform: uppercase;
}
.history-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; min-height: 0; }
.history-empty { padding: 12px 16px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.history-item {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 9px 10px; border-radius: 12px; border: none;
  background: none; color: var(--text); font-family: inherit;
  font-size: .9rem; cursor: pointer; text-align: left;
}
.history-item:hover { background: #ececee; }
.history-item.active { background: #ececee; font-weight: 600; }
.history-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.history-title {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.history-del {
  flex: none; width: 24px; height: 24px; border: none; background: none;
  color: var(--muted); cursor: pointer; border-radius: 50%;
  display: none; place-items: center;
}
.history-item:hover .history-del { display: grid; }
.history-del:hover { color: var(--danger); background: #fff; }
.history-rename {
  flex: none; width: 24px; height: 24px; border: none; background: none;
  color: var(--muted); cursor: pointer; border-radius: 50%;
  display: none; place-items: center;
}
.history-item:hover .history-rename { display: grid; }
.history-rename:hover { color: var(--accent); background: #fff; }
/* Touch devices have no hover — the pin / rename / delete
   buttons would be invisible and unreachable there, so
   always show them when hover is unavailable. */
@media (hover: none) {
  .history-del, .history-rename, .history-pin { display: grid; }
}
.history-rename-input {
  flex: 1; min-width: 0; padding: 4px 8px;
  border: 1px solid var(--accent); border-radius: 8px; outline: none;
  font-family: inherit; font-size: .9rem; color: var(--text); background: #fff;
}
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 12px 12px; }
.sidebar-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 12px; border: none;
  background: none; color: var(--text); font-family: inherit;
  font-size: .9rem; font-weight: 600; cursor: pointer; text-align: left;
}
.sidebar-btn:hover { background: #ececee; text-decoration: none; }
.sidebar-btn svg { flex: none; color: var(--muted); }
.sidebar-btn small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
/* Sidebar bottom user chip (ChatGPT-style): tap to open the
   Profile / Membership / Settings / Log out menu. */
.sidebar-user-wrap { position: relative; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 12px; border: none;
  background: none; color: var(--text); font-family: inherit;
  cursor: pointer; text-align: left;
}
.sidebar-user:hover { background: #ececee; }
.sidebar-user-menu {
  display: none; position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 80;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .14); padding: 6px;
}
.sidebar-user-menu.open { display: block; }
.sidebar-user-menu a,
.sidebar-user-menu button {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border: none; border-radius: 12px;
  background: none; color: var(--text); font-family: inherit;
  font-size: .92rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.sidebar-user-menu a:hover,
.sidebar-user-menu button:hover { background: var(--bg-soft); }
.sidebar-user .mini-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--accent); display: grid; place-items: center;
  font-size: .9rem; color: #fff; font-weight: 700; overflow: hidden;
}
.sidebar-user .mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-info b { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info span { display: block; font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-ad { margin: 10px 4px 0; min-height: 0; }
.sidebar-ad.ad-slot { margin: 10px 4px 0; padding: 10px; min-height: 60px; }

/* ----- Main column ----- */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }
.app-topbar {
  height: 56px; flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--border);
}
.menu-btn {
  display: none; width: 38px; height: 38px; flex: none;
  border: none; background: none; border-radius: 50%;
  color: var(--muted); cursor: pointer; place-items: center;
}
.menu-btn:hover { background: var(--bg-soft); color: var(--text); }
.topbar-title { font-weight: 700; font-size: 1rem; }
.topbar-counter { margin-left: auto; font-size: .82rem; color: var(--muted); }
.sidebar-overlay { display: none; }
.chat-wrap { flex: 1; overflow-y: auto; min-height: 0; }
.chat-log { max-width: 768px; margin: 0 auto; padding: 24px 20px; display: flex; flex-direction: column; gap: 20px; }
.ai-msg {
  max-width: 88%; font-size: .97rem; line-height: 1.75;
  word-wrap: break-word; white-space: pre-wrap;
  animation: ai-msg-in .2s ease-out;
}
@keyframes ai-msg-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.ai-msg-user {
  align-self: flex-end; background: var(--bg-soft);
  padding: 10px 16px; border-radius: 24px; border: 1px solid var(--border);
}
.ai-msg-model { align-self: flex-start; padding: 2px 0; }
.ai-msg-error { color: var(--danger); background: var(--danger-soft); padding: 10px 16px; border-radius: var(--radius-sm); }
.ai-typing { display: flex; gap: 5px; align-items: center; padding: 10px 0; }
.ai-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: ai-dot 1.2s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: .15s; }
.ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ----- Welcome empty state ----- */
.chat-empty { max-width: 640px; margin: 0 auto; padding: 72px 20px 24px; text-align: center; }
.chat-empty-logo {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 18px;
  overflow: hidden; border: 1px solid var(--border);
}
.chat-empty-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-empty h1 { font-size: 1.7rem; margin-bottom: 8px; }
.chat-empty p { color: var(--muted); font-size: 1rem; }
.ai-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 20px; }
.ai-chips button {
  padding: 9px 15px; border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--border-strong);
  color: var(--text); font-family: inherit; font-size: .88rem; font-weight: 600;
}
.ai-chips button:hover { border-color: var(--accent); color: var(--accent); }

/* ----- Composer ----- */
.composer { flex: none; padding: 8px 20px 16px; background: #fff; }
.composer-inner { max-width: 768px; margin: 0 auto; }
.ai-input-row {
  display: flex; gap: 10px; align-items: center;
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 6px 6px 6px 18px; background: #fff;
}
.ai-input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 40, 217, .12); }
.ai-input-row input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  color: var(--text); font-family: inherit; font-size: .98rem; padding: 8px 0;
}
.ai-input-row input::placeholder { color: var(--muted); }
.ai-send {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: none; cursor: pointer;
  background: var(--btn-dark); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.ai-send:hover { background: var(--btn-dark-hover); }
.ai-send:disabled { opacity: .5; cursor: not-allowed; }
.ai-send svg { width: 18px; height: 18px; }
.usage-line { font-size: .82rem; color: var(--muted); margin: 0; }
.ai-note { font-size: .76rem; color: var(--muted); text-align: center; margin: 10px 0 0; }
.composer-links { text-align: center; margin-top: 6px; font-size: .78rem; color: var(--muted); }
.composer-links a { color: var(--muted); }
.composer-links a:hover { color: var(--accent); }

/* ----- Logged-out gate (welcome screen) ----- */
.gate {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  justify-content: safe center;
  padding: 40px 20px; text-align: center; background: #fff;
}
.gate-icon {
  width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 18px;
  overflow: hidden; border: 1px solid var(--border);
}
.gate-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gate h1, .gate .gate-title { font-size: 2rem; margin-bottom: 10px; }
.gate p, .gate .gate-text { color: var(--muted); max-width: 480px; margin: 0 auto 24px; font-size: 1.02rem; }
/* The purpose sentence is the landing's key line — dark, not
   muted — and the friendly sub-line sits under it, smaller. */
.gate .gate-text { color: var(--text); font-size: 1.1rem; line-height: 1.5; margin-bottom: 6px; }
.gate .gate-sub { font-size: .95rem; margin-bottom: 24px; }
.gate-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.gate-features {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  margin-top: 32px; max-width: 560px;
}
.gate-feature {
  border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px; flex: 1 1 160px; text-align: left; background: var(--bg-soft);
}
.gate-feature b { display: block; font-size: .95rem; margin-bottom: 2px; }
.gate-feature span { font-size: .85rem; color: var(--muted); line-height: 1.5; }
.gate-ad { margin-top: 28px; width: 100%; max-width: 560px; }
.gate-links { margin-top: 24px; font-size: .85rem; color: var(--muted); }
.gate-links a { color: var(--muted); }

/* ============================================================
   LEGACY — unlinked pages kept on disk (articles, YouTube,
   about, contact). Plain styles so they still render if the
   owner ever links them again. No glass anywhere.
   ============================================================ */
.hero { padding: 56px 0 40px; border-bottom: 1px solid var(--border); }
.hero-inner { max-width: 860px; }
.hero-eyebrow { display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .14em; color: var(--accent); margin-bottom: 14px; }
.hero-display { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.hero-lede { color: var(--muted); max-width: 640px; margin: 18px 0 24px; font-size: 1.05rem; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 32px; margin-top: 36px; flex-wrap: wrap; }
.hero-stats div { padding-left: 14px; border-left: 2px solid var(--accent); }
.hero-stats b { display: block; font-size: 1.4rem; font-weight: 800; }
.hero-stats span { font-size: .88rem; color: var(--muted); }
.toolbar { display: flex; flex-direction: column; gap: 14px; margin: 8px 0 24px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text); font-family: inherit; font-weight: 600;
  font-size: .9rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--btn-dark); color: #fff; border-color: var(--btn-dark); }
.search-box { position: relative; flex: 1; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input {
  width: 100%; padding: 12px 14px 12px 42px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: #fff;
  color: var(--text); font-family: inherit; font-size: 1rem; outline: none;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 40, 217, .12); }
.grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.card-thumb { height: 150px; display: grid; place-items: center; position: relative; overflow: hidden; }
.card-thumb svg { width: 72px; height: 72px; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-cat {
  position: absolute; top: 12px; left: 12px; padding: 4px 12px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border);
  color: var(--text); font-size: .75rem; font-weight: 700; z-index: 2;
}
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-body h3 { font-size: 1.12rem; line-height: 1.4; }
.card-body h3 a { color: var(--text); }
.card-body h3 a:hover { color: var(--accent); text-decoration: none; }
.card-body p { color: var(--muted); font-size: .95rem; margin: 0; flex: 1; }
.card-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .82rem; }
.card-actions { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: none;
  color: var(--muted); font-family: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; padding: 6px 4px;
}
.icon-btn:hover, .icon-btn.active { color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.h-grad-space { background: #e0e7ff; }
.h-grad-history { background: #fef3c7; }
.h-grad-places { background: #dbeafe; }
.h-grad-mystery { background: var(--accent-soft); }
.article-hero { padding: 36px 0 12px; }
.article-hero .hero-art { border-radius: var(--radius); height: 220px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--border); }
.article-hero .hero-art svg { width: 110px; height: 110px; }
.article-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .88rem; margin: 18px 0 10px; align-items: center; }
.article-meta .cat { color: var(--accent); font-weight: 700; }
.article-body { max-width: 780px; margin: 0 auto; padding-bottom: 12px; }
.article-body p { font-size: 1.05rem; line-height: 1.8; }
.article-body h2 { margin-top: 32px; }
.article-body ul { margin: 0 0 16px 22px; }
.article-body li { margin-bottom: 8px; line-height: 1.7; }
.fact-box {
  border: 1px solid #fde68a; border-left: 4px solid var(--amber);
  background: var(--amber-soft); padding: 15px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 22px 0;
}
.fact-box b { color: var(--amber); }
.article-actions {
  display: flex; gap: 10px; flex-wrap: wrap; margin: 28px 0; padding: 16px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
}
.share-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.video-link {
  display: flex; gap: 14px; align-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; margin: 24px 0;
}
.video-link .play { width: 44px; height: 44px; flex: none; border-radius: 50%; background: #e62117; display: grid; place-items: center; color: #fff; }
.video-link b { color: var(--text); display: block; }
.video-link span { color: var(--muted); font-size: .9rem; }
.related { margin: 36px 0 12px; }
.newsletter { margin: 36px 0; padding: 32px 24px; text-align: center; border-radius: var(--radius); background: var(--bg-soft); border: 1px solid var(--border); }
.newsletter h2 { margin-bottom: 8px; }
.newsletter p { color: var(--muted); }
.newsletter form { display: flex; gap: 10px; max-width: 480px; margin: 18px auto 0; flex-direction: column; }
.newsletter input {
  flex: 1; padding: 12px 16px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: #fff;
  color: var(--text); font-family: inherit; font-size: 1rem; outline: none;
}
.newsletter input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 40, 217, .12); }
.footer-col h3 { font-size: .95rem; margin-bottom: 12px; }
.footer-col a { display: block; color: var(--muted); padding: 4px 0; font-size: .93rem; }
.social-row { display: flex; gap: 10px; margin-top: 14px; }
.social-row a {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; color: var(--text); border: 1px solid var(--border);
}
.social-row a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.yt-minimal { padding: 80px 0 96px; text-align: center; }
.yt-photo { width: 170px; height: 170px; border-radius: 44px; margin-bottom: 24px; border: 1px solid var(--border); }
.yt-minimal h1 { font-size: 2rem; margin-bottom: 4px; }
.yt-handle { color: var(--muted); font-size: 1.02rem; margin: 0 0 24px; }
.yt-deco { display: none; }

/* ---------- Responsive ---------- */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .newsletter form { flex-direction: row; }
  .toolbar { flex-direction: row; align-items: center; }
  h1 { font-size: 2.1rem; }
  .article-hero .hero-art { height: 300px; }
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .menu-btn { display: grid; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 70;
    transform: translateX(-105%);
    transition: transform .25s ease-out;
    box-shadow: 8px 0 32px rgba(0, 0, 0, .15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; z-index: 65;
    background: rgba(0, 0, 0, .4);
  }
  .sidebar-overlay.show { display: block; }
  .topbar-counter { font-size: .78rem; }
}
@media (max-width: 639px) {
  .container { padding: 0 16px; }
  .profile-head { flex-direction: column; text-align: center; padding: 20px 16px; gap: 14px; }
  .profile-logout { margin-left: 0; }
  .profile-card { padding: 18px 16px; }
  .profile-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .profile-value { text-align: left; }
  .form-card { padding: 24px 18px; margin: 32px auto; }
  .modal-card.modal-wide { padding: 22px 18px 18px; }
  .modal-row .modal-select { width: 100%; }
  .chat-log { padding: 20px 14px; gap: 16px; }
  .ai-msg { max-width: 94%; }
  .chat-empty { padding: 48px 16px 20px; }
  .composer { padding: 8px 12px 14px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .logo > span:last-child { display: none; }
  .user-chip .chip-name { display: none; }
  .user-chip { padding-right: 5px; }
  .header-inner { gap: 8px; }
  .header-actions { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   SINGLE-CHAT APP LAYOUT (19 Nov 2026 rebuild)
   Collapsible sidebar, centered greeting, large rounded
   composer, inline chat media. Single unified chat — no
   mode chips, no separate image/video UI.
   ============================================================ */

/* ----- Topbar: hamburger always visible, avatar on the right ----- */
.app-topbar .menu-btn { display: grid; }
.topbar-avatar {
  margin-left: auto; width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .95rem;
  display: grid; place-items: center; overflow: hidden; text-decoration: none;
}
.topbar-avatar:hover { text-decoration: none; color: #fff; }
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ----- Sidebar head: collapse button + logo ----- */
.sidebar-head { display: flex; align-items: center; gap: 8px; }
.sidebar-new { padding: 12px 14px 4px; }
.sidebar-new .new-chat-btn { margin-top: 0; }

/* ----- Sidebar search ----- */
.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 14px 2px; padding: 8px 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted);
}
.sidebar-search:focus-within { border-color: var(--accent); }
.sidebar-search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: .9rem; color: var(--text);
}
.sidebar-search input::placeholder { color: var(--muted); }
.sidebar-search svg { flex: none; }

/* ----- Sidebar footer links ----- */
.sidebar-links { text-align: center; margin: 10px 0 0; font-size: .78rem; color: var(--muted); }
.sidebar-links a { color: var(--muted); }
.sidebar-links a:hover { color: var(--accent); }

/* ----- Collapsed sidebar (desktop only — on mobile the sidebar
   is an overlay and the collapsed state does nothing) ----- */
.sidebar { transition: width .2s ease, transform .25s ease-out; }
@media (min-width: 769px) {
  .sidebar.collapsed { width: 68px; }
  .sidebar.collapsed .sidebar-logo-text,
  .sidebar.collapsed .new-chat-text,
  .sidebar.collapsed .sidebar-btn-text,
  .sidebar.collapsed .sidebar-user-info,
  .sidebar.collapsed .sidebar-user-menu,
  .sidebar.collapsed .sidebar-search,
  .sidebar.collapsed .history-label,
  .sidebar.collapsed .history-list,
  .sidebar.collapsed .sidebar-ad,
  .sidebar.collapsed .sidebar-links { display: none; }
  .sidebar.collapsed .sidebar-head { flex-direction: column; gap: 10px; padding: 14px 8px 10px; }
  .sidebar.collapsed .sidebar-logo { justify-content: center; }
  .sidebar.collapsed .sidebar-new { padding: 12px 8px 4px; }
  .sidebar.collapsed .new-chat-btn { justify-content: center; padding: 10px 0; }
  .sidebar.collapsed .sidebar-foot { padding: 10px 8px 12px; }
  .sidebar.collapsed .sidebar-btn { justify-content: center; padding: 9px 0; }
  .sidebar.collapsed .sidebar-user { justify-content: center; padding: 8px 0; }
}

/* ----- Centered greeting ----- */
.chat-empty .greeting-title { font-size: 2rem; font-weight: 600; margin-bottom: 6px; }
.chat-empty .greeting-sub { font-size: 1.05rem; }

/* ----- Large rounded composer box (ChatGPT-style: plain,
   single rounded input — textarea on top, actions row below,
   no shadow, minimal chrome) ----- */
.composer-box {
  border-radius: 28px;
  flex-direction: column;
  align-items: stretch;
  padding: 12px 10px 8px 18px;
  box-shadow: none;
}
.composer-actions {
  display: flex; align-items: center; gap: 4px; margin-top: 2px;
}
.composer-spacer { flex: 1; min-width: 0; }
.composer-box textarea {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  color: var(--text); font-family: inherit; font-size: 1rem; line-height: 1.5;
  padding: 6px 4px 4px; resize: none; max-height: 140px; overflow-y: auto;
}
.composer-box textarea::placeholder { color: var(--muted); }
.composer-box textarea:disabled { opacity: .6; }
.composer-box .ai-send { margin-bottom: 0; }
.composer-box .composer-icon-btn { margin-bottom: 0; }
.composer-note { font-size: .76rem; color: var(--muted); text-align: center; margin: 10px 0 0; }

/* ----- Inline chat media (image / video results) ----- */
.msg-media { max-width: 520px; }
.msg-media img, .msg-media video {
  max-width: 100%; border-radius: 16px; border: 1px solid var(--border);
  display: block; background: #000;
}
.msg-media video { width: 100%; }
.msg-media-caption { font-size: .88rem; color: var(--muted); margin-top: 8px; }
.msg-download { margin-top: 10px; padding: 8px 14px; font-size: .85rem; }
.media-loading { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 6px 0; }
.media-loading p { margin: 0; }
.media-status { font-size: .92rem; }
.media-elapsed { font-size: .82rem; color: var(--muted); }

/* ============================================================
   MEMBERSHIP + MODEL PICKER + APPS (19 Nov 2026)
   ============================================================ */

/* ----- Auth logo (login / signup — Gemini-style brand mark) ----- */
.auth-logo {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  overflow: hidden; border: 1px solid var(--border);
}
.auth-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ----- Topbar membership button ----- */
.topbar-membership { margin-left: auto; }
.topbar-avatar { margin-left: 0; }

/* ----- Model picker (top bar, Gemini-style) ----- */
.model-picker { position: relative; margin: 0; flex: none; }
.model-picker-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--text); font-family: inherit; font-size: .92rem; font-weight: 600;
  padding: 6px 10px; border-radius: 999px;
}
.model-picker-btn:hover { background: var(--bg-soft); }
.model-picker-btn svg { color: var(--muted); }
.model-picker-menu {
  display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 80;
  min-width: 280px; max-width: calc(100vw - 32px);
  /* 20 models ≈ 880px tall — cap the height and scroll, or
     the Pro models at the bottom are unreachable on phones
     and short windows. */
  max-height: calc(100vh - 120px); overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .14); padding: 6px;
}
.model-picker-menu.open { display: block; }
.model-option {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: none; border-radius: var(--radius-sm);
  background: none; color: var(--text); font-family: inherit;
  font-size: .92rem; cursor: pointer; text-align: left;
}
.model-option:hover { background: var(--bg-soft); }
.model-option.selected { background: var(--accent-soft); }
.model-option-name { font-weight: 600; flex: none; }
.model-option-desc { color: var(--muted); font-size: .82rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-option.locked .model-option-name { color: var(--muted); }
.model-lock { flex: none; color: var(--muted); display: grid; place-items: center; }

/* ----- Membership modal ----- */
.pro-list { margin: 0 0 4px 20px; }
.pro-list li { margin-bottom: 6px; font-size: .95rem; }
.ad-progress {
  height: 6px; background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; margin: 12px 0 8px;
}
.ad-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 1s linear; }
.membership-ad { margin: 12px auto; }

/* ----- Go Pro link under ad units ----- */
.ad-gopro {
  display: inline-block; margin-top: 8px;
  font-size: .78rem; font-weight: 600; color: var(--muted);
}
.ad-gopro:hover { color: var(--accent); }
.ad-slot.ad-live .ad-gopro { margin-top: 6px; }

/* ----- Apps list (New App Coming Soon) ----- */
.apps-empty { text-align: center; font-size: 1.1rem; font-weight: 700; margin: 24px 0 8px; }
.app-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.app-item:last-child { border-bottom: none; }
.app-item-icon {
  width: 48px; height: 48px; border-radius: 16px; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 1.3rem; font-weight: 700; overflow: hidden;
  border: 1px solid var(--border);
}
.app-item-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-item-info { flex: 1; min-width: 0; }
.app-item-info b { display: block; font-size: .98rem; }
.app-item-info span { display: block; font-size: .86rem; color: var(--muted); line-height: 1.5; }

/* ============================================================
   MESSAGE ACTIONS + VOICE + ADS + TOP MENU
   (19 Nov 2026)
   ============================================================ */

/* ----- Mode chip (Video Mode / Photo Mode hint) ----- */
.mode-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 10px 4px; padding: 6px 8px 6px 14px;
  border-radius: 999px; background: var(--accent-soft);
  border: 1px solid var(--border); color: var(--accent);
  font-size: .82rem; font-weight: 600;
}
.mode-chip-clear {
  border: none; background: none; cursor: pointer; font-size: 1.1rem;
  color: var(--muted); line-height: 1; padding: 0 4px; border-radius: 50%;
}
.mode-chip-clear:hover { color: var(--danger); }

/* ----- Image aspect framing (portrait / landscape results) ----- */
.msg-media-portrait { max-width: 360px; }
.msg-media-portrait img { aspect-ratio: 3 / 4; object-fit: cover; width: 100%; }
.msg-media-landscape img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }

/* ----- Message actions: Copy / Like / Report / Regenerate ----- */
.msg-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.msg-copy,
.msg-like,
.msg-report,
.msg-regen-text {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px;
  border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--border-strong);
  color: var(--muted); font-family: inherit; font-size: .8rem; font-weight: 600;
}
.msg-copy:hover,
.msg-like:hover,
.msg-report:hover,
.msg-regen-text:hover { border-color: var(--accent); color: var(--accent); }
.msg-like.liked { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.msg-like.liked svg { fill: var(--accent); }
.msg-report.reported { color: var(--muted); background: var(--bg-soft); }
.msg-regen { margin-left: 8px; }

/* ----- Locked video chip / menu item ----- */
.ai-chips button.locked { opacity: .65; }
.ai-chips button.locked .chip-lock,
.topbar-menu-list button.locked .menu-lock {
  display: inline-flex; align-items: center; margin-right: 4px; vertical-align: -1px;
}
.topbar-menu-list button.locked { color: var(--muted); }

/* ----- Attached photo in a chat bubble ----- */
.msg-attach {
  display: block; max-width: 280px; max-height: 280px;
  border-radius: 12px; border: 1px solid var(--border);
  margin-bottom: 8px; object-fit: cover;
}

/* ----- Composer icon buttons (camera / mic) ----- */
.composer-icon-btn {
  width: 40px; height: 40px; flex: none; border: none; background: none;
  color: var(--muted); cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-bottom: 2px;
}
.composer-icon-btn:hover { color: var(--accent); background: var(--bg-soft); }
.composer-icon-btn.listening { color: #d92d20; background: #fef3f2; animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 45, 32, .25); } 50% { box-shadow: 0 0 0 8px rgba(217, 45, 32, 0); } }

/* ----- Attach preview chip ----- */
.attach-preview {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 10px 4px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-soft); max-width: 320px;
}
.attach-preview img { width: 44px; height: 44px; object-fit: cover; border-radius: 12px; flex: none; }
.attach-preview-label { font-size: .85rem; color: var(--muted); flex: 1; }
.attach-remove {
  border: none; background: none; cursor: pointer; font-size: 1.3rem;
  color: var(--muted); line-height: 1; padding: 2px 6px; border-radius: 50%;
}
.attach-remove:hover { color: var(--danger); }

/* ----- In-chat ad after a generation ----- */
.chat-ad-msg { max-width: 520px; }
.chat-ad { margin: 4px 0; }

/* ----- Ad wrappers (house promo shown by default) ----- */
.ad-live-wrap, .ad-house-wrap {
  width: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
}

/* ----- Usage bars (membership modal + profile) ----- */
.usage-bars { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 10px; }
.usage-bar-row {
  display: flex; align-items: center; gap: 10px;
  font-size: .88rem;
}
.usage-bar-row > span { flex: none; width: 56px; color: var(--muted); }
.usage-bar-row > b { flex: none; font-size: .85rem; min-width: 44px; text-align: right; }
.usage-bar {
  flex: 1; height: 8px; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
}
.usage-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s ease; }

/* ----- Pro requests (owner admin view) ----- */
.pro-request-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.pro-request-row:last-child { border-bottom: none; }
.pro-request-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pro-request-email { font-weight: 600; word-break: break-all; }
.pro-request-meta { color: var(--muted); font-size: .85rem; margin: 0; }
.pro-request-status { flex: none; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); }
.pro-request-status.approved { background: var(--success-soft); color: var(--success); }
.pro-request-status.rejected { background: var(--danger-soft); color: var(--danger); }
.pro-request-actions { display: flex; gap: 8px; margin-top: 2px; }
.pro-request-actions .btn { flex: 1; justify-content: center; }

/* ----- Storage meter (profile) ----- */
.storage-meter { margin: 6px 0 2px; }
.storage-meter-text { font-size: .92rem; margin-bottom: 8px; }
.storage-meter-text b { font-weight: 700; }
.storage-bar {
  height: 10px; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
}
.storage-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.storage-bar-fill.near { background: var(--amber); }
.storage-bar-fill.full { background: var(--danger); }
.storage-note { font-size: .85rem; color: var(--muted); margin-top: 8px; }

/* ----- Report modal reasons ----- */
.report-reasons {
  display: flex; flex-direction: column; gap: 10px;
  margin: 16px 0; text-align: left;
}
.report-reasons label {
  display: flex; align-items: center; gap: 10px;
  font-size: .95rem; cursor: pointer; padding: 8px 4px;
}
.report-reasons input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ----- House promo card (shown when AdSense serves no ad) ----- */
.ad-slot.ad-house { border: 1px solid var(--border); background: var(--accent-soft); }
.house-ad-title { font-size: .95rem; }
.house-ad-cta {
  display: inline-block; margin-top: 8px; padding: 7px 16px;
  border-radius: 999px; background: var(--btn-dark); color: #fff;
  font-size: .85rem; font-weight: 600; text-decoration: none;
}
.house-ad-cta:hover { background: var(--btn-dark-hover); color: #fff; text-decoration: none; }

/* ----- Three-dot menu (top bar) ----- */
.topbar-menu { position: relative; flex: none; }
.topbar-more-btn,
.topbar-back-btn,
.topbar-share-btn {
  width: 38px; height: 38px; border: none; background: none; cursor: pointer;
  color: var(--muted); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.topbar-more-btn:hover,
.topbar-back-btn:hover,
.topbar-share-btn:hover { background: var(--bg-soft); color: var(--text); }
.topbar-menu-list {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 80;
  min-width: 200px; max-height: calc(100vh - 120px); overflow-y: auto;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .14); padding: 6px;
}
.topbar-menu-list.open { display: block; }
.topbar-menu-list a,
.topbar-menu-list button {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border: none; border-radius: var(--radius-sm);
  background: none; color: var(--text); font-family: inherit;
  font-size: .92rem; cursor: pointer; text-decoration: none;
}
.topbar-menu-list a:hover,
.topbar-menu-list button:hover { background: var(--bg-soft); }

/* ----- Login hint (open in Chrome) ----- */
.form-hint { text-align: center; font-size: .85rem; color: var(--muted); margin-top: 14px; }

/* ----- Narrow top bar: the model picker already shows the
     "Farend AI" label, so the title can hide on phones. ----- */
@media (max-width: 640px) {
  .topbar-title { display: none; }
}

/* ============================================================
   DISCOVER FEED (index.html) — suggestions like YouTube /
   Chrome: trending videos + new articles, clean cards.
   ============================================================ */
.sidebar-nav { padding: 10px 14px 0; }
.sidebar-btn.active { background: #ececee; }
.discover-view { flex: 1; overflow-y: auto; min-height: 0; background: #fff; }
.discover-inner { max-width: 960px; margin: 0 auto; padding: 28px 20px 40px; }
.discover-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.discover-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.discover-tabs { display: flex; gap: 6px; }
.discover-tabs button {
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--border-strong);
  color: var(--text); font-family: inherit; font-size: .88rem; font-weight: 600;
}
.discover-tabs button:hover { border-color: var(--accent); color: var(--accent); }
.discover-tabs button.active { background: var(--btn-dark); color: #fff; border-color: var(--btn-dark); }
.discover-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.discover-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column; text-align: left;
  transition: box-shadow .15s ease, border-color .15s ease;
}
a.discover-card { color: var(--text); text-decoration: none; }
a.discover-card:hover { text-decoration: none; box-shadow: 0 4px 16px rgba(0, 0, 0, .07); border-color: var(--border-strong); }
.discover-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9;
  padding: 0; border: none; background: #000; cursor: pointer; overflow: hidden;
}
.discover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.discover-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  display: grid; place-items: center;
}
.discover-play::before {
  content: ""; width: 0; height: 0; margin-left: 4px;
  border-left: 16px solid #fff;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
}
.discover-thumb:hover .discover-play { background: rgba(0, 0, 0, .75); }
.discover-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.discover-card-title {
  font-size: .98rem; font-weight: 600; line-height: 1.4; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin: 0;
}
button.discover-card-title {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: inherit; text-align: left;
}
button.discover-card-title:hover { color: var(--accent); }
.discover-card-snippet {
  font-size: .88rem; color: var(--muted); line-height: 1.5; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.discover-card-meta { font-size: .8rem; color: var(--muted); margin: auto 0 0; padding-top: 6px; }

/* ----- Discover video player modal ----- */
.modal-card.modal-video {
  max-width: 820px; text-align: left; padding: 20px 20px 16px;
  max-height: 92vh; overflow-y: auto;
}
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.video-title { font-size: .95rem; font-weight: 600; color: var(--text); margin: 12px 0 0; }

@media (max-width: 640px) {
  .discover-inner { padding: 20px 14px 32px; }
  .discover-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .discover-card-body { padding: 10px 12px 12px; }
  .discover-card-title { font-size: .88rem; }
  .discover-card-snippet { -webkit-line-clamp: 2; }
}
@media (max-width: 420px) {
  .discover-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   FEATURES ROUND 2 (19 Nov 2026) + CUTE REDESIGN
   Soft, clean, cute, ChatGPT-minimal: plain message sheets,
   plain icons, rounded everything, no shadows on content.
   ============================================================ */

/* ----- Softer borders + shadows everywhere (cute redesign) ----- */
:root {
  --border: #ececec;
  --border-strong: #dddddd;
}
.modal-card { box-shadow: 0 12px 40px rgba(0, 0, 0, .12); }
.model-picker-menu,
.topbar-menu-list,
.sidebar-user-menu,
.user-dropdown { box-shadow: 0 8px 24px rgba(0, 0, 0, .10); }
.toast { box-shadow: 0 6px 20px rgba(0, 0, 0, .20); }

/* ----- Plain message sheets (chat-app-like) ----- */
.ai-msg-user { border-radius: 20px; }
.ai-msg-model.ai-msg-sheet {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 16px;
}
/* Media / typing / ad messages stay plain (no sheet). */
.ai-msg-model .msg-media { margin: 0; }

/* ----- Generated photo/video card (plain, rounded) ----- */
.media-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  max-width: 520px;
}
.media-card img,
.media-card video {
  width: 100%;
  border: none;
  border-radius: 0;
  display: block;
  background: #000;
}
.media-card-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.media-card-actions .ai-download-btn { margin: 0; }
.media-card-actions .msg-regen { margin-left: 0; }

/* ----- Fullscreen image viewer (lightbox) ----- */
.modal-card.modal-media {
  max-width: 900px; text-align: left; padding: 12px;
  max-height: 92vh; overflow-y: auto;
}
.modal-media img {
  width: 100%; border-radius: 12px; display: block;
  background: #000;
}

/* ----- Code blocks (fenced ```lang blocks in AI replies) ----- */
.code-block {
  margin: 10px 0; border: 1px solid #2d2d2d; border-radius: 16px;
  overflow: hidden; background: #171717; max-width: 100%;
}
.code-block-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #262626;
  color: #d4d4d4; font-size: .78rem; font-weight: 600;
}
.code-block-copy {
  background: #404040; color: #fff; border: none; border-radius: 999px;
  padding: 4px 12px; font-family: inherit; font-size: .78rem; font-weight: 600;
  cursor: pointer;
}
.code-block-copy:hover { background: #525252; }
.code-block-pre,
.code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code-block-pre code,
.code-block pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem; line-height: 1.6; color: #f5f5f5; white-space: pre;
}

/* ----- Links in messages + link preview cards ----- */
.msg-link { color: var(--accent); word-break: break-all; }
.link-preview {
  display: flex; gap: 12px; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  background: #fff; color: var(--text); text-decoration: none; max-width: 520px;
}
.link-preview:hover { text-decoration: none; border-color: var(--border-strong); }
.link-preview-img {
  width: 120px; min-height: 90px; object-fit: cover;
  flex: none; background: var(--bg-soft);
}
.link-preview-body {
  padding: 10px 12px; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.link-preview-title {
  font-size: .9rem; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin: 0;
}
.link-preview-desc {
  font-size: .82rem; color: var(--muted); line-height: 1.5; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-preview-host {
  font-size: .76rem; color: var(--muted); margin: auto 0 0; padding-top: 4px;
}

/* ----- Stop button (send slot while generating) ----- */
.ai-send.ai-stop { background: var(--btn-dark); }
.ai-send.ai-stop:hover { background: var(--btn-dark-hover); }

/* ----- Edit message (own messages) ----- */
.msg-edit-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px;
  border-radius: 999px; cursor: pointer;
  background: #fff; border: 1px solid var(--border-strong);
  color: var(--muted); font-family: inherit; font-size: .8rem; font-weight: 600;
}
.msg-edit-btn:hover { border-color: var(--accent); color: var(--accent); }
.msg-edit-box { display: flex; flex-direction: column; gap: 8px; min-width: 220px; }
.msg-edit-input {
  width: 100%; min-height: 64px; padding: 10px 12px;
  border: 1px solid var(--accent); border-radius: 12px; outline: none;
  background: #fff; color: var(--text); font-family: inherit;
  font-size: 1rem; line-height: 1.6; resize: vertical;
}
.msg-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ----- Pin chats (sidebar) ----- */
.history-pin {
  flex: none; width: 24px; height: 24px; border: none; background: none;
  color: var(--muted); cursor: pointer; border-radius: 50%;
  display: none; place-items: center;
}
.history-item:hover .history-pin { display: grid; }
.history-item.pinned .history-pin { display: grid; color: var(--accent); }
.history-pin:hover { color: var(--accent); background: #fff; }
.history-pin.pinned svg { fill: var(--accent); }
.history-section-label {
  padding: 14px 16px 6px; font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; color: var(--muted); text-transform: uppercase;
}

/* ----- Credits flow: real-ad note ----- */
.ad-coming-soon { text-align: center; margin-top: 8px; }

/* ============================================================
   RESPONSIVE — fitted layout for phone AND desktop
   (Round 2, item 7: the phone layout showed everything too big)
   ============================================================ */
@media (max-width: 860px) {
  /* Sidebar is already an overlay drawer here; keep it narrow
     enough to leave a visible edge of the chat behind it. */
  .sidebar { width: 280px; max-width: 84vw; }
}
@media (max-width: 640px) {
  .ai-msg { font-size: .92rem; line-height: 1.65; }
  .ai-msg-user { padding: 8px 13px; }
  .ai-msg-model.ai-msg-sheet { padding: 10px 13px; }
  .chat-empty { padding: 40px 16px 16px; }
  .chat-empty .greeting-title { font-size: 1.5rem; }
  .chat-empty .greeting-sub { font-size: .95rem; }
  .ai-chips button { font-size: .82rem; padding: 8px 12px; }
  .app-topbar { height: 52px; padding: 0 10px; gap: 6px; }
  .model-picker-btn { font-size: .86rem; padding: 6px 8px; }
  .topbar-membership { display: none; }
  .composer { padding: 6px 10px 12px; }
  .composer-box { padding: 10px 8px 6px 14px; border-radius: 24px; }
  /* Text inputs stay at 16px on phones — iOS auto-zooms on
     focus when an input's font is smaller than 16px. */
  .composer-box textarea { font-size: 1rem; }
  .composer-note { font-size: .7rem; margin-top: 8px; }
  .gate { padding: 32px 16px; }
  .gate-feature { flex: 1 1 140px; padding: 12px 14px; }
  .msg-media { max-width: 100%; }
  .media-card { max-width: 100%; }
  .msg-actions { gap: 4px; }
  .msg-copy, .msg-like, .msg-report, .msg-regen-text, .msg-edit-btn {
    padding: 3px 10px; font-size: .76rem;
  }
  .code-block-pre code, .code-block pre code { font-size: .8rem; }
  .link-preview { max-width: 100%; }
  .link-preview-img { width: 96px; min-height: 72px; }
  .discover-inner { padding: 20px 14px 32px; }
}
@media (max-width: 380px) {
  .chat-log { padding: 16px 10px; gap: 14px; }
  .ai-msg { max-width: 96%; font-size: .9rem; }
  .topbar-share-btn { display: none; }
  .composer { padding: 6px 8px 10px; }
  .composer-box { border-radius: 22px; }
  .model-picker-menu { min-width: 0; }
  .history-item { font-size: .86rem; }
}
