:root {
  color-scheme: dark;
  /* Dark surface system mirrored from the supplied grok.com HAR. */
  --surface-base: hsl(30 5% 7%);
  --surface-inset: hsl(30 5% 9%);
  --surface-l1: hsl(30 5% 9%);
  --surface-l1-hover: hsl(30 5% 13%);
  --surface-l2: hsl(30 5% 12%);
  --surface-l2-active: hsl(30 5% 16%);
  --surface-elevated: hsl(30 5% 13%);
  --surface-composer: hsl(30 5% 12%);
  --input-background: #23211f;
  --input-button-background: #23211f;
  --input-button-hover: #2b2927;
  --text: hsl(0 0% 99%);
  --text-secondary: hsl(0 0% 62%);
  --text-tertiary: hsl(0 0% 52%);
  --border-l1: hsl(0 0% 100% / 6%);
  --border-l2: hsl(0 0% 100% / 10%);
  --border-l3: hsl(0 0% 100% / 16%);
  --accent: hsl(207 100% 58%);
  --accent-hover: hsl(207 100% 64%);
  --danger: #f16d73;
  --composer-radius: 24px;
  --sidebar-width: 254px;
  --content-width: 800px;
  --shadow-elevated: 0 18px 60px rgba(0, 0, 0, 0.34);
  --inline-code-bg: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--surface-base);
}

body {
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: "Universal Sans", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
input,
select { font: inherit; }

button { color: inherit; }
button:focus-visible,
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid hsl(207 100% 58% / 55%);
  outline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.banner {
  position: relative;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 42px;
  padding: 9px 48px 9px 16px;
  border-bottom: 1px solid rgba(241, 109, 115, 0.22);
  background: rgba(85, 28, 31, 0.88);
  color: #ffd7d9;
  font-size: 13px;
  backdrop-filter: blur(16px);
}
.banner[hidden] { display: none; }
.banner.notice {
  background: rgba(83, 66, 22, 0.92);
  color: #ffe7a0;
  border-bottom-color: rgba(255, 215, 106, 0.18);
}
.banner-close {
  position: absolute;
  right: 14px;
  top: 50%;
  translate: 0 -50%;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}
.banner-close:hover { background: rgba(255,255,255,.08); }

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  background: var(--surface-base);
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 12px 12px;
  background: var(--surface-l1);
  border-right: 1px solid var(--border-l1);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.12) transparent;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 8px;
  margin-bottom: 8px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.brand-mark svg { width: 24px; height: 24px; stroke-width: 0; fill: var(--text); }
.brand-mark svg path:last-child { opacity: .72; }

.app-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.new-chat-btn {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  text-align: left;
}
.new-chat-btn:hover { background: rgba(255,255,255,.055); }
.new-chat-btn svg { width: 18px; height: 18px; }

.sidebar-section-label {
  padding: 18px 12px 7px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.model-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 11px;
  border-radius: 12px;
  color: var(--text-secondary);
}
.model-card:hover { background: rgba(255,255,255,.035); }
.model-card strong,
.model-card small { display: block; }
.model-card strong { color: var(--text); font-size: 13px; font-weight: 550; }
.model-card small { margin-top: 2px; font-size: 11px; color: var(--text-tertiary); }
.model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #70d49a;
  box-shadow: 0 0 0 4px rgba(112,212,154,.09);
}
.sidebar-spacer { flex: 1; min-height: 18px; }

.settings {
  border-top: 1px solid var(--border-l1);
  padding-top: 8px;
}
.settings > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  user-select: none;
}
.settings > summary::-webkit-details-marker { display: none; }
.settings > summary:hover { background: rgba(255,255,255,.05); color: var(--text); }
.summary-icon { width: 20px; text-align: center; font-size: 15px; }
.summary-chevron { margin-left: auto; transition: transform .16s ease; }
.settings[open] .summary-chevron { transform: rotate(180deg); }
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 17px;
  padding: 14px 8px 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 12px;
}
.field > span:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}
.field output { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.field small { color: var(--text-tertiary); font-size: 10.5px; line-height: 1.45; }
.field textarea,
.field select,
.field input[type="number"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-l2);
  border-radius: 10px;
  background: var(--input-background);
  color: var(--text);
  padding: 9px 10px;
}
.field textarea { resize: vertical; min-height: 84px; line-height: 1.4; }
.field select { color-scheme: dark; }
.field input[type="number"] { appearance: textfield; font-variant-numeric: tabular-nums; }
.field input[type="number"]::-webkit-inner-spin-button,
.field input[type="number"]::-webkit-outer-spin-button { opacity: .45; }
.field input[type="range"] {
  width: 100%;
  accent-color: #f5f5f5;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--surface-base);
}

.mobile-bar { display: none; }
.sidebar-backdrop { display: none; }

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.chat-scroll::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.13); border-radius: 99px; }

.chat-log {
  width: min(var(--content-width), calc(100% - 42px));
  min-height: 100%;
  margin: 0 auto;
  padding: 56px 0 210px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.empty-state {
  min-height: calc(100vh - 290px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px 0 10px;
}
.empty-logo {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--border-l1);
  border-radius: 18px;
  background: rgba(255,255,255,.025);
  font-size: 25px;
}
.empty-title {
  margin: 0;
  color: var(--text);
  font-size: clamp(27px, 3vw, 36px);
  line-height: 1.15;
  font-weight: 500;
  letter-spacing: -0.035em;
}
.empty-hint {
  margin: 10px 0 20px;
  color: var(--text-tertiary);
  font-size: 13px;
}
.examples {
  width: 100%;
  max-width: 680px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.example {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid var(--border-l1);
  border-radius: 14px;
  background: rgba(255,255,255,.022);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
  line-height: 1.35;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.example:hover {
  background: rgba(255,255,255,.055);
  border-color: var(--border-l2);
  color: var(--text);
}
.example-media {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  overflow: visible;
}
.example-thumb,
.example-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--surface-l2);
  color: var(--text-secondary);
}
.example-count {
  position: absolute;
  right: -5px;
  bottom: -4px;
  min-width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  padding: 0 3px;
  border: 2px solid var(--surface-base);
  border-radius: 999px;
  background: var(--text);
  color: #111;
  font-size: 8px;
  font-weight: 700;
}
.show-more {
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
}
.show-more:hover { color: var(--text); }

.msg {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  line-height: 1.55;
}
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: flex-start; }
.bubble { max-width: 100%; overflow-wrap: anywhere; }
.user .bubble {
  max-width: min(78%, 610px);
  padding: 10px 14px;
  border-radius: 18px 18px 5px 18px;
  background: var(--surface-l2);
  color: var(--text);
  white-space: pre-wrap;
}
.assistant .bubble {
  width: 100%;
  color: var(--text);
  background: transparent;
}
.assistant .bubble.streaming { white-space: pre-wrap; }
.assistant-bubbles .assistant .bubble {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface-l1);
}

.md { line-height: 1.65; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 1em; }
.md h1,
.md h2,
.md h3,
.md h4 { color: var(--text); line-height: 1.28; letter-spacing: -.018em; }
.md h1 { font-size: 1.7rem; }
.md h2 { font-size: 1.42rem; }
.md h3 { font-size: 1.18rem; }
.md ul,
.md ol { padding-left: 1.45rem; }
.md li { margin: .28rem 0; }
.md a { color: #75bfff; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.md hr { border: 0; border-top: 1px solid var(--border-l2); margin: 1.5rem 0; }
.md blockquote {
  margin-left: 0;
  padding-left: 14px;
  border-left: 2px solid var(--border-l3);
  color: var(--text-secondary);
}
.md code:not(pre code) {
  padding: .14em .35em;
  border-radius: 5px;
  background: var(--inline-code-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
}
.md pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--border-l1);
  border-radius: 12px;
  background: #0e0e0e !important;
  font-size: 13px;
  line-height: 1.55;
}
.code-wrap { position: relative; margin: 1rem 0; }
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid var(--border-l2);
  border-radius: 8px;
  background: rgba(35,33,31,.9);
  color: var(--text-secondary);
  padding: 5px 8px;
  cursor: pointer;
  font-size: 10px;
}
.copy-btn:hover { color: var(--text); background: #2b2927; }
.md table { border-collapse: collapse; max-width: 100%; display: block; overflow-x: auto; }
.md th,
.md td { border-bottom: 1px solid var(--border-l2); padding: 8px 11px; text-align: left; }
.md th { font-weight: 600; }

.typing { display: inline-flex; align-items: center; gap: 4px; height: 24px; }
.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing-blink 1.25s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes typing-blink { 0%,80%,100%{opacity:.2; transform:translateY(0)} 40%{opacity:1; transform:translateY(-2px)} }

.reasoning {
  width: 100%;
  padding: 0 0 8px;
  color: var(--text-secondary);
  font-size: 13px;
}
.reasoning summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
}
.reasoning summary::marker { color: var(--text-tertiary); }
.reasoning-body {
  margin-top: 10px;
  padding: 10px 13px;
  border-left: 2px solid var(--border-l2);
  color: var(--text-secondary);
}

.turn-note { margin-top: 2px; font-size: 11px; color: var(--text-tertiary); }
.turn-note.error { color: var(--danger); }

.msg-media {
  max-width: min(440px, 72vw);
  max-height: 360px;
  border-radius: 16px;
  object-fit: contain;
  cursor: zoom-in;
  border: 1px solid var(--border-l1);
}
.md img,
.md video { max-width: 100%; border-radius: 12px; }

.composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 18px 22px 12px;
  background: linear-gradient(to bottom, transparent 0, hsl(30 5% 7% / 87%) 24%, var(--surface-base) 48%);
  pointer-events: none;
}
.composer {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  padding: 10px 11px 9px;
  border: 1px solid var(--border-l1);
  border-radius: var(--composer-radius);
  background: var(--surface-composer);
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  pointer-events: auto;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer:focus-within {
  border-color: var(--border-l2);
  box-shadow: 0 8px 34px rgba(0,0,0,.27), 0 0 0 1px rgba(255,255,255,.015);
}
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
}
#message {
  flex: 1;
  min-width: 0;
  max-height: 210px;
  min-height: 40px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0 !important;
  background: transparent;
  color: var(--text);
  padding: 9px 7px 7px;
  font-size: 15px;
  line-height: 1.55;
}
#message::placeholder { color: var(--text-tertiary); opacity: 1; }

.icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-l1);
  border-radius: 999px;
  background: var(--input-button-background);
  color: var(--text-secondary);
  cursor: pointer;
}
.icon-btn:hover { background: var(--input-button-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.bare { background: transparent; border-color: transparent; }

.send-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: #111;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, opacity .12s ease;
}
.send-btn:hover { background: #fff; transform: translateY(-1px); }
.send-btn:disabled { opacity: .38; cursor: default; transform: none; }
.send-btn.stop { background: #f0f0f0; color: #111; }
.send-btn.stop .send-icon { display: none; }
.send-btn.stop::after { content: ""; width: 11px; height: 11px; border-radius: 2px; background: #111; }
.send-label { display: none; }
.send-icon { width: 18px; height: 18px; stroke-width: 2.15; }

.controls-row {
  min-height: 31px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 0;
}
.thinking-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 11.5px;
  user-select: none;
}
.thinking-toggle:hover { background: rgba(255,255,255,.045); color: var(--text-secondary); }
.thinking-toggle:has(input:checked) {
  border-color: hsl(207 100% 58% / 24%);
  background: hsl(207 100% 58% / 9%);
  color: hsl(207 100% 70%);
}
.thinking-toggle input { display: none; }
.thinking-spark { font-size: 12px; }
.edit-last-btn {
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 11px;
}
.edit-last-btn:hover { background: rgba(255,255,255,.045); color: var(--text-secondary); }
.composer-note {
  width: min(var(--content-width), 100%);
  margin: 7px auto 0;
  text-align: center;
  color: hsl(0 0% 45%);
  font-size: 10px;
  pointer-events: none;
}

.file-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 2px 6px; }
.file-chips:empty { display: none; }
.preview {
  position: relative;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border: 1px solid var(--border-l2);
  border-radius: 13px;
  background: var(--surface-l1);
}
.preview-thumb { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.preview-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  background: rgba(0,0,0,.68);
  color: white;
  cursor: pointer;
  font-size: 10px;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(5,5,5,.72);
  backdrop-filter: blur(10px);
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
.drop-message {
  padding: 24px 32px;
  border: 1px dashed var(--border-l3);
  border-radius: 20px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-elevated);
  color: var(--text);
  font-weight: 500;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0,0,0,.88);
  backdrop-filter: blur(10px);
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img,
.lightbox video { max-width: 95vw; max-height: 93vh; border-radius: 14px; box-shadow: var(--shadow-elevated); }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-l2);
  border-radius: 50%;
  background: rgba(30,29,28,.78);
  color: white;
  cursor: pointer;
  font-size: 18px;
}

@media (max-width: 760px) {
  :root { --content-width: 100%; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: 284px;
    max-width: 86vw;
    transform: translateX(-101%);
    transition: transform .2s cubic-bezier(.22,1,.36,1);
    box-shadow: 18px 0 50px rgba(0,0,0,.34);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    background: rgba(0,0,0,.58);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
  }
  .app.sidebar-open + .sidebar-backdrop,
  .app.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  .app.sidebar-open ~ .sidebar-backdrop { opacity: 1; visibility: visible; }
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 54px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-l1);
    background: hsl(30 5% 7% / 88%);
    backdrop-filter: blur(16px);
  }
  .mobile-brand { flex: 1; min-width: 0; text-align: center; }
  .mobile-title { font-size: 13px; font-weight: 550; }
  .chat-log {
    width: calc(100% - 24px);
    padding-top: 26px;
    padding-bottom: 205px;
    gap: 23px;
  }
  .empty-state { min-height: calc(100vh - 300px); padding-top: 10px; }
  .empty-title { font-size: 28px; }
  .examples { grid-template-columns: 1fr; max-width: 520px; }
  .examples .example.secondary:not(.expanded .example.secondary) { display: none; }
  .examples.expanded .example.secondary { display: flex; }
  .show-more { display: block; }
  .composer-wrap { padding: 14px 9px 8px; }
  .composer { border-radius: 22px; padding: 9px 8px 8px; }
  .composer-note { font-size: 9px; }
  .user .bubble { max-width: 88%; }
}

@media (min-width: 761px) {
  .show-more { display: none; }
}

@media (max-width: 420px) {
  .empty-hint { margin-bottom: 14px; }
  .example { min-height: 44px; }
  .chat-log { width: calc(100% - 18px); }
  .composer-note { display: none; }
  .composer-wrap { padding-bottom: 7px; }
}
