:root {
  --bg: #faf9f5;
  --bg-elevated: #fffdf9;
  --sidebar: #f0eee7;
  --sidebar-hover: #e8e4da;
  --bubble: #f0eee7;
  --text: #262521;
  --text-soft: #5f5b52;
  --muted: #8a857a;
  --line: #e4e0d5;
  --line-strong: #d6d0c2;
  --accent: #c96442;
  --accent-dark: #a94f32;
  --accent-soft: #f6e8e0;
  --green: #2f7d5b;
  --red: #b44335;
  --shadow: 0 12px 40px rgba(49, 43, 32, 0.11);
  --shadow-soft: 0 1px 2px rgba(49, 43, 32, 0.06);
  --radius: 16px;
  --font-ui: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Noto Sans SC",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia,
    "Songti SC", "Noto Serif SC", serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Consolas,
    "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

svg {
  display: block;
}

.brand-mark {
  display: inline-flex;
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 18% 18%, rgba(201, 100, 66, 0.09), transparent 34%),
    radial-gradient(circle at 82% 76%, rgba(116, 128, 94, 0.08), transparent 30%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 253, 249, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
}

.login-brand .brand-mark {
  width: 30px;
  height: 30px;
}

.login-wordmark {
  font-family: var(--font-serif);
  font-size: 24px;
  letter-spacing: -0.02em;
}

.login-card h1 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 31px;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.login-sub {
  margin: 0 0 30px;
  color: var(--text-soft);
  line-height: 1.6;
}

.field-label {
  display: block;
  margin: 18px 0 8px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.password-row {
  display: flex;
  gap: 10px;
}

.password-row .text-input {
  flex: 1;
}

.text-input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  background: var(--bg-elevated);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

textarea.text-input {
  height: auto;
  padding: 10px 13px;
  resize: vertical;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.12);
}

.btn {
  height: 44px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  color: #fffaf5;
  box-shadow: 0 4px 12px rgba(201, 100, 66, 0.18);
}

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

.btn.ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--text-soft);
}

.btn.ghost:hover {
  background: var(--sidebar);
}

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

.danger-text {
  color: var(--red);
}

.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #e8c4bd;
  border-radius: 10px;
  background: #fbefec;
  color: #8d3124;
  font-size: 13px;
  line-height: 1.5;
}

.login-foot {
  margin-top: 24px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  width: 264px;
  flex: 0 0 264px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.sidebar-top {
  padding: 20px 14px 12px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px 18px;
}

.brand-row .brand-mark {
  width: 21px;
  height: 21px;
}

.wordmark {
  font-family: var(--font-serif);
  font-size: 21px;
  letter-spacing: -0.02em;
}

.new-chat {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 253, 249, 0.72);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease;
}

.new-chat:hover {
  background: var(--bg-elevated);
  border-color: #c9c2b2;
}

.new-chat svg {
  width: 16px;
  height: 16px;
}

.new-chat kbd {
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--sidebar);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 9px 10px 20px;
}

.nav-label {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
}

.conv-item:hover,
.conv-item.active {
  background: var(--sidebar-hover);
  color: var(--text);
}

.conv-item .conv-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  color: var(--muted);
}

.conv-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.conv-delete {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
}

.conv-item:hover .conv-delete,
.conv-item.active .conv-delete {
  opacity: 1;
}

.conv-delete:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--red);
}

.conv-delete svg {
  width: 13px;
  height: 13px;
}

.empty-conversations {
  padding: 12px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.sidebar-bottom {
  padding: 10px 10px 14px;
  border-top: 1px solid var(--line);
}

.sidebar-item {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
}

.sidebar-item:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.sidebar-item svg {
  width: 16px;
  height: 16px;
}

.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px;
}

.avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
}

.account-avatar {
  width: 30px;
  height: 30px;
  background: var(--accent);
  color: #fff8f1;
  font-size: 12px;
}

.account-meta {
  line-height: 1.25;
}

.account-name {
  font-size: 12px;
  font-weight: 600;
}

.account-plan {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

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

.topbar {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid transparent;
  background: rgba(250, 249, 245, 0.86);
  backdrop-filter: blur(10px);
  z-index: 4;
}

.topbar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-serif);
  font-size: 16px;
  letter-spacing: -0.015em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
}

.icon-btn:hover {
  background: var(--sidebar);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.menu-btn {
  display: none;
}

.sandbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.7);
  color: var(--text-soft);
  font-size: 11px;
}

.sandbox-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6c9b7c;
  box-shadow: 0 0 0 3px rgba(108, 155, 124, 0.12);
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.messages,
.empty-state {
  width: min(760px, calc(100% - 40px));
  margin: 0 auto;
}

.empty-state {
  min-height: calc(100vh - 240px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0 40px;
  text-align: center;
}

.empty-mark {
  width: 44px;
  height: 44px;
  margin-bottom: 22px;
  color: var(--accent);
}

.empty-mark svg {
  width: 100%;
  height: 100%;
}

.empty-state h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(32px, 4.2vw, 45px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.empty-state > p {
  max-width: 520px;
  margin: 15px 0 30px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  width: min(520px, 100%);
}

.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 53px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 249, 0.64);
  color: var(--text-soft);
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.suggestion:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text);
}

.suggestion svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--accent);
}

.empty-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 30px;
  color: var(--muted);
  font-size: 11px;
}

.empty-note svg {
  width: 14px;
  height: 14px;
}

.messages {
  padding: 28px 0 10px;
}

.message {
  display: flex;
  gap: 14px;
  margin-bottom: 28px;
  animation: message-in 220ms ease both;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.assistant-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  margin-top: 2px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff8f1;
}

.assistant-avatar svg {
  width: 16px;
  height: 16px;
}

.message-body {
  min-width: 0;
  flex: 1;
}

.user-bubble {
  max-width: 86%;
  padding: 12px 16px;
  border: 1px solid #e9e5da;
  border-radius: 17px 17px 4px 17px;
  background: var(--bubble);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.user-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.user-bubble .files-grid,
.user-bubble .file-card {
  white-space: normal;
}

.assistant-content {
  color: var(--text);
  font-size: 14px;
  line-height: 1.72;
  word-break: break-word;
}

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

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

.assistant-content p {
  margin: 0 0 12px;
}

.assistant-content h1,
.assistant-content h2,
.assistant-content h3 {
  margin: 24px 0 10px;
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.assistant-content h1 {
  font-size: 24px;
}

.assistant-content h2 {
  font-size: 20px;
}

.assistant-content h3 {
  font-size: 17px;
}

.assistant-content ul,
.assistant-content ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.assistant-content li {
  margin: 4px 0;
}

.assistant-content blockquote {
  margin: 14px 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--line-strong);
  color: var(--text-soft);
}

.assistant-content a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.assistant-content code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #efebe2;
  font-family: var(--font-mono);
  font-size: 0.88em;
}

.assistant-content table {
  width: 100%;
  margin: 14px 0;
  border-collapse: collapse;
  font-size: 13px;
}

.assistant-content th,
.assistant-content td {
  padding: 7px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.assistant-content th {
  background: var(--sidebar);
  font-weight: 600;
}

.code-block {
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid #37352f;
  border-radius: 11px;
  background: #282723;
  color: #f1eee6;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 11px;
  border-bottom: 1px solid #3c3a34;
  color: #aba69a;
  font-size: 11px;
}

.copy-code {
  border: 0;
  background: transparent;
  color: #c9c4b8;
  font-size: 11px;
}

.copy-code:hover {
  color: #fff;
}

.code-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.code-block code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.tool-panel {
  margin: 4px 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 249, 0.6);
  overflow: hidden;
}

.tool-panel summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  list-style: none;
}

.tool-panel summary::-webkit-details-marker {
  display: none;
}

.tool-panel summary svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.tool-panel summary .chevron {
  margin-left: auto;
  transition: transform 150ms ease;
}

.tool-panel[open] summary .chevron {
  transform: rotate(180deg);
}

.tool-list {
  padding: 0 10px 10px;
}

.tool-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 4px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.tool-status {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.tool-status.running {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.tool-status.ok {
  background: var(--green);
}

.tool-status.error {
  background: var(--red);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.tool-name {
  font-family: var(--font-mono);
  color: var(--text);
}

.tool-summary {
  color: var(--muted);
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.2s infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 9px;
  margin-top: 14px;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
}

.file-card.upload {
  min-height: 54px;
  background: rgba(255, 253, 249, 0.78);
}

.file-thumb {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 9px;
  background: var(--sidebar);
  color: var(--accent);
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumb svg {
  width: 20px;
  height: 20px;
}

.file-meta {
  min-width: 0;
  flex: 1;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.file-size {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.file-actions {
  display: flex;
  gap: 4px;
}

.file-action {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
}

.file-action:hover {
  background: var(--sidebar);
  color: var(--text);
}

.file-action svg {
  width: 14px;
  height: 14px;
}

.composer-wrap {
  flex: 0 0 auto;
  width: min(800px, calc(100% - 40px));
  margin: 0 auto;
  padding: 10px 0 14px;
  background: linear-gradient(to bottom, rgba(250, 249, 245, 0), var(--bg) 22%);
}

.upload-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 12px 8px;
}

.upload-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 270px;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elevated);
  font-size: 11px;
}

.upload-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-chip button {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.upload-chip button:hover {
  background: var(--sidebar);
  color: var(--red);
}

.upload-chip svg {
  width: 10px;
  height: 10px;
}

.composer {
  padding: 10px 10px 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--bg-elevated);
  box-shadow: 0 3px 14px rgba(49, 43, 32, 0.07);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.composer:focus-within {
  border-color: #bfb6a5;
  box-shadow: 0 4px 20px rgba(49, 43, 32, 0.1);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 190px;
  padding: 3px 3px 8px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: #aaa397;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.tool-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
}

.tool-btn:hover {
  background: var(--sidebar);
  color: var(--text);
}

.tool-btn svg {
  width: 17px;
  height: 17px;
}

.composer-hint {
  color: #aaa397;
  font-size: 10px;
}

.send-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff8f1;
  transition: background 140ms ease, opacity 140ms ease;
}

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

.send-btn:disabled {
  cursor: default;
  background: #d9d4c8;
  color: #f7f4ee;
}

.send-btn svg {
  width: 16px;
  height: 16px;
}

.send-btn.stop svg {
  width: 12px;
  height: 12px;
}

.disclaimer {
  margin-top: 8px;
  color: #a39c90;
  font-size: 10px;
  text-align: center;
}

.sidebar-backdrop {
  display: none;
}

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(38, 37, 33, 0.28);
  backdrop-filter: blur(3px);
}

.drag-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: min(360px, calc(100% - 40px));
  padding: 34px;
  border: 1px dashed rgba(201, 100, 66, 0.55);
  border-radius: 20px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  text-align: center;
}

.drag-card svg {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.drag-card span {
  color: var(--muted);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(38, 37, 33, 0.35);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: min(600px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.03em;
}

.modal-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.settings-section-title {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.inline-field {
  display: flex;
  gap: 8px;
}

.inline-field .text-input {
  flex: 1;
}

.field-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.info-grid > div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.info-grid span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
}

.info-grid strong {
  font-size: 12px;
  font-weight: 600;
}

.settings-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.modal-actions .spacer {
  flex: 1;
}

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.5;
  animation: toast-in 180ms ease both;
}

.toast.error {
  border-color: #e6c4bd;
  color: #8d3124;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.skeleton {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #ece8de, #f6f3ec, #ece8de);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    transform: translateX(-102%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    background: rgba(38, 37, 33, 0.28);
  }

  .menu-btn {
    display: grid;
  }

  .topbar {
    padding: 0 12px;
  }

  .sandbox-pill span:last-child {
    display: none;
  }

  .sandbox-pill {
    width: 26px;
    justify-content: center;
    padding: 0;
  }

  .messages,
  .empty-state,
  .composer-wrap {
    width: calc(100% - 28px);
  }

  .empty-state {
    min-height: calc(100vh - 220px);
    padding-top: 40px;
  }

  .empty-state h1 {
    font-size: 34px;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .suggestion {
    min-height: 48px;
  }

  .user-bubble {
    max-width: 92%;
  }

  .composer-hint {
    display: none;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    max-height: calc(100vh - 24px);
    padding: 20px;
  }
}

@media (max-width: 520px) {
  .login-card {
    padding: 28px;
  }

  .empty-state h1 {
    font-size: 30px;
  }

  .message {
    gap: 10px;
  }

  .assistant-avatar {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .files-grid {
    grid-template-columns: 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}
