/* ================================================================
   Roest Roast Coach — Design System
   ================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

/* ─── Tokens ─────────────────────────────────────────────────── */
/* Calibre theme — two-color monochrome: #F2F0EF (light) / #101010 (ink).
   Legacy token names are kept and remapped so all existing var(--…) usages
   adopt the new palette without per-file churn. */
:root {
  --paper:   #F2F0EF;   /* main light surface */
  --ink:     #101010;   /* main dark — text, accent, negative buttons */

  /* Remapped legacy tokens */
  --coffee:  #101010;   /* was brown heading color */
  --coffee-light: #2A2A2A;
  --ember:   #101010;   /* was accent orange → now black accent */
  --ember-hover: #2A2A2A;
  --crema:   #F2F0EF;   /* light accent — used as light text on dark surfaces */
  --cream:   #F2F0EF;
  --sand:    #E2DFDD;   /* light border / subtle fill */
  --muted:   #6B6B6B;   /* mid-gray muted text */
  --hilite:  #FAF9F8;   /* very light input fill */
  --rule:    #D6D2CF;   /* input border */
  --white:   #FFFFFF;
  --success: #2D7D46;
  --danger:  #C53030;
  --danger-hover: #9B2C2C;

  /* Admin dark palette (derived from the same two colors) */
  --dark-bg:      #101010;
  --dark-surface: #181818;
  --dark-card:    #1E1E1E;
  --dark-border:  #2E2E2E;
  --dark-text:    #F2F0EF;
  --dark-muted:   #8A8A8A;

  /* Corner radius (Calibre-style, subtle) */
  --radius:    8px;   /* cards, buttons, inputs, modals */
  --radius-sm: 4px;   /* small chips / file-info */
  --radius-lg: 18px;  /* feature panels, hero badges */
  --radius-pill: 999px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.15);
  --shadow-glow: 0 0 30px rgba(16,16,16,.12);
}

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: 'Montserrat', Georgia, serif;
  color: var(--coffee);
  margin: 0 0 .5em;
  line-height: 1.25;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; color: var(--ember); letter-spacing: .02em; text-transform: uppercase; }
p { margin: 0 0 .8em; }
a { color: var(--ember); text-decoration: none; transition: color .2s var(--ease); }
a:hover { color: var(--ember-hover); }

/* ─── Layout helpers ─────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ─── Header ─────────────────────────────────────────────────── */
.site-header {
  background: var(--ink);
  color: var(--cream);
  padding: 20px 0;
  border-bottom: 1px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}
.site-header .wrap {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.site-header .brand {
  display: flex; align-items: center; gap: 14px;
}
.site-header .brand-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--paper); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(16,16,16,.3);
}
.site-header h1 {
  color: var(--cream); margin: 0; font-size: 1.4rem;
  letter-spacing: .02em;
}
.site-header .sub {
  color: rgba(242,240,239,.7); font-family: 'Montserrat', sans-serif;
  font-size: 13px; margin-top: 1px;
}
.site-header nav { display: flex; align-items: center; gap: 6px; }
.site-header nav a {
  color: var(--paper); font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: var(--radius-sm);
  transition: all .2s var(--ease);
}
.site-header nav a:hover { color: var(--white); background: rgba(242,240,239,.12); }
.site-header nav .btn-nav {
  background: transparent; color: var(--paper);
  border: 1px solid rgba(242,240,239,.4);
}
.site-header nav .btn-nav:hover {
  background: var(--paper); color: var(--ink); border-color: var(--paper);
}

/* ─── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--sand);
  border-top: 4px solid var(--ember);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 24px 28px;
  margin-bottom: 24px;
  transition: box-shadow .3s var(--ease), transform .3s var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }
.card.coffee { border-top-color: var(--coffee); }
.card.crema  { border-top-color: var(--ink); }
.card.glass {
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(232,217,191,.5);
}

/* ─── Forms ──────────────────────────────────────────────────── */
label {
  display: block; font-weight: 600; color: var(--coffee);
  font-size: 12px; margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .06em;
  font-family: 'Montserrat', sans-serif;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%; padding: 10px 14px; font-size: 14px;
  border: 1px solid var(--rule); border-radius: 6px;
  background: var(--hilite); color: var(--ink);
  font-family: 'Montserrat', sans-serif;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--ember);
  box-shadow: 0 0 0 3px rgba(16,16,16,.12);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.row { display: grid; gap: 14px; margin-bottom: 14px; }
.row.two { grid-template-columns: 1fr 1fr; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 600px) {
  .row.two, .row.three { grid-template-columns: 1fr; }
}

/* ─── Buttons ────────────────────────────────────────────────── */
button, .btn {
  cursor: pointer; font-family: 'Montserrat', sans-serif; font-size: 14px;
  border: none; border-radius: var(--radius); padding: 12px 20px;
  font-weight: 600; letter-spacing: .03em;
  transition: all .2s var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
/* Negative (inverted) primary button: black fill → inverts to outline on hover */
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  text-transform: uppercase;
}
.btn-primary:hover {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--ink);
}
.btn-primary:disabled {
  background: var(--rule); color: var(--paper);
  border-color: var(--rule); box-shadow: none;
  cursor: not-allowed; transform: none;
}
.btn-primary.full { width: 100%; padding: 14px; }
.btn-ghost {
  background: transparent; color: var(--coffee);
  border: 1px solid var(--rule);
}
.btn-ghost:hover { background: var(--cream); }
.btn-danger {
  background: var(--danger); color: var(--white);
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-success {
  background: var(--success); color: var(--white);
}

/* ─── Spinner ────────────────────────────────────────────────── */
.spin {
  display: inline-block; width: 28px; height: 28px;
  border: 3px solid var(--sand); border-top-color: var(--ember);
  border-radius: 50%; animation: spin-rotate 0.8s linear infinite;
}
@keyframes spin-rotate { to { transform: rotate(360deg); } }

/* ─── Dropzone ───────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--rule);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  background: var(--hilite);
  transition: all .2s var(--ease);
  cursor: pointer;
}
.dropzone:hover, .dropzone.hover {
  background: var(--sand); border-color: var(--ember);
}
.dropzone .icon { font-size: 28px; color: var(--ember); margin-bottom: 8px; }
.dropzone strong { color: var(--coffee); }
.dropzone small { color: var(--muted); display: block; margin-top: 4px; }
.dropzone input[type="file"] { display: none; }

/* ─── File Info ──────────────────────────────────────────────── */
.file-info {
  display: none; margin-top: 12px; padding: 10px 14px;
  background: var(--cream); border-left: 3px solid var(--ember);
  border-radius: 4px; font-size: 13px;
}
.file-info.show { display: block; }
.file-info .name { font-weight: 600; color: var(--coffee); }
.file-info .clear { float: right; cursor: pointer; color: var(--muted); transition: color .2s; }
.file-info .clear:hover { color: var(--danger); }

/* ─── Diagnosis Output ───────────────────────────────────────── */
.diagnosis { background: var(--white); border-radius: 8px; padding: 32px; border: 1px solid var(--sand); }
.diagnosis section { padding: 18px 0; border-bottom: 1px solid var(--sand); }
.diagnosis section:last-child { border-bottom: none; }
.diagnosis h3 { color: var(--ember); margin-bottom: 10px; }
.diagnosis .root-cause {
  background: var(--hilite);
  border-left: 4px solid var(--ember);
  padding: 16px 20px;
  font-family: 'Montserrat', serif;
  font-size: 17px;
  color: var(--coffee);
  border-radius: 0 4px 4px 0;
}
.diagnosis .fix {
  background: var(--ink);
  color: var(--cream);
  padding: 18px 22px; border-radius: var(--radius);
}
.diagnosis .fix strong {
  color: var(--crema); display: block; margin-bottom: 6px;
  text-transform: uppercase; font-size: 11px;
  letter-spacing: .08em; font-family: 'Montserrat', sans-serif;
}
.profile-table {
  width: 100%; border-collapse: collapse; margin-top: 8px;
}
.profile-table th, .profile-table td {
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--sand); font-size: 13px;
}
.profile-table th {
  background: var(--coffee); color: var(--white);
  font-family: 'Montserrat', sans-serif; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
}
.profile-table tr:nth-child(even) td { background: var(--hilite); }

/* ─── Samples ────────────────────────────────────────────────── */
.samples { margin-top: 10px; font-size: 12px; }
.samples a {
  color: var(--ember); margin-right: 12px; cursor: pointer;
  border-bottom: 1px dashed var(--ember);
  padding-bottom: 1px; transition: all .2s var(--ease);
}
.samples a:hover { color: var(--coffee); border-color: var(--coffee); }

/* ─── Footer ─────────────────────────────────────────────────── */
.site-footer {
  text-align: center; padding: 30px 20px;
  color: var(--muted); font-size: 12px;
  font-style: italic; font-family: 'Montserrat', serif;
  border-top: 1px solid var(--sand);
  margin-top: 60px;
}

/* ─── Chat Interface ─────────────────────────────────────────── */
.chat-container {
  display: flex; flex-direction: column;
  height: calc(100vh - 73px);
  max-width: 900px; margin: 0 auto;
}
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 24px 24px 12px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--sand); border-radius: 3px; }

.chat-bubble {
  max-width: 85%; margin-bottom: 16px;
  animation: chat-in .3s var(--ease);
}
@keyframes chat-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-bubble.user {
  margin-left: auto;
}
.chat-bubble.user .bubble-content {
  background: var(--ink);
  color: var(--paper);
  border-radius: 16px 16px 4px 16px;
  padding: 12px 18px;
}
.chat-bubble.assistant .bubble-content {
  background: var(--white);
  border: 1px solid var(--sand);
  border-radius: 16px 16px 16px 4px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.chat-bubble .bubble-meta {
  font-size: 11px; color: var(--muted); margin-top: 4px;
  padding: 0 4px;
}
.chat-bubble.user .bubble-meta { text-align: right; }

/* Chat markdown content */
.chat-bubble.assistant .bubble-content h3 {
  font-size: 14px; margin: 16px 0 8px 0;
  color: var(--ember);
}
.chat-bubble.assistant .bubble-content h3:first-child { margin-top: 0; }
.chat-bubble.assistant .bubble-content p { margin: 0 0 8px; font-size: 14px; line-height: 1.6; }
.chat-bubble.assistant .bubble-content ul, .chat-bubble.assistant .bubble-content ol {
  margin: 0 0 8px; padding-left: 18px; font-size: 14px;
}
.chat-bubble.assistant .bubble-content code {
  background: var(--hilite); padding: 1px 5px; border-radius: 3px;
  font-size: 13px; color: var(--coffee);
}
.chat-bubble.assistant .bubble-content pre {
  background: var(--hilite); padding: 12px; border-radius: 6px;
  overflow-x: auto; font-size: 12px; margin: 8px 0;
}
.chat-bubble.assistant .bubble-content strong { color: var(--coffee); }
.chat-bubble.assistant .bubble-content table {
  width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px;
}
.chat-bubble.assistant .bubble-content th,
.chat-bubble.assistant .bubble-content td {
  padding: 6px 10px; border-bottom: 1px solid var(--sand); text-align: left;
}
.chat-bubble.assistant .bubble-content th { background: var(--hilite); font-weight: 600; color: var(--coffee); }

/* Chat input area */
.chat-input-area {
  padding: 16px 24px 24px;
  background: linear-gradient(to top, var(--cream) 60%, transparent);
}
.chat-input-wrap {
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--white);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  padding: 8px 8px 8px 18px;
  box-shadow: var(--shadow-md);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.chat-input-wrap:focus-within {
  border-color: var(--ember);
  box-shadow: var(--shadow-md), 0 0 0 3px rgba(16,16,16,.08);
}
.chat-input {
  flex: 1; border: none; outline: none; resize: none;
  font-family: 'Montserrat', sans-serif; font-size: 14px;
  background: transparent; color: var(--ink);
  min-height: 24px; max-height: 150px;
  line-height: 1.5; padding: 6px 0;
}
.chat-input::placeholder { color: var(--muted); }
.chat-send {
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper); border: 1px solid var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .2s var(--ease);
}
.chat-send:hover {
  background: var(--paper); color: var(--ink);
}
.chat-send:disabled {
  background: var(--rule); box-shadow: none;
  cursor: not-allowed; transform: none;
}
.chat-send svg { width: 18px; height: 18px; }

/* Chat welcome */
.chat-welcome {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; text-align: center; padding: 40px 24px;
}
.chat-welcome .icon-large {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; margin-bottom: 20px;
  box-shadow: var(--shadow-glow);
}
.chat-welcome h2 { margin-bottom: 8px; }
.chat-welcome p { color: var(--muted); max-width: 480px; font-size: 14px; }
.chat-starters {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 20px; max-width: 600px;
}
.chat-starter {
  background: var(--white); border: 1px solid var(--sand);
  border-radius: var(--radius); padding: 10px 16px;
  font-size: 13px; color: var(--coffee); cursor: pointer;
  transition: all .2s var(--ease);
  box-shadow: var(--shadow-sm);
}
.chat-starter:hover {
  border-color: var(--ember); background: var(--hilite);
  transform: translateY(-2px); box-shadow: var(--shadow-md);
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex; gap: 4px; padding: 12px 18px;
}
.typing-indicator span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce .6s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 100% { transform: translateY(0); opacity: .4; }
  50% { transform: translateY(-6px); opacity: 1; }
}

/* ─── Login / Auth Pages ─────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--cream) 0%, var(--sand) 100%);
  padding: 24px;
}
.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--ember);
}
.auth-card .logo {
  text-align: center; margin-bottom: 28px;
}
.auth-card .logo .icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; margin-bottom: 12px;
  box-shadow: var(--shadow-glow);
}
.auth-card .logo h2 { margin: 0; font-size: 1.5rem; }
.auth-card .logo p { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.auth-card .form-group { margin-bottom: 18px; }
.auth-card .error-msg {
  background: #FEE2E2; color: #991B1B; padding: 10px 14px;
  border-radius: 6px; font-size: 13px; margin-bottom: 16px;
  display: none; border-left: 3px solid var(--danger);
}
.auth-card .error-msg.show { display: block; animation: shake .4s var(--ease); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ─── Admin Panel (Dark Theme) ───────────────────────────────── */
.admin-body {
  background: var(--dark-bg);
  color: var(--dark-text);
}
.admin-body .site-header {
  background: var(--dark-surface);
  border-bottom-color: var(--dark-border);
}
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 73px);
}
@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
}

.admin-sidebar {
  background: var(--dark-surface);
  border-right: 1px solid var(--dark-border);
  padding: 24px 0;
}
.admin-sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 24px; color: var(--dark-muted);
  font-size: 14px; cursor: pointer;
  transition: all .2s var(--ease);
  border-left: 3px solid transparent;
}
.admin-sidebar .nav-item:hover {
  background: rgba(242,240,239,.06); color: var(--dark-text);
}
.admin-sidebar .nav-item.active {
  color: var(--dark-text); border-left-color: var(--dark-text);
  background: rgba(242,240,239,.09);
}
.admin-sidebar .nav-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--dark-muted); padding: 20px 24px 8px;
  font-weight: 600;
}

.admin-main {
  padding: 32px;
  overflow-y: auto;
}

/* Admin stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all .2s var(--ease);
}
.stat-card:hover {
  border-color: var(--dark-muted);
  box-shadow: 0 0 20px rgba(0,0,0,.35);
}
.stat-card .stat-label {
  font-size: 12px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--dark-muted);
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 2rem; font-weight: 700;
  color: var(--crema);
  font-family: 'Montserrat', sans-serif;
}
.stat-card .stat-sub {
  font-size: 12px; color: var(--dark-muted); margin-top: 4px;
}

/* Admin tables */
.admin-table {
  width: 100%; border-collapse: collapse;
}
.admin-table th, .admin-table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--dark-border);
  font-size: 14px;
}
.admin-table th {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--dark-muted);
  font-weight: 600; font-family: 'Montserrat', sans-serif;
}
.admin-table tr:hover td {
  background: rgba(242,240,239,.04);
}

/* Admin cards */
.admin-card {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.admin-card h3 {
  color: var(--crema); text-transform: none;
  letter-spacing: 0; font-family: 'Montserrat', serif;
  margin-bottom: 16px;
}

/* Dark form inputs */
.admin-body input[type="text"],
.admin-body input[type="email"],
.admin-body input[type="password"],
.admin-body input[type="number"],
.admin-body select {
  background: var(--dark-bg);
  border-color: var(--dark-border);
  color: var(--dark-text);
}
.admin-body input:focus, .admin-body select:focus {
  border-color: var(--dark-text);
  box-shadow: 0 0 0 3px rgba(242,240,239,.12);
}
.admin-body label { color: var(--dark-muted); }

/* Status badge */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: var(--radius-pill); font-size: 11px;
  font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-active { background: rgba(45,125,70,.15); color: #4ADE80; }
.badge-inactive { background: rgba(197,48,48,.15); color: #FC8181; }
.badge-admin { background: rgba(242,240,239,.12); color: var(--dark-text); }

/* Toggle switch */
.toggle {
  position: relative; display: inline-block;
  width: 44px; height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--dark-border); border-radius: 24px;
  transition: background .3s var(--ease);
}
.toggle .slider::before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: var(--white); border-radius: 50%;
  transition: transform .3s var(--ease);
}
.toggle input:checked + .slider { background: var(--success); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease);
}
.modal-overlay.show {
  opacity: 1; pointer-events: auto;
}
.modal {
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%; max-width: 480px;
  transform: translateY(20px);
  transition: transform .3s var(--ease);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal h3 {
  color: var(--crema); margin: 0 0 20px;
  text-transform: none; letter-spacing: 0;
}
.modal .form-group { margin-bottom: 16px; }
.modal .modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 24px;
}

/* ─── Notification Toast ─────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--coffee); color: var(--cream);
  padding: 14px 20px; border-radius: 8px;
  font-size: 14px; z-index: 2000;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px); opacity: 0;
  transition: all .3s var(--ease);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .4s var(--ease); }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 15px rgba(16,16,16,.1); }
  50% { box-shadow: 0 0 30px rgba(16,16,16,.25); }
}

/* ─── Responsive / Mobile ────────────────────────────────────── */
/* Tablet & below: tighten the shared header so the brand + nav don't
   overflow once the viewport gets narrow. */
@media (max-width: 768px) {
  .container,
  .site-header .wrap { padding-left: 16px; padding-right: 16px; }

  .site-header { padding: 14px 0; }
  .site-header .wrap {
    flex-wrap: wrap;
    gap: 10px 16px;
  }
  .site-header .brand { gap: 10px; }
  .site-header h1 { font-size: 1.15rem; }
  .site-header nav { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .site-header nav a { padding: 6px 10px; }

  .features { padding: 56px 16px; }
  .features h2 { font-size: 1.6rem; margin-bottom: 32px; }

  /* The header is taller on mobile, so the fixed desktop offset would
     push the input area off-screen — recompute and use dvh where supported. */
  .chat-container { height: calc(100vh - 64px); height: calc(100dvh - 64px); }
  .chat-bubble { max-width: 92%; }
  .chat-messages { padding: 16px 16px 8px; }
  .chat-input-area { padding: 12px 16px 16px; }

  /* Admin tables can scroll horizontally instead of squishing. */
  .admin-main { overflow-x: auto; }
  .admin-main table { min-width: 640px; }
}

/* Phones: stack the header (brand over nav) and drop the long tagline,
   which is decorative and eats the whole width on small screens. */
@media (max-width: 480px) {
  .site-header .wrap {
    flex-direction: column;
    align-items: flex-start;
  }
  .site-header .sub { display: none; }
  .site-header nav {
    width: 100%;
    justify-content: flex-start;
  }
  .site-header h1 { font-size: 1.05rem; }

  .chat-container { height: calc(100vh - 112px); height: calc(100dvh - 112px); }

  .card { padding: 20px 18px; }
  .auth-card { padding: 28px 22px; }

  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }
}
