:root {
  --bg: #000000; /* black */
  --panel: #1a1a1a; /* dark grey (slightly lighter for contrast) */
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #22d3ee;
  --accent-2: #60a5fa;
  --home-top-card-height: 240px;
  --home-article-card-height: 390px;
}
@media (max-width: 960px) {
  :root {
    --home-top-card-height: 220px;
    --home-article-card-height: 364px;
  }
}
@media (max-width: 680px) {
  :root {
    --home-top-card-height: 200px;
    --home-article-card-height: 332px;
  }
}

/* Minimal bootstrap spinner support */
@keyframes spinner-border {
  to { transform: rotate(360deg); }
}
.spinner-border {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  vertical-align: -0.125em;
  border: 0.25em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner-border .75s linear infinite;
}
.spinner-border-sm {
  width: 1.25rem;
  height: 1.25rem;
  border-width: 0.2em;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 840px;
  margin: 0 auto;
  padding: 1rem;
}

.site-header, .site-footer {
  background: #0a0a0a; /* near black header/footer */
  border-bottom: 1px solid #1f2937;
}
.site-footer { border-top: 1px solid #1f2937; border-bottom: none; }

.site-header h1 { margin: 0; font-size: 1.25rem; }
nav a { margin-right: 1rem; }

/* React dark mode additions */
.react-menu { list-style: none; margin: 0; padding: 0; display: flex; gap: .75rem; }
.react-menu .menu-link {
  color: var(--text);
  text-decoration: none;
  padding: .25rem .5rem;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.react-menu .menu-link:hover,
.menu-dropdown__list .menu-link:hover {
  border-color: #1f2937;
  background: #0f0f0f;
  color: var(--text);
}
.react-menu .menu-link.active { color: #0b1220; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-weight: 700; border-color: transparent; }
.react-menu-container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "nav search auth";
  align-items: center;
  column-gap: 1rem;
  row-gap: .5rem;
}
.react-menu-primary {
  grid-area: nav;
  justify-self: start;
  min-width: 0;
}
.react-menu-search {
  grid-area: search;
  justify-self: stretch;
  min-width: 0;
  width: 100%;
  max-width: clamp(200px, 30vw, 340px);
}
.react-menu-search input {
  width: 100%;
}
.auth-status,
.auth-login-icon {
  grid-area: auth;
  justify-self: end;
}
.auth-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  font-size: .9rem;
  color: var(--muted);
  min-width: 0;
}
.auth-status .auth-user {
  order: 1;
  margin-right: 0 !important;
  white-space: nowrap;
}
.auth-status .menu-link {
  color: var(--text);
  text-decoration: none;
  padding: .25rem .5rem;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.auth-status .menu-link:hover {
  border-color: #1f2937;
  background: #0f0f0f;
  color: var(--text);
  text-decoration: none;
}
.auth-status .auth-logout-icon {
  order: 2;
}
.menu-dropdown__list {
  list-style: none;
  color: var(--text);
}
.menu-dropdown__list .menu-link {
  color: var(--text);
  display: block;
}
.menu-dropdown {
  position: relative;
  z-index: 10000;
}
.auth-login-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  color: #fff;
}
.auth-login-icon svg,
.auth-login-icon img,
.auth-logout-icon svg,
.auth-logout-icon img {
  width: 100%;
  height: 100%;
}
.auth-login-icon:hover {
  transform: scale(1.05);
}
.auth-logout-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: #fff;
}
.auth-logout-icon:hover {
  transform: scale(1.05);
}
@media (max-width: 980px) {
  .react-menu-container {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "nav auth"
      "search auth";
    row-gap: .4rem;
    align-items: start;
  }
  .react-menu-search {
    max-width: none;
    min-width: 220px;
  }
  .auth-status {
    display: grid;
    grid-template-rows: auto auto;
    justify-items: end;
    align-items: start;
    row-gap: .2rem;
    min-width: 170px;
  }
  .auth-status .auth-user {
    position: static;
    margin-top: 0;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    order: 1;
  }
  .auth-status .auth-logout-icon {
    order: 0;
  }
}
@media (max-width: 760px) {
  .react-menu-search {
    min-width: 140px;
  }
  .auth-status {
    min-width: 140px;
  }
  .auth-status .auth-user {
    max-width: 140px;
  }
}
@media (max-width: 680px) {
  #react-nav {
    min-width: 300px;
    overflow: visible;
  }
  .react-menu-container {
    min-width: 300px;
  }
}
.article-display.article-display--mini {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.home-top-card-fixed {
  height: var(--home-top-card-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.home-about-preview-card {
  justify-content: flex-start;
}
.home-about-preview-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.home-about-preview-text {
  flex: 1;
  min-height: 0;
  color: var(--muted);
  line-height: 1.34;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.article-display.article-display--mini.home-article-card-fixed {
  height: var(--home-article-card-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.home-article-card-shell {
  overflow: hidden;
}
.mini-pattern-chart {
  margin-top: 0.2rem;
  padding: 0.35rem;
  border: 2px solid #374151;
  border-radius: 10px;
  background: #0a0a0a;
  width: 100%;
}
.mini-pattern-chart--link {
  display: block;
  text-decoration: none;
}
.mini-pattern-chart--compact {
  padding: 0.25rem;
  border-width: 1.5px;
  width: 100%;
}
.article-display--mini .mini-pattern-chart {
  margin-top: auto;
}
.mini-pattern-chart__grid {
  display: flex;
  width: 100%;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: flex-end;
  align-content: flex-end;
  gap: 1px;
  min-height: 45px;
  max-height: 45px;
  overflow: hidden;
}
.mini-pattern-chart--compact .mini-pattern-chart__grid {
  min-height: 22px;
  max-height: 22px;
}
.mini-pattern-chart__column {
  position: relative;
  flex: 0 0 4px;
  height: 40px;
  overflow: hidden;
  box-sizing: border-box;
}
.mini-pattern-chart--compact .mini-pattern-chart__column {
  flex: 0 0 2px;
  height: 20px;
}
.mini-pattern-chart__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 999px;
  opacity: 0.45;
}
.mini-pattern-chart__rail {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(-50%);
  background: #1f2937;
}
.mini-pattern-chart__dot {
  position: absolute;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #0a0a0a;
  transform: translate(-50%, 50%);
  background: var(--accent-2);
}
.mini-pattern-chart--compact .mini-pattern-chart__dot {
  width: 6px;
  height: 6px;
}
.article-display--list-with-chart {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.article-display__chart {
  flex: 0 0 140px;
  max-width: 40%;
}
.article-display__chart .mini-pattern-chart {
  margin-top: 0;
  overflow: hidden;
}
.article-display--list-with-chart .mini-pattern-chart--compact .mini-pattern-chart__grid {
  min-height: 43px;
  max-height: 43px;
  flex-wrap: nowrap;
  gap: 0;
}
.article-display--list-with-chart .mini-pattern-chart--compact .mini-pattern-chart__column {
  height: 39px;
}
.article-display__body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.article-display__excerpt-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin-top: .4rem;
}
.article-display__excerpt {
  flex: 1;
  min-height: 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.article-display__excerpt--mini {
  font-size: 1rem;
}
.article-display__excerpt-inline {
  color: var(--muted);
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.article-display__more-inline {
  font-weight: 600;
}
.article-display__tail-nowrap {
  white-space: nowrap;
}
.auth-login-icon:hover {
  transform: scale(1.05);
}

.react-shell .page h2 { margin-top: 0; }
.react-shell .page p { color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: 0px 10px 30px rgba(0,0,0,0.25);
}

label { display: block; margin: 1rem 0 .25rem; color: var(--muted); }
input {
  background: #0f0f0f;
  border: 1px solid #1f2937;
  color: var(--text);
  padding: .5rem .75rem;
  border-radius: 6px;
  margin-right: .5rem;
}
button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #0b1220;
  padding: .5rem .75rem;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }

/* Removed temporary debug outlines */

/* TEMP: word-item attribute spans should fill container width */
.word-item { display: inline-block; }
.word-item .attributes-markers { display: block; width: 100%; }
.word-item .attributes-markers .attr {
  display: block;
  width: 100%;
  height: 0;
  line-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--accent-2);
}

/* Highlight style and interactions */
.highlighted {
  background: #ffff33; /* neon yellow */
  color: #000;
}
.word-item { cursor: pointer; }
.word-item .word-text {
  background: #000;
  color: #fff;
  padding: 0 .15rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.word-item.word-on .word-text {
  background: #ffff33;
  color: #000;
}

/* Selection highlight for article words */
.word-item::selection { background: #ffff33; color: #000; }
.word-item *::selection { background: #ffff33; color: #000; }

.article-side-panel {
  position: fixed;
  top: 70px;
  bottom: 20px;
  width: min(320px, 85vw);
  background: #060606;
  border: 1px solid #1f2937;
  border-radius: 12px 0 0 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.65);
  transform: translateX(110%);
  transition: transform 0.35s ease;
  z-index: 1200;
  pointer-events: none;
}
.article-side-panel.open {
  pointer-events: auto;
}
.article-side-panel--left {
  left: 0;
  border-radius: 0 12px 12px 0;
  transform: translateX(-100%);
}
.article-side-panel--left.open {
  transform: translateX(0);
}
.article-side-panel--right {
  right: 0;
  border-radius: 12px 0 0 12px;
}
.article-side-panel--right.open {
  transform: translateX(0);
}
.article-side-panel__inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
  overflow-y: auto;
}
.article-side-panel__inner::-webkit-scrollbar {
  width: 10px;
}
.article-side-panel__inner::-webkit-scrollbar-track {
  background: #050505;
}
.article-side-panel__inner::-webkit-scrollbar-thumb {
  background: #2b2b2b;
  border-radius: 999px;
}
.article-side-panel__inner::-webkit-scrollbar-thumb:hover {
  background: #3d3d3d;
}
.article-side-panel__inner {
  scrollbar-width: thin;
  scrollbar-color: #2b2b2b #050505;
}
.article-side-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
}
.article-panel-controls button {
  min-width: 170px;
}
.mouse-indicator {
  font-size: .9rem;
  color: var(--muted);
}
.mouse-indicator strong {
  color: var(--text);
}

.pattern-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.pattern-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .75rem;
  border: 1px solid #1f2937;
  background: #0d0d0d;
  color: var(--text);
  border-radius: 8px;
  padding: .6rem .8rem;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.pattern-item .pattern-label {
  font-weight: 600;
}
.pattern-item .pattern-pin {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid currentColor;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.panel-close {
  align-self: flex-end;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.panel-close:hover {
  color: var(--text);
}
.panel-tab {
  position: fixed;
  top: 120px;
  background: #0d0d0d;
  color: var(--text);
  border: 1px solid #1f1f1f;
  border-radius: 8px 0 0 8px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  z-index: 1150;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-weight: 600;
  font-size: 0.78rem;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
  background-image: radial-gradient(circle at top, rgba(255,255,255,0.08), transparent 50%);
  transition: left 0.35s ease, right 0.35s ease, border-color 0.2s ease, color 0.2s ease, background-image 0.2s ease;
}
.panel-tab--right {
  right: 0;
}
.panel-tab--left {
  left: 0;
  border-radius: 0 8px 8px 0;
}
.panel-tab--reasoning {
  top: 220px;
}
.panel-tab:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
  background-image: radial-gradient(circle at top, rgba(255,255,255,0.15), transparent 50%);
}

.article-side-panel select {
  background: #0d0d0d;
  border: 1px solid #1f2937;
  color: var(--text);
  padding: .5rem .75rem;
  border-radius: 6px;
}
.article-side-panel select:focus {
  outline: 2px solid var(--accent);
}

.stats-panel h4 {
  margin: 0 0 .5rem 0;
  color: var(--text);
}
.stats-row {
  margin-bottom: .75rem;
}
.stats-row__header {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  color: var(--text);
}
.stats-row__bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #101010;
  border: 1px solid #1f1f1f;
  overflow: hidden;
  margin-top: .25rem;
  position: relative;
}
.stats-row__bar-text {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
  text-align: right;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.stats-row__stacked {
  margin-top: 0;
  height: 14px;
}
.stats-row__segment {
  margin-top: 0;
}
.stats-row__segment + .stats-row__segment {
  margin-top: 0;
}
.stats-row__segment + .stats-row__segment {
  margin-top: 0;
}
.stats-row__fill {
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}
.stats-row__fill--primary {
  position: relative;
  z-index: 2;
}
.stats-row__fill--secondary {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0.35;
  z-index: 1;
}
.stats-row__fill--tertiary {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0.2;
  z-index: 0;
}
.stats-meta {
  color: var(--muted);
  font-size: .85rem;
}
.articles-filter-bar input,
.articles-filter-bar select {
  width: 100%;
  background: #0f0f0f;
  border: 1px solid #1f2937;
  color: var(--text);
  padding: .5rem .75rem;
  border-radius: 6px;
}
.articles-filter-bar select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
.articles-filter-bar input:focus,
.articles-filter-bar select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.articles-pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}
.articles-pagination button {
  border: 1px solid #1f2937;
  background: #0b0b0b;
  color: var(--text);
  padding: .4rem .9rem;
  border-radius: 6px;
  cursor: pointer;
}
.articles-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.articles-pagination span {
  color: var(--muted);
}
.articles-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.articles-footer__count {
  color: var(--muted);
}
.word-item--has-tooltip {
  position: relative;
}

.word-item--has-tooltip::after {
  content: attr(data-tooltip);
  position: fixed;
  left: 40px;
  right: 40px;
  bottom: 0;
  transform: none;
  background: rgba(8, 8, 8, 0.95);
  color: #fff;
  padding: 1rem 1.5rem;
  border-radius: 0;
  white-space: pre-line;
  max-width: 800px;
  text-align: left;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  max-height: 40vh;
  overflow-y: auto;
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
  z-index: 2147483647;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.45);
  left: 50%;
  transform: translateX(-50%);
  padding-right: 2rem;
  padding-left: 2rem;
}

.word-item--has-tooltip:hover::after {
  opacity: 1;
  pointer-events: auto;
}

/* content page status spinner */
.status-spinner{display:inline-block;width:14px;height:14px;border:2px solid #777;border-top-color:transparent;border-radius:50%;vertical-align:middle}
.status-spinner.is-active{border-color:#4caf50;border-top-color:transparent;animation:status-spin .8s linear infinite}
@keyframes status-spin{to{transform:rotate(360deg)}}
