/* =====================================================================
   Harvest Kernel Faculty Toolkit — Stylesheet
   Brand: Sage Green #949676 | Charcoal #262626 | Cream #faf9f5
   Typography: Poppins (headings) | Lora (body)
   ===================================================================== */

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

:root {
  --sage:          #949676;
  --sage-hover:    #7f8165;
  --sage-light:    #e8e9df;
  --sage-deep:     #6f7159;
  --sage-whisper:  #eef0e4;
  --charcoal:      #262626;
  --charcoal-soft: #3d3d3d;
  --charcoal-muted:#6b6b68;
  --cream:         #faf9f5;
  --cream-warm:    #f4f2ea;
  --paper:         #ffffff;
  --white:         #ffffff;
  --gray-medium:   #808080;
  --gray-border:   #d5d5d0;
  --gray-light:    #f0efeb;
  --border-soft:   rgba(38, 38, 38, 0.05);
  --border-mid:    rgba(38, 38, 38, 0.08);
  --border-strong: rgba(38, 38, 38, 0.14);
  --error-red:     #b91c1c;
  --error-bg:      #fef2f2;
  --error-border:  #fecaca;
  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --radius-btn:    24px;
  --radius-pill:   999px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06);
  --shadow-md:     0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.10);
  --font-heading:  'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:     'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif:    'Lora', Georgia, 'Times New Roman', serif;
  --max-width:     820px;
  --transition:    180ms ease;
}

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--charcoal);
  background:
    radial-gradient(ellipse 80% 60% at 15% 0%, rgba(148, 150, 118, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 10%, rgba(194, 109, 78, 0.04) 0%, transparent 55%),
    var(--cream);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.25;
}

/* Generated documents keep the serif voice — they should read like
   finished documents, while the app UI itself is Poppins. */
.feedback-output,
.syllabus-output,
.rubric-output,
.result-output,
.saved-output-body {
  font-family: var(--font-serif);
}

/* ── Header (unified topnav — matches dashboard.css) ────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 245, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
}

.topnav-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--charcoal);
}

.brand-logo {
  height: 44px;
  width: auto;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 28px;
  background: var(--border-strong);
  display: block;
}

.brand-sublabel {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  font-weight: 400;
  color: var(--charcoal-muted);
  letter-spacing: 0.01em;
}

/* ── Navigation (unified) ───────────────────────────────────────────── */
.nav-links { display: flex; align-items: center; gap: 4px; }

.nav-link {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 500;
  color: var(--charcoal-soft);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover { background: var(--sage-whisper); color: var(--sage-deep); }
.nav-link.active,
.nav-link.nav-active { color: var(--sage-deep); background: var(--sage-whisper); }
.nav-link svg { width: 16px; height: 16px; }

.nav-right { display: flex; align-items: center; gap: 16px; }

.usage-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--paper);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-heading);
}

.usage-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sage);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 900px) {
  .topnav-inner { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .usage-pill { display: none; }
}

/* ── Home Page ──────────────────────────────────────────────────────── */
.home-page {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.home-heading {
  text-align: center;
  margin-bottom: 2.5rem;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

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

.tool-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  text-decoration: none;
  color: var(--charcoal);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
}

.tool-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--sage);
}

.tool-card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.tool-card h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--charcoal);
}

.tool-card p {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--gray-medium);
  line-height: 1.5;
  flex: 1;
}

.tool-card-action {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sage-hover);
  margin-top: 1rem;
}

.tool-card:hover .tool-card-action { color: var(--sage); }

/* ── Main Content ───────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.page-heading {
  margin-bottom: 2rem;
}

.page-heading h1 {
  font-size: 2.25rem;         /* close to 36px, feels like an h2 for the page */
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 0.4rem;
}

.subhead {
  color: var(--gray-medium);
  font-family: var(--font-body);
  font-size: 1rem;
}

/* ── Batch Banner ───────────────────────────────────────────────────── */
.batch-banner {
  background: var(--sage-light);
  border: 1px solid var(--sage);
  border-left: 4px solid var(--sage);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--charcoal);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.batch-banner strong { font-family: var(--font-heading); font-weight: 600; }

.batch-banner-link {
  margin-left: auto;
  color: var(--sage-hover);
  font-family: var(--font-heading);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
}

.batch-banner-link:hover { text-decoration: underline; }

/* ── Error Banner ───────────────────────────────────────────────────── */
.error-banner {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-left: 4px solid var(--error-red);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--error-red);
}

.error-banner strong {
  display: block;
  font-family: var(--font-heading);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.error-banner ul { margin: 0; padding-left: 1.25rem; }
.error-banner li { margin-bottom: 0.2rem; }

/* ── Form Sections ──────────────────────────────────────────────────── */
.form-section {
  background: var(--cream);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.section-label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sage);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Fields ─────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 1.25rem;
}

.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 0.3rem;
}

.field-hint {
  font-size: 0.85rem;
  color: var(--gray-medium);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.required-star { color: var(--error-red); margin-left: 2px; }
.label-note { font-weight: 400; color: var(--gray-medium); font-size: 0.85em; }

/* Plain-language UX standard: discoverable, expandable help under a field.
   Native <details>, no JS, works on touch + keyboard. See PLAIN_LANGUAGE_UX_STANDARD.md */
.tool-help { margin: 0.4rem 0 0.25rem; font-size: 0.85rem; color: var(--gray-dark, #374151); }
.tool-help > summary { cursor: pointer; color: var(--sage-deep); font-weight: 600; display: list-item; }
.tool-help[open] > summary { margin-bottom: 0.4rem; }
.tool-help ul { margin: 0.3rem 0 0; padding-left: 1.1rem; line-height: 1.55; }
.tool-help li { margin-bottom: 0.3rem; }
.tool-help p { margin: 0.3rem 0; }
.tool-help strong { color: var(--sage-deep); }

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--charcoal);
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

select {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 0.9rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23808080' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(148,150,118,.2);
}

textarea { resize: vertical; min-height: 80px; }

.char-count {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--gray-medium);
  text-align: right;
  margin-top: 0.25rem;
}

/* ── File upload ────────────────────────────────────────────────────── */
.file-upload-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.file-upload-or {
  font-size: 0.82rem;
  color: var(--gray-medium);
  font-style: italic;
}

.file-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  background: var(--gray-light);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-medium);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  margin-bottom: 0;
}

.file-upload-label:hover {
  background: var(--sage-light);
  border-color: var(--sage);
  color: var(--sage-hover);
}

.file-upload-icon { font-style: normal; }
.file-input { display: none; }

.file-name-display {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--sage-hover);
  font-weight: 500;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Two-column field rows ──────────────────────────────────────────── */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ── Checkbox group ─────────────────────────────────────────────────── */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--charcoal);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--gray-medium);
  border-radius: var(--radius-sm);
  cursor: pointer;
  accent-color: var(--sage);
  flex-shrink: 0;
}

/* ── Toggle switch ──────────────────────────────────────────────────── */
.toggle-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
}

.toggle-label {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-bottom: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-border);
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider { background: var(--sage); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Tooltip ────────────────────────────────────────────────────────── */
.tooltip-anchor {
  position: relative;
  display: inline-block;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gray-border);
  color: var(--gray-medium);
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: help;
  font-style: normal;
}

.tooltip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--charcoal);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.5;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  width: 280px;
  z-index: 50;
  box-shadow: var(--shadow-md);
  text-align: left;
}

.tooltip-text strong {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--sage-light);
}

.tooltip-anchor:hover .tooltip-text,
.tooltip-anchor:focus-within .tooltip-text { display: block; }

/* ── Toggle optional button ─────────────────────────────────────────── */
.toggle-optional {
  background: none;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.75rem;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sage-hover);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  text-transform: none;
  letter-spacing: 0;
}

.toggle-optional:hover {
  background: var(--sage-light);
  border-color: var(--sage);
}

/* ── Submit area ────────────────────────────────────────────────────── */
.submit-area {
  text-align: center;
  margin-top: 0.5rem;
}

.submit-hint {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--gray-medium);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--charcoal);
  color: var(--cream);
  border: none;
  border-radius: var(--radius-btn);
  padding: 0.8rem 2rem;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  display: inline-block;
  text-decoration: none;
}

.btn-primary:hover { background: var(--charcoal-soft); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--white);
  color: var(--sage-deep);
  border: 1px solid var(--sage);
  border-radius: var(--radius-btn);
  padding: 0.7rem 1.5rem;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  display: inline-block;
  text-decoration: none;
}

.btn-secondary:hover { background: var(--sage-light); }

.btn-ghost {
  background: none;
  color: var(--gray-medium);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-btn);
  padding: 0.7rem 1.5rem;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  display: inline-block;
  text-decoration: none;
}

.btn-ghost:hover { background: var(--gray-light); color: var(--charcoal); }

.btn-accent {
  background: var(--sage);
  color: var(--white);
  border: none;
  border-radius: var(--radius-btn);
  padding: 0.8rem 2rem;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  display: inline-block;
  text-decoration: none;
}

.btn-accent:hover { background: var(--sage-hover); transform: translateY(-1px); }
.btn-accent:active { transform: translateY(0); }

/* ── Loading Overlay ─────────────────────────────────────────────────── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(38,38,38,.45);
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.loading-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-border);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 0.25rem;
}

.loading-subtext { font-size: 0.85rem; color: var(--gray-medium); }

/* ── Result Page ─────────────────────────────────────────────────────── */
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.result-meta h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 0.3rem;
}

.result-context {
  font-size: 0.88rem;
  color: var(--gray-medium);
  margin-bottom: 0.15rem;
}

.result-assignment span { font-style: italic; }

.result-warning {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 500;
  color: #b5751a;
  background: #fef3e2;
  border: 1px solid #e8a838;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  margin-top: 0.4rem;
}

.result-actions-top,
.result-actions-bottom {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.result-actions-bottom {
  margin-top: 1.5rem;
  justify-content: center;
}

/* ── Feedback Output ─────────────────────────────────────────────────── */
.feedback-container {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-sm);
}

.feedback-output {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--charcoal);
  white-space: pre-wrap;
}

.feedback-output strong {
  font-family: var(--font-heading);
  color: var(--charcoal);
  font-weight: 600;
}

.feedback-output p {
  margin-bottom: 1rem;
}

.feedback-output p:last-child { margin-bottom: 0; }

/* ── Copy Toast ──────────────────────────────────────────────────────── */
.copy-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--sage);
  color: var(--white);
  padding: 0.6rem 1.25rem;
  border-radius: 2rem;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 300;
  animation: fadeInUp 0.2s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Footer (unified — light, matches dashboard) ────────────────────── */
.site-footer {
  background: var(--cream-warm);
  border-top: 1px solid var(--border-mid);
  color: var(--charcoal-muted);
  text-align: center;
  padding: 1.75rem 1.5rem;
  font-size: 0.82rem;
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-brand {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--charcoal);
  margin-bottom: 0.25rem;
}

.footer-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--charcoal-muted);
  margin-bottom: 0.5rem;
}

.footer-link {
  color: var(--sage-deep);
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.8rem;
}

.footer-link:hover { text-decoration: underline; color: var(--charcoal); }

/* ── Mode Selector (Rubric Build/Import) ─────────────────────────────── */
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 560px) { .mode-selector { grid-template-columns: 1fr; } }

.mode-card {
  background: var(--white);
  border: 2px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: var(--font-body);
  color: var(--charcoal);
}

.mode-card:hover { border-color: var(--sage); }

.mode-card-active {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(148,150,118,.2);
}

.mode-icon { font-size: 1.5rem; margin-bottom: 0.4rem; }
.mode-card strong { font-family: var(--font-heading); font-size: 1rem; display: block; margin-bottom: 0.25rem; }
.mode-card p { font-size: 0.85rem; color: var(--gray-medium); margin: 0; line-height: 1.4; }

/* ── Library Selector ────────────────────────────────────────────────── */
.library-selector { margin-bottom: 0.5rem; }

.library-dropdown {
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sage-hover);
  background: var(--sage-light);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23808080' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.library-dropdown:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(148,150,118,.2);
}

/* ── Save Modal ──────────────────────────────────────────────────────── */
.save-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(38,38,38,.45);
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.save-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.save-modal h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.save-modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.html-code-modal { max-width: 640px; }

/* ── Copy Options ────────────────────────────────────────────────────── */
.copy-options-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.copy-option-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--cream);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-family: var(--font-body);
  color: var(--charcoal);
}

.copy-option-btn:hover {
  border-color: var(--sage);
  background: var(--sage-light);
}

.copy-option-btn strong {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.2rem;
  color: var(--charcoal);
}

.copy-option-btn span {
  font-size: 0.82rem;
  color: var(--gray-medium);
  line-height: 1.3;
}

.html-code-textarea {
  width: 100%;
  height: 280px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.75rem;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--charcoal);
  resize: vertical;
}

/* ── Edit Modal (Library) ─────────────────────────────────────────────── */
.edit-modal-body { padding: 0 0.5rem; }

.edit-controls {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.edit-table-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.edit-table-container {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow-x: auto;
}

.edit-table-container table { font-size: 13px; }
.edit-table-container th,
.edit-table-container td { padding: 8px 10px; font-size: 13px; min-height: 40px; }
.edit-table-container th { font-size: 14px; }

.edit-table-container [contenteditable]:focus {
  outline: 2px solid var(--sage);
  outline-offset: -1px;
  background: #fffff0;
}

/* ── Rubric Result Page Layout ───────────────────────────────────────── */
.rubric-result-main {
  width: 100%;
  padding: 0;
}

/* Sticky action bar */
.rubric-sticky-bar {
  position: sticky;
  top: 64px; /* below site header */
  z-index: 90;
  background: var(--white);
  border-bottom: 1px solid var(--gray-border);
  box-shadow: var(--shadow-sm);
  padding: 0.5rem 1.5rem;
}

.rubric-sticky-inner {
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.rubric-sticky-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--charcoal);
  margin-right: auto;
}

.rubric-sticky-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Customize bar (below sticky, collapsible) */
.rubric-customize-bar {
  padding: 0.6rem 1.5rem;
  background: var(--cream);
  border-bottom: 1px solid var(--gray-border);
}

.rubric-customize-fields {
  padding-top: 0.75rem;
}

.rubric-customize-fields .field-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: end;
}

.rubric-customize-fields .field { flex: 1; min-width: 120px; }

/* Full-width rubric display container */
.rubric-display-container {
  width: 100%;
  padding: 1rem 1.5rem 3rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Rubric Output (on-screen, readable) ─────────────────────────────── */
.rubric-output {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  color: var(--charcoal);
}

.rubric-output table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 14px;
}

.rubric-output th,
.rubric-output td {
  border: 1px solid var(--gray-border);
  padding: 10px 12px;
  vertical-align: top;
  text-align: left;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.45;
}

.rubric-output th {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  color: var(--charcoal);
}

.rubric-output td strong {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--charcoal);
}

.rubric-output p { margin-bottom: 0.75rem; font-size: 15px; }
.rubric-output p:last-child { margin-bottom: 0; }

/* ── Full-width rubric overlay ───────────────────────────────────────── */

.fullscreen-rubric-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--cream);
  z-index: 250;
  overflow: auto;
  padding: 1.5rem;
}

.fullscreen-rubric-overlay.active { display: block; }

.fullscreen-rubric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  background: var(--cream);
  padding: 0.5rem 0;
  z-index: 2;
}

.fullscreen-rubric-header h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--charcoal);
}

.fullscreen-rubric-body {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  overflow-x: auto;
}

.fullscreen-rubric-body table {
  min-width: 900px;
}

/* ── Library Page ────────────────────────────────────────────────────── */
.library-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.library-item {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.library-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  flex-wrap: wrap;
}

.library-item-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--charcoal);
  margin: 0;
}

.library-item-date {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--gray-medium);
}

.library-item-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
}

.btn-danger { color: var(--error-red); border-color: var(--error-red); }
.btn-danger:hover { background: var(--error-bg); color: var(--error-red); }

.library-item-preview {
  border-top: 1px solid var(--gray-border);
  padding: 1.25rem 1.5rem;
  background: var(--cream);
}

.library-item-content {
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--charcoal);
  white-space: pre-wrap;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }

.empty-state h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--gray-medium);
  font-size: 0.95rem;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ── Field Error Pulse (scroll-to highlight) ─────────────────────────── */
.field-error-pulse {
  animation: errorPulse 0.6s ease 2;
}

@keyframes errorPulse {
  0%   { border-color: var(--error-red); box-shadow: 0 0 0 0 rgba(185,28,28,.3); }
  50%  { border-color: var(--error-red); box-shadow: 0 0 0 6px rgba(185,28,28,.15); }
  100% { border-color: var(--error-red); box-shadow: 0 0 0 0 rgba(185,28,28,.0); }
}

/* ── Syllabus Upload ─────────────────────────────────────────────────── */
.syllabus-loaded {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: var(--sage-light);
  border: 1px solid var(--sage);
  border-radius: var(--radius-sm);
  margin-top: 0.25rem;
}

.syllabus-badge {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sage-hover);
}

.syllabus-paste-toggle {
  margin-top: 0.5rem;
}

.syllabus-paste-toggle summary {
  font-size: 0.82rem;
  color: var(--gray-medium);
}

/* ── Email Decoder Zones ─────────────────────────────────────────────── */
.decoder-zone {
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
}

.decoder-instructor-zone {
  background: #fef3e2;
  border: 2px solid #e8a838;
  border-left: 5px solid #e8a838;
}

.decoder-response-zone {
  background: var(--white);
  border: 1px solid var(--gray-border);
  box-shadow: var(--shadow-sm);
}

.decoder-zone-label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0,0,0,.1);
}

.decoder-instructor-zone .decoder-zone-label { color: #b5751a; }
.decoder-response-zone .decoder-zone-label { color: var(--sage-hover); }

.decoder-zone-hint {
  font-weight: 400;
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

.decoder-zone-content {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--charcoal);
}

.decoder-zone-content strong {
  font-family: var(--font-heading);
  font-weight: 600;
}

.decoder-zone-content p { margin-bottom: 0.75rem; }
.decoder-zone-content p:last-child { margin-bottom: 0; }

/* ── Login Page ──────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px - 120px); /* viewport minus header and footer */
}

.login-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 0.5rem;
}

.login-note {
  font-size: 0.9rem;
  color: var(--gray-medium);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.login-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-sm);
  color: var(--error-red);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
}

.login-card .field {
  text-align: left;
  margin-bottom: 1.25rem;
}

.login-btn {
  width: 100%;
  padding: 0.85rem;
  font-size: 1.05rem;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .main-content { padding: 1.25rem 1rem 3rem; }
  .page-heading h1 { font-size: 1.75rem; }
  .form-section { padding: 1.25rem; }
  .feedback-container { padding: 1.25rem; }
  .result-header { flex-direction: column; }
  .result-actions-top { order: -1; }
  .btn-primary, .btn-secondary, .btn-ghost, .btn-accent {
    font-size: 0.9rem;
    padding: 0.65rem 1.25rem;
  }
}

/* Accessibility: skip link + visible keyboard focus (A-grade pass) */
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--charcoal); color: #fff;
  padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 1000; font-family: 'Poppins', system-ui, sans-serif; }
.skip-link:focus { left: 0; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--sage-deep); outline-offset: 2px; border-radius: 2px; }

/* Result pages: clear action hierarchy — Copy/Save prominent, the rest quiet. */
.result-actions-top .btn-secondary,
.result-actions-top .btn-ghost,
.result-actions-bottom .btn-secondary,
.result-actions-bottom .btn-ghost {
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  font-weight: 500;
}
