/* ─── Design tokens: Claude Code–inspired terminal ─── */
:root {
  --bg: #0c0c0c;
  --bg-elevated: #141414;
  --bg-input: #111111;
  --bg-user: #161616;
  --bg-assistant: transparent;
  --border: #2a2a2a;
  --border-focus: #c96442;
  --border-soft: #1e1e1e;
  --text: #e8e6e3;
  --text-dim: #8a8780;
  --text-muted: #5c5a55;
  --accent: #d97757;
  --accent-soft: #c96442;
  --accent-glow: rgba(217, 119, 87, 0.18);
  --green: #6a9f6a;
  --blue: #6b9bd1;
  --yellow: #c9a227;
  --red: #c75c5c;
  --purple: #a78bfa;
  --cyan: #5eb1bf;
  --font: "IBM Plex Mono", "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
  --radius: 8px;
  --composer-max: 920px;
  --line: 1.55;
}

[data-theme="light"] {
  --bg: #f5f4f1;
  --bg-elevated: #ffffff;
  --bg-input: #ffffff;
  --bg-user: #eceae4;
  --border: #d4d1c9;
  --border-focus: #c96442;
  --border-soft: #e5e2da;
  --text: #1a1917;
  --text-dim: #5c5a55;
  --text-muted: #8a8780;
  --accent-glow: rgba(201, 100, 66, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
}

.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;
}

/* ─── App shell ─── */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-glow), transparent 55%),
    var(--bg);
}

/* ─── Fake window chrome ─── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  height: 40px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  backdrop-filter: blur(8px);
  user-select: none;
}

.traffic {
  display: flex;
  gap: 7px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  opacity: 0.9;
}

.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.topbar-title {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.topbar-spacer {
  width: 52px;
}

/* ─── Terminal scroll area ─── */
.terminal {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 20px 12px;
  scroll-behavior: smooth;
}

.terminal::-webkit-scrollbar {
  width: 8px;
}

.terminal::-webkit-scrollbar-track {
  background: transparent;
}

.terminal::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.terminal::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.inner {
  max-width: var(--composer-max);
  margin: 0 auto;
}

/* ─── Welcome / banner ─── */
.banner {
  margin-bottom: 20px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(
    165deg,
    color-mix(in srgb, var(--accent) 8%, var(--bg-elevated)),
    var(--bg-elevated)
  );
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 6%, transparent);
}

/* Super Mario head — reference pixel art (Claude Code logo slot) */
.ascii-logo {
  margin: 0 0 14px;
  padding: 2px 0 4px;
  user-select: none;
}

.mario-logo {
  display: block;
  width: 168px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-user-drag: none;
  filter: drop-shadow(0 0 18px rgba(224, 48, 32, 0.18));
}

@media (max-width: 640px) {
  .mario-logo {
    width: 132px;
  }
}

.banner-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.banner-logo {
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.banner-version {
  font-size: 12px;
  color: var(--text-muted);
}

.banner-tagline {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 14px;
}

.banner-highlight {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
}

.section-title {
  margin: 22px 0 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

.tips {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}

.tips li {
  position: relative;
  padding: 4px 0 4px 18px;
  color: var(--text-dim);
  font-size: 13px;
}

.tips li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
}

.tips code,
.msg-body code {
  font-family: inherit;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--cyan);
}

.divider {
  height: 1px;
  margin: 20px 0;
  background: var(--border-soft);
  border: none;
}

/* ─── Messages ─── */
.msg {
  margin: 0 0 16px;
  animation: fade-in 0.22s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.msg-role {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.msg-user .msg-role {
  color: var(--blue);
}

.msg-assistant .msg-role {
  color: var(--accent);
}

.msg-system .msg-role {
  color: var(--yellow);
}

.msg-time {
  color: var(--text-muted);
  font-size: 11px;
}

.msg-body {
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
}

.msg-user .msg-body {
  padding: 10px 12px;
  background: var(--bg-user);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.msg-assistant .msg-body {
  padding: 2px 0;
}

.msg-system .msg-body {
  color: var(--text-dim);
  font-size: 13px;
}

/* Markdown-ish blocks inside assistant replies */
.msg-body p {
  margin: 0 0 0.75em;
}

.msg-body p:last-child {
  margin-bottom: 0;
}

.msg-body ul,
.msg-body ol {
  margin: 0.4em 0 0.75em;
  padding-left: 1.25em;
}

.msg-body li {
  margin: 0.2em 0;
}

.msg-body strong {
  font-weight: 600;
  color: var(--text);
}

.msg-body a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg-body pre {
  margin: 0.6em 0;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
}

.msg-body pre code {
  padding: 0;
  background: none;
  color: var(--text);
}

/* ─── Thinking indicator ─── */
.thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 12px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ─── Composer ─── */
.composer-wrap {
  flex-shrink: 0;
  padding: 0 16px 12px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.composer {
  max-width: var(--composer-max);
  margin: 0 auto;
}

.composer-border {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-border:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.prompt-char {
  flex-shrink: 0;
  padding-bottom: 2px;
  color: var(--accent);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.4;
  user-select: none;
}

.composer-input {
  flex: 1;
  min-height: 24px;
  max-height: 160px;
  margin: 0;
  padding: 2px 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  overflow-y: auto;
}

.composer-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-bottom: -2px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--accent-soft);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}

.send-btn:hover {
  background: var(--accent);
}

.send-btn:active {
  transform: scale(0.96);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: var(--composer-max);
  margin: 8px auto 0;
  padding: 0 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-item.muted {
  color: var(--text-muted);
  opacity: 0.85;
}

.status-sep {
  opacity: 0.5;
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  .msg,
  .thinking-dots span {
    animation: none;
  }

  .terminal {
    scroll-behavior: auto;
  }
}

/* ─── Mobile ─── */
@media (max-width: 640px) {
  html,
  body {
    font-size: 13px;
  }

  .terminal {
    padding: 14px 12px 8px;
  }

  .banner {
    padding: 12px 14px;
  }

  .statusbar .status-item.muted {
    display: none;
  }

  .topbar-title {
    font-size: 11px;
  }
}
