/* =====================================================================
 * Orwell — GLTHS Writing Tool stylesheet
 * Theme tokens (light + dark), WCAG-AA-aligned palette, reduced-motion,
 * focus-visible, responsive down to 320 px.
 * ===================================================================== */

/* ===== Light theme (default) ===== */
:root,
:root[data-theme="light"] {
  --navy:          #1F3886;
  --navy-dark:     #162a6a;
  --navy-deep:     #0f1e4d;
  --gold:          #FFCA38;
  --gold-aa:       #8A6300;   /* darkened for AA on white */
  --bronze:        #6b5831;

  --bg:            #f5f6f8;
  --editor-bg:     #ffffff;
  --panel-bg:      #f0f2f7;
  --surface-1:     #ffffff;
  --surface-2:     #f7f8fb;
  --border:        #dde1ec;
  --border-strong: #c8ceda;
  --text:          #1a1d2e;
  --text-muted:    #5b6474;
  --placeholder:   #8a92a2;

  /* Highlight underlines — all tested ≥ 4.5:1 on #ffffff and #1f1f24 */
  --red-stroke:    #b71c1c;
  --yellow-stroke: #8a6300;
  --blue-stroke:   #1F3886;
  --purple-stroke: #5b21b6;
  --green-stroke:  #15803d;
  --orange-stroke: #9a3412;
  --teal-stroke:   #0e6c66;
  --pink-stroke:   #861551;
  --indigo-stroke: #3730a3;
  --amber-stroke:  #78350f;
  --slate-stroke:  #334155;

  --red-bg:        rgba(183, 28, 28,  0.12);
  --yellow-bg:     rgba(138, 99, 0,   0.16);
  --blue-bg:       rgba(31, 56, 134,  0.12);
  --purple-bg:     rgba(91, 33, 182,  0.12);
  --green-bg:      rgba(21, 128, 61,  0.12);
  --orange-bg:     rgba(154, 52, 18,  0.13);
  --teal-bg:       rgba(14, 108, 102, 0.14);
  --pink-bg:       rgba(134, 21, 81,  0.14);
  --indigo-bg:     rgba(55, 48, 163,  0.12);
  --amber-bg:      rgba(120, 53, 15,  0.14);
  --slate-bg:      rgba(51, 65, 85,   0.13);

  --toast-bg:      #1a1d2e;
  --toast-text:    #ffffff;

  --accent-soft:   rgba(31, 56, 134, 0.08);

  --font-display:  'Bebas Neue', 'Arial Narrow', sans-serif;
  --font-ui:       'Lato', 'Helvetica Neue', Arial, sans-serif;
  --font-editor:   'Georgia', 'Times New Roman', serif;

  --nav-height:    58px;
  --panel-width:   260px;
  --radius:        6px;

  --focus-ring:    0 0 0 3px rgba(31, 56, 134, 0.45);
}

/* ===== Dark theme ===== */
:root[data-theme="dark"] {
  --navy:          #3a5bb5;
  --navy-dark:     #28437c;
  --navy-deep:     #17224a;
  --gold:          #FFD86B;
  --gold-aa:       #FFD86B;
  --bronze:        #cfb98a;

  --bg:            #12141c;
  --editor-bg:     #1b1f2b;
  --panel-bg:      #181b26;
  --surface-1:     #1b1f2b;
  --surface-2:     #232839;
  --border:        #2f3548;
  --border-strong: #424a63;
  --text:          #eaecf3;
  --text-muted:    #a7aec0;
  --placeholder:   #676e80;

  --red-stroke:    #ff7a7a;
  --yellow-stroke: #FFD86B;
  --blue-stroke:   #8ba7ff;
  --purple-stroke: #b39bff;
  --green-stroke:  #7cd9a0;
  --orange-stroke: #ffa76b;
  --teal-stroke:   #70d2ca;
  --pink-stroke:   #ff94c6;
  --indigo-stroke: #b3b6ff;
  --amber-stroke:  #ffbf7a;
  --slate-stroke:  #c8cfdd;

  --red-bg:        rgba(255, 122, 122, 0.15);
  --yellow-bg:     rgba(255, 216, 107, 0.15);
  --blue-bg:       rgba(139, 167, 255, 0.14);
  --purple-bg:     rgba(179, 155, 255, 0.14);
  --green-bg:      rgba(124, 217, 160, 0.14);
  --orange-bg:     rgba(255, 167, 107, 0.14);
  --teal-bg:       rgba(112, 210, 202, 0.14);
  --pink-bg:       rgba(255, 148, 198, 0.14);
  --indigo-bg:     rgba(179, 182, 255, 0.14);
  --amber-bg:      rgba(255, 191, 122, 0.14);
  --slate-bg:      rgba(200, 207, 221, 0.14);

  --toast-bg:      #eaecf3;
  --toast-text:    #12141c;

  --accent-soft:   rgba(139, 167, 255, 0.12);

  --focus-ring:    0 0 0 3px rgba(255, 216, 107, 0.55);
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Focus outline (baseline) ===== */
:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

/* ===== Nav ===== */
.top-bar {
  flex-shrink: 0;
  background: var(--navy);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 12px rgba(15, 30, 77, 0.35);
  position: relative;
  z-index: 10;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-logo {
  height: 36px;
  width: auto;
  display: block;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

.nav-title-group {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.nav-app-name {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.nav-tagline {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-style: italic;
  color: #fff;             /* 4.5:1 on navy */
  letter-spacing: 0.03em;
  margin-top: 2px;
}

.theme-toggle {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.22);
}

.theme-toggle-icon {
  font-size: 13px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}

.nav-btn:hover { background: rgba(255,255,255,0.22); }
.nav-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.nav-btn-icon { font-size: 13px; }

.export-menu-wrapper {
  position: relative;
}

.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 6px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.export-menu-item {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  text-align: left;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.export-menu-item:hover { background: var(--accent-soft); }
.export-menu-item:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: -2px;
}

/* ===== Drafts drawer ===== */
.drafts-drawer {
  position: fixed;
  top: var(--nav-height);
  right: 0;
  width: 340px;
  max-width: 92vw;
  height: calc(100vh - var(--nav-height));
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(0,0,0,0.12);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 20px;
  overflow-y: auto;
}

.drafts-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.drafts-drawer-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--navy);
  margin: 0;
  letter-spacing: 0.02em;
}

.drafts-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 6px;
}

.drafts-close-btn:hover { color: var(--text); }
.drafts-close-btn:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.new-draft-btn {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  margin-bottom: 16px;
}
.new-draft-btn:hover { background: var(--navy-dark, #162a66); }
.new-draft-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.drafts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drafts-empty {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  line-height: 1.5;
}

.draft-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: var(--editor-bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.draft-item-active {
  border-color: var(--navy);
  background: var(--accent-soft);
}

.draft-open {
  background: transparent;
  border: none;
  text-align: left;
  padding: 2px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text);
}

.draft-open:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
  border-radius: 4px;
}

.draft-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--navy);
}

.draft-meta {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.draft-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.draft-rename,
.draft-delete {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-ui);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.draft-rename:hover { background: var(--accent-soft); }
.draft-delete:hover { background: #fde8e8; color: #8b1c1c; border-color: #e5b5b5; }

.draft-rename:focus-visible,
.draft-delete:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

/* ===== Paragraph heatmap rail ===== */
.editor-stage {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.paragraph-heatmap {
  flex-shrink: 0;
  width: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
}

.heatmap-band {
  flex: 1 1 auto;
  min-height: 12px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s;
}

.heatmap-band:hover { transform: scaleX(1.6); }
.heatmap-band:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.band-empty { background: var(--border); }
.band-cool  { background: #3b7bbf; }  /* below target — a bit easy */
.band-on    { background: #2f7a3a; }  /* on target */
.band-warm  { background: #c27b0f; }
.band-hot   { background: #a63030; }

.editor-stage > #editor {
  flex: 1 1 auto;
}

/* ===== Simplify to target button ===== */
.simplify-btn {
  width: 100%;
  margin-top: 10px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s;
}

.simplify-btn:hover:not(:disabled) { background: var(--navy-dark, #162a66); }
.simplify-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.simplify-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ===== App layout ===== */
.app-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ===== Editor ===== */
.editor-wrapper {
  flex: 1;
  background: var(--editor-bg);
  overflow-y: auto;
  padding: 60px 80px;
  box-shadow: inset 2px 0 8px rgba(31,56,134,0.04);
}

.editor-intro { max-width: 680px; margin: 0 auto 18px; }

.intro-eyebrow {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--navy);
}

.editor-intro h1 {
  font-family: var(--font-ui);
  font-size: 30px;
  line-height: 1.1;
  color: var(--text);
  margin-top: 4px;
}

.intro-copy {
  margin-top: 8px;
  max-width: 60ch;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.editor-status-bar {
  max-width: 680px;
  margin: 0 auto 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.editor-helper,
.analysis-status {
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.5;
}

.editor-helper { color: var(--text-muted); }

.analysis-status {
  margin-top: 4px;
  color: var(--navy);
  font-weight: 700;
}

.analysis-status.is-error { color: var(--red-stroke); }
.analysis-status.is-loading { color: var(--gold-aa); }

#editor {
  max-width: 680px;
  margin: 0 auto;
  min-height: calc(100vh - 200px);
  font-family: var(--font-editor);
  font-size: 19px;
  line-height: 1.9;
  color: var(--text);
  word-wrap: break-word;
  white-space: pre-wrap;
  caret-color: var(--navy);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 32px 40px;
  background: var(--editor-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#editor:focus { outline: none; }

#editor:focus-visible {
  border-color: var(--navy);
  box-shadow: var(--focus-ring);
}

#editor:empty::before {
  content: attr(data-placeholder);
  color: var(--placeholder);
  pointer-events: none;
  font-style: italic;
}

/* ===== Highlights ===== */
.highlight-red,
.highlight-yellow,
.highlight-blue,
.highlight-purple,
.highlight-green,
.highlight-orange,
.highlight-teal,
.highlight-pink,
.highlight-indigo,
.highlight-amber,
.highlight-underline {
  border-radius: 2px;
  border-bottom-style: solid;
  border-bottom-width: 2px;
}

.highlight-red    { background: var(--red-bg);    border-bottom-color: var(--red-stroke);    }
.highlight-yellow { background: var(--yellow-bg); border-bottom-color: var(--yellow-stroke); }
.highlight-blue   { background: var(--blue-bg);   border-bottom-color: var(--blue-stroke);   }
.highlight-purple { background: var(--purple-bg); border-bottom-color: var(--purple-stroke); }
.highlight-green  { background: var(--green-bg);  border-bottom-color: var(--green-stroke);  }
.highlight-orange { background: var(--orange-bg); border-bottom-color: var(--orange-stroke); }
.highlight-teal   { background: var(--teal-bg);   border-bottom-color: var(--teal-stroke);   }
.highlight-pink   { background: var(--pink-bg);   border-bottom-color: var(--pink-stroke);   }
.highlight-indigo { background: var(--indigo-bg); border-bottom-color: var(--indigo-stroke); }
.highlight-amber  { background: var(--amber-bg);  border-bottom-color: var(--amber-stroke);  }

/* sentence-starter variety: underline only, no background */
.highlight-underline {
  background: transparent;
  border-bottom-color: var(--slate-stroke);
  border-bottom-style: dashed;
}

[data-suggestion] { cursor: pointer; }

[data-start][data-end]:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

/* ===== Stats panel ===== */
.stats-panel {
  flex-shrink: 0;
  width: var(--panel-width);
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ===== Grade card ===== */
.grade-card {
  background: var(--navy);
  color: #fff;
  padding: 18px 18px 14px;
  border-bottom: 3px solid var(--gold);
}

.grade-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.grade-card-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #fff;
  opacity: 0.75;
}

.grade-confidence {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.grade-point-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.grade-point {
  font-family: var(--font-display);
  font-size: 48px;
  color: var(--gold);
  line-height: 1;
}

.grade-range {
  font-family: var(--font-ui);
  font-size: 11px;
  color: #fff;
  opacity: 0.85;
}

.grade-interpretation {
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.45;
  color: #fff;
  margin-top: 8px;
  opacity: 0.92;
}

.grade-card[data-state="on-target"] { border-bottom-color: #7cd9a0; }
.grade-card[data-state="above"]     { border-bottom-color: #ff9b6b; }
.grade-card[data-state="below"]     { border-bottom-color: #8ba7ff; }

/* Target grade controls */
.target-grade-group {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.18);
}

.target-grade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.target-grade-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.8);
}

.target-grade-preset {
  flex: 1;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 4px 6px;
  font-family: var(--font-ui);
  font-size: 11px;
  cursor: pointer;
}

.target-grade-preset option {
  color: #000;   /* so the dropdown list stays legible */
}

.target-grade-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

#target-grade-slider {
  flex: 1;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
}

#target-grade-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--navy-deep);
  cursor: pointer;
}

#target-grade-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--navy-deep);
  cursor: pointer;
}

#target-grade-slider:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 216, 107, 0.55);
}

.target-grade-value {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--gold);
  min-width: 26px;
  text-align: right;
}

.grade-delta {
  font-family: var(--font-ui);
  font-size: 11px;
  color: #fff;
  opacity: 0.88;
  margin-top: 8px;
  min-height: 14px;
}

/* ===== Stats grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.stat-item {
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--navy);
  letter-spacing: 0.02em;
  line-height: 1;
}

.stat-label {
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Legend ===== */
.legend {
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.legend-title {
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--navy);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--navy);
  display: inline-block;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: background 0.12s;
}

.legend-item:hover { background: rgba(31, 56, 134, 0.06); }

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.legend-glyph { display: inline-block; }

.swatch-red    { background: var(--red-stroke);    }
.swatch-yellow { background: var(--yellow-stroke); }
.swatch-blue   { background: var(--blue-stroke);   }
.swatch-purple { background: var(--purple-stroke); }
.swatch-green  { background: var(--green-stroke);  }
.swatch-orange { background: var(--orange-stroke); }
.swatch-teal   { background: var(--teal-stroke);   }
.swatch-pink   { background: var(--pink-stroke);   }
.swatch-indigo { background: var(--indigo-stroke); }
.swatch-brown  { background: var(--amber-stroke);  }
.swatch-slate  { background: var(--slate-stroke);  }

.legend-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-ui);
}

.legend-count {
  font-weight: 700;
  color: var(--navy);
  min-width: 18px;
  text-align: right;
}

.legend-desc {
  color: var(--text-muted);
  line-height: 1.3;
}

/* ===== Panel footer ===== */
.panel-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.orwell-quote {
  font-family: var(--font-ui);
  font-size: 11px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.65;
}

.orwell-quote cite {
  display: block;
  margin-top: 5px;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--bronze);
}

.glths-footer-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.footer-crest { height: 28px; width: auto; flex-shrink: 0; }

.glths-footer-mark span {
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--navy);
  line-height: 1.3;
  text-transform: uppercase;
}

/* ===== Suggestions ===== */
.suggestions-section {
  border-top: 1px solid var(--border);
  padding: 14px 16px 8px;
}

.suggestions-title {
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--navy);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--navy);
  display: inline-block;
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 6px 6px 8px;
  border-radius: var(--radius);
  margin-bottom: 3px;
  border-left: 3px solid transparent;
  transition: background 0.12s;
}

.suggestion-item:hover { background: rgba(31, 56, 134, 0.05); }
.suggestion-item.type-complex   { border-left-color: var(--purple-stroke); }
.suggestion-item.type-cliche    { border-left-color: var(--orange-stroke); }
.suggestion-item.type-redundant { border-left-color: var(--teal-stroke); }

.suggestion-words {
  flex: 1;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 11.5px;
  line-height: 1.4;
}

.suggestion-original {
  color: var(--text-muted);
  text-decoration: line-through;
  font-style: italic;
  word-break: break-word;
}

.suggestion-arrow {
  color: var(--navy);
  font-size: 10px;
  margin: 0 2px;
}

.suggestion-replacement {
  color: var(--navy);
  font-weight: 600;
  word-break: break-word;
}

.suggestion-replace-btn {
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s;
}

.suggestion-replace-btn:hover { background: var(--navy-dark); }

.suggestions-overflow {
  font-family: var(--font-ui);
  font-size: 10.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 0 2px;
  font-style: italic;
}

/* ===== Popup (dialog) ===== */
.suggestion-popup {
  position: fixed;
  z-index: 1000;
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 8px 28px rgba(15, 30, 77, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 24px));
  animation: popup-in 0.15s ease;
}

.suggestion-popup[hidden] { display: none; }

@keyframes popup-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.popup-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.popup-original {
  color: var(--text-muted);
  text-decoration: line-through;
  font-style: italic;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-arrow {
  color: var(--navy);
  font-size: 13px;
}

.popup-replacement {
  color: var(--navy);
  font-weight: 700;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-grade-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.popup-grade-hint[hidden] { display: none; }

.popup-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.popup-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 5px;
  padding: 5px 12px;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s, border-color 0.12s;
}

.popup-btn:hover { background: var(--border); }

.popup-accept {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.popup-accept:hover { background: var(--navy-dark); }

.popup-btn kbd {
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border: 1px solid currentColor;
  border-radius: 3px;
  opacity: 0.75;
  letter-spacing: 0.03em;
}

/* ===== Toast ===== */
.toast-region {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 10px 14px;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(15, 30, 77, 0.3);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
  max-width: 320px;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Scrollbars ===== */
.editor-wrapper::-webkit-scrollbar,
.stats-panel::-webkit-scrollbar { width: 5px; }

.editor-wrapper::-webkit-scrollbar-track,
.stats-panel::-webkit-scrollbar-track { background: transparent; }

.editor-wrapper::-webkit-scrollbar-thumb {
  background: rgba(31, 56, 134, 0.15);
  border-radius: 3px;
}

.stats-panel::-webkit-scrollbar-thumb {
  background: rgba(31, 56, 134, 0.2);
  border-radius: 3px;
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .app-layout { flex-direction: column; }
  .stats-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    overflow-y: visible;
  }
  .grade-card { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .panel-footer { display: none; }
  .editor-wrapper { padding: 28px 20px; }
  .editor-intro h1 { font-size: 24px; }
  .nav-tagline { display: none; }
  .nav-logo { height: 28px; }
}

@media (max-width: 480px) {
  .top-bar { padding: 0 14px; }
  .editor-wrapper { padding: 20px 14px; }
  #editor { padding: 20px 16px; font-size: 17px; line-height: 1.75; }
  .grade-point { font-size: 40px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .legend { padding: 12px 12px 6px; }
  .theme-toggle { padding: 4px 10px; font-size: 11px; }
  .theme-toggle-text,
  .nav-btn-text { display: none; }
  .nav-btn { padding: 4px 10px; }
  .drafts-drawer { width: 100%; }
  .paragraph-heatmap { width: 6px; }
}

@media (max-width: 360px) {
  .top-bar { padding: 0 10px; }
  .editor-wrapper { padding: 16px 10px; }
  #editor { padding: 16px 12px; font-size: 16px; }
  .grade-card { padding: 14px 12px; }
  .grade-point { font-size: 34px; }
  .target-grade-slider-row { flex-wrap: wrap; }
  .toast-region { left: 10px; right: 10px; bottom: 10px; }
  .toast { max-width: none; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .suggestion-popup { animation: none; }
  .toast { transition: none; }
}
