:root {
  --ink: #12201B;
  --panel: #1B2B23;
  --panel-light: #223830;
  --stone: #EDEAE2;
  --stone-dim: #B9C2BC;
  --gold: #D7A34E;
  --river: #6E8C97;
  --line: rgba(237, 234, 226, 0.12);
  --radius: 10px;
  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background-color: var(--ink);
  background-image:
    radial-gradient(ellipse 800px 500px at 15% -10%, rgba(215, 163, 78, 0.07), transparent 60%),
    radial-gradient(ellipse 700px 450px at 105% 110%, rgba(110, 140, 151, 0.06), transparent 60%);
  background-attachment: fixed;
  color: var(--stone);
  font-family: var(--font-body);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
}

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

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  animation: appLoad 0.4s ease both;
  position: relative;
  z-index: 5;
  transition: box-shadow 0.2s ease;
}
.header--scrolled { box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); }

.header__brand { display: flex; align-items: center; gap: 0.5rem; }
.header__mark {
  height: 24px;
  width: 24px;
  object-fit: contain;
  flex-shrink: 0;
}
.header__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  margin: 0;
}

.header__right { display: flex; align-items: center; gap: 0.75rem; position: relative; }
.header__stats {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--stone-dim);
  margin: 0;
}
.header__stats.skeleton {
  display: inline-block;
  width: 160px;
  height: 0.9em;
  color: transparent;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--panel) 25%, var(--panel-light) 50%, var(--panel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================
   LOCATION POPOVER
   ============================================ */

.location { position: relative; }

.location__btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--stone-dim);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.location__icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}

.location__btn:hover,
.location__btn[aria-expanded="true"] {
  border-color: var(--gold);
  color: var(--gold);
}

.location__panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transform-origin: top right;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.location__panel--visible { opacity: 1; transform: translateY(0) scale(1); }

.location__header {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--stone-dim);
  margin: 0;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.location__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  cursor: pointer;
  gap: 0.75rem;
}

.location__distance {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.location__distance--visible { opacity: 1; transform: translateY(0); }
.location__distance label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--stone-dim);
  margin-bottom: 0.4rem;
}
.location__distance input[type="range"] { width: 100%; accent-color: var(--gold); }

.location__status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--stone-dim);
  margin: 0;
  min-height: 1em;
}

.toggle { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.toggle__input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle__track {
  position: absolute;
  inset: 0;
  background: var(--panel-light);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}
.toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--stone-dim);
  transition: transform 0.18s ease, background-color 0.18s ease;
}
.toggle__input:checked + .toggle__track { background: var(--gold); border-color: var(--gold); }
.toggle__input:checked + .toggle__track .toggle__thumb { transform: translateX(16px); background: var(--ink); }
.toggle__input:focus-visible + .toggle__track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ============================================
   CHAT
   ============================================ */

.chat-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

.jump-btn {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-light);
  border: 1px solid var(--gold);
  color: var(--stone);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  animation: msgIn 0.2s ease both;
}
.jump-btn:hover { background: var(--panel); }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-group { display: flex; flex-direction: column; gap: 0.3rem; max-width: 80%; }
.msg-group--user { align-self: flex-end; align-items: flex-end; }
.msg-group--assistant { align-self: flex-start; align-items: flex-start; }

.msg {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
  animation: msgIn 0.25s ease both;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

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

.msg--user { background: var(--panel-light); color: var(--stone); }
.msg--assistant { background: var(--panel); border: 1px solid var(--line); }
.msg--error {
  align-self: center;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  box-shadow: none;
}

.msg__time {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--stone-dim);
  opacity: 0.75;
  padding: 0 0.3rem;
}

@keyframes completeFlash {
  0% { box-shadow: 0 0 0 0 rgba(215, 163, 78, 0.45); }
  100% { box-shadow: 0 0 0 7px rgba(215, 163, 78, 0); }
}
.msg--complete { animation: completeFlash 0.6s ease-out; }

.msg__cursor {
  display: inline-block;
  width: 0.5em;
  height: 1em;
  background: var(--gold);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { to { opacity: 0; } }

/* ============================================
   THINKING INDICATOR
   ============================================ */

.thinking {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: msgIn 0.2s ease both;
}
.thinking__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--stone-dim); animation: thinkingBounce 1.2s ease-in-out infinite; }
.thinking__dot:nth-child(2) { animation-delay: 0.15s; }
.thinking__dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinkingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* ============================================
   TRACE STRIP
   ============================================ */

@keyframes traceIn {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

.trace {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--stone-dim);
  padding: 0.4rem 0.75rem;
  border-left: 2px solid var(--river);
  animation: traceIn 0.2s ease both;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.trace--done { border-left-color: var(--gold); color: var(--stone); }

.trace__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--river); animation: pulse 1.4s ease-in-out infinite; }
.trace__dot--done { background: var(--gold); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}
.trace__query { color: var(--stone); }

/* ============================================
   SUGGESTIONS
   ============================================ */

.suggestions { display: flex; flex-direction: column; gap: 1rem; margin-top: 0.5rem; }

.suggestions__intro {
  font-size: 0.95rem;
  color: var(--stone-dim);
  margin: 0 0 0.25rem;
  animation: sectionIn 0.3s ease both;
}

@keyframes sectionIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.suggestions__section { animation: sectionIn 0.3s ease both; }
.suggestions__section:nth-of-type(1) { animation-delay: 0.05s; }
.suggestions__section:nth-of-type(2) { animation-delay: 0.11s; }
.suggestions__section:nth-of-type(3) { animation-delay: 0.17s; }
.suggestions__section:nth-of-type(4) { animation-delay: 0.23s; }

.suggestions__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--stone-dim);
  margin: 0 0 0.5rem;
}
.suggestions__row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.examples__chip {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--stone);
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}
.examples__chip:hover { border-color: var(--gold); background: var(--panel-light); transform: translateY(-1px); }

/* ============================================
   COMPOSER
   ============================================ */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--line);
  animation: appLoad 0.4s ease 0.05s both;
}
.composer__input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--stone);
  border-radius: 16px;
  padding: 0.7rem 1rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  resize: none;
  overflow-y: auto;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer__input:disabled { opacity: 0.6; }
.composer__input:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(215, 163, 78, 0.18);
}

.composer__send {
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: var(--radius);
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.composer__send:hover:not(:disabled) { transform: translateY(-1px); }
.composer__send:active:not(:disabled) { transform: translateY(0) scale(0.95); }
.composer__send:disabled { opacity: 0.5; cursor: default; }

.composer__input::-webkit-scrollbar { width: 6px; }
.composer__input::-webkit-scrollbar-track { background: transparent; }
.composer__input::-webkit-scrollbar-thumb {
  background: var(--panel-light);
  border-radius: 3px;
}
.composer__input::-webkit-scrollbar-thumb:hover { background: var(--gold); }
.composer__input { scrollbar-width: thin; scrollbar-color: var(--panel-light) transparent; }

/* ============================================
   ACCESSIBILITY
   ============================================ */

.examples__chip:focus-visible,
.composer__send:focus-visible,
.location__btn:focus-visible,
.jump-btn:focus-visible,
.location__distance input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .header, .composer, .msg, .trace, .suggestions__section, .suggestions__intro,
  .trace__dot, .thinking__dot, .msg--complete, .jump-btn,
  .location__panel, .location__distance, .toggle__track, .toggle__thumb, .location__btn,
  .examples__chip, .composer__send, .header__stats.skeleton {
    animation: none;
    transition: none;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
  .header { padding: 1rem; }
  .chat { padding: 1rem; }
  .composer { padding: 0.75rem 1rem 1rem; }
  .msg-group { max-width: 90%; }
  .location__panel { right: -0.5rem; width: 240px; }
}

.msg--system {
  align-self: center;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--stone-dim);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  box-shadow: none;
}

/* ============================================
   SITE FOOTER — COMPACT RAG PIPELINE STRIP
   ============================================ */

html, body { overflow: hidden; }

.site-footer {
  flex-shrink: 0;
  padding: 0.5rem 1rem 0.6rem;
  background: rgba(27, 43, 35, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.pipeline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.pipeline::-webkit-scrollbar { display: none; }

.pipeline__stage {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  cursor: default;
}

.pipeline__icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-light);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pipeline__icon svg { width: 12px; height: 12px; }

.pipeline__title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  white-space: nowrap;
  color: var(--stone-dim);
}

.pipeline__arrow {
  position: relative;
  width: 28px;
  height: 1px;
  flex-shrink: 0;
  overflow: hidden;
}
.pipeline__track { position: absolute; inset: 0; border-top: 2px dashed var(--line); }
.pipeline__pulse {
  position: absolute;
  top: -2.5px;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 5px 1px rgba(215, 163, 78, 0.6);
  animation: pipelineFlow 2.2s linear infinite;
}
@keyframes pipelineFlow {
  0%   { left: -8%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

.site-footer__copyright {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--stone-dim);
  margin: 0.4rem 0 0;
}
.site-footer__copyright a { color: var(--stone-dim); text-decoration: underline; text-decoration-color: var(--line); }
.site-footer__copyright a:hover { color: var(--gold); }

.site-footer__social {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.site-footer__social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.site-footer__social a:hover {
  background: var(--panel-light);
  transform: translateY(-2px);
}

.site-footer__social img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  filter: grayscale(1) brightness(1.7) opacity(0.6);
  transition: filter 0.2s ease;
}

.site-footer__social a:hover img {
  filter: none;
}

.site-footer__social a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .site-footer__social a,
  .site-footer__social img {
    transition: none;
  }
}