:root {
  color-scheme: dark;
  --bg: #000000;
  --sidebar: #090909;
  --surface: #171717;
  --surface-2: #212121;
  --surface-3: #2a2a2a;
  --hover: #181818;
  --text: #ececec;
  --text-strong: #ffffff;
  --muted: #9b9b9b;
  --muted-2: #666666;
  --line: rgba(255, 255, 255, 0.09);
  --sidebar-width: 260px;
  --content-width: 800px;
  --topbar-height: 52px;
  --composer-radius: 28px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000000;
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
  background: #000000;
}

.sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.035);
}

.sidebar-top {
  flex: 0 0 auto;
  padding: 10px 10px 6px;
}

.brand-row {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark,
.welcome-mark {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f4f4f4;
  color: #050505;
  font-weight: 700;
  user-select: none;
}

.brand-mark {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--hover);
  color: #eee;
}

#sidebar-close {
  margin-left: auto;
}

.new-chat-button,
.sidebar-bottom-button,
.conversation-item {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #e7e7e7;
  cursor: pointer;
  text-align: left;
}

.new-chat-button {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  margin-top: 2px;
  border-radius: 9px;
  font-size: 13px;
}

.new-chat-button:hover,
.sidebar-bottom-button:hover,
.conversation-item:hover,
.conversation-item.active {
  background: var(--hover);
}

.new-chat-icon {
  width: 18px;
  font-size: 17px;
  color: #cfcfcf;
}

.sidebar-label {
  flex: 0 0 auto;
  padding: 15px 18px 7px;
  color: #6f6f6f;
  font-size: 11px;
  font-weight: 500;
}

.conversation-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: #2d2d2d transparent;
}

.conversation-list::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.settings-body::-webkit-scrollbar {
  width: 5px;
}

.conversation-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.settings-body::-webkit-scrollbar-thumb {
  background: #2d2d2d;
  border-radius: 999px;
}

.conversation-item {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

.conversation-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-delete {
  width: 24px;
  height: 24px;
  display: none;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #777;
  cursor: pointer;
  font-size: 16px;
}

.conversation-item:hover .conversation-delete {
  display: grid;
}

.conversation-delete:hover {
  background: #272727;
  color: #ddd;
}

.sidebar-bottom {
  flex: 0 0 auto;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.035);
}

.sidebar-bottom-button {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 12px;
}

.sidebar-bottom-icon {
  width: 18px;
  color: #aaa;
}

.model-mini {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 10px 7px;
}

.model-mini-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9a9a9a;
}

.model-mini-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-mini-copy strong {
  color: #d6d6d6;
  font-size: 10px;
  font-weight: 600;
}

.model-mini-copy span {
  color: #646464;
  font-size: 9px;
}

.main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr) auto;
  overflow: hidden;
  background: #000000;
}

.topbar {
  min-width: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: #000000;
}

.topbar-left,
.topbar-right {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-selector {
  min-width: 0;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #eeeeee;
  cursor: default;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.model-selector:hover {
  background: #111111;
}

.chevron {
  color: #777;
  font-size: 13px;
}

.runtime-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8b8b8b;
}

.runtime-dot.ready {
  background: #bdbdbd;
}

.runtime-dot.busy {
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.runtime-dot.error {
  background: #ef6969;
}

.runtime-label {
  color: #777;
  font-size: 10px;
}

.chat-stage {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #000000;
}

.welcome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 120px;
  text-align: center;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.welcome.hidden {
  opacity: 0;
  visibility: hidden;
}

.welcome-mark {
  width: 38px;
  height: 38px;
  margin-bottom: 18px;
  font-size: 15px;
}

.welcome h1 {
  margin: 0;
  color: #f0f0f0;
  font-size: clamp(25px, 2.25vw, 31px);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.messages {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #2d2d2d transparent;
  padding: 22px max(18px, calc((100% - var(--content-width)) / 2)) 36px;
  scroll-behavior: smooth;
}

.message-row {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto 18px;
  display: flex;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message {
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.message.user {
  max-width: min(78%, 620px);
  padding: 10px 15px;
  border-radius: 18px;
  background: #252525;
  color: #f4f4f4;
  white-space: pre-wrap;
}

.message.assistant {
  width: 100%;
  padding: 3px 0 12px;
  background: transparent;
}

.message.assistant > :first-child {
  margin-top: 0;
}

.message.assistant > :last-child {
  margin-bottom: 0;
}

.message.assistant p {
  margin: 0.62em 0;
}

.message.assistant h1,
.message.assistant h2,
.message.assistant h3,
.message.assistant h4 {
  margin: 1.15em 0 0.48em;
  color: #f4f4f4;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.message.assistant h1 { font-size: 1.45em; }
.message.assistant h2 { font-size: 1.28em; }
.message.assistant h3 { font-size: 1.12em; }

.message.assistant ul,
.message.assistant ol {
  padding-left: 1.5em;
}

.message.assistant a {
  color: #ececec;
  text-decoration-color: #777;
  text-underline-offset: 3px;
}

.message.assistant blockquote {
  margin: 0.9em 0;
  padding-left: 1em;
  border-left: 2px solid #444;
  color: #bbb;
}

.message.assistant pre {
  position: relative;
  overflow-x: auto;
  margin: 1em 0;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d0d0d;
  color: #e8e8e8;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.message.assistant code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.message.assistant :not(pre) > code {
  padding: 0.14em 0.36em;
  border-radius: 5px;
  background: #171717;
  font-size: 0.92em;
}

.message.assistant table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 14px;
}

.message.assistant th,
.message.assistant td {
  padding: 8px 10px;
  border: 1px solid #303030;
  text-align: left;
}

.message-actions {
  display: flex;
  gap: 3px;
  margin-top: 5px;
}

.message-action {
  height: 28px;
  padding: 0 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #707070;
  cursor: pointer;
  font-size: 11px;
}

.message-action:hover {
  background: #141414;
  color: #cfcfcf;
}

.typing-cursor::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 16px;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 1px;
  background: #bdbdbd;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.composer-zone {
  min-width: 0;
  padding: 0 16px max(10px, env(safe-area-inset-bottom));
  background: #000000;
}

.composer {
  width: min(var(--content-width), 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 10px 10px 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--composer-radius);
  background: #212121;
  box-shadow: none;
}

.composer textarea {
  width: 100%;
  min-height: 28px;
  max-height: 180px;
  display: block;
  resize: none;
  overflow-y: auto;
  padding: 3px 2px 5px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f4f4f4;
  font-size: 15px;
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: #999;
  opacity: 1;
}

.composer-actions {
  min-height: 35px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.composer-actions-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer-icon-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #c7c7c7;
  cursor: pointer;
  font-size: 20px;
}

.composer-icon-button:hover {
  background: #2d2d2d;
}

.send-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f2f2f2;
  color: #080808;
  cursor: pointer;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}

.send-button:hover:not(:disabled) {
  background: #ffffff;
}

.send-button:disabled {
  cursor: default;
  background: #5f5f5f;
  color: #222;
}

.send-button.stop-mode {
  background: #eeeeee;
}

.send-button.stop-mode #send-icon {
  width: 11px;
  height: 11px;
  display: block;
  border-radius: 2px;
  background: #080808;
  color: transparent;
  font-size: 0;
}

.composer-caption {
  width: min(var(--content-width), 100%);
  min-height: 22px;
  margin: 4px auto 0;
  color: #5f5f5f;
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
}

.scrim,
.settings-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(2px);
}

.settings-scrim.open,
.scrim.open {
  display: block;
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(420px, 92vw);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(102%);
  transition: transform 180ms ease;
  border-left: 1px solid var(--line);
  background: #0b0b0b;
  box-shadow: -18px 0 60px rgba(0, 0, 0, 0.35);
}

.settings-panel.open {
  transform: translateX(0);
}

.settings-header {
  flex: 0 0 auto;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}

.settings-header h2 {
  margin: 0;
  color: #f1f1f1;
  font-size: 16px;
  font-weight: 600;
}

.settings-header p {
  margin: 3px 0 0;
  color: #6f6f6f;
  font-size: 10px;
}

.settings-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

.field {
  display: block;
  margin-bottom: 20px;
}

.field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 9px;
  color: #cfcfcf;
  font-size: 11px;
}

.field > span b {
  font-weight: 500;
}

.field output {
  color: #777;
  font-size: 10px;
}

.field input[type="range"] {
  width: 100%;
  accent-color: #d7d7d7;
}

.field textarea,
.field input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #151515;
  color: #eaeaea;
  outline: none;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
  padding: 10px 11px;
  font-size: 12px;
  line-height: 1.45;
}

.field input[type="number"] {
  height: 38px;
  padding: 0 10px;
}

.field small {
  display: block;
  margin-top: 5px;
  color: #666;
  font-size: 9px;
}

.runtime-card {
  margin-top: 24px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #111;
}

.runtime-card-title {
  color: #cfcfcf;
  font-size: 10px;
  font-weight: 600;
}

.runtime-card-copy {
  margin-top: 5px;
  color: #727272;
  font-size: 9px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.mobile-only {
  display: none;
}

@media (max-width: 760px) {
  :root {
    --content-width: 100%;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 45;
    width: min(280px, 86vw);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    border-right: 1px solid var(--line);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: grid;
  }

  .topbar {
    padding: 0 9px;
  }

  .runtime-label {
    display: none;
  }

  .messages {
    padding: 18px 13px 30px;
  }

  .message.user {
    max-width: 88%;
  }

  .composer-zone {
    padding: 0 9px max(8px, env(safe-area-inset-bottom));
  }

  .composer-caption {
    display: none;
  }
}

@media (max-height: 560px) {
  .welcome {
    justify-content: flex-start;
    padding-top: 14vh;
  }
}
