:root {
  --bg: #09111f;
  --panel: #101b2f;
  --panel-alt: #13223b;
  --text: #eef4ff;
  --text-soft: #b7c3da;
  --line: rgba(255,255,255,0.12);
  --accent: #62d7ff;
  --accent-2: #7ef0c5;
  --danger: #ff807a;
  --shadow: 0 20px 60px rgba(0,0,0,0.28);
  --font-size: 18px;
  --radius: 24px;
  --focus: #ffe27a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: var(--font-size);
  line-height: 1.65;
  background: linear-gradient(180deg, var(--bg) 0%, #0d1628 100%);
  color: var(--text);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button, a, input, select { border-radius: 18px; }
:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 4px;
}

body.light-mode {
  --bg: #f4f8ff;
  --panel: #ffffff;
  --panel-alt: #edf4ff;
  --text: #10213e;
  --text-soft: #4a5e83;
  --line: rgba(10,37,84,0.15);
  --shadow: 0 18px 40px rgba(39,78,139,0.10);
}

body.extra-contrast {
  --bg: #000000;
  --panel: #111111;
  --panel-alt: #181818;
  --text: #ffffff;
  --text-soft: #ffffff;
  --line: rgba(255,255,255,0.4);
  --focus: #00ffea;
}

body.more-spacing { line-height: 1.95; }
body.more-spacing p, body.more-spacing li { margin-bottom: 0.8em; }
body.dyslexia-mode { font-family: Verdana, Arial, sans-serif; letter-spacing: 0.02em; word-spacing: 0.08em; }

.skip-link {
  position: absolute;
  left: 14px;
  top: -60px;
  background: #fff;
  color: #111;
  padding: 12px 16px;
  z-index: 1000;
}
.skip-link:focus { top: 14px; }

.container { width: min(100% - 40px, 1180px); margin: 0 auto; }
.narrow { width: min(100%, 860px); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(9,17,31,0.82);
  border-bottom: 1px solid var(--line);
}
body.light-mode .topbar { background: rgba(255,255,255,0.88); }
.topbar-inner {
  min-height: 84px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 12px 0;
}
.topline { margin: 0 0 4px; color: var(--text-soft); }
.brand { font-size: 1.2rem; }
.tool-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
.mini-btn, .btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.mini-btn {
  min-height: 48px;
  padding: 10px 14px;
}
.link-btn { display: inline-flex; align-items: center; }

.hero { padding: 50px 0 18px; }
.hero-grid, .layout-grid, .info-grid, .timeline-grid {
  display: grid;
  gap: 24px;
}
.hero-grid { grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.85fr); align-items: start; }
.layout-grid { grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr); }
.info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.timeline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section { padding: 32px 0; }
.section-alt { background: rgba(255,255,255,0.02); }
body.light-mode .section-alt { background: rgba(18,69,149,0.04); }

.eyebrow, .card-label, .summary-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  color: var(--accent-2);
  margin: 0 0 12px;
}
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: clamp(2.1rem, 4vw, 3.7rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2.1vw, 1.7rem); }
p { margin: 0 0 16px; }
.lead { font-size: 1.1rem; color: var(--text-soft); }
.muted { color: var(--text-soft); }
.panel-subtitle, .section-lead { color: var(--text-soft); max-width: 760px; }

.hero-card, .panel, .search-panel, .info-card, .timeline-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.hero-card { position: sticky; top: 102px; }
.search-panel { margin-top: 20px; }
.field-label { display: block; font-weight: 700; margin-bottom: 10px; }
.small-label { margin-bottom: 6px; }
.search-row, .reader-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px auto;
  gap: 12px;
  align-items: stretch;
}
.search-actions-row, .section-head, .panel-head, .summary-top, .summary-box-head, .footer-grid {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.wrap-gap { flex-wrap: wrap; }
.search-actions-row { margin-top: 18px; flex-wrap: wrap; }
.inline-group { display: flex; flex-direction: column; gap: 6px; }
.button-group { flex-direction: row; flex-wrap: wrap; align-items: end; }
.search-panel input, .search-panel select {
  min-height: 62px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 14px 18px;
}
body.light-mode .search-panel input,
body.light-mode .search-panel select {
  background: #fff;
}
.btn {
  min-height: 58px;
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 700;
}
.small-btn { min-height: 46px; padding: 10px 14px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07233f;
  border: none;
}
.btn-secondary { background: var(--panel-alt); }
.form-note { margin-top: 16px; color: var(--text-soft); }

.info-strip, .quick-tags, .hero-stats, .result-meta, .cta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.info-strip span, .tag-btn, .pill, .check-tile {
  border: 1px solid var(--line);
  background: var(--panel-alt);
  border-radius: 16px;
}
.info-strip span, .pill { padding: 8px 12px; }
.tag-btn {
  padding: 10px 14px;
  color: var(--text);
  min-height: 46px;
}
.settings-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.check-tile {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
}
.check-tile input { width: 22px; height: 22px; }

.check-list, .plain-list, .step-list {
  padding-left: 20px;
  margin: 0;
}
.large-list li { margin-bottom: 12px; }
.hero-stats { margin-top: 18px; }
.hero-stats article {
  min-width: 110px;
  flex: 1 1 110px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: var(--panel-alt);
}
.hero-stats strong { display: block; font-size: 1.8rem; }
.small-note-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
}
kbd {
  background: #101010;
  color: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.95rem;
}
body.light-mode kbd { background: #1c2840; }

.summary-card {
  display: grid;
  gap: 20px;
}
.summary-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.summary-columns article, .summary-box {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  background: rgba(255,255,255,0.03);
}
.summary-highlight {
  background: linear-gradient(135deg, rgba(98,215,255,0.10), rgba(126,240,197,0.08));
}
.empty-state, .status-box {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 18px;
  color: var(--text-soft);
}
.context-note {
  margin-top: 14px;
  border-left: 4px solid var(--accent-2);
  padding-left: 14px;
  color: var(--text-soft);
}
.fact-list {
  margin: 16px 0 0;
  display: grid;
  gap: 12px;
}
.fact-list div {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255,255,255,0.03);
}
.fact-list dt { font-weight: 700; margin-bottom: 6px; }
.fact-list dd { margin: 0; color: var(--text-soft); }

.image-wrap {
  min-height: 300px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #050d17;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-wrap img { width: 100%; height: 100%; object-fit: cover; }
.image-fallback {
  color: var(--text-soft);
  padding: 24px;
  text-align: center;
}
.image-reader-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
}
.reader-image-grid { display: grid; grid-template-columns: 0.92fr 1.08fr; gap: 18px; }
.compact-image-wrap { min-height: 220px; }
.compact-facts { margin-top: 12px; }

.results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.result-card {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.result-select {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  width: 100%;
  padding: 0;
}
.thumb {
  min-height: 220px;
  background: #08111f;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
}
.result-content { padding: 18px; }
.result-title { margin-bottom: 10px; }
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 18px 18px;
}
.reader-results-grid, body.screenreader-mode .results-grid { grid-template-columns: 1fr; }
body.screenreader-mode .hero-grid,
body.screenreader-mode .layout-grid,
body.screenreader-mode .info-grid,
body.screenreader-mode .timeline-grid,
body.screenreader-mode .summary-columns { grid-template-columns: 1fr; }
body.screenreader-mode .hero-card,
body.screenreader-mode .panel,
body.screenreader-mode .search-panel,
body.screenreader-mode .info-card,
body.screenreader-mode .timeline-card { padding: 26px; }

.info-card p, .timeline-card p { color: var(--text-soft); }
.space-top { margin-top: 28px; }
.footer { border-top: 1px solid var(--line); padding: 26px 0 40px; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; color: var(--text-soft); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.reading-ruler {
  position: fixed;
  left: 0;
  right: 0;
  height: 60px;
  pointer-events: none;
  z-index: 9999;
  background: linear-gradient(to bottom, rgba(255,230,120,0.18), rgba(255,230,120,0.04));
  border-top: 2px solid rgba(255,226,122,0.85);
  border-bottom: 2px solid rgba(255,226,122,0.85);
}
body.ruler-active { cursor: crosshair; }

@media (max-width: 1080px) {
  .hero-grid, .layout-grid, .info-grid, .timeline-grid, .results-grid, .summary-columns, .reader-image-grid, .settings-grid {
    grid-template-columns: 1fr;
  }
  .hero-card { position: static; }
  .section-head, .panel-head, .summary-top, .search-actions-row, .summary-box-head, .footer-grid, .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .container { width: min(100% - 22px, 1180px); }
  .search-row, .reader-search-row { grid-template-columns: 1fr; }
  .panel, .hero-card, .search-panel, .info-card, .timeline-card { padding: 18px; }
  .tool-buttons { justify-content: flex-start; }
}


.preset-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.preset-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel-alt);
  color: var(--text);
  border-radius: 20px;
  padding: 16px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.preset-card strong { font-size: 1.05rem; }
.preset-card span { color: var(--text-soft); }
.journey-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}
.space-top { margin-top: 24px; }

@media (max-width: 960px) {
  .preset-grid,
  .journey-grid,
  .settings-grid,
  .info-grid,
  .timeline-grid,
  .hero-grid,
  .layout-grid {
    grid-template-columns: 1fr;
  }
}


.machine-box {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.03);
}

.machine-columns article {
  min-height: 100%;
}

.upload-card {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px dashed rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.025);
}

.upload-input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.2);
  color: inherit;
}

.vision-upload-preview {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 18px;
  margin-top: 1rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
}

.result-card.is-analyzing {
  outline: 2px solid rgba(255,255,255,0.18);
}

body.light-mode .upload-input {
  background: rgba(255,255,255,0.9);
  border-color: rgba(12,23,48,0.18);
}

body.light-mode .machine-box,
body.light-mode .upload-card {
  background: rgba(12,23,48,0.03);
  border-color: rgba(12,23,48,0.12);
}
