/* ══════════════════════════════════════════════════════════════
   Kobi Design System
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ─── Design tokens ─────────────────────────────────────────── */
:root {
  /* Core palette */
  --teal:        #00B4B4;
  --teal-dark:   #009999;
  --teal-light:  #E0F7F7;
  --teal-bg:     #C8F0F0;
  --navy:        #0F2A35;
  --navy-mid:    #1B3A47;

  /* Neutrals */
  --white:       #FFFFFF;
  --bg-app:      #F2F3F5;
  --bg-card:     #FFFFFF;
  --bg-panel:    #FFFFFF;
  --border:      #E2E4E8;
  --border-light:#EDEFF2;

  /* Text */
  --text-primary:   #1A2332;
  --text-secondary: #5A6474;
  --text-muted:     #8A93A2;
  --text-mono:      #2C3E50;

  /* Status */
  --green-notice:   #7CB518;
  --green-notice-bg:#F4FAE8;

  /* Sidebar */
  --sidebar-w:   68px;

  /* Typography */
  --font-sans: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-full:9999px;

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

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 18px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; }

/* ─── Layout shell ───────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 24px;
  z-index: 100;
  background: transparent;
}

.sidebar-logo {
  width: 42px; height: 42px;
  background: var(--navy);
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .2s;
}
.sidebar-logo:hover { transform: scale(1.06); }
.sidebar-logo svg   { width: 26px; height: 14px; }

.sidebar-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.btn-add {
  width: 42px; height: 42px;
  background: var(--teal);
  border: none; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0,180,180,.35);
  transition: background .2s, transform .15s;
}
.btn-add:hover { background: var(--teal-dark); transform: scale(1.08); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: auto 0;
}

.sidebar-nav-btn {
  width: 42px; height: 42px;
  background: var(--navy);
  border: none; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,.75);
  transition: background .2s, color .2s;
}
.sidebar-nav-btn:hover,
.sidebar-nav-btn.active { background: var(--navy-mid); color: #fff; }

/* ─── Top bar ────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 90;
  background: transparent;
}

.topbar-tabs {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 18px;
  border: none; border-radius: var(--r-full);
  background: var(--teal);
  color: #fff;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 400;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.tab-btn:hover    { background: var(--teal-dark); }
.tab-btn.inactive { background: rgba(0,180,180,.15); color: var(--teal); }
.tab-btn svg      { width: 14px; height: 14px; opacity: .85; }

.topbar-right {
  display: flex; align-items: center; gap: 10px;
}

.btn-new-exploration {
  display: flex; align-items: center; gap: 5px;
  background: var(--teal); border: none; border-radius: var(--r-sm);
  color: #fff; font-family: var(--font-mono); font-size: .72rem;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn-new-exploration:hover { background: var(--teal-dark); }

.avatar {
  width: 34px; height: 34px;
  background: #8FBF00;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-sans);
  font-weight: 600; font-size: .9rem;
  color: #fff;
  cursor: pointer;
}

.btn-settings {
  width: 34px; height: 34px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .15s;
}
.btn-settings:hover { background: var(--border-light); }

/* ─── Main content area ──────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  padding-top: 64px;
  min-height: 100vh;
  flex: 1;
}

.page-content {
  padding: 28px 32px;
}

/* ─── Panel / white card ─────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
}

.panel-title {
  font-family: var(--font-mono);
  font-size: 1.1rem; font-weight: 400;
  color: var(--text-primary);
}

.panel-controls {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted);
}

.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 2px;
  display: flex; align-items: center;
  transition: color .15s;
}
.icon-btn:hover { color: var(--text-primary); }

/* ─── Explore grid ───────────────────────────────────────────── */
.explore-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 16px;
  height: calc(100vh - 64px - 56px);
  padding: 28px 32px;
}

.explore-grid .panel { display: flex; flex-direction: column; }

.panel-body {
  flex: 1;
  overflow: auto;
  padding: 0 18px 18px;
}

/* Knowledge space graph placeholder */
.graph-canvas {
  width: 100%; height: 100%;
  min-height: 240px;
  background: var(--bg-app);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .75rem;
}

/* ─── Chat ───────────────────────────────────────────────────── */
.chat-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  min-height: 160px;
}

.chat-logo {
  width: 56px; height: 56px;
  background: var(--navy);
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  opacity: .18;
}

.chat-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border-light);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-secondary);
  placeholder-color: var(--text-muted);
}

.btn-send {
  width: 30px; height: 30px;
  background: var(--border-light);
  border: none; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: background .15s;
}
.btn-send:hover { background: var(--teal); color: #fff; }

.clipboard-only-toggle {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--text-muted);
}

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 32px; height: 18px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--teal); }
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); }

/* ─── Lexicon ────────────────────────────────────────────────── */
.lexicon-search {
  background: none; border: none; outline: none;
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--text-muted);
  width: 140px;
}

.lexicon-item {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light);
}

.lexicon-num {
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--text-muted); margin-bottom: 2px;
}

.lexicon-term {
  font-family: var(--font-mono); font-size: 1.05rem;
  font-weight: 500; color: var(--text-primary);
}

.lexicon-concept {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
}

.concept-label {
  font-family: var(--font-mono); font-size: .75rem;
  color: var(--text-secondary);
}

.btn-expand {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 12px;
  background: var(--teal);
  color: #fff;
  border: none; border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: .72rem;
  cursor: pointer; transition: background .15s;
}
.btn-expand:hover { background: var(--teal-dark); }

/* ─── Clipboard cards ────────────────────────────────────────── */
.clipboard-empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 40px 16px; color: var(--text-muted);
  font-family: var(--font-mono); font-size: .75rem; text-align: center;
}

.clipboard-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  overflow: hidden;
}

.clipboard-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 4px;
}

.clipboard-card-title {
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 190px;
}

.clipboard-card-preview {
  padding: 0 12px;
}
.clipboard-card-preview img {
  width: 100%; max-height: 130px; object-fit: cover;
  border-radius: var(--r-sm); display: block;
}
.preview-text {
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--text-secondary); line-height: 1.5;
  max-height: 72px; overflow: hidden;
  margin: 0;
}

.clipboard-card-meta {
  padding: 4px 12px 6px;
  font-family: var(--font-mono); font-size: .65rem; color: var(--text-muted);
}

.clipboard-card-actions {
  display: flex; gap: 2px;
  padding: 6px 10px 8px;
  border-top: 1px solid var(--border-light);
}
.cb-action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 5px;
  border-radius: var(--r-sm); transition: background .12s, color .12s;
}
.cb-action-btn:hover { background: var(--teal-light); color: var(--teal-dark); }
.cb-action-btn:disabled { opacity: .5; cursor: default; }
.cb-action-btn:disabled:hover { background: none; color: var(--text-muted); }
.cb-action-soon { opacity: .35; cursor: not-allowed; }
.cb-action-soon:hover { background: none !important; color: var(--text-muted) !important; }

.cb-header-btn { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 6px; }
.cb-header-btn:hover { border-color: var(--teal); background: var(--teal-light); color: var(--teal-dark); }

/* ── View modal ──────────────────────────────────────────────── */
.view-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,42,53,.45); z-index: 200;
}
.view-modal-overlay.open { display: block; }

.view-modal {
  display: none; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(860px, 92vw); max-height: 88vh;
  background: var(--bg-panel); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); z-index: 201;
  flex-direction: column; overflow: hidden;
}
.view-modal.open { display: flex; }

.view-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 24px 14px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.view-modal-title {
  font-family: var(--font-mono); font-size: .95rem; font-weight: 500;
  color: var(--text-primary); margin-bottom: 3px;
}
.view-modal-meta {
  font-family: var(--font-mono); font-size: .72rem; color: var(--text-muted);
}
.view-modal-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}
.view-modal-text {
  font-family: var(--font-mono); font-size: .82rem; line-height: 1.7;
  color: var(--text-primary); white-space: pre-wrap;
}

.view-method-section { margin-bottom: 18px; }
.view-method-section:last-child { margin-bottom: 0; }
.view-method-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 6px;
}
.view-method-body { font-size: .88rem; color: var(--text-primary); line-height: 1.6; }
.view-method-phase { margin-bottom: 6px; }
.view-method-phase strong { margin-right: 4px; color: var(--teal-dark, var(--text-primary)); }

.btn-expand-sm {
  padding: 3px 10px;
  background: var(--border-light);
  border: none; border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: .7rem;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  transition: background .15s;
}
.btn-expand-sm:hover { background: var(--teal-light); color: var(--teal); }

/* ─── K-Box ──────────────────────────────────────────────────── */
.kbox-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 24px;
}

.kbox-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.kbox-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--border-light);
}

.kbox-card-title {
  font-family: var(--font-mono); font-size: .75rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}

.kbox-card-img {
  width: 100%; aspect-ratio: 4/3;
  object-fit: cover;
}

.kbox-card-img-placeholder {
  width: 100%;
  background: var(--bg-app);
  aspect-ratio: 4/3;
  display: flex; align-items: center; justify-content: center;
}
.kbox-card-img-placeholder span {
  font-family: var(--font-mono); font-size: .7rem;
  color: var(--text-muted);
}

.kbox-card-footer {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
}
.kbox-card-footer svg { width: 15px; height: 15px; cursor: pointer; }
.kbox-card-footer svg:hover { color: var(--teal); }

/* ─── History ────────────────────────────────────────────────── */
.history-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  padding: 28px 32px;
  min-height: calc(100vh - 64px);
}

.history-list-panel {
  background: var(--bg-panel);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.history-list-header {
  padding: 22px 22px 14px;
  font-family: var(--font-mono); font-size: 1.1rem;
  font-weight: 500;
}

.history-item {
  padding: 11px 22px;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s;
}
.history-item:hover { background: var(--border-light); }
.history-item.active { background: var(--teal); color: #fff; }
.history-item.active .history-item-date { color: rgba(255,255,255,.7); }

.history-item-label {
  font-family: var(--font-mono); font-size: .8rem; font-weight: 400;
}
.history-item-date {
  font-family: var(--font-mono); font-size: .7rem;
  color: var(--text-muted); margin-top: 1px;
}

.history-detail-panel {
  background: var(--bg-panel);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.history-detail-title {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 1rem; font-weight: 500;
  margin-bottom: 4px;
}

.history-detail-date {
  font-family: var(--font-mono); font-size: .75rem;
  color: var(--text-muted); margin-bottom: 20px;
}

.history-section-label {
  display: inline-block;
  padding: 5px 14px;
  background: var(--teal-bg);
  color: var(--teal-dark);
  border-radius: var(--r-full);
  font-family: var(--font-mono); font-size: .75rem;
  margin: 10px 0 14px;
}

.history-divider {
  border: none;
  border-top: 1px solid var(--teal-bg);
  margin: 4px 0;
}

.history-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ─── Login ──────────────────────────────────────────────────── */
.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.login-left {
  background: var(--navy);
  display: flex; flex-direction: column;
  padding: 48px 52px;
}

.login-left-logo {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: auto;
}

.login-left-logo-mark {
  color: rgba(255,255,255,.9);
}

.login-left-logo-text {
  font-family: var(--font-sans); font-size: 2.6rem;
  font-weight: 300; color: #fff; letter-spacing: -.5px;
}

.login-tagline {
  font-family: var(--font-sans); font-size: .88rem; font-weight: 300;
  color: rgba(255,255,255,.65); line-height: 1.6;
  max-width: 460px; margin-bottom: 48px;
}

.login-partners { margin-top: auto; }
.login-partners-label {
  font-family: var(--font-mono); font-size: .7rem; font-weight: 500;
  color: rgba(255,255,255,.4); letter-spacing: .06em;
  text-transform: uppercase; margin-bottom: 14px;
}

.login-partners-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 24px;
}
.login-partner-item {
  font-family: var(--font-mono); font-size: .68rem;
  color: rgba(255,255,255,.45); line-height: 1.5;
}

.login-right {
  background: var(--bg-app);
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
}

.login-form-box {
  width: 100%; max-width: 400px;
}

.login-title {
  font-family: var(--font-sans); font-size: 1.9rem;
  font-weight: 600; color: var(--text-primary); margin-bottom: 6px;
}

.login-subtitle {
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--text-muted); margin-bottom: 28px;
}

.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-family: var(--font-mono); font-size: .75rem;
  color: var(--text-secondary); margin-bottom: 5px;
}
.form-label sup { color: var(--teal); }

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: .85rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--teal); }

.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-right: 42px; }
.input-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--teal);
  color: #fff;
  border: none; border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: .85rem;
  letter-spacing: .05em;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
}
.btn-login:hover { background: var(--teal-dark); }

.login-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px;
}

.checkbox-label {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: .75rem;
  color: var(--text-secondary); cursor: pointer;
}

.form-checkbox { accent-color: var(--teal); }

.link-forgot {
  font-family: var(--font-mono); font-size: .75rem;
  color: var(--text-primary); text-decoration: underline;
  text-underline-offset: 2px;
}

.alert-error {
  background: #FEE;
  border: 1px solid #FBB;
  border-radius: var(--r-sm);
  padding: 9px 14px;
  font-family: var(--font-mono); font-size: .78rem;
  color: #B00;
  margin-bottom: 14px;
}

/* ─── Settings drawer ────────────────────────────────────────── */
.settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  display: none;
}
.settings-overlay.open { display: block; }

.settings-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 560px;
  background: var(--bg-app);
  z-index: 201;
  transform: translateX(100%);
  transition: transform .3s ease;
  display: flex; flex-direction: column;
}
.settings-drawer.open { transform: translateX(0); }

.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 28px 28px 20px;
}
.settings-title {
  font-family: var(--font-mono); font-size: 1.1rem; font-weight: 500;
}

.settings-body { padding: 0 28px; flex: 1; overflow-y: auto; }

.notice-box {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--green-notice-bg);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 22px;
}
.notice-icon {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--green-notice);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .7rem; font-weight: 700;
  flex-shrink: 0; margin-top: 1px;
}
.notice-text-title {
  font-family: var(--font-mono); font-size: .78rem; font-weight: 500;
  color: var(--text-primary); margin-bottom: 2px;
}
.notice-text-body {
  font-family: var(--font-mono); font-size: .75rem;
  color: var(--text-secondary);
}

.settings-section-title {
  font-family: var(--font-mono); font-size: .8rem; font-weight: 500;
  color: var(--text-primary); margin-bottom: 12px;
}

.ks-checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.ks-checkbox-item {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: .8rem;
  color: var(--text-secondary);
}
.ks-checkbox-item input[type="checkbox"] { accent-color: var(--teal); width: 15px; height: 15px; }

.settings-footer {
  display: flex; gap: 12px;
  padding: 20px 28px 28px;
  border-top: 1px solid var(--border);
}

.btn-back {
  flex: 1; padding: 12px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: .82rem;
  cursor: pointer; transition: background .15s;
}
.btn-back:hover { background: var(--border-light); }

.btn-save {
  flex: 1; padding: 12px;
  background: var(--teal); border: none;
  border-radius: var(--r-sm); color: #fff;
  font-family: var(--font-mono); font-size: .82rem;
  cursor: pointer; transition: background .15s;
}
.btn-save:hover { background: var(--teal-dark); }

/* ─── Page title ─────────────────────────────────────────────── */
.page-title {
  font-family: var(--font-mono); font-size: 1.3rem; font-weight: 400;
  color: var(--text-primary); margin-bottom: 22px;
}

/* ─── Chat bubbles ───────────────────────────────────────────── */
.chat-bubble-user {
  text-align: right;
  padding: 6px 12px;
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--text-primary);
}
.chat-bubble-ai {
  padding: 10px 14px;
  background: var(--teal-light);
  border-radius: var(--r-md);
  margin: 6px 12px;
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
}
.chat-bubble-error {
  padding: 8px 14px;
  background: #FEE2E2;
  border-radius: var(--r-md);
  margin: 6px 12px;
  font-family: var(--font-mono); font-size: .75rem;
  color: #B91C1C;
}
.chat-thinking { padding: 10px 14px; }

.dot-pulse { display: inline-flex; gap: 5px; align-items: center; height: 18px; }
.dot-pulse span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--teal);
  animation: dot-bounce .9s ease-in-out infinite;
}
.dot-pulse span:nth-child(2) { animation-delay: .15s; }
.dot-pulse span:nth-child(3) { animation-delay: .30s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0);   opacity: .4; }
  40%            { transform: translateY(-6px); opacity: 1; }
}
.citation {
  font-size: .65rem;
  color: var(--teal-dark);
  cursor: default;
  margin: 0 1px;
}

/* ─── Utilities ──────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--text-muted); font-family: var(--font-mono); font-size: .72rem; }
.three-dots { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; padding: 0 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
