:root {
  color-scheme: light;
  --ink: #102a43;
  --ink-soft: #486581;
  --paper: #f7f5ef;
  --surface: #fffefa;
  --line: #d9e2ec;
  --accent: #f3a712;
  --accent-dark: #ad6800;
  --teal: #0b7285;
  --teal-pale: #d9f2f3;
  --muted: #829ab1;
  --shadow: 0 18px 50px rgba(16, 42, 67, .12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 0%, rgba(11, 114, 133, .08), transparent 34rem),
    var(--paper);
}

button, input, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button { color: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex="0"]:focus-visible {
  outline: 3px solid rgba(11, 114, 133, .44);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: .5rem;
  left: .5rem;
  transform: translateY(-160%);
  padding: .65rem .9rem;
  border-radius: .5rem;
  background: var(--ink);
  color: white;
}

.skip-link:focus { transform: none; }

.app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.topbar {
  position: relative;
  z-index: 20;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem clamp(1rem, 2.8vw, 2.75rem);
  border-bottom: 1px solid rgba(130, 154, 177, .28);
  background: rgba(255, 254, 250, .9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  position: relative;
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 3px;
  right: -9px;
  bottom: 1px;
  border-radius: 3px;
  background: var(--ink);
  transform: rotate(45deg);
}

.brand-mark span { width: 13px; height: 2px; background: var(--accent); box-shadow: 0 -5px 0 var(--teal), 0 5px 0 var(--muted); }
.brand strong { display: block; font-size: .94rem; letter-spacing: .075em; }
.brand small { display: block; margin-top: .08rem; color: var(--ink-soft); font-size: .68rem; letter-spacing: .025em; }

.main-nav { display: flex; align-items: center; gap: .25rem; }
.main-nav button, .nav-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem .72rem;
  border: 0;
  border-radius: .65rem;
  background: transparent;
  color: var(--ink-soft);
  font-size: .84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.main-nav button:hover, .nav-button:hover { background: #edf2f5; color: var(--ink); }
.main-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-button.is-disabled { opacity: .38; pointer-events: none; }

main { flex: 1; min-height: 0; }

.home-view {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(370px, .9fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 6rem);
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 5rem);
}

.home-copy { max-width: 700px; }
.eyebrow { display: flex; align-items: center; gap: .55rem; margin: 0 0 1.25rem; color: var(--teal); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow span { width: 28px; height: 2px; background: var(--accent); }
.home-copy h1 { margin: 0; font-size: clamp(2.85rem, 6vw, 6.65rem); line-height: .94; letter-spacing: -.066em; font-weight: 600; }
.home-copy h1 em { color: var(--teal); font-family: Iowan Old Style, Charter, Georgia, serif; font-weight: 400; }
.home-intro { max-width: 680px; margin: 2rem 0 0; color: var(--ink-soft); font-size: clamp(1.02rem, 1.45vw, 1.25rem); line-height: 1.65; }
.home-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2rem; }
.primary-button, .secondary-button {
  min-height: 49px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .9rem;
  border-radius: .7rem;
  padding: .72rem 1.15rem;
  font-weight: 700;
  cursor: pointer;
}
.primary-button { border: 1px solid var(--ink); background: var(--ink); color: white; box-shadow: 0 7px 18px rgba(16, 42, 67, .16); }
.primary-button:hover { background: #183d5a; }
.secondary-button { border: 1px solid #b7c6d2; background: rgba(255,255,255,.6); color: var(--ink); }
.secondary-button:hover { border-color: var(--teal); background: white; }
.home-note { margin: 1.25rem 0 0; color: var(--muted); font-size: .85rem; }

.focus-illustration { position: relative; min-height: 440px; display: grid; place-items: center; }
.illustration-label { position: absolute; z-index: 3; top: 2.4rem; right: 0; padding: .55rem .8rem; border: 1px solid rgba(11,114,133,.3); border-radius: 99px; color: var(--teal); background: var(--teal-pale); font-size: .66rem; font-weight: 700; letter-spacing: .12em; }
.mock-window { position: relative; width: min(100%, 510px); aspect-ratio: 1.25; overflow: hidden; border: 1px solid rgba(72,101,129,.3); border-radius: 1.1rem; background: rgba(255,255,255,.75); box-shadow: var(--shadow); transform: rotate(-1.5deg); }
.mock-toolbar { height: 13%; display: flex; align-items: center; gap: .3rem; padding: 0 5%; border-bottom: 1px solid var(--line); }
.mock-toolbar i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.mock-toolbar i:first-child { background: var(--accent); }
.mock-toolbar span { width: 36%; height: 7px; margin-left: auto; border-radius: 9px; background: #edf2f5; }
.mock-body { height: 87%; display: grid; grid-template-columns: 1.12fr .18fr .75fr; align-items: stretch; padding: 8%; }
.mock-text { display: flex; flex-direction: column; justify-content: center; gap: 7%; }
.mock-text b { display: block; width: 86%; height: 6px; border-radius: 8px; background: #dbe3ea; }
.mock-text b:nth-child(2n) { width: 73%; }
.mock-text b.lit { width: 82%; height: 10px; background: var(--accent); box-shadow: 0 0 0 5px rgba(243,167,18,.12); }
.mock-text b.short { width: 48%; }
.mock-connection { position: relative; }
.mock-connection::before { content: ""; position: absolute; top: 17%; bottom: 17%; left: 50%; width: 1px; background: rgba(11,114,133,.35); }
.mock-connection span { position: absolute; left: 50%; width: 16px; height: 16px; transform: translate(-50%,-50%); border: 4px solid var(--surface); border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 1px rgba(11,114,133,.3); }
.mock-connection span:nth-child(1) { top: 29%; }.mock-connection span:nth-child(2) { top: 53%; }.mock-connection span:nth-child(3) { top: 75%; }
.mock-concepts { display: flex; flex-direction: column; justify-content: center; gap: 7%; padding-left: 8%; }
.mock-concepts strong { color: var(--teal); font-size: .55rem; letter-spacing: .12em; }
.mock-concepts i { width: 94%; height: 8px; border-radius: 8px; background: #c9d5df; }.mock-concepts i:nth-child(3) { width: 68%; }
.mock-concepts em { height: 20px; border-left: 3px solid var(--accent); background: #eef2f5; }.mock-concepts em:last-child { width: 76%; }
.lens { position: absolute; z-index: 4; right: -1%; bottom: 6%; width: 135px; height: 135px; border: 9px solid var(--ink); border-radius: 50%; background: rgba(217,242,243,.28); box-shadow: 0 14px 35px rgba(16,42,67,.2); }
.lens::after { content: ""; position: absolute; width: 70px; height: 13px; right: -57px; bottom: -25px; border-radius: 9px; background: var(--ink); transform: rotate(45deg); }
.lens span { position: absolute; width: 54%; height: 13px; left: 23%; top: 45%; background: var(--accent); box-shadow: 0 -28px 0 rgba(11,114,133,.8), 0 28px 0 rgba(130,154,177,.65); }

.analysis-view { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.analysis-view[hidden], .home-view[hidden] { display: none; }
.focus-strip { min-height: 82px; display: flex; align-items: center; gap: 2rem; padding: .75rem clamp(1rem, 2.5vw, 2.5rem); border-bottom: 1px solid var(--line); background: #f1f5f5; }
.text-identity { flex: 0 0 min(25vw, 335px); min-width: 180px; padding-right: 1rem; border-right: 1px solid #c8d4dd; }
.text-identity p, .text-identity h1 { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; }
.text-identity p { color: var(--teal); font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.text-identity h1 { margin-top: .16rem; font-family: Iowan Old Style, Charter, Georgia, serif; font-size: clamp(1.05rem, 1.6vw, 1.35rem); }
.focus-controls { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; overflow-x: auto; padding: .35rem .15rem; scrollbar-width: thin; }
.focus-button { flex: 0 0 auto; min-height: 42px; padding: .55rem .9rem; border: 1px solid #bdcad4; border-radius: 999px; background: rgba(255,255,255,.74); color: var(--ink-soft); font-size: .81rem; font-weight: 700; cursor: pointer; }
.focus-button:hover { border-color: var(--teal); color: var(--teal); }
.focus-button.is-active { border-color: var(--ink); background: var(--ink); color: white; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(370px, .92fr); }
.text-panel, .insight-panel { min-height: 0; }
.text-panel { display: flex; flex-direction: column; padding: clamp(1.1rem, 2.2vw, 2.25rem) clamp(1.2rem, 3vw, 3.5rem); border-right: 1px solid var(--line); background: var(--surface); }
.panel-heading { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.panel-kicker { margin: 0 0 .25rem; color: var(--teal); font-size: .66rem; font-weight: 700; letter-spacing: .14em; }
.panel-heading h2, .insight-panel h2 { margin: 0; font-size: clamp(1.05rem, 1.4vw, 1.3rem); }
.text-reset { min-height: 40px; padding: .5rem .75rem; border: 1px solid #bdcad4; border-radius: .55rem; background: transparent; color: var(--ink-soft); font-size: .78rem; font-weight: 700; cursor: pointer; }
.text-reset.is-active { border-color: var(--teal); background: var(--teal-pale); color: var(--teal); }
.text-content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: clamp(1.25rem, 2.2vw, 2.5rem) clamp(.2rem, 1.4vw, 1.25rem) 4rem 0; scroll-padding: 25% 0; font-family: Iowan Old Style, Charter, Georgia, serif; font-size: clamp(1.04rem, 1.5vw, 1.35rem); line-height: 1.82; }
.text-unit { display: block; width: fit-content; max-width: 100%; margin: 0 0 .56em; border-radius: .18em; transition: opacity .18s ease, background-color .18s ease, box-shadow .18s ease; }
.text-unit.is-paragraph { width: 100%; margin-bottom: 1.3em; }
.text-unit.is-label { margin-top: 1.3em; color: var(--teal); font-family: Inter, system-ui, sans-serif; font-size: .72em; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.text-content.has-focus .text-unit:not(.is-match) { opacity: .24; }
.text-content.has-focus .text-unit.is-match { padding-inline: .18em; background: linear-gradient(transparent 12%, rgba(243,167,18,.38) 12%, rgba(243,167,18,.38) 90%, transparent 90%); }
.text-unit.is-current { box-shadow: 0 0 0 4px rgba(11,114,133,.2); background-color: rgba(243,167,18,.58) !important; }

.insight-panel { display: grid; grid-template-rows: minmax(220px, .92fr) minmax(200px, 1.08fr); background: #eef3f4; }
.why-section, .connections-section { min-height: 0; overflow-y: auto; padding: clamp(1.35rem, 2.5vw, 2.7rem) clamp(1.25rem, 3vw, 3.4rem); }
.why-section { border-bottom: 1px solid #ccd8df; background: rgba(255,255,255,.48); }
.focus-fragment { display: inline-block; max-width: 100%; margin-top: 1.2rem; padding: .65rem .8rem; border-left: 3px solid var(--accent); background: rgba(255,255,255,.75); color: var(--ink-soft); font-family: Iowan Old Style, Charter, Georgia, serif; font-size: .85rem; line-height: 1.55; }
.focus-explanation { max-width: 760px; margin: 1.1rem 0 0; color: var(--ink-soft); font-size: clamp(.92rem, 1.15vw, 1.05rem); line-height: 1.65; }
.occurrence-nav { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1.15rem; padding-top: 1rem; border-top: 1px solid #d3dde3; }
.occurrence-nav button { min-height: 39px; border: 0; border-radius: .5rem; background: transparent; color: var(--teal); font-size: .82rem; font-weight: 700; cursor: pointer; }
.occurrence-nav button:hover { background: var(--teal-pale); }
.occurrence-nav output { color: var(--ink-soft); font-size: .77rem; font-weight: 700; }
.section-title-row { margin-bottom: 1.05rem; }
.connections-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .72rem; }
.connection-card { padding: .9rem 1rem; border: 1px solid rgba(130,154,177,.32); border-left: 3px solid var(--teal); border-radius: .65rem; background: rgba(255,255,255,.72); }
.connection-card:nth-child(2n) { border-left-color: var(--accent); }
.connection-card h3 { margin: 0 0 .38rem; color: var(--teal); font-size: .69rem; letter-spacing: .09em; text-transform: uppercase; }
.connection-card p { margin: 0; color: var(--ink-soft); font-size: .83rem; line-height: 1.5; }
.empty-connections { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }

.catalog-dialog { width: min(1040px, calc(100% - 2rem)); max-height: min(820px, calc(100dvh - 2rem)); padding: 0; overflow: hidden; border: 1px solid rgba(130,154,177,.45); border-radius: 1.1rem; background: var(--surface); color: var(--ink); box-shadow: 0 28px 90px rgba(16,42,67,.32); }
.catalog-dialog::backdrop { background: rgba(16,42,67,.52); backdrop-filter: blur(4px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.5rem 1.6rem 1.25rem; border-bottom: 1px solid var(--line); }
.dialog-head .eyebrow { margin-bottom: .5rem; }.dialog-head h2 { margin: 0; font-size: 1.75rem; }.dialog-head p:not(.eyebrow) { margin: .35rem 0 0; color: var(--ink-soft); }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; font-size: 1.8rem; line-height: 1; cursor: pointer; }
.catalog-filters { display: grid; grid-template-columns: 2fr 1fr 1fr auto; align-items: end; gap: .75rem; padding: 1rem 1.6rem; background: #f2f6f6; }
.catalog-filters label { display: grid; gap: .28rem; color: var(--ink-soft); font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.catalog-filters input, .catalog-filters select { width: 100%; min-height: 43px; padding: .55rem .7rem; border: 1px solid #bdcad4; border-radius: .55rem; background: white; color: var(--ink); text-transform: none; }
.clear-filters { min-height: 43px; padding: .55rem .8rem; border: 1px solid #bdcad4; border-radius: .55rem; background: transparent; color: var(--ink-soft); font-size: .76rem; font-weight: 700; cursor: pointer; }
.catalog-results { max-height: 370px; overflow-y: auto; padding: 1.15rem 1.6rem; }
.catalog-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.catalog-card:first-child { padding-top: 0; }.catalog-card:last-child { border-bottom: 0; }
.catalog-card .metadata { display: flex; flex-wrap: wrap; gap: .35rem .75rem; margin-bottom: .3rem; color: var(--teal); font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.catalog-card h3 { margin: 0; font-family: Iowan Old Style, Charter, Georgia, serif; font-size: 1.1rem; }.catalog-card p { margin: .3rem 0 0; color: var(--ink-soft); font-size: .84rem; }
.catalog-actions { display: flex; gap: .5rem; }.catalog-actions button, .catalog-actions a { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: .5rem .8rem; border: 1px solid var(--ink); border-radius: .5rem; background: var(--ink); color: white; font-size: .77rem; font-weight: 700; text-decoration: none; cursor: pointer; }.catalog-actions a { border-color: #bdcad4; background: transparent; color: var(--ink-soft); }
.catalog-empty { padding: 2rem 1rem; color: var(--ink-soft); text-align: center; }
.demo-entry { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.6rem 1.25rem; border-top: 1px solid var(--line); background: #fbf5e8; }
.demo-entry span { display: block; color: var(--accent-dark); font-size: .62rem; font-weight: 700; letter-spacing: .1em; }.demo-entry strong { display: block; margin-top: .12rem; }.demo-entry p { margin: .15rem 0 0; color: var(--ink-soft); font-size: .77rem; }
.status-message { position: fixed; z-index: 100; left: 50%; bottom: calc(1rem + var(--safe-bottom)); transform: translate(-50%, 150%); max-width: calc(100% - 2rem); padding: .7rem 1rem; border-radius: .6rem; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: .82rem; opacity: 0; transition: .2s ease; }
.status-message.is-visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 980px) {
  .main-nav span { display: none; }
  .main-nav .wide-label { display: none; }
  .main-nav button, .nav-button { padding-inline: .65rem; }
  .home-view { grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr); gap: 2rem; padding: 2.2rem; }
  .focus-illustration { min-height: 330px; }.lens { width: 100px; height: 100px; border-width: 7px; }.lens::after { width: 50px; right: -40px; bottom: -18px; height: 10px; }
  .focus-strip { gap: 1rem; }.text-identity { flex-basis: 210px; }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(330px, .82fr); }
  .catalog-filters { grid-template-columns: 2fr 1fr 1fr; }.clear-filters { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 699px) {
  body { overflow: auto; }
  .app-shell { min-height: 100dvh; height: auto; }
  .topbar { position: sticky; top: 0; min-height: 62px; padding: .65rem .85rem; }
  .brand small { display: none; }.brand strong { font-size: .76rem; }.brand-mark { width: 30px; height: 30px; }
  .main-nav button, .nav-button { min-width: 40px; min-height: 40px; padding: .5rem; justify-content: center; }
  .main-nav button:nth-child(2) { display: none; }
  main { min-height: calc(100dvh - 62px); }
  .home-view { min-height: calc(100dvh - 62px); height: auto; grid-template-columns: 1fr; align-content: center; padding: 2.2rem 1.2rem 3rem; }
  .home-copy h1 { font-size: clamp(2.7rem, 14vw, 4.2rem); }.focus-illustration { display: none; }
  .analysis-view { height: auto; min-height: calc(100dvh - 62px); }
  .focus-strip { position: sticky; z-index: 10; top: 62px; flex-direction: column; align-items: stretch; gap: .5rem; padding: .65rem .9rem; }
  .text-identity { flex: none; min-width: 0; padding: 0; border: 0; }.text-identity p { font-size: .62rem; }.text-identity h1 { font-size: 1rem; }
  .focus-controls { width: 100%; }.focus-button { min-height: 38px; padding: .45rem .75rem; }
  .workspace { display: block; }
  .text-panel { height: min(62dvh, 650px); padding: 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .text-content { padding-top: 1.15rem; padding-bottom: 2rem; font-size: 1.03rem; }
  .insight-panel { display: block; }.why-section, .connections-section { overflow: visible; padding: 1.35rem 1rem; }
  .catalog-dialog { width: calc(100% - 1rem); max-height: calc(100dvh - 1rem); }.dialog-head { padding: 1rem; }.catalog-filters { grid-template-columns: 1fr; padding: .8rem 1rem; }.clear-filters { grid-column: auto; }.catalog-results { padding: 1rem; max-height: 42dvh; }.catalog-card { grid-template-columns: 1fr; }.demo-entry { align-items: stretch; flex-direction: column; padding: 1rem; }
}

@media (max-height: 650px) and (min-width: 700px) {
  .topbar { min-height: 58px; padding-block: .45rem; }.brand small { display: none; }
  .focus-strip { min-height: 66px; padding-block: .45rem; }
  .focus-button { min-height: 37px; }.home-view { padding-block: 1.5rem; }.focus-illustration { min-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  body { overflow: visible; background: white; }.topbar, .focus-strip, .insight-panel { display: none; }.app-shell, main, .analysis-view, .workspace, .text-panel { height: auto; display: block; }.text-panel { border: 0; }.text-content { overflow: visible; font-size: 12pt; }
}
