/* CiteLyra — light, warm-neutral, editorial design system.
   No purple/blue/indigo, no neon, no gradients. Calm and trustworthy. */

:root {
  /* Design Tokens - Sandbox/App compatibility */
  --canvas: #F0ECE3;        /* Warm sand/tan background */
  --surface: #FFFFFF;
  --elevated: #F4F1EB;      /* Warm beige */
  --text: #1A1816;          /* Dark ink */
  --text-secondary: #4A4540; /* Soft ink */
  --text-muted: #6B665E;    /* Slate sand — darkened for WCAG AA (>=4.5:1 on canvas) */
  /* Aliases used by the landing markup (light contexts) */
  --ink-soft: var(--text-secondary);
  --ink-muted: var(--text-muted);
  --border: rgba(26, 24, 22, 0.10);
  --border-strong: rgba(26, 24, 22, 0.18);
  
  --primary: #1A1816;       /* Dark ink button primary */
  --primary-hover: #000000;
  --soft-primary: rgba(26, 24, 22, 0.05);
  
  --accent: #2E7A28;        /* Forest green */
  --warning: #B14A28;
  --error: #B14A28;
  --success: #2E7A28;
  --citation: #2C6CDB;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 12px rgba(20, 18, 16, 0.03), 0 1px 2px rgba(20, 18, 16, 0.02);
  --shadow-md: 0 18px 48px -20px rgba(20, 30, 50, 0.12), 0 2px 6px rgba(20, 30, 50, 0.04);

  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* Global transitions for a fluid feel */
.btn, .nav-tab, .doctype, .card, input, select, textarea, a {
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

html { background: var(--canvas); }
body {
  margin: 0;
  padding: 0;
  position: relative;
  isolation: isolate;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-color: var(--canvas);
  background-image: radial-gradient(rgba(26, 24, 22, 0.07) 1.2px, transparent 1.2px);
  background-size: 24px 24px;
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(700px 480px at 18% 12%, rgba(46, 122, 40, 0.04), transparent 70%),
    radial-gradient(800px 520px at 50% 95%, rgba(173, 122, 66, 0.04), transparent 72%);
  pointer-events: none;
}

h1, h2, h3, h4 { font-family: var(--font-serif); color: var(--text); line-height: 1.25; margin: 0 0 .4em; font-weight: 600; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; color: var(--text-secondary); }
a { color: var(--primary); }

code, .mono { font-family: var(--font-mono); font-size: .85em; }

/* Layout */
.app-header {
  display: flex; align-items: center; gap: .75rem 1rem; flex-wrap: wrap;
  padding: .75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--font-serif); font-weight: 700; font-size: 1.15rem; }
.brand small { font-family: var(--font-sans); font-weight: 500; color: var(--text-muted); font-size: .7rem; letter-spacing: .04em; }
.header-spacer { flex: 1 1 auto; }
.header-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; min-width: 0; }

@media (max-width: 560px) {
  .app-header { padding: .6rem .9rem; gap: .5rem; }
  .brand { font-size: 1rem; }
  .brand small { display: none; }
  #user-email { display: none; }            /* shown via account/email elsewhere */
  .header-actions { gap: .4rem; }
  main { padding: 1.25rem .9rem 4rem; }
  .nav-tabs { padding-left: .9rem; padding-right: .9rem; }
}

.nav-tabs { display: flex; gap: .25rem; padding: .5rem 1.25rem 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.nav-tab {
  appearance: none; border: none; background: none; cursor: pointer;
  font: inherit; color: var(--text-secondary); padding: .6rem .9rem;
  border-bottom: 2px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.nav-tab-link { text-decoration: none; display: inline-flex; align-items: center; }
.nav-tab:hover { color: var(--text); background: var(--elevated); }
.nav-tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

main { max-width: 960px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }

.view { display: none; }
.view.active { display: block; }

/* Cards & panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }

.account-menu-wrap {
  position: relative;
}

.account-trigger {
  max-width: 240px;
}

.account-trigger #user-email {
  color: var(--text-secondary);
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  min-width: 180px;
  padding: .35rem;
  position: absolute;
  right: 0;
  top: calc(100% + .35rem);
  z-index: 20;
}

.account-menu button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  display: block;
  font: inherit;
  padding: .5rem .6rem;
  text-align: left;
  width: 100%;
}

.account-menu button:hover {
  background: var(--elevated);
  color: var(--text);
}

.composer {
  display: grid;
  gap: 1rem;
}

.composer-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.composer-heading {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.composer-heading h2 {
  margin: .1rem 0 0;
}

.eyebrow {
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  margin: 0;
  text-transform: uppercase;
}

.composer-estimate {
  color: var(--text-secondary);
  font-size: .84rem;
  margin: .15rem 0 0;
  max-width: 320px;
  text-align: right;
}

.composer-topic textarea {
  font-size: 1.02rem;
  min-height: 130px;
}

.composer-context-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .65fr);
}

.composer-context-grid textarea {
  min-height: 150px;
}

.composer-controls {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .composer-heading,
  .composer-context-grid {
    display: block;
  }
  .composer-estimate {
    margin-top: .5rem;
    max-width: none;
    text-align: left;
  }
}

/* Forms */
label { display: block; font-weight: 500; color: var(--text); margin-bottom: .35rem; }
.field { margin-bottom: 1rem; }
.hint { color: var(--text-muted); font-size: .82rem; margin-top: .3rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: .55rem .7rem;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus, button:focus-visible, .nav-tab:focus-visible, a:focus-visible {
  outline: 3px solid var(--soft-primary);
  outline-offset: 1px;
  border-color: var(--primary);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }

details.advanced { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: .5rem .9rem; margin-bottom: 1rem; }
details.advanced summary { cursor: pointer; font-weight: 500; color: var(--text-secondary); }

.attachment-list {
  display: grid;
  gap: .55rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: .65rem;
}

.attachment-dropzone {
  align-items: center;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: .45rem;
  justify-content: center;
  min-height: 150px;
  padding: 1rem;
  text-align: center;
}

.attachment-dropzone.dragover {
  background: var(--soft-primary);
  border-color: var(--primary);
}

.attachment-dropzone span {
  color: var(--text);
  font-weight: 600;
}

.attachment-dropzone small,
.attachment-feedback {
  color: var(--text-muted);
  font-size: .78rem;
}

.attachment-feedback {
  margin-top: .55rem;
}

.attachment-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .7rem;
}

.attachment-card header {
  align-items: flex-start;
  display: flex;
  gap: .6rem;
  justify-content: space-between;
}

.attachment-name {
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.attachment-meta {
  color: var(--text-muted);
  display: block;
  font-size: .75rem;
  margin-top: .15rem;
}

.attachment-preview {
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: .78rem;
  line-height: 1.45;
  margin: .55rem 0 0;
  max-height: 5.5rem;
  overflow: hidden;
  padding-top: .5rem;
}

.attachment-card button {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 1rem;
  line-height: 1;
  padding: .05rem .2rem;
}

.attachment-card button:hover {
  color: var(--text);
}

.source-library {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  padding-top: 1rem;
}

.source-library-head {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.source-library-head h3 {
  font-size: .98rem;
  margin: 0;
}

.source-library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: flex-end;
}

.source-library-list {
  display: grid;
  gap: .6rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: .85rem;
}

.source-file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem;
}

.source-file-card header {
  align-items: flex-start;
  display: flex;
  gap: .6rem;
  justify-content: space-between;
}

.source-file-card label {
  align-items: flex-start;
  display: flex;
  gap: .55rem;
  margin: 0;
}

.source-file-card input {
  margin-top: .2rem;
  width: auto;
}

.source-file-card small {
  color: var(--text-muted);
  display: block;
  font-size: .75rem;
  font-weight: 400;
  margin-top: .15rem;
}

.source-file-card p {
  color: var(--text-secondary);
  font-size: .78rem;
  line-height: 1.45;
  margin: .55rem 0 .4rem;
}

.source-points {
  color: var(--text-secondary);
  font-size: .76rem;
  line-height: 1.4;
  margin: .45rem 0 .55rem;
  padding-left: 1.05rem;
}

.source-points li + li {
  margin-top: .2rem;
}

.source-preview-toggle {
  background: transparent;
  border: 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: .78rem;
  font-weight: 700;
  padding: 0;
}

.source-preview {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: .76rem;
  line-height: 1.45;
  margin: .55rem 0 0;
  max-height: 12rem;
  overflow: auto;
  padding: .65rem;
  white-space: pre-wrap;
}

.source-library-empty {
  grid-column: 1 / -1;
  padding: 1rem;
}

@media (max-width: 640px) {
  .source-library-head {
    display: grid;
  }

  .source-library-actions {
    justify-content: flex-start;
  }
}

/* Buttons */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600;
  border-radius: var(--radius-sm); padding: .6rem 1.05rem;
  border: 1px solid transparent; display: inline-flex; align-items: center; gap: .45rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--elevated); }
.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text); background: var(--elevated); }
.btn-danger { background: var(--surface); color: var(--error); border-color: var(--error); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }

/* Credit pill */
.credit-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--soft-primary); color: var(--success);
  border: 1px solid #cfe2d4; border-radius: 999px; padding: .25rem .7rem;
  font-weight: 600; font-size: .85rem;
}

/* Status badges (text + icon, never color alone) */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600;
  border-radius: 999px; padding: .15rem .6rem; border: 1px solid var(--border-strong); color: var(--text-secondary); background: var(--elevated); }
.badge .dot { width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.badge.completed { color: var(--success); border-color: #cfe2d4; background: var(--soft-primary); }
.badge.failed { color: var(--error); border-color: #e6cdc8; background: #fbeeeb; }
.badge.running, .badge.queued, .badge.cancelling { color: var(--accent); border-color: #ead7c2; background: #f7efe5; }
.badge.cancelled { color: var(--text-muted); }

/* Document-type selector */
.doctype-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
@media (max-width: 640px) { .doctype-grid { grid-template-columns: 1fr; } }
.doctype {
  text-align: left; cursor: pointer; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem;
}
.doctype:hover { border-color: var(--border-strong); background: var(--elevated); }
.doctype[aria-pressed="true"] { border-color: var(--primary); background: var(--soft-primary); box-shadow: inset 0 0 0 1px var(--primary); }
.doctype strong { display: block; font-family: var(--font-serif); }
.doctype span { color: var(--text-muted); font-size: .82rem; }
.doctype .cost { float: right; color: var(--success); font-weight: 600; font-size: .82rem; }

/* Lists / projects */
.projects-toolbar {
  align-items: end;
  display: grid;
  gap: .75rem;
  grid-template-columns: minmax(160px, 220px) minmax(180px, 260px) auto 1fr;
  margin: 0 0 1rem;
}

.projects-count {
  color: var(--text-muted);
  font-size: .9rem;
  justify-self: end;
  padding-bottom: .65rem;
}

.project { display: flex; align-items: center; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--border); }
.project:last-child { border-bottom: none; }
.project-main { flex: 1; min-width: 0; }
.project-main h4 { margin: 0 0 .2rem; font-size: 1rem; }
.project-meta { display: flex; flex-wrap: wrap; gap: .5rem .9rem; color: var(--text-muted); font-size: .82rem; align-items: center; }
.project-actions { display: flex; flex-wrap: wrap; gap: .4rem; flex-shrink: 0; justify-content: flex-end; }
.project-detail { color: var(--text-muted); font-size: .82rem; line-height: 1.45; margin: .35rem 0 0; }
.project-detail.error { color: var(--error); }
.project-empty { display: grid; justify-items: center; gap: .45rem; }
.project-empty strong { color: var(--text-primary); font-size: 1rem; }
.project-empty span { display: block; max-width: 34rem; }

@media (max-width: 760px) {
  .projects-toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .projects-count {
    justify-self: start;
    padding-bottom: 0;
  }

  .project {
    align-items: stretch;
    flex-direction: column;
  }

  .project-actions {
    justify-content: flex-start;
  }
}

/* Progress */
.progress-track { height: 10px; background: var(--elevated); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); width: 0; transition: width .4s ease; }
@media (prefers-reduced-motion: reduce) { .progress-fill { transition: none; } }
.phase-line { display: flex; justify-content: space-between; color: var(--text-secondary); font-size: .85rem; margin: .5rem 0; }
.run-details {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin: 1rem 0 .75rem;
}
.run-details div {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .65rem;
}
.run-details dt {
  color: var(--text-muted);
  font-size: .72rem;
  margin-bottom: .15rem;
}
.run-details dd {
  color: var(--text);
  font-size: .84rem;
  font-weight: 600;
  margin: 0;
  overflow-wrap: anywhere;
}

.activity { max-height: 280px; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.activity li { display: flex; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.activity li:last-child { border-bottom: none; }
.activity .ts { color: var(--text-muted); font-family: var(--font-mono); font-size: .75rem; flex-shrink: 0; }

/* Empty / messages */
.empty { text-align: center; color: var(--text-muted); padding: 2.5rem 1rem; }
.notice { padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 1rem; border: 1px solid; }
.notice.error { color: var(--error); background: #fbeeeb; border-color: #e6cdc8; }
.notice.success { color: var(--success); background: var(--soft-primary); border-color: #cfe2d4; }
.notice.warn { color: var(--warning); background: #f7efe5; border-color: #ead7c2; }

/* Auth */
.auth-wrap { max-width: 420px; margin: 4rem auto; }
.auth-wrap .brand { justify-content: center; margin-bottom: 1.5rem; font-size: 1.5rem; }

/* Disclaimer */
.disclaimer { color: var(--text-muted); font-size: .82rem; border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1.5rem; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(32,37,31,.35); display: none; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); max-width: 460px; width: 100%; padding: 1.5rem; }
.pack { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.pack:last-child { border-bottom: none; }
.settings-modal {
  max-width: 560px;
}

.settings-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

.settings-section h3 {
  font-size: .98rem;
  margin: 0 0 .75rem;
}

.settings-list {
  display: grid;
  gap: .6rem;
  margin: 0;
}

.settings-list div {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.settings-list dt {
  color: var(--text-muted);
  font-size: .84rem;
}

.settings-list dd {
  color: var(--text);
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.danger-zone {
  border-color: #ead2ce;
}

.settings-delete-row {
  display: grid;
  gap: .6rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

@media (max-width: 560px) {
  .settings-list div,
  .settings-delete-row {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .settings-list dd {
    text-align: left;
  }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff; padding: .5rem .9rem; z-index: 100; }
.skip-link:focus { left: .5rem; top: .5rem; }
.hidden { display: none !important; }

/* ============ Landing page (ThesisAI Redesign) ============ */
.landing-nav {
  position: sticky;
  top: 16px;
  z-index: 100;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 16px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px 8px 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 8px 28px rgba(20, 18, 16, 0.06);
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.15rem;
}
.logo-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  padding-bottom: 2px;
}
.logo-mark {
  display: inline-block;
  flex: 0 0 auto;
  height: 34px;
  width: 34px;
}
.logo-mark-sm {
  height: 28px;
  width: 28px;
}
.logo-text em {
  font-family: var(--font-serif);
  font-weight: 500;
  font-style: italic;
  margin-left: 2px;
  color: var(--text);
}
.nav-links {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--border);
}
.nav-links li {
  margin: 0;
}
.nav-links a {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}
.nav-links a:hover {
  color: var(--text);
}
.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}
.btn-nav-login {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: color 0.15s ease;
}
.btn-nav-login:hover {
  color: var(--text);
  text-decoration: underline;
}
.btn-nav-signup {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--surface);
  background: var(--text);
  border: 1px solid var(--text);
  padding: 7px 7px 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  box-shadow: 0 4px 12px rgba(20, 18, 16, 0.1);
}
.btn-nav-signup:hover {
  transform: translateY(-1px);
  background: #000000;
  color: var(--surface);
  box-shadow: 0 8px 22px rgba(20, 18, 16, 0.18);
}
.signup-arrow {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: transform 0.18s ease;
}
.btn-nav-signup:hover .signup-arrow {
  transform: translateX(2px);
}
.nav-lang {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.landing-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 6rem;
}
.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 4rem;
  padding: 5.5rem 0 3.5rem;
  align-items: center;
}
.hero-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.hero h1 {
  font-size: 3.25rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text);
  max-width: 16ch;
}
.hero h1 em {
  font-style: italic;
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--citation);
}
.hero-content .lead {
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 2.25rem;
  max-width: 48ch;
}
.hero-cta {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.hero-btn {
  padding: 10px 10px 10px 22px;
  font-size: 1.05rem;
  text-decoration: none;
}
.btn-hero-secondary {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}
.btn-hero-secondary:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Interactive Sandbox Redesign */
.sandbox-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.sandbox-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.sandbox-card h3 {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sandbox-presets {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sandbox-preset-btn {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.18s ease;
  box-shadow: 0 1px 2px rgba(20, 18, 16, 0.02);
  width: 100%;
}
.sandbox-preset-btn:hover:not(:disabled) {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface);
  transform: translateX(4px);
}
.sandbox-preset-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.terminal-mockup {
  border-radius: 8px;
  border: 1px solid #1A1816;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.terminal-header {
  background: #2D2924;
  padding: 0.55rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border-bottom: 1px solid #1A1816;
}
.terminal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.terminal-dot.red { background: #FF5F56; }
.terminal-dot.yellow { background: #FFBD2E; }
.terminal-dot.green { background: #27C93F; }
.terminal-title {
  color: #AAB1A8;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  margin-left: auto;
  margin-right: auto;
  padding-right: 24px;
}
.sandbox-console {
  background: #1A1816;
  color: #A3B899;
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  height: 125px;
  overflow-y: auto;
  border: 0;
}
.sandbox-console div {
  margin-bottom: 0.25rem;
}
.sandbox-console div.info { color: #8F8C89; }
.sandbox-console div.success { color: #6BBF80; }
.sandbox-result {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--elevated);
  animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.sandbox-result-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.sandbox-result-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 960px) {
  .landing-nav {
    width: calc(100% - 24px);
    gap: 16px;
    padding: 8px 12px;
  }
  .landing-nav .nav-links,
  .landing-nav .nav-lang {
    display: none;
  }
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 3rem;
    padding-top: 3.5rem;
  }
  .hero-content {
    align-items: center;
  }
  .hero h1 {
    font-size: 2.5rem;
    max-width: 100%;
  }
  .hero-content .lead {
    max-width: 100%;
  }
  .hero-cta {
    justify-content: center;
  }
}

/* Partner Trust Banner */
.partners-banner {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 1.75rem 0;
  margin-top: 2rem;
  margin-bottom: 3rem;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.partners-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}
.partner-logo {
  font-size: 1.05rem;
  color: var(--text-secondary);
  opacity: 0.85;
}
.partner-logo.semantic-scholar {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.partner-logo.crossref {
  font-family: var(--font-sans);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.partner-logo.openalex {
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.95rem;
}
.partner-logo.arxiv {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Redesigned Features */
.section {
  padding: 5rem 0;
}
.section h2 {
  text-align: center;
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text);
}
.section .sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 58ch;
  margin: 0 auto 3rem;
}
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem;
  box-shadow: var(--shadow);
  transition: all 0.22s ease;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.feature:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--text);
}
.feature-num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.feature h3 {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.feature p {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}

@media (max-width: 800px) {
  .features {
    grid-template-columns: 1fr;
  }
}

/* Interactive Paper Highlights & Tooltips */
.interactive-paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: 800px;
  margin: 2.5rem auto 0;
  padding: 2.5rem;
  font-family: var(--font-sans);
  line-height: 1.7;
  text-align: left;
}
.paper-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.paper-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.paper-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.paper-body h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text);
}
.paper-body p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}
.claim-hl {
  position: relative;
  cursor: help;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}
.claim-hl.hl-success {
  background-color: rgba(46, 122, 40, 0.12);
  border-bottom: 2px solid var(--accent);
  color: var(--text);
}
.claim-hl.hl-success:hover {
  background-color: rgba(46, 122, 40, 0.2);
}
.claim-hl.hl-info {
  background-color: rgba(44, 108, 219, 0.1);
  border-bottom: 2px solid var(--citation);
  color: var(--text);
}
.claim-hl.hl-info:hover {
  background-color: rgba(44, 108, 219, 0.18);
}
.claim-hl.hl-warning {
  background-color: rgba(217, 119, 87, 0.12);
  border-bottom: 2px solid var(--warning);
  color: var(--text);
}
.claim-hl.hl-warning:hover {
  background-color: rgba(217, 119, 87, 0.2);
}

/* Floating CSS tooltips */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background: #1A1816;
  color: #FAF8F4;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  width: 250px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-sans);
  font-weight: 500;
  text-align: left;
}
[data-tooltip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1A1816;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
  opacity: 1;
}
/* Keyboard users: make tooltip triggers focusable with a visible ring. */
[data-tooltip]:focus-visible {
  outline: 3px solid var(--soft-primary);
  outline-offset: 2px;
}

/* Testimonial Section */
.testimonial-section {
  padding: 5rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 3rem 0;
}
.testimonial-container {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  padding: 0 1.5rem;
}
.testimonial-quote {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-style: italic;
  line-height: 1.45;
  color: var(--text);
  margin-bottom: 1.75rem;
}
.testimonial-author {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.author-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.author-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.author-title {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Pricing Section */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  align-items: stretch;
  max-width: 1080px;
  margin: 0 auto 3rem;
  text-align: left;
}
.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  position: relative;
  transition: all 0.22s ease;
}
.price-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--text);
}
.price-card.recommended {
  border-color: var(--text);
  box-shadow: var(--shadow-md);
  background: var(--surface);
}
.badge-recommended {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--accent);
  color: var(--surface);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
}
.price-title {
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.price-amount {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.price-amount span {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 6px;
}
.price-credits {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1.25rem;
}
.price-desc {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
  min-height: 4.5em;
}
.price-features {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-grow: 1;
}
.price-features li::before {
  color: var(--success);
  content: "✓";
  font-weight: 700;
  margin-right: .45rem;
}
.btn-pricing {
  width: 100%;
  justify-content: center;
}
.credit-breakdown-card {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 800px;
  margin: 3rem auto 0;
  padding: 1.75rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.credit-breakdown-card h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-right: 1px solid var(--border);
  padding: 0 0.5rem;
}
.breakdown-item:last-child {
  border-right: none;
}
.breakdown-item strong {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
}
.breakdown-item span {
  font-size: 0.78rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
}

@media (max-width: 900px) {
  .pricing-grid {
    grid-template-columns: 1fr;
    max-width: 450px;
  }
  .breakdown-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
  .breakdown-item {
    border-right: none;
  }
  .breakdown-item:nth-child(2n) {
    border-left: 1px solid var(--border);
  }
}
@media (max-width: 480px) {
  .breakdown-grid {
    grid-template-columns: 1fr;
  }
  .breakdown-item:nth-child(2n) {
    border-left: none;
  }
}

/* FAQ Accordion Details */
.faq-container {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  transition: all 0.2s ease;
}
.faq-item[open] {
  border-color: var(--text);
  box-shadow: var(--shadow);
}
.faq-item summary {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.75rem 0;
  cursor: pointer;
  user-select: none;
  outline: none;
}
.faq-item p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 0.5rem 0 0.75rem;
  margin: 0;
  border-top: 1px solid var(--border);
}

.landing-footer {
  border-top: 1px solid var(--border);
  margin-top: 5rem;
  padding: 3rem 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
}
.landing-footer a {
  color: var(--text-secondary);
  margin: 0 0.5rem;
  text-decoration: none;
  transition: color 0.15s ease;
}
.landing-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ============ Source review / outline / draft preview ============ */
.sources { list-style: none; margin: 0; padding: 0; }
.sources li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.source-meta { color: var(--text-muted); font-size: .82rem; display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.verified { color: var(--success); font-weight: 600; }
.unverified { color: var(--warning); font-weight: 600; }
.outline-list { margin: 0; padding-left: 1.2rem; color: var(--text-secondary); }
.outline-list li { margin: .2rem 0; }
.draft-preview { white-space: pre-wrap; font-family: var(--font-mono); font-size: .82rem; line-height: 1.5;
  max-height: 420px; overflow: auto; background: var(--elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem; color: var(--text); }

/* ============ Document pages (legal, guides) ============ */
.doc { max-width: 760px; margin: 2.5rem auto; padding: 0 1.25rem 4rem; }
.doc h1 { margin: 1rem 0 .25rem; }
.doc h2 { margin-top: 2rem; }
.doc p, .doc li { color: var(--text-secondary); }
.doc strong { color: var(--text); }
.doc table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .92rem; }
.doc th, .doc td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc th { color: var(--text); }
.doc pre { background: var(--elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 1rem; overflow: auto; font-family: var(--font-mono); font-size: .82rem; }
.doc code { background: var(--elevated); padding: .1rem .3rem; border-radius: 4px; font-family: var(--font-mono); font-size: .85em; }
.doc blockquote { border-left: 3px solid var(--border-strong); margin: 1rem 0; padding: .25rem 0 .25rem 1rem; color: var(--text-muted); }

.examples-page h1 {
  margin-top: 1.25rem;
}

.examples-toolbar {
  align-items: end;
  display: grid;
  gap: .75rem;
  grid-template-columns: minmax(180px, 240px) minmax(180px, 280px) auto 1fr;
  margin-top: 1.25rem;
}

.examples-count {
  color: var(--text-muted);
  font-size: .9rem;
  justify-self: end;
  padding-bottom: .65rem;
}

.examples-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 1.5rem;
}

.example-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.example-card h2 {
  font-size: 1.1rem;
  margin: .65rem 0 .45rem;
}

.example-card p {
  color: var(--text-secondary);
  font-size: .92rem;
  line-height: 1.55;
}

.example-topline,
.example-meta {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: .78rem;
  gap: .5rem;
}

.example-topline {
  justify-content: space-between;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.example-meta {
  margin: .9rem 0;
}

.example-meta span {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .25rem .5rem;
}

.example-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

@media (max-width: 720px) {
  .examples-toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .examples-count {
    justify-self: start;
    padding-bottom: 0;
  }
}

/* Polished Back Buttons */
.doc .btn-ghost, #auth-back {
  background: var(--surface);
  border: 1px solid var(--border) !important;
  color: var(--text-secondary) !important;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 1.5rem;
}
.doc .btn-ghost:hover, #auth-back:hover {
  background: var(--elevated);
  border-color: var(--text) !important;
  color: var(--text) !important;
  transform: translateX(-3px);
}
