@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Manrope:wght@400;500;600;700&display=swap");

:root {
  --ink: #0b0d0f;
  --panel: #111417;
  --panel-raised: #171b1f;
  --line: #30363b;
  --text: #f2f0e9;
  --muted: #9ca4a7;
  --signal: #b7f24a;
  --signal-dark: #1a2810;
  --coral: #ff6b57;
  --paper: #e8e4d8;
  --radius: 6px;
  --mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  scroll-behavior: smooth;
}

body.jarvis-page {
  min-width: 320px;
  margin: 0;
  background: var(--ink);
  color: var(--text);
  letter-spacing: 0;
}

button, textarea, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--signal);
  color: var(--ink);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.jarvis-header {
  min-height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 12px clamp(18px, 3vw, 46px);
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 15, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font: 500 13px/1 var(--mono);
}

.wordmark__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--signal);
  color: var(--signal);
  font-size: 15px;
}

.runtime-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 400 10px/1 var(--mono);
  color: var(--muted);
  text-transform: uppercase;
}

.runtime-pill__light {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 107, 87, 0.15);
}

.runtime-pill.is-ready .runtime-pill__light {
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(183, 242, 74, 0.12);
}

.jarvis-nav {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
  font: 400 11px/1 var(--mono);
  text-transform: uppercase;
}

.jarvis-nav a, .jarvis-footer a { color: var(--muted); }
.jarvis-nav a:hover, .jarvis-footer a:hover { color: var(--signal); }

.jarvis-shell {
  display: grid;
  grid-template-columns: minmax(380px, 0.92fr) minmax(500px, 1.08fr);
  min-height: calc(100vh - 64px);
}

.identity-panel,
.console-panel { min-width: 0; }

.identity-panel {
  padding: clamp(20px, 3vw, 46px);
  border-right: 1px solid var(--line);
  background: #0d1012;
}

.identity-panel__topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--muted);
  font: 400 9px/1.4 var(--mono);
}

.portrait {
  margin: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}

.portrait__media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #1e211f;
}

.portrait__media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center 42%;
  filter: saturate(0.82) contrast(1.05);
  transform: scale(1.06);
  transition: filter 260ms ease;
  animation: portrait-breathe 6s ease-in-out infinite;
}

.portrait[data-state="listening"] .portrait__media img {
  filter: saturate(1.05) contrast(1.05);
  animation: portrait-listen 1.4s ease-in-out infinite;
}

.portrait[data-state="thinking"] .portrait__media img {
  filter: saturate(0.65) contrast(1.14);
  animation: portrait-think 2.8s ease-in-out infinite;
}

.portrait[data-state="speaking"] .portrait__media img {
  filter: saturate(1) contrast(1.07);
  animation: portrait-speak 420ms ease-in-out infinite alternate;
}

.portrait__scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0, transparent 5px, rgba(11, 13, 15, 0.1) 6px);
  mix-blend-mode: multiply;
}

.portrait__focus {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: var(--signal);
  opacity: 0.8;
}
.portrait__focus--top { top: 14px; left: 14px; border-top: 1px solid; border-left: 1px solid; }
.portrait__focus--bottom { right: 14px; bottom: 14px; border-right: 1px solid; border-bottom: 1px solid; }

.portrait__wave {
  display: block;
  width: 100%;
  height: 54px;
  background: #0a0c0d;
  border-top: 1px solid var(--line);
}

.portrait figcaption {
  min-height: 38px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font: 400 8px/1.3 var(--mono);
  text-transform: uppercase;
}
.portrait__state { color: var(--signal); }

.identity-copy { padding: clamp(22px, 3vw, 38px) 0 18px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--signal);
  font: 400 10px/1.4 var(--mono);
}

.identity-copy h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(42px, 5.4vw, 82px);
  line-height: 0.92;
  font-weight: 600;
  letter-spacing: 0;
}

.identity-copy__intro {
  max-width: 620px;
  margin: 20px 0 0;
  color: #c5c9c8;
  font-size: clamp(13px, 1.2vw, 16px);
  line-height: 1.7;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.signal-grid div { padding: 12px 10px; border-right: 1px solid var(--line); }
.signal-grid div:first-child { padding-left: 0; }
.signal-grid div:last-child { border-right: 0; }
.signal-grid dt { color: var(--muted); font: 400 8px/1.3 var(--mono); }
.signal-grid dd { margin: 5px 0 0; font: 500 13px/1.2 var(--mono); }

.console-panel {
  display: grid;
  grid-template-rows: auto auto minmax(250px, 1fr) auto auto auto;
  gap: 14px;
  padding: clamp(20px, 3vw, 46px);
  background: var(--ink);
}

.console-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}
.console-heading h2 { margin: 0; font-size: clamp(28px, 3vw, 42px); line-height: 1; }

.icon-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}
.icon-button svg { width: 17px; height: 17px; }
.icon-button:hover { border-color: var(--signal); color: var(--signal); }
.icon-button:focus-visible, .load-button:focus-visible, .prompt-shelf button:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.model-loader {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.model-loader__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.model-loader__row strong, .model-loader__row span { display: block; }
.model-loader__row strong { font: 500 11px/1.4 var(--mono); }
.model-loader__row span { margin-top: 3px; color: var(--muted); font: 400 8px/1.3 var(--mono); }

.load-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--signal);
  border-radius: var(--radius);
  background: var(--signal-dark);
  color: var(--signal);
  font: 500 9px/1 var(--mono);
  cursor: pointer;
}
.load-button svg { width: 14px; height: 14px; }
.load-button:disabled { opacity: 0.55; cursor: progress; }

.progress-track {
  height: 2px;
  margin-top: 10px;
  overflow: hidden;
  background: #292e31;
}
.progress-track span { display: block; width: 0; height: 100%; background: var(--signal); transition: width 180ms ease; }

.chat-log {
  min-height: 250px;
  max-height: min(47vh, 560px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.message {
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--line);
}
.message:first-child { padding-top: 2px; }
.message__meta { display: flex; justify-content: space-between; color: var(--muted); font: 400 8px/1.2 var(--mono); }
.message--assistant .message__meta span { color: var(--signal); }
.message--user .message__meta span { color: var(--coral); }
.message__body { margin-top: 9px; color: #dde0dc; font-size: 13px; line-height: 1.72; white-space: pre-wrap; overflow-wrap: anywhere; }
.message__body a { color: var(--signal); text-decoration: underline; text-underline-offset: 3px; }
.message.is-streaming .message__body::after { content: ""; display: inline-block; width: 7px; height: 14px; margin-left: 4px; background: var(--signal); animation: cursor-blink 800ms steps(2) infinite; vertical-align: -2px; }

.prompt-shelf { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.prompt-shelf::-webkit-scrollbar { display: none; }
.prompt-shelf button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: 400 8px/1 var(--mono);
  cursor: pointer;
}
.prompt-shelf button:hover { color: var(--text); border-color: #687176; }

.composer {
  min-height: 66px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 10px;
  border: 1px solid #4a5358;
  border-radius: var(--radius);
  background: var(--panel-raised);
}
.composer:focus-within { border-color: var(--signal); }
.composer textarea {
  width: 100%;
  max-height: 140px;
  min-height: 42px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 10px 8px;
  background: transparent;
  color: var(--text);
  line-height: 1.5;
}
.composer textarea::placeholder { color: #747d81; }
.composer__actions { display: flex; gap: 7px; }
.icon-button--mic.is-listening { color: var(--coral); border-color: var(--coral); animation: mic-pulse 1s ease-in-out infinite; }
.icon-button--send { background: var(--signal); border-color: var(--signal); color: var(--ink); }
.icon-button--send:hover { background: #c5ff58; color: var(--ink); }
.icon-button--send:disabled { opacity: 0.45; cursor: wait; }

.console-footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; color: var(--muted); font: 400 8px/1.4 var(--mono); }
.voice-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.voice-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.voice-toggle > span { width: 25px; height: 13px; position: relative; border: 1px solid #5a6266; border-radius: 9px; pointer-events: none; }
.voice-toggle > span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 7px; height: 7px; border-radius: 50%; background: #70787b; transition: transform 150ms ease, background 150ms ease; }
.voice-toggle input:checked + span { border-color: var(--signal); }
.voice-toggle input:checked + span::after { transform: translateX(12px); background: var(--signal); }

.jarvis-footer {
  min-height: 52px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(18px, 3vw, 46px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 400 8px/1.4 var(--mono);
}
.jarvis-footer__links { display: flex; gap: 20px; }
.jarvis-footer > a:last-child { justify-self: end; }

noscript { display: block; padding: 20px; color: var(--paper); }

@keyframes portrait-breathe { 0%, 100% { transform: scale(1.06) translateY(0); } 50% { transform: scale(1.075) translateY(-2px); } }
@keyframes portrait-listen { 0%, 100% { transform: scale(1.07) rotate(0); } 50% { transform: scale(1.08) rotate(-0.35deg); } }
@keyframes portrait-think { 0%, 100% { transform: scale(1.07) translateX(0); } 50% { transform: scale(1.08) translateX(-3px); } }
@keyframes portrait-speak { from { transform: scale(1.07) translateY(0); } to { transform: scale(1.085) translateY(-2px); } }
@keyframes cursor-blink { 50% { opacity: 0; } }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 5px rgba(255, 107, 87, 0.12); } }

@media (max-width: 980px) {
  .jarvis-header { grid-template-columns: 1fr auto; }
  .runtime-pill { display: none; }
  .jarvis-shell { grid-template-columns: 1fr; }
  .identity-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .portrait__media { aspect-ratio: 16 / 10; }
  .console-panel { min-height: 760px; }
}

@media (max-width: 640px) {
  .jarvis-header { min-height: 56px; padding: 10px 16px; }
  .jarvis-nav { gap: 12px; }
  .jarvis-nav a:nth-child(2) { display: none; }
  .identity-panel, .console-panel { padding: 18px 16px; }
  .identity-copy h1 { font-size: 46px; }
  .portrait__media { aspect-ratio: 1 / 1; }
  .signal-grid dd { font-size: 11px; }
  .console-panel { min-height: calc(100vh - 56px); grid-template-rows: auto auto minmax(320px, 1fr) auto auto auto; }
  .chat-log { max-height: 52vh; }
  .console-footer { align-items: flex-start; }
  .jarvis-footer { grid-template-columns: 1fr; }
  .jarvis-footer__links { flex-wrap: wrap; gap: 12px 18px; }
  .jarvis-footer > a:last-child { justify-self: start; }
}

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