:root {
  --color-background-primary: #ffffff;
  --color-background-secondary: #f7f7f8;
  --color-text-primary: #111827;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; font-family: system-ui, -apple-system, sans-serif; background: #fff; }

/* ================================================================
   LOGIN — SPLIT LAYOUT
   ================================================================ */

.login-split-page {
  display: flex;
  flex-direction: row;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ---- Left panel (58%) ---- */
.login-left {
  flex: 0 0 58%;
  width: 58%;
  max-width: 58%;
  height: 100vh;
  background: #f7f7f8;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  padding: 48px 48px;
  box-sizing: border-box;
}
.login-left-inner {
  /* padding handled by .login-left */
}
.login-left-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.login-left-appname {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text-primary);
}
.login-hero-headline {
  font-size: 26px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--color-text-primary);
  margin-bottom: 12px;
}
.login-hero-sub {
  font-size: 15px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 32px;
}
.login-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}

/* Differentiator cards */
.login-diff-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}
.login-diff-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--color-background-primary);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px;
}
.login-diff-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-diff-icon--purple { background: #7F77DD; }
.login-diff-icon--green  { background: #16a34a; }
.login-diff-icon--amber  { background: #d97706; }
.login-diff-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}
.login-diff-body {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}
.login-subject-inline {
  font-family: monospace;
  background: #EEEDFE;
  color: #534AB7;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Example output card */
.login-example-card {
  background: var(--color-background-primary);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 16px;
}
.login-example-user {
  font-size: 13px;
  font-style: italic;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}
.login-example-prompt {
  background: var(--color-background-primary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text-primary);
  margin-bottom: 12px;
}
.login-example-prompt code { font-family: monospace; }
.login-example-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.login-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
}
.login-badge--purple { background: #EEEDFE; color: #534AB7; }
.login-badge--green  { background: #dcfce7; color: #166534; }
.login-badge--amber  { background: #fef3c7; color: #92400e; }

/* ---- Right panel (42%) ---- */
.login-right {
  flex: 0 0 42%;
  width: 42%;
  max-width: 42%;
  height: 100vh;
  background: #f8f7ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 56px;
  box-sizing: border-box;
}
.login-right-inner {
  width: 100%;
  max-width: 380px;
}
.login-right-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.login-right-appname {
  font-size: 24px;
  font-weight: 500;
  color: var(--color-text-primary);
  margin-top: 16px;
}
.login-right-tagline {
  font-size: 15px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 8px;
  line-height: 1.5;
}
.login-card-box {
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 28px;
  margin-top: 32px;
  width: 100%;
}
.login-error {
  color: #dc2626;
  font-size: 13px;
  margin-bottom: 14px;
  text-align: center;
}
.login-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: var(--color-background-primary);
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text-primary);
  text-decoration: none;
  min-height: 44px;
  transition: border-color 0.15s;
}
.login-google-btn:hover { border-color: #7F77DD; color: #534AB7; }
.login-free-note {
  font-size: 13px;
  color: #9ca3af;
  text-align: center;
  margin-top: 12px;
}

/* Stats row */
.login-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 40px;
  width: 100%;
  max-width: 380px;
}
.login-stat {
  flex: 1;
  text-align: center;
}
.login-stat-value {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-text-primary);
}
.login-stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
  white-space: nowrap;
}
.login-stat-divider {
  width: 1px;
  height: 32px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* ---- Legacy .login-page fallback (unused but kept safe) ---- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-background-secondary);
  height: 100vh;
  overflow: auto;
}

/* ---- App Layout ---- */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ---- Hamburger ---- */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-height: 44px;
  min-width: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: #f3f4f6; }
.hamburger-btn svg { display: block; }

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

/* ---- Sidebar close button (mobile) ---- */
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  min-height: 44px;
  min-width: 44px;
  align-items: center;
  justify-content: center;
}
.sidebar-close-btn:hover { background: #f3f4f6; }

/* ---- Sidebar ---- */
.sidebar {
  width: 220px;
  min-width: 220px;
  height: 100vh;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  overflow: hidden;
  transition: transform 0.25s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid #e5e7eb;
}
.app-name { font-weight: 700; font-size: 0.9rem; color: #7c3aed; }
.user-avatar {
  width: 30px; height: 30px;
  background: #7c3aed;
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600;
  cursor: pointer;
}
.new-session-btn {
  display: block;
  margin: 10px 10px 8px;
  padding: 8px 12px;
  background: #7c3aed;
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  transition: background 0.2s;
  min-height: 44px;
  line-height: 28px;
}
.new-session-btn:hover { background: #6d28d9; }
.session-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.session-group-label { padding: 6px 14px 2px; font-size: 0.7rem; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.05em; }
.session-item {
  display: block;
  padding: 8px 14px;
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 6px;
  transition: background 0.15s;
  min-height: 44px;
}
.session-item:hover, .session-item.active { background: #ede9fe; }
.session-item-title { font-size: 0.82rem; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-tool-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 1px 5px;
  background: #ede9fe;
  color: #7c3aed;
  border-radius: 3px;
  margin-top: 2px;
}
.sidebar-footer { padding: 10px 14px; border-top: 1px solid #e5e7eb; }
.logout-link { font-size: 0.8rem; color: #9ca3af; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.logout-link:hover { color: #6b7280; }

/* ---- Main ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: white;
  min-height: 56px;
}
.session-title { font-size: 0.95rem; font-weight: 600; color: #1f2937; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tool-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 4px;
  white-space: nowrap;
}
.generate-btn {
  padding: 7px 14px;
  background: #7c3aed;
  color: white;
  border: none;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  min-height: 44px;
}
.generate-btn:hover:not(:disabled) { background: #6d28d9; }
.generate-btn:disabled { background: #d1d5db; cursor: not-allowed; }

/* ---- Messages ---- */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message { display: flex; align-items: flex-end; gap: 8px; }
.ai-message { align-self: flex-start; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }

.message-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 600;
  flex-shrink: 0;
}
.ai-avatar { background: #1f2937; color: white; }
.user-avatar-circle { background: #7c3aed; color: white; }

.message-bubble {
  background: #f7f7f8;
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 10px 14px;
  max-width: 75%;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #1f2937;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.user-bubble {
  background: #e8f4fd;
  border-radius: 12px;
  border-top-right-radius: 4px;
  color: #1f2937;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}
.typing-dots {
  display: flex;
  gap: 4px;
  background: #f7f7f8;
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 12px 16px;
}
.typing-dot {
  width: 6px; height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Ready-to-generate card */
.ready-card {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  align-self: flex-start;
  max-width: 85%;
}
.ready-card-text { font-size: 0.88rem; color: #1e40af; flex: 1; }
.ready-card-badge {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.ready-generate-btn {
  padding: 7px 14px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 7px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 44px;
}
.ready-generate-btn:hover { background: #1d4ed8; }

/* [SUBJECT] highlight */
.subject-var {
  color: #7c3aed;
  background: #f3e8ff;
  border-radius: 3px;
  padding: 0 3px;
  font-family: monospace;
  font-size: 0.9em;
}

/* Templates */
.templates-section { margin-top: 8px; }
.templates-heading { font-size: 0.95rem; font-weight: 600; color: #374151; margin-bottom: 12px; }
.template-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}
.template-header { margin-bottom: 10px; }
.type-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.type-faithful { background: #dbeafe; color: #1d4ed8; }
.type-cinematic { background: #fef3c7; color: #92400e; }
.type-stylised { background: #f3e8ff; color: #6d28d9; }
.type-experimental { background: #dcfce7; color: #166534; }

.template-text { font-size: 0.88rem; color: #1f2937; line-height: 1.6; margin-bottom: 8px; font-family: monospace; background: #f9fafb; padding: 8px 10px; border-radius: 6px; word-break: break-word; }
.template-example { font-size: 0.83rem; color: #6b7280; margin-bottom: 6px; }
.template-tip { font-size: 0.82rem; color: #9ca3af; font-style: italic; margin-bottom: 10px; }
.copy-btn {
  padding: 6px 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  color: #374151;
  transition: all 0.2s;
  min-height: 44px;
}
.copy-btn:hover { border-color: #7c3aed; color: #7c3aed; }
.copy-btn.copied { background: #dcfce7; border-color: #86efac; color: #166534; }

/* ---- Completion banner ---- */
.completion-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 10px 16px;
  font-size: 13px;
  text-align: center;
}

/* ---- Input ---- */
.input-bar {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  background: white;
}
.message-input {
  flex: 1;
  resize: none;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  max-height: 120px;
  overflow-y: auto;
}
.message-input:focus { border-color: #7c3aed; }
.send-btn {
  padding: 10px 18px;
  background: #7c3aed;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  align-self: flex-end;
  min-height: 44px;
}
.send-btn:hover { background: #6d28d9; }
.send-btn:disabled { background: #d1d5db; cursor: not-allowed; }

/* ================================================================
   TABLET  768px – 1024px
   ================================================================ */
@media (max-width: 1024px) {
  .sidebar {
    width: 180px;
    min-width: 180px;
  }
  .message-bubble {
    max-width: 80%;
  }
}

/* ================================================================
   TABLET  login panel  768px – 1024px
   ================================================================ */
@media (max-width: 1024px) and (min-width: 769px) {
  .login-left { flex: 0 0 55%; width: 55%; max-width: 55%; padding: 40px 36px; }
  .login-right { flex: 0 0 45%; width: 45%; max-width: 45%; padding: 40px 36px; }
  .login-right-inner { max-width: 320px; }
  .login-stats { max-width: 320px; }
}

/* ================================================================
   MOBILE  ≤ 768px
   ================================================================ */
@media (max-width: 768px) {
  /* html/body: allow page to scroll on mobile */
  html, body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  /* Login split → vertical stack: hero on top, login below */
  .login-split-page {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .login-left {
    flex: none;
    width: 100%;
    max-width: 100%;
    height: auto;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: 32px 24px;
  }
  .login-right {
    flex: none;
    width: 100%;
    max-width: 100%;
    height: auto;
    padding: 32px 24px;
    align-items: stretch;
    justify-content: flex-start;
  }
  .login-right-inner {
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
  }
  .login-stats { max-width: 100%; margin-top: 28px; }
  /* Hide example card and right-side logo on mobile */
  .login-example-card { display: none; }
  .login-right-logo { display: none; }
  .login-right-tagline { text-align: left; margin-top: 0; margin-bottom: 20px; }
  .login-hero-headline { font-size: 20px; }
  /* Diff cards full width */
  .login-diff-cards { gap: 10px; }
  /* Show hamburger, hide close btn by default (shown when overlay active) */
  .hamburger-btn { display: flex; }

  /* Sidebar becomes a fixed overlay, hidden off-screen by default */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    min-width: 260px;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close-btn { display: flex; }

  /* Main takes full width */
  .main { width: 100%; }

  /* Header tweaks */
  .chat-header {
    padding: 8px 12px;
    gap: 8px;
  }
  .generate-btn {
    font-size: 0.75rem;
    padding: 6px 10px;
  }

  /* Message area */
  .messages-area {
    padding: 12px;
    gap: 10px;
  }
  .message-bubble {
    max-width: 85%;
    padding: 8px 12px;
    font-size: 14px;
  }

  /* Template cards */
  .template-card {
    margin-left: 0;
    margin-right: 0;
    border-radius: 6px;
  }
  .copy-btn {
    width: 100%;
    text-align: center;
  }

  /* Input bar */
  .input-bar {
    padding: 8px 10px;
    gap: 6px;
  }
  .message-input {
    font-size: 16px; /* prevents iOS zoom */
    padding: 10px 12px;
  }
  .send-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  /* Login page */
  .login-card {
    padding: 32px 24px;
  }
  .login-title { font-size: 1.4rem; }
}
