/* ══════════════════════════════════════════════════════════════════════════════
   FISHFINDER — Lowrance-inspired retro fish finder UI
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  /* Device housing (charcoal gray, like the Lowrance body) */
  --housing:       #50545a;
  --housing-dark:  #3e4146;
  --housing-light: #62666c;
  --housing-edge:  #2e3136;

  /* LCD screen (muted sage green, classic fish finder) */
  --lcd:         #8d9b76;
  --lcd-dark:    #7d8b66;
  --lcd-darker:  #6d7b56;
  --lcd-text:    #0e1a04;
  --lcd-muted:   #1c2c0c;

  /* Highlight colors — tuned for readability on LCD green */
  --hl-valid-bg:       #9ab882;
  --hl-valid-text:     #1a3a08;
  --hl-changed-bg:     #82a8c8;
  --hl-changed-text:   #082840;
  --hl-outdated-bg:    #c8b060;
  --hl-outdated-text:  #483800;
  --hl-misspelled-bg:  #c88080;
  --hl-misspelled-text:#480808;
  --hl-unknown-bg:     #a080b8;
  --hl-unknown-text:   #280838;
  --hl-common-bg:      #80b8a8;
  --hl-common-text:    #083830;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #2a2520;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  gap: 1.5rem;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 2rem;
}

/* ── Accessibility utilities ──────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 9999;
}
.skip-link:focus {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  padding: 0.75rem 1.5rem;
  background: var(--housing);
  color: #e8eaed;
  font-size: 0.9rem;
  font-weight: 700;
  z-index: 9999;
  outline: 2px solid #a0c8e8;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ══════════════════════════════════════════════════════════════════════════════
   DEVICE HOUSING
   ══════════════════════════════════════════════════════════════════════════════ */
.device {
  background: linear-gradient(175deg, var(--housing-light) 0%, var(--housing) 40%, var(--housing-dark) 100%);
  border-radius: 14px;
  border: 2px solid var(--housing-edge);
  box-shadow:
    0 12px 40px rgba(0,0,0,0.5),
    0 4px 12px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.07);
  max-width: 920px;
  width: 100%;
  padding: 1.25rem 1.5rem 1rem;
}

/* ── Brand header ──────────────────────────────────────────────────────────── */
.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.4rem 0.5rem;
}

.brand {
  font-family: "Arial Black", Impact, "Helvetica Neue", sans-serif;
  font-weight: 900;
  font-size: 2.2rem;
  color: #e8eaed;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.model {
  font-family: Arial, sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  color: #c4c8ce;
  letter-spacing: 0.05em;
}

/* ══════════════════════════════════════════════════════════════════════════════
   SCREEN
   ══════════════════════════════════════════════════════════════════════════════ */

/* Dark bezel frame (recessed look) */
.screen-bezel {
  background: #2a2e34;
  border-radius: 6px;
  padding: 6px;
  box-shadow:
    inset 2px 2px 8px rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.05);
}

/* LCD surface */
.screen {
  position: relative;
  background: var(--lcd);
  border-radius: 3px;
  padding: 1.25rem;
  color: var(--lcd-text);
  font-size: 0.9rem;
  line-height: 1.6;
  overflow: hidden;
}

.screen.drag-over {
  outline: 2px dashed var(--lcd-muted);
  outline-offset: -4px;
  background: var(--lcd-dark);
}

/* Scanline overlay — subtle horizontal lines for LCD feel */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.03) 3px,
    rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* Watermark logo — faint green brand mark on the LCD */
.screen-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, 56%);
  height: auto;
  object-fit: contain;
  opacity: 0.04;
  pointer-events: none;
  z-index: 3;
}

/* Scan animation canvas overlay */
.scan-animation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  border-radius: 3px;
  cursor: pointer;
}

/* Content sits above scanlines visually but remains interactive */
.screen-content {
  position: relative;
  z-index: 2;
}

/* ── Screen labels (LCD readout style) ─────────────────────────────────────── */
.screen-label {
  display: block;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--lcd-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 0.3rem;
}

.input-hint {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.65rem;
  color: var(--lcd-muted);
  letter-spacing: 0.03em;
}

.file-name {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.65rem;
  color: var(--lcd-muted);
  letter-spacing: 0.03em;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-name:empty { display: none; }

/* ══════════════════════════════════════════════════════════════════════════════
   TEXTAREA (inset LCD area)
   ══════════════════════════════════════════════════════════════════════════════ */
textarea {
  display: block;
  width: 100%;
  padding: 0.75rem 0.85rem;
  background: var(--lcd-dark);
  border: 1px solid #2d3b1e;
  border-radius: 3px;
  box-shadow: inset 1px 1px 4px rgba(0,0,0,0.15);
  color: var(--lcd-text);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.75;
  resize: vertical;
  transition: border-color 0.15s;
}
textarea::placeholder {
  color: var(--lcd-muted);
  opacity: 0.6;
}
textarea:focus {
  outline: none;
  border-color: var(--lcd-muted);
  box-shadow: inset 1px 1px 4px rgba(0,0,0,0.15), 0 0 0 2px rgba(30,46,16,0.15);
}

/* LCD-themed scrollbar */
textarea::-webkit-scrollbar         { width: 8px; }
textarea::-webkit-scrollbar-track   { background: var(--lcd-darker); }
textarea::-webkit-scrollbar-thumb   { background: var(--lcd-muted); border-radius: 4px; }

/* ══════════════════════════════════════════════════════════════════════════════
   LOADING / ERROR STATES
   ══════════════════════════════════════════════════════════════════════════════ */
.loading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0 0.75rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.8rem;
  color: var(--lcd-muted);
  position: relative;
  z-index: 2;
}
.loading[hidden] {
  display: none;
}
.loading-spinner {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 2px solid var(--lcd-darker);
  border-top-color: var(--lcd-text);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.load-error {
  padding: 0.8rem;
  background: var(--lcd-dark);
  border: 1px solid #8a6a5a;
  border-radius: 3px;
  color: #3f0d05;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.8rem;
  position: relative;
  z-index: 2;
}
.load-error code {
  background: var(--lcd-darker);
  padding: 0.1em 0.3em;
  border-radius: 2px;
  font-size: 0.85em;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESULTS
   ══════════════════════════════════════════════════════════════════════════════ */
#results-section {
  position: relative;
  z-index: 2;
}

.results-divider {
  height: 1px;
  background: var(--lcd-darker);
  margin: 1rem 0;
}

/* ── Legend (LCD status indicators) ────────────────────────────────────────── */
.legend {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.legend-item {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.12);
}
.legend-item.valid      { background: var(--hl-valid-bg);      color: var(--hl-valid-text); }
.legend-item.changed    { background: var(--hl-changed-bg);    color: var(--hl-changed-text); }
.legend-item.outdated   { background: var(--hl-outdated-bg);   color: var(--hl-outdated-text); }
.legend-item.misspelled { background: var(--hl-misspelled-bg); color: var(--hl-misspelled-text); }
.legend-item.unknown    { background: var(--hl-unknown-bg);    color: var(--hl-unknown-text); }
.legend-item.common     { background: var(--hl-common-bg);     color: var(--hl-common-text); }

/* ── Results grid ──────────────────────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.panel-header {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--lcd-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Highlighted text (LCD readout area) ───────────────────────────────────── */
.highlighted-text {
  background: var(--lcd-dark);
  border: 1px solid var(--lcd-darker);
  border-radius: 3px;
  padding: 0.75rem 0.85rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.85rem;
  line-height: 1.8;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.1);
  color: var(--lcd-text);
}

.highlighted-text::-webkit-scrollbar       { width: 8px; }
.highlighted-text::-webkit-scrollbar-track { background: var(--lcd-darker); }
.highlighted-text::-webkit-scrollbar-thumb { background: var(--lcd-muted); border-radius: 4px; }

/* ── Species list (inside highlighted-text container) ──────────────────────── */
.species-row {
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 0.85rem;
  line-height: 1.5;
}
.species-row:last-child { border-bottom: none; }

.species-empty {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.75rem;
  color: var(--lcd-muted);
  text-align: center;
  padding: 1rem;
}

.species-badge {
  background: var(--lcd-dark);
  color: var(--lcd-text);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1em 0.45em;
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
}
.species-badge:empty { display: none; }

.confirm-hint {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.65rem;
  color: var(--hl-changed-text);
  opacity: 0.8;
  font-style: normal;
}

/* ── Highlight spans ───────────────────────────────────────────────────────── */
.hl {
  border-radius: 2px;
  padding: 0.05em 0.18em;
  cursor: help;
}
.hl.valid      { background: var(--hl-valid-bg);      color: var(--hl-valid-text); }
.hl.changed    { background: var(--hl-changed-bg);    color: var(--hl-changed-text);
                 text-decoration: underline; text-decoration-style: dotted; }
.hl.outdated   { background: var(--hl-outdated-bg);   color: var(--hl-outdated-text);
                 text-decoration: underline; text-decoration-style: wavy; }
.hl.misspelled { background: var(--hl-misspelled-bg); color: var(--hl-misspelled-text);
                 text-decoration: underline; text-decoration-style: wavy; }
.hl.unknown    { background: var(--hl-unknown-bg);    color: var(--hl-unknown-text);
                 text-decoration: underline; text-decoration-style: dotted; }
.hl.common     { background: var(--hl-common-bg);     color: var(--hl-common-text); }

/* ══════════════════════════════════════════════════════════════════════════════
   ISSUES TABLE
   ══════════════════════════════════════════════════════════════════════════════ */
.issue-badge {
  background: #7a3838;
  color: #f0d0d0;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1em 0.45em;
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
}
.issue-badge:empty { display: none; }

.no-issues {
  padding: 0.6rem 0.8rem;
  background: var(--hl-valid-bg);
  color: var(--hl-valid-text);
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
  font-size: 0.75rem;
  text-align: center;
}

#table-wrap {
  overflow-x: auto;
  border-radius: 3px;
  border: 1px solid var(--lcd-darker);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  background: var(--lcd-dark);
  color: var(--lcd-text);
}
th {
  background: var(--lcd-dark);
  padding: 0.45rem 0.65rem;
  text-align: left;
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--lcd-muted);
  color: var(--lcd-text);
}
td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
td.name-cell { font-style: italic; }

/* Status badges — colored pills for readability on LCD */
.status-valid,
.status-changed,
.status-outdated,
.status-misspelled,
.status-unknown {
  display: inline-block;
  padding: 0.08em 0.4em;
  border-radius: 2px;
  font-weight: 700;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}
.status-valid      { background: var(--hl-valid-bg);      color: var(--hl-valid-text); }
.status-changed    { background: var(--hl-changed-bg);    color: var(--hl-changed-text); }
.status-outdated   { background: var(--hl-outdated-bg);   color: var(--hl-outdated-text); }
.status-misspelled { background: var(--hl-misspelled-bg); color: var(--hl-misspelled-text); }
.status-unknown    { background: var(--hl-unknown-bg);    color: var(--hl-unknown-text); }
.status-common     { background: var(--hl-common-bg);     color: var(--hl-common-text); }

.common-name {
  color: var(--lcd-muted);
  font-style: normal;
}

/* ══════════════════════════════════════════════════════════════════════════════
   DEVICE BUTTONS (Lowrance-style physical controls)
   ══════════════════════════════════════════════════════════════════════════════ */
.controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 0 0.25rem;
  flex-wrap: wrap;
}

a.device-btn {
  text-decoration: none;
  text-align: center;
}
a.device-btn:hover { color: #c0c8d0; }

.device-btn {
  background: linear-gradient(180deg, #50545a 0%, #42464c 50%, #36393e 100%);
  border: 1.5px solid var(--housing-edge);
  border-radius: 18px;
  color: #c0c8d0;
  padding: 0.55rem 1.6rem;
  font-family: Arial, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 2px 4px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.08);
  transition: all 0.1s;
  min-width: 80px;
}
.device-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #5a5e64 0%, #4c5056 50%, #404448 100%);
  color: #c0c8d0;
}
.device-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    0 1px 2px rgba(0,0,0,0.3),
    inset 0 1px 3px rgba(0,0,0,0.2);
}
.device-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.device-btn:focus-visible {
  outline: 2px solid #a0c8e8;
  outline-offset: 2px;
}

/* Primary button (SCAN) — subtle blue accent like Lowrance branding */
.device-btn.primary {
  background: linear-gradient(180deg, #445566 0%, #3a4a5a 50%, #304050 100%);
  border-color: #283848;
  color: #a0c8e8;
}
.device-btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4e6070 0%, #445464 50%, #3a4a5a 100%);
  color: #b0d8f8;
}

/* ══════════════════════════════════════════════════════════════════════════════
   DEVICE FOOTER
   ══════════════════════════════════════════════════════════════════════════════ */
.device-footer {
  text-align: center;
  padding: 0.75rem 0.5rem 0.25rem;
  font-size: 0.65rem;
  color: #c0c8d0;
  letter-spacing: 0.01em;
}

/* ══════════════════════════════════════════════════════════════════════════════
   INFO MODAL
   ══════════════════════════════════════════════════════════════════════════════ */
/* ── Info panel (on-screen, matches textarea style) ───────────────────────── */
.info-panel {
  position: absolute;
  inset: 0;
  background: var(--lcd-dark);
  border: 1px solid #2d3b1e;
  border-radius: 3px;
  box-shadow: inset 1px 1px 4px rgba(0,0,0,0.15);
  z-index: 10;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.75;
  color: var(--lcd-text);
}
.info-panel[hidden] { display: none; }
.info-panel::-webkit-scrollbar       { width: 8px; }
.info-panel::-webkit-scrollbar-track { background: var(--lcd-darker); }
.info-panel::-webkit-scrollbar-thumb { background: var(--lcd-muted); border-radius: 4px; }

.info-panel-header {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lcd-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--lcd-darker);
}

.info-panel h3 {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lcd-muted);
  margin: 1rem 0 0.4rem;
  border-top: 1px solid var(--lcd-darker);
  padding-top: 0.5rem;
}

.info-panel p { margin-bottom: 0.5rem; }
.info-panel ol, .info-panel ul {
  padding-left: 1.3rem;
  margin-bottom: 0.5rem;
}
.info-panel li { margin-bottom: 0.25rem; }

.info-panel a {
  color: var(--lcd-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.info-panel a:hover { color: var(--lcd-text); }

/* ── Report form (on-screen) ──────────────────────────────────────────────── */
.report-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.report-label {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lcd-muted);
  margin-top: 0.3rem;
}

.report-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--lcd-darker);
  border: 1px solid #2d3b1e;
  border-radius: 3px;
  color: var(--lcd-text);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  box-sizing: border-box;
}
.report-input:focus {
  outline: none;
  border-color: var(--lcd-muted);
}
.report-input::placeholder {
  color: var(--lcd-muted);
  opacity: 0.5;
}

select.report-input {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231c2c0c' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

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

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

.report-status {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  text-align: center;
  padding: 0.4rem;
  border-radius: 3px;
  margin-top: 0.25rem;
}
.report-status.success {
  color: #9ab882;
  background: rgba(154, 184, 130, 0.1);
}
.report-status.error {
  color: #c88080;
  background: rgba(200, 128, 128, 0.1);
}

.modal-body {
  font-size: 0.85rem;
  line-height: 1.75;
  color: var(--lcd-text);
}
.modal-body p { margin-bottom: 0.6rem; }
.modal-body h3 {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lcd-muted);
  margin: 1.1rem 0 0.4rem;
  border-top: 1px solid var(--lcd-darker);
  padding-top: 0.6rem;
}
.modal-body ol, .modal-body ul {
  padding-left: 1.3rem;
  margin-bottom: 0.5rem;
}
.modal-body li { margin-bottom: 0.25rem; }

/* ══════════════════════════════════════════════════════════════════════════════
   CITATIONS SECTION
   ══════════════════════════════════════════════════════════════════════════════ */
.citations-section {
  max-width: 920px;
  width: 100%;
  background: #211f1b;
  border: 1px solid #3a3630;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.citations-header {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #8a8e86;
  margin-bottom: 0.85rem;
}

.citations-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.citation-entry a {
  color: #c8d0b8;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.citation-entry a:hover {
  color: #e0e8d0;
}

.citation-entry {
  font-size: 0.78rem;
  line-height: 1.65;
  color: #9a9e94;
  padding-left: 1.2rem;
  text-indent: -1.2rem;
}
.citation-entry em { font-style: italic; }

.citation-placeholder {
  color: #8a8e86;
  font-style: italic;
  border-left: 2px solid #3a3630;
  padding-left: 0.75rem;
  text-indent: 0;
}

.cite-copy-btn {
  margin-top: 1rem;
  background: linear-gradient(180deg, #2e2c28 0%, #252320 100%);
  border: 1px solid #3a3630;
  border-radius: 4px;
  color: #80847a;
  padding: 0.4rem 1rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.1s;
}
.cite-copy-btn:hover {
  background: linear-gradient(180deg, #363430 0%, #2c2a26 100%);
  color: #a0a498;
  border-color: #504c48;
}
.cite-copy-btn:active {
  transform: translateY(1px);
}
.cite-copy-btn:focus-visible {
  outline: 2px solid #80847a;
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   AFFILIATIONS MODULE
   ══════════════════════════════════════════════════════════════════════════════ */
.affiliations-section {
  max-width: 920px;
  width: 100%;
  background: #211f1b;
  border: 1px solid #3a3630;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.affiliations-header {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #8a8e86;
  margin-bottom: 1rem;
}

.affiliations-body {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.affiliation-link {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.affiliation-link:hover {
  opacity: 0.85;
  transform: scale(1.04);
}
.affiliation-link:first-child {
  background: #fff;
  padding: 0.5rem 0.7rem;
  border-radius: 16px;
  max-width: 100%;
}
.affiliation-link:first-child .affiliation-logo {
  height: 150px;
}

.affiliation-logo {
  height: 250px;
  width: auto;
  max-width: 100%;
  transition: filter 0.2s ease;
}

/* ══════════════════════════════════════════════════════════════════════════════
   SUPPORT MODULE
   ══════════════════════════════════════════════════════════════════════════════ */
.support-section {
  max-width: 920px;
  width: 100%;
  background: #211f1b;
  border: 1px solid #3a3630;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.support-header {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #8a8e86;
  margin-bottom: 0.85rem;
}

.support-body {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.support-thumb {
  width: 340px;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid #3a3630;
}

.support-pitch {
  flex: 1 1 280px;
  min-width: 0;
}

.support-text {
  font-size: 0.78rem;
  line-height: 1.65;
  color: #9a9e94;
  max-width: 540px;
  margin: 0 0 1rem;
}

.support-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #2e2c28 0%, #252320 100%);
  border: 1px solid #3a3630;
  border-radius: 4px;
  color: #80847a;
  padding: 0.4rem 1rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s;
}
.support-btn:hover {
  background: linear-gradient(180deg, #363430 0%, #2c2a26 100%);
  color: #a0a498;
  border-color: #504c48;
}
.support-btn:active {
  transform: translateY(1px);
}
.support-btn:focus-visible {
  outline: 2px solid #80847a;
  outline-offset: 2px;
}

.support-methods {
  margin-top: 0.6rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.58rem;
  color: #8a8e86;
  letter-spacing: 0.03em;
}

/* ══════════════════════════════════════════════════════════════════════════════
   USAGE DASHBOARD
   ══════════════════════════════════════════════════════════════════════════════ */
.dashboard {
  max-width: 920px;
  width: 100%;
  background: #211f1b;
  border: 1px solid #3a3630;
  border-radius: 8px;
  padding: 1.25rem 1.5rem 1rem;
}

.dashboard-header {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #8a8e86;
  margin-bottom: 1rem;
}

.stats-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  flex: 1;
  background: #1a1816;
  border: 1px solid #2e2c28;
  border-radius: 6px;
  padding: 0.85rem 1rem;
  text-align: center;
}

.stat-value {
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: #a8c080;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.stat-label {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: #8a8e86;
  margin-top: 0.3rem;
  text-transform: uppercase;
}

.usage-map {
  height: 300px;
  border-radius: 5px;
  border: 1px solid #2e2c28;
  overflow: hidden;
  background: #1a1816;
  margin-bottom: 0.6rem;
  /* Leaflet overrides for dark theme */
}
.usage-map .leaflet-container {
  background: #1a2030;
}

.dashboard-note {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.58rem;
  color: #8a8e86;
  text-align: center;
  letter-spacing: 0.02em;
}

.dashboard-setup-msg {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.7rem;
  color: #8a8e86;
  text-align: center;
  padding: 2rem;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════════════════════════
   CONSENT BANNER
   ══════════════════════════════════════════════════════════════════════════════ */
.consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #1a1816;
  border-top: 2px solid #3e3c38;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  flex-wrap: wrap;
}
.consent-banner[hidden] {
  display: none;
}
.consent-text {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.75rem;
  color: #c4c8c0;
  line-height: 1.5;
  max-width: 600px;
  margin: 0;
}
.consent-text a {
  color: #a0c8e8;
  text-decoration: underline;
}
.consent-buttons {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}
.consent-btn {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.4rem 1rem;
  border: 1px solid #3e3c38;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.03em;
}
.consent-accept {
  background: #2a3a20;
  color: #b4c8a0;
}
.consent-accept:hover { background: #3a4a2a; }
.consent-decline {
  background: #2e2c28;
  color: #8a8e86;
}
.consent-decline:hover { background: #3e3c38; }
.consent-btn:focus-visible {
  outline: 2px solid #a0c8e8;
  outline-offset: 2px;
}

.privacy-link {
  color: #8c9096;
  text-decoration: underline;
  cursor: pointer;
}
.privacy-link:hover { color: #a0c8e8; }

/* Leaflet attribution: subtle, expand on hover */
.usage-map .leaflet-control-attribution {
  max-width: 20px !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  background: rgba(0,0,0,0.5) !important;
  color: #8c9096 !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
  transition: max-width 0.3s ease !important;
}
.usage-map .leaflet-control-attribution:hover {
  max-width: 400px !important;
}
.usage-map .leaflet-control-attribution a {
  color: #8c9096 !important;
}
.usage-map .leaflet-control-zoom a {
  background-color: rgba(0,0,0,0.5) !important;
  color: #8c9096 !important;
  border-color: #444 !important;
}
.usage-map .leaflet-control-zoom a:hover {
  background-color: rgba(0,0,0,0.7) !important;
  color: #c0c8d0 !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  body { padding: 0.5rem; gap: 1rem; }
  .device { padding: 0.75rem 1rem 0.75rem; border-radius: 10px; }
  .screen { padding: 0.85rem; }
  .results-grid { grid-template-columns: 1fr; }
  .brand { font-size: 1.8rem; }
  .stats-row { flex-direction: column; }
  .citations-section, .affiliations-section, .support-section, .dashboard { padding: 1rem; }
  .affiliations-body { gap: 1.5rem; }
  .affiliation-logo { height: 190px; }
  .device-btn,
  .consent-btn,
  .cite-copy-btn,
  .support-btn { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation: none; }
  textarea,
  .device-btn,
  .cite-copy-btn,
  .support-btn,
  .affiliation-logo { transition: none; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   ONBOARDING HINT (first session only)
   Overlayed at the bottom of the text input area. Click-through pass to
   textarea except on the dismiss button.
   ══════════════════════════════════════════════════════════════════════════════ */
.text-input-wrap {
  position: relative;
}

/* ── Placeholder overlay with blinking cursor ─────────────────────────────────
   Replaces the native placeholder so we can render a blinking caret next to
   it, making the input area visibly interactive. Native placeholder is set to
   a single space and hidden via transparent color (see textarea::placeholder
   override below). Shown only when textarea is empty AND unfocused. */
.placeholder-overlay {
  position: absolute;
  top: 0.75rem;        /* match textarea padding-top */
  left: 0.85rem;       /* match textarea padding-left */
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--lcd-muted);
  opacity: 0.6;
  pointer-events: none;
  user-select: none;
  z-index: 3;
}
.placeholder-text { white-space: pre; }

.blinking-cursor {
  display: inline-block;
  margin-left: 1px;
  font-weight: 700;
  animation: cursor-blink 1.05s steps(2, start) infinite;
}

@keyframes cursor-blink {
  to { visibility: hidden; }
}

/* Hide overlay when user focuses the textarea or types anything */
.text-input-wrap textarea:focus ~ .placeholder-overlay,
.text-input-wrap textarea:not(:placeholder-shown) ~ .placeholder-overlay {
  display: none;
}

/* Hide the native placeholder since the overlay supplies the visible text */
#manuscript-text::placeholder { color: transparent; }

/* Respect reduced-motion preference — keep the cursor visible but static */
@media (prefers-reduced-motion: reduce) {
  .blinking-cursor { animation: none; }
}

.onboarding-hint {
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--lcd-muted);
  color: var(--lcd);
  border: 1px solid var(--lcd-text);
  border-radius: 3px;
  padding: 0.5rem 0.65rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 4;
  cursor: pointer; /* whole banner dismisses on click */
}
/* Critical: .onboarding-hint has display: flex, which overrides the browser's
   default [hidden] { display: none }. Must restore display: none for the
   hidden state, otherwise the banner stays visible even when dismissed. */
.onboarding-hint[hidden] { display: none; }
.onboarding-hint:hover { background: var(--lcd-text); }

.onboarding-text { flex: 1; }
.onboarding-text strong {
  letter-spacing: 0.05em;
  color: var(--hl-outdated-bg); /* sand/gold against the dark callout */
}

.onboarding-dismiss {
  background: transparent;
  border: 1px solid var(--lcd);
  border-radius: 2px;
  color: var(--lcd);
  font-family: Arial, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  padding: 0 0.45rem;
  cursor: pointer;
  flex-shrink: 0;
}
.onboarding-dismiss:hover { background: var(--lcd); color: var(--lcd-muted); }
.onboarding-dismiss:focus-visible {
  outline: 2px solid var(--lcd);
  outline-offset: 1px;
}

/* Quick start list (top of INFO panel) — compact and visually distinct */
.quick-start {
  background: var(--lcd-dark);
  border-radius: 3px;
  padding: 0.5rem 0.75rem 0.5rem 2rem;
  margin: 0 0 0.6rem 0;
}
.quick-start li { margin-bottom: 0.3rem; }
.quick-start li:last-child { margin-bottom: 0; }

.info-tip {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--lcd-muted);
  margin-bottom: 0.6rem !important;
}

/* ══════════════════════════════════════════════════════════════════════════════
   HIGH-CONTRAST DISPLAY MODE
   Toggled via the HI-CON button. Applied to <body> as data-theme="hi-contrast".
   All 23 default text/background pairs already meet WCAG AA (verified, Lighthouse
   100/100). HI-CON exceeds this with ≥7:1 ratios for all classification colors
   on a white background.
   ══════════════════════════════════════════════════════════════════════════════ */
body[data-theme="hi-contrast"] {
  --lcd:         #ffffff;
  --lcd-dark:    #f1f3f5;
  --lcd-darker:  #d6dade;
  --lcd-text:    #15171a;
  --lcd-muted:   #404448;

  --hl-valid-bg:       #b8e8a0; /* WCAG ≥7:1 with valid-text */
  --hl-valid-text:     #0a2400;
  --hl-changed-bg:     #a0c8f0;
  --hl-changed-text:   #001838;
  --hl-outdated-bg:    #ffd070;
  --hl-outdated-text:  #302200;
  --hl-misspelled-bg:  #ff9090;
  --hl-misspelled-text:#3a0000;
  --hl-unknown-bg:     #c8a0e0;
  --hl-unknown-text:   #1f0033;
  --hl-common-bg:      #90d8c0;
  --hl-common-text:    #002a20;
}

/* Scanline overlay would harm readability on white — suppress in HI-CON */
body[data-theme="hi-contrast"] .screen::after {
  display: none;
}

/* Watermark logo is faint by design; further dim against white for clarity */
body[data-theme="hi-contrast"] .screen-watermark {
  opacity: 0.06;
}

/* Pressed-state styling for the HI-CON button itself when active */
.device-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, #2c3035 0%, #232629 50%, #1a1c1f 100%);
  color: #e0e6ec;
  box-shadow:
    inset 0 1px 3px rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.05);
}

/* In HI-CON, give the screen-bezel a slightly lighter inner shadow so the
   white LCD doesn't look "floating" against the dark device housing. */
body[data-theme="hi-contrast"] .screen-bezel {
  background: #1e2127;
  box-shadow:
    inset 2px 2px 8px rgba(0,0,0,0.4),
    0 1px 0 rgba(255,255,255,0.05);
}
