/* ===================================================================
   THEPH — developer-first / technical blueprint
   =================================================================== */

:root {
  /* base — cool pale slate (was creamy paper) */
  --bg:         #eceef4;
  --paper:      #f6f7fb;
  --paper-2:    #e3e6ef;
  --ink:        #0c0e16;
  --ink-2:      #1c1f2a;
  --ink-muted:  #5e6273;
  --ink-soft:   #9396a2;
  --rule:       #ccd0db;
  --rule-soft:  #dde0e9;

  /* functional palette */
  --ruby:     #c8324f;
  --ruby-soft:#f0bac8;
  --blue:       #3056d3;
  --blue-soft:  #c4cfee;
  --mint:       #3da872;
  --mint-soft:  #b9e0cb;
  --yellow:     #d8a02e;
  --yellow-soft:#f4dca5;
  --purple:     #7c4cdb;
  --purple-soft:#d8c8f3;
  --pink:       #d8488e;
  --pink-soft:  #f5c5dc;
  --cyan:       #2aa9c0;
  --cyan-soft:  #bce4ec;
  --red:        #d04848;

  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --max-w:      1240px;
  --pad-x:      32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ─────────── State toggle (hero vs reader) ─────────── */

.hero, .features { display: block; }
.reader-shell    { display: none; }

body.state-reading .hero,
body.state-reading .features { display: none; }
body.state-reading .reader-shell { display: block; }

/* ─────────── Topbar ─────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 32px;
  padding: 14px var(--pad-x);
  background: rgba(236, 238, 244, 0.88);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: inherit;
}
.brand-bracket {
  font-family: var(--font-mono);
  font-weight: 500;
}
.brand-bracket:first-child { color: var(--ruby); }
.brand-bracket:nth-child(3) { color: var(--blue); }
.brand-name { color: var(--ink); }
.brand-version {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.topnav {
  display: flex;
  gap: 22px;
  justify-self: center;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.topnav-link {
  cursor: pointer;
  color: var(--ink-soft);
  position: relative;
  padding: 4px 0;
  text-decoration: none;
  transition: color 0.15s;
}
.topnav-link:hover { color: var(--ink); }
.topnav-link.active { color: var(--ink); }
.topnav-link.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--ruby);
}

.topbar-actions { justify-self: end; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.status-dot {
  width: 7px; height: 7px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(79, 154, 110, 0.18);
}

/* ─────────── Layout ─────────── */

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 56px var(--pad-x) 80px;
}

/* ─────────── Eyebrows / type ─────────── */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--ruby);
  text-transform: uppercase;
  margin-bottom: 22px;
}

.eyebrow-mini {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ─────────── Hatch separators ─────────── */

.hatch-rule {
  height: 22px;
  margin: 56px 0 56px;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--ink) 0,
    var(--ink) 1px,
    transparent 1px,
    transparent 8px
  );
  opacity: 0.42;
}
.hatch-rule.mini { height: 14px; margin: 18px 0 22px; opacity: 0.32; }

.hatch-strip {
  display: block;
  height: 14px;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--ruby) 0,
    var(--ruby) 1px,
    transparent 1px,
    transparent 7px
  );
  opacity: 0.55;
}

/* ─────────── Card with L-bracket corners ─────────── */

.card-bracketed {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--rule);
}
.card-bracketed::before,
.card-bracketed::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 0 solid var(--ink);
  pointer-events: none;
}
.card-bracketed::before {
  top: -1px; left: -1px;
  border-top-width: 2px;
  border-left-width: 2px;
}
.card-bracketed::after {
  bottom: -1px; right: -1px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

/* ─────────── Hero ─────────── */

.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 72px;
  align-items: start;
  padding-top: 28px;
}

.hero-title {
  font-size: clamp(40px, 5.4vw, 68px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 24px;
  color: var(--ink);
}
.hero-italic {
  font-style: italic;
  font-weight: 400;
  font-family: 'Inter', serif;
  color: var(--purple);
  position: relative;
}
.hero-italic::after {
  content: "";
  position: absolute;
  left: -2px; right: -2px; bottom: 0.08em;
  height: 0.18em;
  background: var(--purple-soft);
  z-index: -1;
  opacity: 0.6;
}

.hero-sub {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-muted);
  max-width: 540px;
  margin: 0 0 36px;
}

.hero-cta {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 56px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--paper);
  color: var(--ink);
  transition: transform 0.08s ease, background 0.15s, color 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: var(--ruby); border-color: var(--ruby); }

.btn-arrow {
  font-family: var(--font-mono);
  font-weight: 500;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.back-btn:hover {
  background: var(--ruby);
  border-color: var(--ruby);
}
.back-btn .btn-arrow { font-weight: 600; }

.toolbar-divider {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--rule);
}

/* Toggle pill — used for "tradução em frases" */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.toggle-btn:hover { border-color: var(--ink); color: var(--ink); }
.toggle-pill {
  position: relative;
  width: 22px;
  height: 12px;
  background: var(--rule);
  border-radius: 999px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toggle-pill::after {
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: left 0.15s;
}
.toggle-btn.active {
  color: var(--ink);
  border-color: var(--ink);
}
.toggle-btn.active .toggle-pill { background: var(--mint); }
.toggle-btn.active .toggle-pill::after { left: 11px; }

.hero-cta-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}
.dot-sep { color: var(--ruby); margin-right: 4px; }

.hero-meta-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--rule);
  padding-top: 22px;
  max-width: 540px;
}
.meta-block {
  padding: 14px 24px 0 14px;
  position: relative;
}
.meta-block::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 28px; height: 3px;
}
.meta-block:nth-child(1)::before { background: var(--blue); }
.meta-block:nth-child(2)::before { background: var(--purple); }
.meta-block:nth-child(3)::before { background: var(--mint); }
.meta-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.meta-value {
  font-family: var(--font-sans);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.meta-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-left: 4px;
  letter-spacing: 0;
}

/* ─────────── Hero diagram ─────────── */

.hero-right { position: relative; }

.diagram {
  padding: 0;
  background: var(--paper);
}

.diagram-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.diagram-title { color: var(--ink); font-weight: 600; }
.diagram-tag {
  color: var(--pink);
  background: var(--pink-soft);
  text-transform: uppercase;
  padding: 3px 7px;
  font-size: 9px;
  letter-spacing: 0.14em;
  font-weight: 600;
}

.diagram-stage {
  position: relative;
  padding: 18px 18px 18px 60px;
  border-left: 3px solid var(--rule);
}
.diagram-stage:nth-of-type(1) { border-left-color: var(--blue); }
.diagram-stage:nth-of-type(2) { border-left-color: var(--ruby); }
.diagram-stage:nth-of-type(3) { border-left-color: var(--mint); }

.stage-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.stage-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.stage-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.stage-code {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.stage-code .dim { color: var(--ink-soft); }

.stage-demo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 8px 12px;
  margin-bottom: 10px;
}
.word-demo {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.word-demo.translated {
  background: var(--mint-soft);
  color: #1f5e3a;
  padding: 2px 6px;
  font-weight: 600;
}
.arrow-mini {
  font-family: var(--font-mono);
  color: var(--ruby);
  font-weight: 600;
}

.stage-status {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid currentColor;
}
.status-blue   { color: var(--blue); }
.status-ruby { color: var(--ruby); }
.status-mint   { color: var(--mint); }

.diagram-line {
  margin-left: 32px;
  height: 28px;
  width: 2px;
  background-image: linear-gradient(
    to bottom,
    var(--ruby) 0, var(--ruby) 4px,
    transparent 4px, transparent 8px
  );
  background-size: 2px 8px;
  background-repeat: repeat-y;
}

.diagram-footer { padding: 0; }

/* numbered prefix on stages */
.diagram-stage::before {
  content: "";
  position: absolute;
  left: 32px; top: 24px;
  width: 14px; height: 1px;
  background: var(--ruby);
}

/* ─────────── Features ─────────── */

.features-header { margin-bottom: 32px; }
.features-header .eyebrow { color: var(--cyan); }
.features-header h2 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--ink);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.feature-card {
  padding: 30px 24px 22px;
  background: var(--paper);
  border: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}
.feature-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.feature-card:nth-child(1)::before { background: var(--blue); }
.feature-card:nth-child(2)::before { background: var(--purple); }
.feature-card:nth-child(3)::before { background: var(--mint); }

.feature-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}
.feature-card:nth-child(1) .feature-num { color: var(--blue); }
.feature-card:nth-child(2) .feature-num { color: var(--purple); }
.feature-card:nth-child(3) .feature-num { color: var(--mint); }
.feature-card:nth-child(1) .feature-tag { color: var(--blue); border-color: var(--blue-soft); background: var(--blue-soft); }
.feature-card:nth-child(2) .feature-tag { color: var(--purple); border-color: var(--purple-soft); background: var(--purple-soft); }
.feature-card:nth-child(3) .feature-tag { color: #1f5f3f; border-color: var(--mint-soft); background: var(--mint-soft); }
.feature-card h3 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.feature-card p {
  margin: 0 0 18px;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.6;
}
.feature-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  padding: 3px 8px;
}

/* ─────────── Reader toolbar ─────────── */

.reader-shell { padding-top: 8px; }

.reader-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 12px 18px;
  background: var(--paper);
  border: 1px solid var(--rule);
}

.toolbar-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}
.toolbar-cluster.right { margin-left: auto; }

/* Keep labels/buttons on a single line; toolbar itself wraps to a new row instead */
.toolbar-cluster .toggle-label,
.toolbar-cluster .btn-ghost,
.toolbar-cluster .back-btn,
.toolbar-cluster .status-inline {
  white-space: nowrap;
}
.toolbar-item { white-space: nowrap; }
.file-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.file-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-item select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  padding: 5px 22px 5px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
    linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position:
    right 9px center,
    right 5px center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.toolbar-item select:hover { border-color: var(--ink); }

.status-inline {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: 4px 10px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--cyan);
}

/* ─────────── Document container (PDF mode) ─────────── */

.document {
  background: var(--paper-2);
  padding: 32px;
  border: 1px solid var(--rule);
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.document:empty::before {
  content: "// nenhum documento carregado.";
  font-family: var(--font-mono);
  color: var(--ink-soft);
  font-size: 14px;
  align-self: center;
  margin-top: 80px;
}

.loading-block {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
  padding: 60px 0;
  letter-spacing: 0.04em;
  align-self: center;
}
.loading-block.error { color: var(--red); }

.error-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ruby);
  padding: 28px 32px;
  max-width: 580px;
  text-align: left;
  align-self: center;
  font-family: var(--font-sans);
  color: var(--ink-2);
  letter-spacing: normal;
  font-size: 14px;
  line-height: 1.6;
  margin-top: 40px;
}
.error-card .error-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ruby);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.error-card .error-title {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 10px;
  line-height: 1.25;
}
.error-card .error-body {
  color: var(--ink-muted);
  font-size: 14px;
  margin-bottom: 22px;
}
.error-card .error-meta {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
  margin-bottom: 18px;
}
.error-card .error-meta-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 18px;
  position: relative;
}
.error-card .error-meta-item:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--rule);
}
.error-card .emi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.error-card .emi-value {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.015em;
}
.error-card .error-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  font-style: normal;
}

/* ─────────── Page label (above each rendered page) ─────────── */

.pdf-page-label {
  width: 820px;
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 28px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pdf-page-label:first-child { margin-top: 0; }
.pdf-page-tick {
  display: inline-block;
  width: 24px;
  height: 2px;
  background: var(--ruby);
}
.pdf-page-label:nth-of-type(4n+2) .pdf-page-tick { background: var(--blue); }
.pdf-page-label:nth-of-type(4n+3) .pdf-page-tick { background: var(--purple); }
.pdf-page-label:nth-of-type(4n+4) .pdf-page-tick { background: var(--mint); }
.pdf-page-of { color: var(--ink-soft); margin-left: auto; }

/* ─────────── PDF page (image + word overlay) ─────────── */

.pdf-page {
  position: relative;
  background: white;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.06),
    0 8px 28px rgba(0,0,0,0.09);
  margin-bottom: 8px;
  user-select: none;
  -webkit-user-select: none;
}
.pdf-page img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.word-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.word {
  position: absolute;
  pointer-events: auto;
  cursor: none;          /* D — pointer disappears over a word so it doesn't block reading */
  background: transparent;
  color: transparent;
  font-family: var(--font-sans);
  font-weight: 500;
  white-space: nowrap;
  display: flex;
  align-items: center;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 2px;
  transition: background 0.08s, color 0.08s;
  line-height: 1;
}
/* C — when hover translation is disabled, the cursor stays as a text caret */
body.hover-disabled .word { cursor: text; }
body.hover-disabled .word:hover { background: transparent; }
.word:hover {
  background: rgba(216, 160, 46, 0.32);
}
.word.loading {
  background: rgba(200, 50, 79, 0.28);
}
.word.translated {
  background: var(--mint);
  color: white;
  cursor: none;          /* keep pointer hidden even after the pill appears */
  z-index: 10;
  width: auto !important;
  padding: 0 8px;
  border-radius: 3px;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.18),
    0 8px 22px rgba(0, 0, 0, 0.16),
    0 0 0 1px rgba(0, 0, 0, 0.06);
  letter-spacing: -0.01em;
}
.word.selected {
  background: rgba(124, 76, 219, 0.32);
  cursor: text;
}
/* ─────────── Modal (confirmation dialog) ─────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 14, 22, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-fade-in 0.18s ease;
}
.modal-backdrop.hidden { display: none; }

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  max-width: 520px;
  width: 100%;
  padding: 32px 36px 24px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.25),
    0 8px 20px rgba(0, 0, 0, 0.12);
  animation: modal-slide-in 0.22s ease;
}

@keyframes modal-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ruby);
  margin-bottom: 14px;
}

.modal-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 12px;
  line-height: 1.2;
}

.modal-body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 20px;
}
.modal-body strong { color: var(--ink); font-weight: 600; }

.modal-meta {
  border-top: 1px solid var(--rule);
  padding-top: 16px;
  margin-bottom: 22px;
}
.modal-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.modal-meta-item .emi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.modal-meta-item .emi-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
}
.modal-actions .btn,
.modal-actions .btn-ghost {
  padding: 9px 16px;
  font-size: 13px;
}

/* ─────────── Tooltip (selection translation) ─────────── */

.tooltip {
  position: fixed;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px 12px 18px;
  border-left: 3px solid var(--ruby);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  max-width: 400px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 10px 32px rgba(0,0,0,0.22);
  z-index: 200;
  pointer-events: auto;
  white-space: pre-wrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.tooltip::-webkit-scrollbar { width: 8px; }
.tooltip::-webkit-scrollbar-track { background: transparent; }
.tooltip::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 4px;
}
.tooltip::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }
.tooltip.hidden { display: none; }
/* ─────────── Context strip (sentence translation while hovering) ─── */

.context-strip {
  position: fixed;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  border-left: 3px solid var(--mint);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.55;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  z-index: 150;
  pointer-events: none;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.22),
    0 12px 30px rgba(0, 0, 0, 0.16);
  max-width: min(92vw, 580px);
}
.context-strip.hidden { display: none; }

.context-strip .ctx-eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mint);
  flex-shrink: 0;
  padding-top: 3px;
}

.ctx-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ctx-row {
  display: block;
  word-wrap: break-word;
}
.ctx-source {
  color: var(--ink-soft);
  font-style: italic;
}
.ctx-target {
  color: var(--paper);
  font-weight: 500;
}
.ctx-target.loading { opacity: 0.55; font-style: italic; font-weight: 400; }
.ctx-highlight {
  background: rgba(216, 160, 46, 0.45);
  color: white;
  font-style: normal;
  font-weight: 600;
  padding: 0 3px;
  border-radius: 2px;
}

.tooltip .label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ruby);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}

/* ─────────── Footer ─────────── */

.footer {
  max-width: var(--max-w);
  margin: 32px auto 0;
  padding: 0 var(--pad-x) 40px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  flex-wrap: wrap;
}
.footer-brand { display: inline-flex; align-items: baseline; gap: 2px; }
.footer-brand .brand-name { color: var(--ink); font-weight: 600; }
.footer-brand .brand-bracket { font-family: var(--font-mono); font-weight: 500; }
.footer-brand .brand-bracket:first-child { color: var(--ruby); }
.footer-brand .brand-bracket:nth-child(3) { color: var(--blue); }

.footer-links {
  display: flex;
  gap: 18px;
}
.footer-links a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-links a:hover { color: var(--ink); }

/* ─────────── Content pages (docs / help / about / legal) ─────────── */

.content-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 0 48px;
}

.page-hero {
  margin-bottom: 56px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--rule);
}
.page-hero .eyebrow { color: var(--ruby); margin-bottom: 18px; }
.page-hero h1 {
  font-size: clamp(34px, 4.5vw, 52px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0 0 18px;
  color: var(--ink);
}
.page-hero h1 .hero-italic {
  font-style: italic;
  font-weight: 400;
  color: var(--purple);
}
.page-hero p.lead {
  font-size: 17px;
  color: var(--ink-muted);
  line-height: 1.6;
  margin: 0;
  max-width: 600px;
}

.page-meta {
  display: flex;
  gap: 28px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-top: 22px;
}
.page-meta-item .meta-label {
  text-transform: uppercase;
  color: var(--ink-soft);
}
.page-meta-item .meta-value {
  color: var(--ink);
  margin-left: 6px;
}

.content-section {
  margin: 48px 0;
}
.content-section .section-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ruby);
  margin-bottom: 12px;
}
.content-section h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  color: var(--ink);
}
.content-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 26px 0 8px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.content-section p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
  margin: 0 0 14px;
  max-width: 660px;
}
.content-section a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: var(--blue-soft);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}
.content-section a:hover { text-decoration-color: var(--blue); }

.content-section ul {
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-2);
  padding-left: 0;
  list-style: none;
  margin: 0 0 14px;
  max-width: 660px;
}
.content-section ul li {
  padding-left: 24px;
  position: relative;
  margin-bottom: 4px;
}
.content-section ul li::before {
  content: "→";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--ruby);
  font-family: var(--font-mono);
  font-size: 13px;
}

.content-section code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--paper-2);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--ink);
  border: 1px solid var(--rule-soft);
}

.content-section pre {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 660px;
}
.content-section pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 13px;
}

.kv-list {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px 28px;
  margin: 24px 0;
  font-size: 14px;
  max-width: 660px;
  border-top: 1px solid var(--rule-soft);
  padding-top: 18px;
}
.kv-list dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 2px;
}
.kv-list dd {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.55;
}

.callout {
  border-left: 3px solid var(--ruby);
  background: var(--paper);
  padding: 16px 20px;
  margin: 24px 0;
  font-size: 14px;
  color: var(--ink-2);
  max-width: 660px;
  line-height: 1.6;
}
.callout .callout-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ruby);
  margin-bottom: 8px;
  font-weight: 600;
}
.callout strong { color: var(--ink); font-weight: 600; }

@media (max-width: 720px) {
  .content-page { padding: 0 4px 32px; }
  .kv-list { grid-template-columns: 1fr; gap: 4px 0; }
  .kv-list dt { padding-top: 14px; }
  .kv-list dt:first-of-type { padding-top: 2px; }
  .page-meta { flex-wrap: wrap; gap: 16px; }
}

/* ─────────── Workspace (lateral collapsible panel) ─────────── */

main { transition: padding-right 0.25s ease; }
body.workspace-open main { padding-right: 360px; }

.workspace-toggle,
.workspace-panel { display: none; }

body.state-reading .workspace-toggle { display: flex; }
body.state-reading .workspace-panel  { display: flex; }

.workspace-toggle {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 18px 8px 18px 10px;
  cursor: pointer;
  z-index: 91;
  border: 0;
  border-radius: 6px 0 0 6px;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: right 0.25s ease, background 0.15s;
  box-shadow: -3px 4px 14px rgba(0,0,0,0.18);
}
.workspace-toggle:hover { background: var(--ruby); }
body.workspace-open .workspace-toggle { right: 360px; }

.ws-toggle-arrow {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--paper);
  letter-spacing: 0;
}
.ws-toggle-arrow::before { content: "⟨"; }
body.workspace-open .ws-toggle-arrow::before { content: "⟩"; }

.ws-toggle-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.workspace-panel {
  position: fixed;
  top: 60px;
  right: 0;
  bottom: 0;
  width: 360px;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 90;
  box-shadow: -10px 0 30px rgba(0,0,0,0.06);
}
body.workspace-open .workspace-panel { transform: translateX(0); }

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.workspace-title { display: flex; flex-direction: column; gap: 4px; }
.workspace-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ruby);
}
.workspace-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.workspace-close {
  background: transparent;
  border: 1px solid var(--rule);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-muted);
  line-height: 1;
  transition: all 0.15s;
  border-radius: 3px;
}
.workspace-close:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.workspace-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.workspace-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  color: var(--ink-soft);
  gap: 14px;
  padding: 32px 20px;
  margin: auto 0;
}
.ws-empty-icon {
  font-family: var(--font-mono);
  font-size: 28px;
  color: var(--rule);
  letter-spacing: 0;
}
.workspace-empty p {
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}

.workspace-item {
  border: 1px solid var(--rule);
  background: white;
  padding: 12px 14px;
  font-size: 13px;
  position: relative;
  animation: ws-item-in 0.22s ease;
}
@keyframes ws-item-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.workspace-item.latest { border-left: 3px solid var(--mint); }

.ws-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.ws-item-type { color: var(--purple); font-weight: 600; }
.ws-item-langs { color: var(--ruby); }

.ws-item-source {
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 6px;
  line-height: 1.5;
  word-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ws-item-target {
  color: var(--ink-2);
  font-weight: 500;
  line-height: 1.55;
  word-wrap: break-word;
}

.workspace-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
.workspace-clear {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 3px;
}
.workspace-clear:hover:not(:disabled) {
  color: var(--ruby);
  border-color: var(--ruby);
}
.workspace-clear:disabled { opacity: 0.4; cursor: default; }

@media (max-width: 960px) {
  .workspace-panel { width: 320px; }
  body.workspace-open main { padding-right: 320px; }
  body.workspace-open .workspace-toggle { right: 320px; }
}

/* ─────────── Responsive ─────────── */

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 48px; }
  .features-grid { grid-template-columns: 1fr; }
  .topnav { display: none; }
  .reader-toolbar { grid-template-columns: 1fr; gap: 14px; }
  .toolbar-cluster.right { justify-self: start; }
  .document { padding: 36px 28px; }
  main { padding: 32px var(--pad-x) 56px; }
}
