:root {
  --ink: #071737;
  --blue: #164cff;
  --lime: #b8ff28;
  --paper: #ffffff;
  --muted: #6b7488;
  --line: #aab4c8;
  --soft-blue: #eaf0ff;
  font-family: "Courier New", Courier, monospace;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.48;
  pointer-events: none;
  background-image: radial-gradient(circle, #dce7ff 1px, transparent 1.2px);
  background-size: 8px 8px;
  mask-image: linear-gradient(90deg, #000 0%, transparent 18%, transparent 82%, #000 100%);
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 3px;
}

.site-shell {
  width: min(100% - 40px, 840px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 36px 0 24px;
  display: flex;
  flex-direction: column;
}

.site-header {
  text-align: center;
}

.wordmark {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.wordmark span {
  color: var(--blue);
}

.header-rule {
  height: 18px;
  margin-top: 20px;
  border-top: 2px solid var(--ink);
  position: relative;
}

.header-rule i {
  position: absolute;
  top: -3px;
  left: 50%;
  width: 58px;
  height: 4px;
  transform: translateX(-50%);
  background: var(--ink);
}

.replay-view,
.capture-view {
  flex: 1;
  padding: clamp(40px, 7vw, 84px) clamp(0px, 4vw, 72px) 32px;
}

.replay-heading {
  min-height: 28px;
  margin-bottom: 34px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}

.replay-heading p {
  margin: 0;
  color: var(--blue);
  font-size: 1rem;
  font-weight: 700;
}

.quiet-link {
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
}

.exchange,
.capture-panel {
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.exchange-meta {
  padding: 12px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.72rem;
  border-bottom: 1px solid var(--line);
}

.message {
  padding: 29px 0;
}

.message-label,
.capture-source {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: 0.77rem;
  font-weight: 700;
  text-transform: uppercase;
}

.prompt-line {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.prompt-cursor {
  flex: 0 0 4px;
  height: 1.55em;
  margin-top: 1px;
  background: var(--blue);
  animation: cursor-pulse 1.05s steps(2, start) infinite;
}

.prompt-line p,
.capture-turn p:last-child {
  max-width: 66ch;
  margin: 0;
  font-size: clamp(0.93rem, 2vw, 1.06rem);
  line-height: 1.58;
}

.send-state {
  padding: 17px 0 20px;
  color: var(--blue);
  font-size: 0.79rem;
  border-top: 1px solid var(--line);
}

.ellipsis {
  display: inline-flex;
  margin-left: 8px;
  gap: 4px;
}

.ellipsis i {
  width: 4px;
  height: 4px;
  background: currentColor;
  animation: ellipsis 1.1s infinite ease-in-out;
}

.ellipsis i:nth-child(2) {
  animation-delay: 0.16s;
}

.ellipsis i:nth-child(3) {
  animation-delay: 0.32s;
}

.section-rule {
  height: 2px;
  background: var(--ink);
}

.response-message {
  min-height: 292px;
}

.response-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.stream-status,
.copy-status,
.capture-status {
  color: var(--muted);
  font-size: 0.72rem;
}

.response-text {
  min-height: 12em;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(0.9rem, 2vw, 1rem);
  line-height: 1.55;
}

.live-cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-top: 3px;
  background: var(--lime);
  vertical-align: text-bottom;
  animation: cursor-pulse 0.82s steps(2, start) infinite;
}

.replay-actions {
  padding: 24px 0 14px;
  display: flex;
  justify-content: center;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.primary-action,
.secondary-action,
.copy-action {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--blue);
  border-radius: 0;
  font-size: 0.78rem;
  font-weight: 700;
}

.primary-action {
  color: var(--paper);
  background: var(--blue);
}

.secondary-action,
.copy-action {
  color: var(--blue);
  background: transparent;
}

.primary-action:hover {
  background: var(--ink);
  border-color: var(--ink);
}

.secondary-action:hover,
.copy-action:hover,
.quiet-link:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.copy-actions {
  min-height: 51px;
  padding-bottom: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.copy-action {
  min-height: auto;
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid var(--blue);
  font-size: 0.72rem;
  font-weight: 400;
}

.capture-panel {
  padding: 0 0 24px;
}

.import-form {
  padding: 26px 0;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.import-form label {
  display: block;
  margin-bottom: 12px;
  color: var(--blue);
  font-size: 0.77rem;
  font-weight: 700;
  text-transform: uppercase;
}

.import-row {
  display: flex;
  gap: 10px;
}

.import-row input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
  font-size: 0.85rem;
}

.manual-form textarea {
  width: 100%;
  margin: 0 0 18px;
  padding: 10px 11px;
  resize: vertical;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.45;
}

.manual-form .primary-action {
  display: block;
  margin: 0 auto;
}

.manual-toggle {
  display: block;
  margin: 18px auto 0;
}

.import-row input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.import-row .primary-action {
  flex: 0 0 auto;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.62;
}

.import-note {
  max-width: 62ch;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.55;
}

.loading-message {
  min-height: 12em;
  margin: 0;
  padding: 29px 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.capture-source {
  padding: 15px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.capture-source span {
  color: var(--blue);
}

.capture-turn {
  padding: 25px 0;
  border-bottom: 1px solid var(--line);
}

.capture-answer {
  padding-bottom: 30px;
}

.capture-panel .primary-action {
  display: block;
  margin: 24px auto 0;
}

.capture-status {
  min-height: 1em;
  margin: 12px 0 0;
  text-align: center;
}

.site-footer {
  padding-top: 16px;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.clipboard-fallback {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

@keyframes cursor-pulse {
  50% {
    opacity: 0;
  }
}

@keyframes ellipsis {
  50% {
    transform: translateY(-4px);
  }
}

@media (max-width: 560px) {
  .site-shell {
    width: min(100% - 28px, 840px);
    padding-top: 24px;
  }

  .wordmark {
    font-size: clamp(1.8rem, 10vw, 2.65rem);
  }

  .replay-view,
  .capture-view {
    padding: 38px 0 20px;
  }

  .exchange-meta,
  .response-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .replay-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .replay-actions button {
    width: 100%;
  }

  .copy-actions {
    flex-wrap: wrap;
  }

  .import-row {
    align-items: stretch;
    flex-direction: column;
  }

  .import-row .primary-action {
    width: 100%;
  }
}

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