:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #050505;
  --soft-ink: #555555;
  --line: #d9d9d9;
  --pale: #f5f5f5;
  --pale-2: #eeeeee;
  --link: #0645d6;
  --good: #111111;
  --warn: #777777;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px) 0 0 / 72px 72px,
    var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  margin-bottom: 40px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.wordmark-mark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  position: relative;
}

.wordmark-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 2px;
  width: 2px;
  height: 10px;
  background: var(--ink);
  transform: rotate(36deg);
  transform-origin: bottom center;
}

.icon-button,
.search-button,
.close-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.icon-button:hover,
.search-button:hover,
.close-button:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-1px);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.3);
  animation: pulseDot 1.8s ease-in-out infinite;
}

.search-panel {
  display: grid;
  gap: 18px;
  max-width: 820px;
  padding-bottom: 32px;
}

.search-panel h1 {
  margin: 0;
  font-size: clamp(42px, 9vw, 104px);
  line-height: 0.92;
  font-weight: 400;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  align-items: center;
  gap: 12px;
  width: min(760px, 100%);
}

.search-form input {
  width: 100%;
  min-width: 0;
  height: 58px;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(24px, 5vw, 44px);
  line-height: 1;
  outline: none;
  padding: 0 2px 8px;
}

.search-form input::placeholder {
  color: #999999;
  opacity: 1;
}

.search-icon {
  width: 17px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: -6px;
  width: 10px;
  height: 2px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left center;
}

.search-activity {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 24px;
  color: var(--soft-ink);
  font-size: 14px;
}

.activity-line {
  display: block;
  height: 1px;
  background: linear-gradient(90deg, var(--ink), transparent);
  transform-origin: left center;
  opacity: 0.5;
}

.is-generating .activity-line {
  animation: activitySweep 1.1s ease-in-out infinite;
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 42px;
  align-items: start;
}

.article {
  min-height: 320px;
  padding-top: 12px;
}

.empty-state {
  border-top: 1px solid var(--line);
  padding-top: 26px;
  color: var(--soft-ink);
  font-size: 18px;
  line-height: 1.55;
}

.article-header {
  display: grid;
  gap: 14px;
  border-top: 2px solid var(--ink);
  padding-top: 24px;
  margin-bottom: 30px;
}

.article-title {
  margin: 0;
  font-size: clamp(46px, 9vw, 96px);
  font-weight: 400;
  line-height: 0.96;
}

.subtitle {
  margin: 0;
  max-width: 760px;
  color: var(--soft-ink);
  font-size: clamp(18px, 2.2vw, 26px);
  line-height: 1.25;
}

.lead,
.definition,
.article-section p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.58;
}

.definition {
  border-left: 2px solid var(--ink);
  padding-left: 18px;
  margin: 24px 0 36px;
  font-weight: 700;
}

.article-section {
  border-top: 1px solid var(--line);
  padding: 28px 0 30px;
}

.article-section h2 {
  margin: 0 0 14px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.08;
  font-weight: 400;
}

.wiki-link {
  color: var(--link);
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.wiki-link:hover {
  color: var(--ink);
}

.diffuse-word {
  opacity: 0;
  filter: blur(8px);
  animation: revealWord 520ms ease forwards;
}

.space-word {
  white-space: pre-wrap;
}

.side-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 20px;
  min-width: 0;
}

.info-block {
  border-top: 1px solid var(--ink);
  padding-top: 16px;
}

.info-block h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  font-weight: 700;
}

.facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.fact-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  font-size: 14px;
  line-height: 1.35;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.fact-row dt {
  color: var(--soft-ink);
}

.fact-row dd {
  margin: 0;
  min-width: 0;
}

.related-list,
.role-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-list button {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease;
}

.related-list button:hover {
  border-color: var(--ink);
  transform: translateX(3px);
}

.role-pill {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.35;
}

.role-pill strong {
  font-size: 13px;
}

.role-pill span {
  color: var(--soft-ink);
}

.role-pill.is-online {
  border-color: var(--ink);
}

.notice {
  color: var(--soft-ink);
  font-size: 13px;
  line-height: 1.45;
}

.status-dialog {
  width: min(680px, calc(100% - 28px));
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.status-dialog::backdrop {
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 400;
}

.close-button {
  width: 34px;
  height: 34px;
  font-weight: 700;
}

.status-content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.status-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  padding: 14px;
}

.status-item h3 {
  margin: 0;
  font-size: 16px;
}

.status-item p {
  margin: 0;
  color: var(--soft-ink);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

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

@keyframes revealWord {
  0% {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(5px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

@keyframes activitySweep {
  0%,
  100% {
    transform: scaleX(0.32);
    opacity: 0.3;
  }
  50% {
    transform: scaleX(1);
    opacity: 0.8;
  }
}

@keyframes pulseDot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.18);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(0, 0, 0, 0);
  }
}

@media (max-width: 840px) {
  body {
    background: var(--paper);
  }

  .shell {
    width: min(100% - 24px, 760px);
    padding: 12px 0 36px;
  }

  .topbar {
    margin-bottom: 26px;
  }

  .search-panel {
    padding-bottom: 18px;
  }

  .search-panel h1 {
    font-size: clamp(38px, 13vw, 64px);
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) 48px;
    gap: 10px;
  }

  .search-form input {
    height: 54px;
  }

  .page-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .side-panel {
    position: static;
    grid-template-columns: 1fr;
  }

  .fact-row {
    grid-template-columns: 86px minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 22px, 420px);
  }

  .topbar {
    min-height: 38px;
    margin-bottom: 22px;
  }

  .search-panel {
    gap: 14px;
    padding-bottom: 10px;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .search-form input {
    height: 50px;
    font-size: 28px;
  }

  .search-activity {
    grid-template-columns: 54px minmax(0, 1fr);
    font-size: 13px;
  }

  .article {
    padding-top: 2px;
  }

  .article-header {
    padding-top: 18px;
    margin-bottom: 22px;
  }

  .article-title {
    font-size: clamp(42px, 15vw, 58px);
  }

  .subtitle {
    font-size: 18px;
  }

  .lead,
  .definition,
  .article-section p {
    font-size: 18px;
    line-height: 1.72;
  }

  .definition {
    margin: 20px 0 26px;
    padding-left: 14px;
  }

  .article-section {
    padding: 24px 0 26px;
  }

  .article-section h2 {
    font-size: 27px;
    margin-bottom: 12px;
  }

  .info-block {
    padding-top: 14px;
  }

  .related-list button {
    min-height: 42px;
  }
}

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