:root {
  --bg:           #f4ede0;
  --surface:      #fffcf7;
  --surface-hi:   #ffffff;
  --border:       #e0d4bf;
  --ink:          #1e1812;
  --muted:        #6b6057;
  --accent:       #AC3931;                                          /* ← change only this */
  --accent-dark:  color-mix(in srgb, var(--accent) 75%, black);
  --accent-soft:  color-mix(in srgb, var(--accent) 18%, white);
  --mob:          #9046CF;                                          /* ← mobile button color */
  --mob-dark:     color-mix(in srgb, var(--mob) 75%, black);
  --mob-soft:     color-mix(in srgb, var(--mob) 18%, white);
  --radius:       10px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.07);
  --shadow:       0 4px 18px rgba(0,0,0,0.08);
}

@font-face {
  font-family: "VG5000";
  src: url("fonts/webfonts/VG5000-Regular_web.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
textarea { resize: vertical; }

/* ── Header ────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
}

.brand-name {
  font-family: "VG5000", sans-serif;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.nav-user {
  color: var(--muted);
  font-size: 13px;
}

.btn-ghost {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-soft);
}

/* ── Page shell ─────────────────────── */

.page-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── Buttons ────────────────────────── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--accent-dark);
  color: #fff;
  text-decoration: none;
}

/* ── Home page ──────────────────────── */

.home-header {
  margin-bottom: 20px;
}

.home-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.home-header p {
  color: var(--muted);
  font-size: 15px;
}

.dataset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.dataset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.dataset-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-dark);
  margin-bottom: 4px;
}

.dataset-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.dataset-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.stats-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.chip--muted {
  color: var(--muted);
  font-style: italic;
}

/* ── Login ──────────────────────────── */

.auth-wrap {
  max-width: 420px;
  margin: 60px auto 0;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-card > p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

input[type="text"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hi);
  color: var(--ink);
  font-size: 15px;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.error-msg {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fde8e8;
  border: 1px solid #f5b8b8;
  border-radius: var(--radius);
  color: #8a2f27;
  font-size: 14px;
}

/* ── Annotate layout ────────────────── */

.annotate-wrap {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 20px;
  align-items: start;
}

/* Reading column */

.reading-col {
  display: grid;
  gap: 14px;
}

.item-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.item-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-breadcrumb a { color: var(--muted); }
.item-breadcrumb a:hover { color: var(--accent); text-decoration: none; }

.progress-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.thread-meta-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.subreddit-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.thread-title {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
}

.turn-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.turn-target {
  border-color: color-mix(in srgb, var(--accent) 50%, white);
  border-width: 2px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--accent) 10%, white), var(--surface));
}

.turn-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-dark);
  margin-bottom: 4px;
}

.turn-author {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.turn-body {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.75;
  white-space: pre-wrap;
  color: var(--ink);
}

/* Collapsible options block (mobile) */

.options-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.options-block summary {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.options-block summary::before {
  content: '▸ ';
  font-size: 11px;
}

.options-block[open] summary::before {
  content: '▾ ';
}

.options-fields {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.options-fields label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Mobile nav row */

.mobile-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.nav-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.nav-btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.nav-btn--primary:hover { background: var(--accent-dark); color: #fff; }

/* Sidebar */

.sidebar-inner {
  position: sticky;
  top: 68px;
  display: grid;
  gap: 10px;
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.sidebar-card label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.progress-display {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}

.progress-num {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.progress-label {
  font-size: 13px;
  color: var(--muted);
}

.team-note {
  font-size: 12px;
  color: var(--muted);
  width: 100%;
}

.sidebar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sidebar-nav a {
  font-size: 13px;
  color: var(--muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.sidebar-nav a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.export-link {
  font-size: 12px;
  color: var(--muted);
}

.export-link:hover { color: var(--accent); }

.saved-label {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 7px 10px;
}

/* Desktop label buttons */

.label-stack {
  display: grid;
  gap: 5px;
}

.label-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color 100ms, background 100ms;
}

.label-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.label-btn--on {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.label-btn--skip {
  justify-content: center;
  color: var(--muted);
}

.lb-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.label-btn--on .lb-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lb-text {
  font-size: 13px;
}

.shortcut-hint {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-hi);
  font-size: 11px;
}

/* Collapsible sidebar panels */

.sidebar-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.sidebar-details > summary {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  color: var(--muted);
}

.sidebar-details > summary::before {
  content: '▸ ';
  font-size: 11px;
}

.sidebar-details[open] > summary::before {
  content: '▾ ';
}

.rubric-list {
  padding: 0 16px 14px 28px;
  display: grid;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.inline-rubric {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

.inline-rubric-row {
  display: flex;
  gap: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.inline-rubric-row p {
  color: var(--muted);
  margin-top: 2px;
}

.inline-rubric-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 1px;
}

.rubric-note {
  margin: 4px 16px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.recent-list {
  padding: 4px 16px 14px;
  display: grid;
  gap: 6px;
}

.recent-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.recent-label-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.recent-id {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Mobile fixed label bar ─────────── */

.mobile-bar {
  display: none;
}

.mobile-bar-spacer {
  display: none;
}

/* ── Empty state ────────────────────── */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}

.empty-state h2 {
  font-size: 1.3rem;
  color: var(--ink);
  margin-bottom: 8px;
}

.empty-state p { margin-bottom: 16px; }

/* ── Mobile ─────────────────────────── */

@media (min-width: 769px) {
  .mobile-only { display: none !important; }
}

@media (max-width: 768px) {
  .desktop-only { display: none !important; }

  .page-wrap { padding: 16px 14px; }

  .annotate-wrap {
    grid-template-columns: 1fr;
  }

  .turn-body { font-size: 15px; }

  /* Show mobile-only elements */
  .options-block,
  .mobile-nav { display: block; }

  .mobile-nav { display: flex; }

  /* Fixed bottom label bar */
  .mobile-bar {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 12px max(12px, env(safe-area-inset-bottom));
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  }

  .mobile-saved {
    display: block;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    margin-bottom: 6px;
  }

  .mobile-btns {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .mob-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 4px;
    min-height: 58px;
    background: var(--surface-hi);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 100ms, border-color 100ms;
    -webkit-tap-highlight-color: transparent;
  }

  .mob-btn:active { background: var(--accent-soft); }

  .mob-btn--on {
    background: var(--mob-soft);
    border-color: var(--mob);
  }

  .mob-btn--skip { color: var(--muted); }

  .mob-num {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
  }

  .mob-lbl {
    font-size: 10px;
    color: var(--muted);
    line-height: 1;
  }

  .mob-btn--on .mob-num { color: var(--mob); }
  .mob-btn--on .mob-lbl { color: var(--mob-dark); font-weight: 600; }

  /* Space at the bottom so content isn't hidden by the bar */
  .mobile-bar-spacer {
    display: block;
    height: 96px;
  }
}

@media (max-width: 380px) {
  .mob-lbl { display: none; }
  .mob-btn { min-height: 48px; }
  .mob-num { font-size: 18px; }
}
