:root {
  --ink: #0B0B0D;
  --graphite: #17181C;
  --graphite-2: #1D1E23;
  --hairline: #2A2B31;
  --amber: #FFB238;
  --ember: #C97C24;
  --paper: #F4F1EA;
  --smoke: #91929B;
  --error: #F2555A;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Ambient background: a soft amber glow orb drifting slowly behind the
   page, like a light source moving behind frosted glass. Remove this block
   to go back to plain black — nothing else depends on it. */
body::before {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: clamp(320px, 45vw, 640px);
  height: clamp(320px, 45vw, 640px);
  margin-top: clamp(-320px, -22.5vw, -160px);
  margin-left: clamp(-320px, -22.5vw, -160px);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 178, 56, 0.5) 0%,
    rgba(255, 178, 56, 0.25) 38%,
    rgba(255, 178, 56, 0) 72%
  );
  filter: blur(50px);
  pointer-events: none;
  z-index: 0;
  animation: driftGlow 34s ease-in-out infinite;
}
@keyframes driftGlow {
  0%   { transform: translate(-32vw, -18vh) scale(1); }
  25%  { transform: translate(26vw, -24vh) scale(1.1); }
  50%  { transform: translate(30vw, 22vh) scale(0.92); }
  75%  { transform: translate(-26vw, 24vh) scale(1.05); }
  100% { transform: translate(-32vw, -18vh) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
}

.page {
  position: relative;
  z-index: 1;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

button {
  font: inherit;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  justify-content: flex-end;
  padding: 20px 0 0;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.lang-btn {
  background: none;
  border: none;
  color: var(--smoke);
  cursor: pointer;
  padding: 4px 2px;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: 0.03em;
}
.lang-btn.active { color: var(--amber); font-weight: 600; }
.lang-sep { color: var(--hairline); }

/* ---------- hero ---------- */

.stage {
  flex: 1;
  padding-top: clamp(16px, 5vh, 56px);
}

.hero {
  text-align: center;
  overflow: hidden;
  max-height: 420px;
  opacity: 1;
  transform: translateY(0);
  margin-bottom: clamp(28px, 5vh, 48px);
  transition: opacity 0.5s ease, transform 0.5s ease, max-height 0.5s ease, margin 0.5s ease;
}
.hero.collapsed {
  opacity: 0;
  transform: translateY(-14px);
  max-height: 0;
  margin-bottom: 0;
  pointer-events: none;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.25rem, 4vw + 1.25rem, 4.75rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  color: var(--paper);
}
.hero h1 em {
  font-style: italic;
  color: var(--amber);
  font-weight: 600;
}

.hero .sub {
  font-family: var(--font-body);
  color: var(--smoke);
  font-size: clamp(1rem, 1vw + 0.75rem, 1.15rem);
  max-width: 38ch;
  margin: 0 auto;
  line-height: 1.55;
}

/* ---------- console (the signature element) ---------- */

.console {
  max-width: 640px;
  margin: 0 auto;
  background: var(--graphite);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 30px 60px -30px rgba(0, 0, 0, 0.6),
    0 0 40px -12px rgba(255, 178, 56, 0.1);
}

.console-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 52px;
}

.dots { display: flex; gap: 6px; flex-shrink: 0; }
.dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hairline);
}

.bar-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

#url-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--paper);
  font-family: var(--font-mono);
  /* 16px minimum — anything smaller makes iOS Safari auto-zoom on focus,
     which then pans the page as you type to keep the caret in view. */
  font-size: 1rem;
  padding: 6px 0;
}
#url-input::placeholder { color: var(--smoke); }

#scan-btn, #send-btn {
  background: var(--amber);
  color: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.15s ease;
}
#scan-btn:hover, #send-btn:hover { filter: brightness(1.08); }
#scan-btn:disabled, #send-btn:disabled,
#url-input:disabled, #chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bar-domain {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--paper);
}
.bar-domain span#bar-domain-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 178, 56, 0.45); }
  50% { opacity: 0.65; box-shadow: 0 0 0 5px rgba(255, 178, 56, 0); }
}

#restart-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--hairline);
  color: var(--smoke);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
}
#restart-btn:hover { color: var(--paper); border-color: var(--smoke); }

.hidden { display: none !important; }

.hp-field { position: absolute; left: -9999px; top: -9999px; }

/* ---------- scan log ---------- */

.console-log {
  border-top: 1px solid var(--hairline);
  padding: 16px;
  position: relative;
  min-height: 100px;
  overflow: hidden;
}

.log-lines {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.83rem;
}

.log-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--smoke);
  opacity: 0;
  transform: translateY(4px);
  animation: lineIn 0.35s ease forwards;
}
@keyframes lineIn { to { opacity: 1; transform: translateY(0); } }

.log-line .label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-line.done { color: var(--paper); }
.log-line.final .label { color: var(--amber); font-weight: 600; }
.log-line .status {
  color: var(--amber);
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.log-line.active .status::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 12px;
  margin-left: 3px;
  background: var(--amber);
  vertical-align: text-bottom;
  animation: blink 0.9s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.scan-sweep {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  opacity: 0;
  box-shadow: 0 0 14px 1px rgba(255, 178, 56, 0.55);
  animation: sweep 2.1s ease-in-out infinite;
}
@keyframes sweep {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: 0.65; }
  88% { opacity: 0.65; }
  100% { transform: translateY(150px); opacity: 0; }
}

/* ---------- chat ---------- */

.console-chat {
  border-top: 1px solid var(--hairline);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 2px;
}

.bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 85%;
}
.bubble.user {
  align-self: flex-end;
  background: var(--amber);
  color: var(--ink);
  font-weight: 500;
  border-bottom-right-radius: 4px;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--graphite-2);
  color: var(--paper);
  border-bottom-left-radius: 4px;
}
.bubble.typing { color: var(--smoke); font-style: italic; }
.bubble a { color: var(--amber); text-decoration: underline; text-underline-offset: 2px; }
.bubble.user a { color: var(--ink); }
.bubble.limit { border: 1px solid var(--hairline); }

#chat-form { display: flex; gap: 8px; }
#chat-input {
  flex: 1;
  background: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--paper);
  font-family: var(--font-body);
  /* 16px minimum — see the comment on #url-input for why. */
  font-size: 1rem;
  outline: none;
}
#chat-input:focus { border-color: var(--amber); }

.tries-left {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--smoke);
  text-align: right;
  margin: 0;
}

/* ---------- status / disclosure ---------- */

.status {
  text-align: center;
  color: var(--smoke);
  font-family: var(--font-body);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 14px 0 0;
}
.status.error { color: var(--error); }

.disclosure {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--smoke);
  text-align: center;
  line-height: 1.6;
  margin-top: 48px;
  padding: 0 8px;
}
.disclosure-link {
  color: var(--amber);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 6px;
  white-space: nowrap;
}

/* ---------- responsive ---------- */

@media (max-width: 520px) {
  /* Dots align with the input's row — only the action button (Scan /
     Rescan) drops to its own line when tight, so the bar-form grows taller
     than the dots and needs top alignment instead of center. */
  .console-bar { align-items: flex-start; }
  .dots { margin-top: 12px; }
  .bar-domain, #restart-btn { margin-top: 6px; }
  .bar-form { flex-wrap: wrap; row-gap: 10px; }
  #url-input { flex: 1 1 140px; min-width: 0; }
  #scan-btn { flex: 1 0 100%; }
}

@media (max-width: 380px) {
  .hero h1 { letter-spacing: -0.005em; }
}

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