:root {
  color-scheme: light;
  --sidebar: #f9f9f9;
  --surface: #ffffff;
  --surface-soft: #f7f7f8;
  --surface-hover: #ececf1;
  --text: #171717;
  --muted: #6b7280;
  --muted-strong: #4b5563;
  --border: #e5e5e5;
  --border-strong: #d9d9e3;
  --accent: #111827;
  --danger: #b42318;
  --code: #0d1117;
  --shadow: 0 12px 38px rgba(0, 0, 0, 0.09);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
  padding: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 4px 8px;
}

.mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 650;
}

.brand p,
.hint,
.section-title,
.chat-header span,
.underbar,
.result-card span {
  color: var(--muted);
}

.brand p {
  margin-top: 2px;
  font-size: 12px;
}

.brand p.ok {
  color: #047857;
}

.brand p.bad {
  color: var(--danger);
}

.new-chat,
.prompt-link,
.ghost,
.text-button,
.suggestions button {
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
}

.new-chat {
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
}

.prompt-link {
  width: 100%;
  color: #303030;
}

.new-chat:hover,
.prompt-link:hover,
.ghost:hover,
.text-button:hover,
.suggestions button:hover {
  background: var(--surface-hover);
}

.side-section,
.advanced {
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--border);
  padding-top: 13px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #9ca3af;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.07);
}

.side-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.side-actions button,
.advanced > button {
  min-height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

.side-actions .ghost,
.chat-header .ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

.hint {
  font-size: 12px;
  line-height: 1.4;
}

.advanced summary {
  cursor: pointer;
  color: #303030;
  font-size: 13px;
  font-weight: 650;
}

.advanced[open] {
  padding-bottom: 8px;
}

.advanced[open] label {
  margin-top: 8px;
}

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

.check input {
  width: auto;
}

.dev-tools textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

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

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 10px 22px;
}

.chat-header div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.chat-header strong {
  font-size: 15px;
  font-weight: 650;
}

.chat-header span {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header .ghost {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 11px;
  font-size: 13px;
}

.messages {
  overflow: auto;
  padding: 36px 18px 24px;
}

.welcome {
  width: min(760px, 100%);
  margin: 13vh auto 0;
  text-align: center;
}

.welcome h2 {
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 600;
  letter-spacing: 0;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 30px;
}

.suggestions button {
  min-height: 58px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #303030;
  text-align: left;
  line-height: 1.35;
}

.message {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 19px 0;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 15px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 750;
}

.message.user .avatar {
  background: #ececf1;
  color: #202123;
}

.bubble {
  min-width: 0;
  color: #202123;
  line-height: 1.6;
  padding-top: 1px;
}

.bubble p + p {
  margin-top: 10px;
}

.assistant-note {
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.45;
}

.message.thinking .bubble {
  color: var(--muted);
}

.result-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  margin-top: 10px;
}

.result-card strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 650;
}

.result-card span {
  display: block;
  white-space: pre-line;
  font-size: 13px;
  line-height: 1.45;
}

.composer-wrap {
  padding: 16px 18px 22px;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: end;
  gap: 8px;
  width: min(760px, 100%);
  margin: 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  padding: 8px;
  box-shadow: var(--shadow);
}

.composer:focus-within {
  border-color: #b9bbc6;
}

.composer textarea {
  max-height: 180px;
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  box-shadow: none;
  padding: 9px 8px;
  resize: none;
  font-size: 15px;
}

.composer textarea:focus {
  box-shadow: none;
}

.composer button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}

.underbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(760px, 100%);
  margin: 8px auto 0;
  gap: 12px;
  font-size: 12px;
}

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

.text-button {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.raw-panel {
  width: min(760px, 100%);
  margin: 10px auto 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 10px;
}

.summary.empty {
  color: var(--muted);
  padding: 8px;
}

pre {
  max-height: 280px;
  overflow: auto;
  margin: 10px 0 0;
  border-radius: 8px;
  background: var(--code);
  color: #e5e7eb;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .chat {
    height: auto;
    min-height: 58vh;
  }

  .chat-header {
    padding: 10px 14px;
  }

  .messages {
    padding: 26px 14px 18px;
  }

  .welcome {
    margin-top: 5vh;
  }

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

  .composer-wrap {
    padding: 12px 12px 16px;
  }
}
