:root {
  /* Brand Colors - The Differentiator */
  --primary: #1E3A8A;        /* Brand Blue */
  --secondary: #16A34A;      /* Brand Green */
  --accent: #F97316;         /* Brand Orange */

  /* Grayscale */
  --fg: #1d1d21;
  --muted: #6b7280;
  --bg: #f7f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Roboto', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--bg);
}

/* Headings use Montserrat */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
}

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  padding: 0.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-content {
  display: flex;
  gap: 1rem;
  align-items: center;
  width: 100%;
}

.logo {
  height: 120px;
  width: auto;
}

h1 { 
  font-size: 1.25rem; 
  margin: 0;
  font-weight: 700;
}

.badge { 
  font-size: .8rem; 
  color: #fff; 
  background: var(--primary); 
  padding: .15rem .5rem; 
  border-radius: .5rem;
  font-weight: 600;
}

/* ---------- Layout ---------- */
main {
  max-width: 1400px;
  margin: 1.25rem auto;
  padding: 0 1.5rem;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media(min-width:1000px){ 
  main { 
    grid-template-columns: 1fr 1fr; 
  } 
}

/* Modern card with subtle shadow */
.card { 
  background: var(--card); 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.row { 
  display: flex; 
  gap: .75rem; 
  align-items: flex-start; 
  margin: .75rem 0; 
}

.grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: .75rem; 
}

@media(min-width:800px){
  .grid { 
    grid-template-columns: 1fr 1fr; 
  }
  .checkbox { 
    grid-column: 1/-1; 
  }
}

/* ---------- Forms ---------- */
label { 
  font-weight: 600; 
  display: block; 
  margin-bottom: .25rem;
  color: var(--fg);
}

textarea { 
  width: 100%; 
  min-height: 180px; 
  resize: vertical;
  font-family: 'Roboto', sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
}

input[type="text"], select, textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .6rem .7rem;
  width: 100%;
  background: #fff;
  font-family: 'Roboto', sans-serif;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

input[type="file"]{
  border: 1px dashed var(--border);
  padding: .6rem .7rem;
  border-radius: 10px;
  background: #fff;
  font-family: 'Roboto', sans-serif;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.checkbox input[type="checkbox"] {
  margin: 0;
  transform: translateY(0);
  accent-color: var(--secondary);
}

.checkbox + * { 
  margin-top: .25rem; 
}

.small { 
  font-size: .9rem; 
}

.muted { 
  color: var(--muted); 
}

.small, .muted { 
  font-size: .85rem; 
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ---------- Buttons / Actions ---------- */
.actions, .actions-row {
  display: flex;
  gap: .5rem;
  margin-top: .5rem;
  flex-wrap: wrap;
}

/* Primary button - uses brand secondary green */
button {
  border: 1px solid transparent;
  background: var(--secondary);
  color: #fff;
  padding: .6rem .9rem;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-family: 'Roboto', sans-serif;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  background: #15803d;
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Secondary button - uses brand primary blue */
button.secondary { 
  background: var(--primary);
}

button.secondary:hover:not(:disabled) {
  background: #1e40af;
}

/* Outline button */
button.outline { 
  background: #fff; 
  color: var(--primary); 
  border-color: var(--primary);
}

button.outline:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
}

/* Ghost button */
button.ghost { 
  background: #fff; 
  color: var(--fg); 
  border-color: var(--border);
}

button.ghost:hover:not(:disabled) {
  background: var(--bg);
}

button:disabled { 
  opacity: .6; 
  cursor: not-allowed; 
}

/* Copy buttons (compact) */
.copy-btn {
  font-size: .85rem;
  padding: .25rem .5rem;
}

/* Result headers */
.result-header,
.result-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

/* ---------- Results ---------- */
#result {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.result-block { 
  margin: .75rem 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
  transition: background 0.2s ease;
}

.result-block:hover {
  background: linear-gradient(to bottom, #fafbfc 0%, #f5f5f5 100%);
}

.result-block[hidden] { 
  display: none; 
}

/* NEW: Preserve line breaks in result content */
.result-block p,
.result-block div:not(.result-header):not(.result-block-head) {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Ensure spacing between sections */
.result-block + .result-block {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ---------- Section Headers (Professional Typography) ---------- */
.result-block h3,
.result-block-head h3,
.result-section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
  margin-top: 0;
  margin-bottom: 0.75rem;
  padding-left: 0.75rem;
  border-left: 4px solid var(--primary); /* Blue accent bar */
  transition: border-color 0.2s ease;
}

/* Subtle hover effect for interactive sections */
.result-block:hover h3 {
  border-left-color: #1e40af; /* Darker blue on hover */
}

pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafa;
  font-family: 'Roboto', sans-serif;  /* Changed from ui-monospace, monospace */
  font-size: 0.9rem;  /* ADD THIS LINE for consistency */
  line-height: 1.6;   /* ADD THIS LINE for readability */
}

/* ---------- Footer ---------- */
footer { 
  padding: 2rem 1rem; 
  text-align: center; 
  background: var(--primary);
  color: #fff;
  margin-top: 2rem;
}

.footer-copyright {
  margin: 0 0 .5rem 0;
  font-size: .85rem;
  opacity: 0.9;
}

.footer-tagline {
  margin: 0;
  font-size: .9rem;
  font-weight: 600;
}

/* ---------- Strategy picker ---------- */
.strategy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .3rem .6rem;
  margin-top: .35rem;
  align-items: start;
}

.strategy-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  line-height: 1.2;
  font-size: .9rem;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.strategy-pill:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: scale(1.02);
}

.strategy-pill input[type="checkbox"] {
  transform: translateY(1px) scale(.95);
  accent-color: var(--secondary);
}

#strategies-picker {
  max-height: 220px;
  overflow: auto;
  padding-right: .25rem;
}

/* Toast notifications */
.toast-bubble {
  position: absolute;
  transform: translateY(-50%);
  background: #111827;
  color: #fff;
  border-radius: 8px;
  padding: .3rem .5rem;
  font-size: .8rem;
  line-height: 1;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
  z-index: 50;
}

.toast-bubble.show {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.success-toast {
  background: var(--secondary) !important;
  color: #fff;
  font-weight: 600;
  padding: .5rem .75rem;
  font-size: .9rem;
}

/* ---------- Student Copy Modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh; /* Changed from 80vh */
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column; /* NEW: Enables sticky footer */
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;  /* Reduced vertical from 1rem to 0.75rem */
  border-bottom: 3px solid var(--primary);
  background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 0.75rem;  /* Reduced from 1rem */
  padding-bottom: 1.5rem;
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* NEW: Gradient fade above footer */
.modal-body::after {
  content: '';
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.95));
  pointer-events: none;
  z-index: 1;
}

.modal-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;  /* Reduced from 1rem */
  border-top: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.modal-footer-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-start;
  margin-bottom: 0.5rem;  /* ADD THIS - space before Drive card */
}

.student-section {
  margin-bottom: 0.5rem;  /* Reduced from 1rem - aggressive cut */
}

.student-section h4 {
  margin: 0 0 0.35rem 0;  /* Reduced from 0.5rem */
  font-size: 0.9rem;  /* Reduced from 0.95rem - slightly smaller headers */
  color: var(--fg);
}

.student-section pre {
  margin: 0;
  font-size: 0.9rem;
}

.student-section:empty {
  display: none;
}

.student-options {
  margin-bottom: 0.75rem;  /* Reduced from 1rem */
  padding-bottom: 0.75rem;  /* Reduced from 1rem */
  border-bottom: 1px solid var(--border);
}

.options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;  /* Reduced from 0.75rem */
}

.options-header h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg);
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  letter-spacing: -0.01em;
}

.select-controls {
  display: flex;
  gap: 0.5rem;
}

.select-controls button {
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
}

.checkbox-group {
  display: flex;
  gap: 0.75rem;  /* Reduced from 1rem */
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* Style modal checkboxes to match app aesthetic */
.checkbox-group .checkbox {
  background: #fff;
  padding: 0.3rem 0.5rem;  /* Reduced from 0.4rem 0.6rem */
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.checkbox-group .checkbox:hover {
  background: #f9fafb;
  border-color: var(--primary);
}

.checkbox-group .checkbox input[type="checkbox"] {
  accent-color: var(--secondary);
  cursor: pointer;
}

.checkbox-group .checkbox span {
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
}

@media (max-width: 480px) {
  .checkbox-group {
    flex-direction: column;
    gap: 0.5rem;
  }

  .options-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

.warning-toast {
  background: #fef3cd;
  border: 1px solid #fde047;
  color: #a16207;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Height limiting */
#out-original, #student-original {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#out-items {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#btn-docx { 
  display: none !important; 
}

/* Success animation */
@keyframes successPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.btn-success-animation {
  animation: successPulse 0.5s ease;
}

/* Main Differentiate button */
#btn-diff {
  font-size: 1rem;
  padding: 0.7rem 1.5rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

#btn-diff:hover:not(:disabled) {
  box-shadow: 0 6px 16px rgba(22, 163, 74, 0.4);
}

/* ---------- Custom Tooltips ---------- */
.custom-tooltip {
  position: absolute;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.4;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: normal;
  word-wrap: break-word;
}

.custom-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.custom-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--primary);
}

/* ---------- Google Drive Export Card ---------- */
.drive-export-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;  /* Reduced from 1.25rem */
  margin-top: 0.75rem;  /* Reduced from 1rem */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.drive-export-header {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 0.5rem 0;  /* Reduced from 1rem */
  padding-left: 0.75rem;
  border-left: 4px solid var(--primary);
  font-family: 'Roboto', sans-serif;
}

.drive-export-radios {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;  /* Reduced from 0.75rem */
  margin-bottom: 0.75rem;  /* Reduced from 1rem */
}

.drive-radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem;  /* Reduced from 0.5rem */
  border-radius: 6px;
  transition: background 0.2s ease;
}

.drive-radio-option:hover {
  background: #f9fafb;
}

.drive-radio-option input[type="radio"] {
  accent-color: var(--secondary);
  cursor: pointer;
  margin: 0;
}

.drive-radio-option label {
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0;
  cursor: pointer;
}

.drive-filename-container {
  margin-bottom: 0.75rem;  /* Reduced from 1rem */
}

.drive-filename-input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'Roboto', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.drive-filename-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.drive-tip {
  margin: 0.5rem 0 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.drive-export-button {
  width: 100%;
  margin-top: 0.5rem;
}

/* ---------- Google Drive Import Section (Promoted) ---------- */
.google-import-section {
  border-left: 4px solid var(--primary);  /* Blue accent */
  padding-left: 1rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(to right, rgba(30, 58, 138, 0.02), transparent);
}

.google-import-section label {
  color: var(--primary);
  font-weight: 600;
}

/* ---------- Custom File Upload Dropzone ---------- */
.file-upload-wrapper {
  position: relative;
}

.file-dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  background: #F9FAFB;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.file-dropzone:hover {
  border-color: var(--primary) !important;
  background: #F3F4F6 !important;
}

.file-dropzone.dragover {
  border-color: var(--secondary) !important;
  background: rgba(22, 163, 74, 0.05) !important;
  border-style: solid !important;
}

.file-dropzone-icon {
  font-size: 2rem;
  opacity: 0.5;
}

.file-dropzone-text {
  font-size: 0.9rem;
  color: var(--fg);
  font-weight: 500;
}

.file-dropzone-subtext {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Hide the actual file input */
.file-upload-wrapper input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  cursor: pointer;
}

/* ---------- Input Section Headers ---------- */
.input-section-header {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9CA3AF;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.input-section-header:first-of-type {
  margin-top: 0.75rem;
}

/* ---------- Final Polish - Input Panel ---------- */

/* Google Drive Section - More Breathing Room */
.google-import-section {
  border-left: 4px solid var(--primary);
  padding-left: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(to right, rgba(30, 58, 138, 0.02), transparent);
}

/* Textarea Styling - Match Dropzone Aesthetic */
#text {
  background: #F9FAFB;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

#text:focus {
  background: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

/* Differentiate Button - Wider and Centered */
#btn-diff {
  width: 90%;
  max-width: 400px;
  margin: 0 auto;
  display: block;
}

/* Section Headers - More Spacing */
.input-section-header {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9CA3AF;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

.input-section-header:first-of-type {
  margin-top: 0.75rem;
}

/* ---------- Space Optimization - Maximize Textarea ---------- */

/* Textarea - EXTRA TALL (primary focus) */
#text {
  min-height: 400px;  /* Increased from 320px */
  background: #F9FAFB;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

#text:focus {
  background: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

/* File Dropzone - EXTRA SHORT + CENTERED */
.file-dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;  /* Further reduced - was 1rem */
  text-align: center;
  background: #F9FAFB;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;  /* Further reduced - was 0.35rem */
}

.file-dropzone-icon {
  font-size: 1.25rem;  /* Further reduced - was 1.5rem */
  opacity: 0.5;
}

.file-dropzone-text {
  font-size: 0.875rem;  /* Slightly reduced */
  color: var(--fg);
  font-weight: 500;
}

.file-dropzone-subtext {
  font-size: 0.75rem;  /* Further reduced - was 0.8rem */
  color: var(--muted);
}

/* Section Headers - Tighter Spacing */
.input-section-header {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9CA3AF;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
}

.input-section-header:first-of-type {
  margin-top: 0.75rem;
}

/* Differentiate Button - Wider and Centered */
#btn-diff {
  width: 90%;
  max-width: 400px;
  margin: 0 auto;
  display: block;
}

/* ---------- Reading Level Gray-Out & Tooltip ---------- */
.reading-level-note {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.5rem;
  margin-bottom: 0;
  font-style: italic;
  line-height: 1.4;
}

/* Disabled reading level dropdown styling */
select#reading-level:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #f1f5f9;
}