:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #171d1a;
  --muted: #69756f;
  --line: #dadfd9;
  --accent: #111816;
  --green: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell:has(.process-panel.open) {
  grid-template-columns: 290px minmax(0, 1fr) 360px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand div:last-child {
  display: grid;
  gap: 2px;
}

.brand span,
.side-label,
.sidebar p,
.source-button small,
.topbar p,
.meta {
  color: var(--muted);
}

.new-chat,
.source-button,
.ghost-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
}

.new-chat {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 700;
}

.side-group {
  display: grid;
  gap: 8px;
}

.side-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.source-button {
  height: auto;
  min-height: 58px;
  display: grid;
  gap: 3px;
  text-align: left;
}

.source-button.active {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

code {
  overflow-wrap: anywhere;
}

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

.topbar {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.ghost-button.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.messages {
  width: min(860px, calc(100% - 32px));
  justify-self: center;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  padding: 48px 0 22px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-top: min(18vh, 150px);
  text-align: center;
}

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

.empty-state p {
  max-width: 640px;
  color: var(--muted);
}

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

.suggestions button {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 18px 0;
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.message.user .avatar {
  background: var(--green);
}

.speaker {
  margin: 5px 0 8px;
  font-weight: 700;
}

.bubble {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

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

.message.error .bubble {
  color: #991b1b;
}

.meta {
  margin-top: 10px;
  font-size: 12px;
}

.composer {
  width: min(860px, calc(100% - 32px));
  justify-self: center;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 76px;
  gap: 8px;
  align-items: end;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 8px;
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.09);
}

.composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 170px;
  resize: none;
  border: 0;
  outline: none;
  padding: 13px 2px;
  color: var(--ink);
}

.icon-button,
.send-button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
}

.icon-button {
  background: #eef2ed;
  color: var(--ink);
}

.icon-button.recording {
  background: #991b1b;
  color: white;
}

.send-button {
  background: var(--accent);
  color: white;
}

.process-panel {
  min-width: 0;
  display: none;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
}

.process-panel.open {
  display: block;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.flow-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

.flow-card p {
  color: var(--muted);
  margin-top: 5px;
}

@media (max-width: 900px) {
  .app-shell,
  .app-shell:has(.process-panel.open) {
    grid-template-columns: 1fr;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .process-panel.open {
    position: fixed;
    inset: auto 0 0;
    max-height: 70vh;
    z-index: 20;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
