:root {
  color-scheme: dark;
  --black: #000000;
  --panel: #080808;
  --panel-soft: #101010;
  --panel-raised: #151515;
  --line: #262626;
  --line-strong: #3a3a3a;
  --text: #f5f5f5;
  --muted: #9b9b9b;
  --dim: #6f6f6f;
  --accent: #57d17f;
  --error: #ff6b6b;
  --radius: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  background: var(--black);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell,
.login-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--black);
}

.sidebar {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #0b0b0b 0%, #070707 100%);
  padding: 25px 14px 16px;
}

.sidebar-header {
  padding: 0 10px;
}

.brand {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  color: var(--text);
  font-size: 21px;
  font-weight: 780;
  line-height: 1;
}

.sidebar-kicker {
  margin: 7px 0 0;
  color: var(--dim);
  font-size: 12px;
  font-weight: 620;
}

.account-strip {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 8px;
  padding: 12px 10px;
  color: var(--muted);
}

.account-strip strong,
.thread-item span:last-child {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-strip span:last-child {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(87, 209, 127, 0.65);
}

.new-chat-button,
.ghost-button,
.send-button,
.login-button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 680;
}

.new-chat-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.new-chat-button:hover,
.ghost-button:hover,
.send-button:hover,
.login-button:hover {
  border-color: #555555;
  background: var(--panel-raised);
}

.new-chat-button span:first-child {
  font-size: 20px;
  font-weight: 420;
  line-height: 1;
}

.thread-list {
  display: grid;
  gap: 8px;
}

.thread-item {
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  text-align: left;
}

.thread-item span:first-child {
  width: 13px;
  height: 13px;
  border: 1px solid var(--muted);
  border-radius: 4px;
}

.thread-item.is-active {
  border-color: #191919;
  background: #111111;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 0 4px;
}

.mode-switch button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.mode-switch button.is-active {
  border-color: var(--line-strong);
  background: var(--panel-raised);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
}

.ghost-button {
  width: 100%;
}

.chat-screen,
.login-screen {
  position: relative;
  min-width: 0;
  min-height: 100vh;
  background: var(--black);
}

.main-surface {
  min-width: 0;
  min-height: 100vh;
  background: var(--black);
}

.chat-screen {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 100vh;
}

.is-hidden {
  display: none !important;
}

.message-stream {
  display: flex;
  min-height: 0;
  flex-direction: column;
  justify-content: flex-end;
  gap: 26px;
  overflow-y: auto;
  padding: 9vh min(10vw, 140px) 26px;
}

.message {
  width: min(720px, 100%);
  color: var(--text);
}

.message.is-user {
  align-self: flex-start;
}

.message.is-assistant {
  align-self: flex-start;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--dim);
  font-size: 12px;
}

.message-meta strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
}

.message-body {
  color: #dedede;
  font-size: 15px;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.is-user .message-body {
  color: #f1f1f1;
}

.message.is-pending .message-body {
  color: var(--dim);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 10px;
  width: min(940px, calc(100% - 60px));
  margin: 0 auto 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.92);
  padding: 8px;
}

.composer textarea,
.login-form input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
}

.composer textarea {
  min-height: 40px;
  max-height: 180px;
  resize: none;
  padding: 10px 8px;
  color: #eeeeee;
  line-height: 1.4;
}

.composer textarea::placeholder,
.login-form input::placeholder {
  color: var(--dim);
}

.send-button {
  min-height: 40px;
  background: var(--panel-raised);
}

.vfs-screen {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--black);
}

.vfs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line-strong);
  padding: 0 22px;
}

.vfs-topbar strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
  line-height: 1.25;
}

.vfs-topbar span {
  display: block;
  margin-top: 3px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 620;
}

.vfs-actions,
.vfs-commit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vfs-actions button,
.vfs-commit button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 720;
}

.vfs-actions button:hover,
.vfs-commit button:hover {
  border-color: #555555;
  background: var(--panel-raised);
}

.vfs-workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 0;
}

.vfs-files {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line-strong);
  background: #050505;
  padding: 12px;
}

.vfs-file-list {
  display: grid;
  gap: 6px;
}

.vfs-file {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 9px;
  text-align: left;
}

.vfs-file:hover,
.vfs-file.is-active {
  border-color: var(--line);
  background: #111111;
}

.vfs-file span {
  color: var(--dim);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.vfs-file strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vfs-file.is-dirty span {
  color: var(--accent);
}

.vfs-file.is-deleted span,
.vfs-log[data-tone="error"] {
  color: var(--error);
}

.vfs-empty {
  margin: 8px;
  color: var(--dim);
  font-size: 12px;
}

.vfs-editor {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
}

.vfs-editor-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
}

.vfs-editor-bar input,
.vfs-commit input,
.vfs-editor textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #050505;
  color: var(--text);
}

.vfs-editor-bar input,
.vfs-commit input {
  min-height: 36px;
  padding: 0 11px;
  font-size: 13px;
}

.vfs-editor-bar span {
  overflow: hidden;
  color: var(--dim);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vfs-editor textarea {
  min-height: 0;
  resize: none;
  border-width: 0 0 1px;
  border-radius: 0;
  padding: 18px;
  color: #e8e8e8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.58;
  tab-size: 2;
}

.vfs-commit {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.vfs-commit input {
  flex: 1;
}

.vfs-log {
  min-height: 42px;
  max-height: 92px;
  overflow: auto;
  margin: 0;
  padding: 10px 12px;
  color: var(--dim);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.login-sidebar {
  gap: 34px;
}

.login-form {
  display: grid;
  gap: 12px;
  padding: 0 10px;
}

.login-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.form-note {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.login-form input {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 12px;
}

.login-button {
  width: 100%;
  background: var(--text);
  color: var(--black);
}

.login-button:hover {
  background: #dcdcdc;
  color: var(--black);
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--error);
  font-size: 12px;
}

.login-screen {
  display: flex;
  align-items: flex-end;
  padding: 0 min(10vw, 140px) 58px;
}

.login-mark {
  width: min(520px, 100%);
  color: #141414;
  font-size: clamp(54px, 10vw, 140px);
  font-weight: 800;
  line-height: 0.9;
  user-select: none;
}

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

@media (max-width: 760px) {
  .app-shell,
  .login-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
    padding: 18px 14px 14px;
  }

  .sidebar-footer {
    margin-top: 0;
  }

  .chat-screen,
  .main-surface,
  .vfs-screen,
  .login-screen {
    min-height: calc(100vh - 240px);
  }

  .message-stream {
    padding: 42px 18px 22px;
  }

  .composer {
    grid-template-columns: 1fr;
    width: calc(100% - 28px);
    margin-bottom: 14px;
  }

  .send-button {
    width: 100%;
  }

  .vfs-screen {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .vfs-topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .vfs-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .vfs-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(120px, 28vh) minmax(0, 1fr);
  }

  .vfs-files {
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .vfs-editor-bar,
  .vfs-commit {
    grid-template-columns: 1fr;
  }

  .vfs-commit {
    display: grid;
  }

  .login-screen {
    align-items: flex-end;
    padding: 28px 18px;
  }
}
