:root {
  --bg: #020202;
  --panel: rgba(5, 5, 5, 0.94);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #e2e2e2;
  --muted: #777777;
  --accent: #f0f0f0;
  --danger: #9a6262;
  --shadow: rgba(0, 0, 0, 0.8);
  --font-mono: "IBM Plex Mono", "Cascadia Mono", "Consolas", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  background: var(--bg);
}

body {
  margin: 0;
  height: 100vh;
  background: #020202;
  color: var(--text);
  font-family: var(--font-mono);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
  background-size: 100% 3px, 80px 100%;
  opacity: 0.08;
  pointer-events: none;
}

.noise,
.signal-grid {
  display: none;
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02) 0,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.1;
}

.screen-glitch {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(255, 255, 255, 0.04) 8% 9%, transparent 9% 100%),
    linear-gradient(180deg, transparent 0 48%, rgba(154, 98, 98, 0.12) 48% 49%, transparent 49% 100%),
    linear-gradient(90deg, transparent 0 72%, rgba(255, 255, 255, 0.025) 72% 74%, transparent 74% 100%);
  mix-blend-mode: screen;
  opacity: 0.28;
  animation: screenGlitch 3.2s steps(1) infinite;
}

.title-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.06), transparent 24%),
    rgba(2, 2, 2, 0.9);
  backdrop-filter: blur(2px);
  z-index: 10;
  animation: titleScreenFade 2200ms ease forwards;
}

.title-screen.is-hidden {
  display: none;
}

.link-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.04), transparent 20%),
    rgba(2, 2, 2, 0.92);
  z-index: 9;
}

.link-overlay.is-hidden {
  display: none;
}

.link-overlay__panel {
  width: min(420px, 100%);
  padding: 18px 16px;
  border: 1px solid rgba(154, 98, 98, 0.22);
  background: rgba(8, 8, 8, 0.76);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.02);
}

.link-overlay__label {
  margin: 0;
  color: #d4b9b9;
  font-size: 0.88rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.link-overlay__status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.link-overlay__meter {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.link-overlay__meter span {
  width: 18px;
  height: 6px;
  background: rgba(154, 98, 98, 0.75);
  animation: linkPulse 1s ease-in-out infinite;
}

.link-overlay__meter span:nth-child(2) {
  animation-delay: 0.16s;
}

.link-overlay__meter span:nth-child(3) {
  animation-delay: 0.32s;
}

.title-screen__inner {
  width: min(760px, 100%);
  padding: 20px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 8, 8, 0.5);
  box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.02);
  position: relative;
  animation: titleInnerRise 2400ms ease forwards;
}

.title-screen__inner::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 0 18%, rgba(255, 255, 255, 0.03) 18% 19%, transparent 19% 100%),
    linear-gradient(90deg, transparent 0 64%, rgba(154, 98, 98, 0.08) 64% 65%, transparent 65% 100%);
  mix-blend-mode: screen;
  opacity: 0.36;
  animation: panelGlitch 2.8s steps(1) infinite;
  pointer-events: none;
}

.title-screen__title {
  margin: 0;
  font-size: clamp(1.2rem, 3.8vw, 2.4rem);
  font-weight: 400;
  line-height: 1.08;
  color: rgba(240, 240, 240, 0.92);
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  animation:
    titleTextResolve 2600ms ease forwards,
    titleTextPulse 4.6s ease-in-out 2600ms infinite;
}

.title-screen__subtitle {
  margin: 10px 0 0;
  color: rgba(190, 190, 190, 0.72);
  font-size: 0.8rem;
}

.title-screen__enter {
  display: block;
  margin: 28px auto 0;
  min-width: 148px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(154, 98, 98, 0.34);
  background: rgba(255, 255, 255, 0.01);
  color: #d4b9b9;
  font: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  animation:
    enterButtonPulse 1.1s ease-in-out infinite,
    enterButtonGlitch 1.9s steps(1) infinite;
}

.title-screen__enter::before {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px solid rgba(154, 98, 98, 0.16);
  opacity: 0;
  animation: enterButtonAura 1.1s ease-in-out infinite;
  pointer-events: none;
}

.title-screen__enter:hover {
  background: rgba(154, 98, 98, 0.08);
}

.title-screen__enter.translatable::after {
  left: 50%;
  top: calc(100% + 8px);
  right: auto;
  bottom: auto;
  transform: translate(-50%, 3px);
}

.title-screen__enter.translatable:hover::after {
  transform: translate(-50%, 0);
}

.shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(920px, calc(100% - 24px));
  height: calc(100vh - 24px);
  margin: 12px auto;
  padding: 10px 96px 10px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 40px var(--shadow);
  overflow: hidden;
}

.shell.is-hidden {
  display: none;
}

.shell-header {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.system-label,
.access-meta,
.log-head,
.prompt-line,
.log-time,
.log-speaker,
.order-toggle {
  letter-spacing: 0.03em;
}

.system-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.title-group__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.translatable {
  position: relative;
  width: fit-content;
}

.translatable::after {
  content: attr(data-ja);
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #0a0a0a;
  color: var(--text);
  font-size: 0.66rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 5;
}

.translatable:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.access-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.header-actions {
  display: grid;
  gap: 8px;
}

.access-meta span,
.order-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.63rem;
  background: transparent;
}

.disconnect-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 120px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(154, 98, 98, 0.4);
  background: rgba(154, 98, 98, 0.04);
  color: #e2c7c7;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 2;
  animation:
    disconnectPulse 1.7s ease-in-out infinite,
    disconnectGlitch 2.8s steps(1) infinite;
}

.disconnect-button::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(154, 98, 98, 0.12);
  opacity: 0;
  pointer-events: none;
  animation: disconnectAura 1.7s ease-in-out infinite;
}

.disconnect-button:hover {
  border-color: rgba(154, 98, 98, 0.6);
  background: rgba(154, 98, 98, 0.1);
}

.disconnect-button.translatable::after {
  left: auto;
  right: 0;
  top: calc(100% + 8px);
  bottom: auto;
}

.access-meta span:nth-child(2) {
  color: #d1b0b0;
  border-color: rgba(154, 98, 98, 0.28);
}

.log-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  border: 1px solid var(--line);
  background: #030303;
  overflow: hidden;
}

.log-toolbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.log-head {
  display: grid;
  grid-template-columns: 78px 116px 1fr;
  gap: 10px;
  padding: 7px 9px;
  color: var(--muted);
  font-size: 0.63rem;
  text-transform: uppercase;
  flex: 1;
}

.order-toggle {
  margin: 6px 6px 6px 0;
  cursor: pointer;
  text-transform: uppercase;
  position: relative;
  width: auto;
}

.order-toggle:hover {
  border-color: var(--line-strong);
}

.log-head .translatable::after,
.order-toggle.translatable::after {
  top: auto;
  bottom: calc(100% + 6px);
}

.order-toggle.translatable::after {
  left: auto;
  right: 0;
}

.order-toggle__hint {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #0a0a0a;
  color: var(--text);
  font-size: 0.66rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 6;
}

.order-toggle:hover .order-toggle__hint {
  opacity: 1;
  transform: translateY(0);
}

.log-stream {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(154, 98, 98, 0.32) rgba(255, 255, 255, 0.04);
}

.log-stream::-webkit-scrollbar {
  width: 8px;
}

.log-stream::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

.log-stream::-webkit-scrollbar-thumb {
  background: rgba(154, 98, 98, 0.28);
}

.log-entry {
  position: relative;
  display: grid;
  grid-template-columns: 78px 116px 1fr;
  gap: 10px;
  padding: 7px 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  opacity: 0;
  animation: logReveal 220ms linear forwards;
}

.log-entry::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(154, 98, 98, 0.38);
}

.log-time,
.log-speaker {
  color: var(--muted);
  font-size: 0.69rem;
  white-space: nowrap;
}

.log-speaker {
  color: var(--accent);
}

.log-text {
  margin: 0;
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.5;
  word-break: break-word;
}

.prompt-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.63rem;
  text-transform: uppercase;
  flex-shrink: 0;
}

.prompt-text.translatable::after {
  top: auto;
  bottom: calc(100% + 6px);
}

.prompt-symbol {
  color: #c4aaaa;
}

.cursor {
  width: 9px;
  height: 1em;
  background: var(--danger);
  animation: blink 1s steps(1) infinite;
}

.disconnect-page {
  min-height: 100vh;
  padding: 20px;
  background: #020202;
  color: var(--text);
  font-family: var(--font-mono);
  height: auto;
  overflow-y: auto;
}

.disconnect-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.disconnect-header {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.disconnect-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.disconnect-title {
  margin: 0;
  font-size: clamp(1.2rem, 3.8vw, 2rem);
  font-weight: 400;
  line-height: 1.16;
  color: var(--accent);
}

.disconnect-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.disconnect-section {
  margin-top: 18px;
}

.disconnect-section h2 {
  margin: 0 0 10px;
  font-size: 0.82rem;
}

.disconnect-section p {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.7;
}

.credit-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(154, 98, 98, 0.28);
  padding-bottom: 1px;
}

.credit-link::after {
  content: attr(data-note);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: #0a0a0a;
  color: var(--text);
  font-size: 0.66rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 5;
}

.credit-link:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.credit-link:hover {
  color: var(--accent);
  border-color: rgba(154, 98, 98, 0.48);
}

.credit-link__icon {
  color: #d4b9b9;
  font-size: 0.78em;
  line-height: 1;
}

.disconnect-link {
  display: inline-block;
  margin-top: 22px;
  color: #d4b9b9;
  text-decoration: none;
  border-bottom: 1px solid rgba(154, 98, 98, 0.34);
  padding-bottom: 2px;
}

.disconnect-link:hover {
  border-color: rgba(154, 98, 98, 0.5);
}

.page-credit {
  margin: 12px 2px 0;
  color: rgba(226, 226, 226, 0.42);
  font-size: 0.68rem;
  line-height: 1.4;
  letter-spacing: 0.06em;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

@keyframes logReveal {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes titleScreenFade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes titleInnerRise {
  from {
    opacity: 0;
    transform: translateY(24px);
    filter: blur(18px);
  }

  55% {
    opacity: 0.58;
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes titleTextResolve {
  from {
    opacity: 0;
    filter: blur(14px);
    letter-spacing: 0.16em;
  }

  50% {
    opacity: 0.56;
  }

  to {
    opacity: 1;
    filter: blur(0);
    letter-spacing: 0;
  }
}

@keyframes titleTextPulse {
  0%,
  100% {
    opacity: 0.9;
    filter: blur(0);
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.06);
  }

  30% {
    opacity: 0.76;
    filter: blur(1.2px);
    text-shadow: 0 0 26px rgba(255, 255, 255, 0.1);
  }

  58% {
    opacity: 0.95;
    filter: blur(0.1px);
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.04);
  }

  78% {
    opacity: 0.8;
    filter: blur(0.8px);
    text-shadow: 0 0 22px rgba(255, 255, 255, 0.08);
  }
}

@keyframes linkPulse {
  0%,
  100% {
    opacity: 0.2;
    transform: scaleX(1);
  }

  50% {
    opacity: 1;
    transform: scaleX(1.28);
  }
}

@keyframes screenGlitch {
  0%,
  60%,
  100% {
    opacity: 0.08;
    transform: translate3d(0, 0, 0);
  }

  61% {
    opacity: 0.3;
    transform: translate3d(-0.8%, 0, 0);
  }

  62% {
    opacity: 0.16;
    transform: translate3d(0.7%, 0, 0);
  }

  63% {
    opacity: 0.28;
    transform: translate3d(-0.3%, 0.4%, 0);
  }

  64% {
    opacity: 0.12;
    transform: translate3d(0.2%, -0.2%, 0);
  }
}

@keyframes panelGlitch {
  0%,
  72%,
  100% {
    opacity: 0.14;
    transform: translate3d(0, 0, 0);
  }

  73% {
    opacity: 0.34;
    transform: translate3d(-0.6%, 0, 0);
  }

  74% {
    opacity: 0.18;
    transform: translate3d(0.4%, 0, 0);
  }
}

@keyframes enterButtonPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 rgba(154, 98, 98, 0),
      inset 0 0 0 rgba(154, 98, 98, 0);
    letter-spacing: 0.08em;
  }

  50% {
    transform: scale(1.06);
    box-shadow:
      0 0 26px rgba(154, 98, 98, 0.2),
      inset 18px 0 20px rgba(154, 98, 98, 0.08);
    letter-spacing: 0.11em;
  }
}

@keyframes enterButtonAura {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.98);
  }

  50% {
    opacity: 0.58;
    transform: scale(1.08);
  }
}

@keyframes enterButtonGlitch {
  0%,
  58%,
  100% {
    transform: translate3d(0, 0, 0);
    filter: blur(0);
  }

  59% {
    transform: translate3d(-2px, 0, 0);
    filter: blur(0.6px);
  }

  60% {
    transform: translate3d(2px, 0, 0);
    filter: blur(0);
  }

  61% {
    transform: translate3d(-1px, 0.4px, 0);
    filter: blur(0.4px);
  }

  62% {
    transform: translate3d(1px, -0.3px, 0);
    filter: blur(0);
  }
}

@keyframes disconnectPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(154, 98, 98, 0);
  }

  50% {
    transform: scale(1.04);
    box-shadow: 0 0 22px rgba(154, 98, 98, 0.2);
  }
}

@keyframes disconnectAura {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.99);
  }

  50% {
    opacity: 0.42;
    transform: scale(1.05);
  }
}

@keyframes disconnectGlitch {
  0%,
  86%,
  100% {
    transform: translate3d(0, 0, 0);
    filter: blur(0);
  }

  87% {
    transform: translate3d(-2px, 0, 0);
    filter: blur(0.35px);
  }

  88% {
    transform: translate3d(2px, 0, 0);
    filter: blur(0);
  }
}

@media (max-width: 640px) {
  body {
    height: 100dvh;
  }

  .title-screen {
    padding: 12px;
  }

  .title-screen__inner {
    padding: 16px 14px;
  }

  .title-screen__title {
    white-space: normal;
  }

  .shell {
    width: min(100% - 12px, 920px);
    height: calc(100dvh - 12px);
    margin: 6px auto;
    padding: 56px 8px 8px;
  }

  .log-toolbar {
    display: block;
  }

  .log-head {
    display: none;
  }

  .order-toggle {
    margin: 6px;
  }

  .log-entry {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .log-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .log-text {
    font-size: 0.84rem;
  }

  .translatable::after {
    font-size: 0.62rem;
    white-space: normal;
    max-width: min(220px, 70vw);
  }

  .disconnect-page {
    min-height: 100dvh;
    padding: 12px;
    overflow-y: auto;
  }

  .disconnect-shell {
    padding: 14px 12px;
  }

  .disconnect-button {
    top: 8px;
    right: 8px;
    min-width: 110px;
    min-height: 38px;
    font-size: 0.68rem;
  }
}
