:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #617067;
  --line: #dce4df;
  --panel: #f7faf8;
  --surface: #ffffff;
  --accent: #0f7b63;
  --accent-strong: #095947;
  --warn: #b45f06;
  --shadow: 0 18px 48px rgba(23, 32, 27, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
textarea,
input {
  font: inherit;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px;
  background: #10251f;
  color: #f6fbf8;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: #6e8177;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #9db9ad;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.65rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.45rem;
}

.sidebar-top {
  display: grid;
  gap: 20px;
}

.secondary-button,
#sendBtn,
.icon-button,
.mode-option,
.new-chat-button,
.history-item {
  border: 0;
  cursor: pointer;
}

.new-chat-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #f6fbf8;
  font-weight: 800;
}

.new-chat-button:hover {
  background: #d8eee5;
  color: #10251f;
}

.history-panel {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.history-title {
  margin: 0 0 10px;
  color: #9db9ad;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.history-list {
  display: grid;
  align-content: start;
  gap: 6px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-right: 2px;
}

.history-item {
  display: grid;
  gap: 3px;
  min-height: 50px;
  border-radius: 8px;
  padding: 9px 10px;
  background: transparent;
  color: #f6fbf8;
  text-align: left;
}

.history-item:hover,
.history-item.is-active {
  background: rgba(216, 238, 229, 0.14);
}

.history-item strong,
.history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item strong {
  font-size: 0.92rem;
}

.history-item span {
  color: #9db9ad;
  font-size: 0.78rem;
}

.history-empty {
  margin: 0;
  color: #9db9ad;
  font-size: 0.9rem;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 18px;
  color: #d8eee5;
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warn);
}

.status-dot.ready {
  background: #42d392;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto;
  width: min(980px, 100%);
  padding: 8px 0 18px;
}

.secondary-button {
  min-width: 84px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.messages {
  width: min(980px, 100%);
  margin: 0 auto;
  overflow: auto;
  padding: 8px 0 24px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 52vh;
  color: var(--muted);
  text-align: center;
}

.message {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.bubble {
  width: fit-content;
  max-width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(23, 32, 27, 0.06);
  white-space: pre-wrap;
  line-height: 1.5;
}

.message.user {
  justify-items: end;
}

.message.user .bubble {
  background: #d8eee5;
  border-color: #b7dccf;
}

.message.assistant .bubble img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  margin-top: 10px;
}

.composer {
  position: relative;
  width: min(980px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: visible;
}

.image-tools {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  background: var(--surface);
  border-radius: 8px 8px 0 0;
}

.file-drop {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px dashed #99aaa1;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
  cursor: pointer;
}

.file-drop input {
  width: 1px;
  height: 1px;
  opacity: 0;
}

textarea {
  display: block;
  width: 100%;
  min-height: 92px;
  max-height: 260px;
  border: 0;
  resize: vertical;
  padding: 16px;
  color: var(--ink);
  outline: none;
  border-radius: 8px 8px 0 0;
}

.composer-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 10px 12px;
}

.tool-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
  color: var(--accent-strong);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.icon-button:hover,
.icon-button[aria-expanded="true"] {
  border-color: #b7dccf;
  background: #d8eee5;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid #d3e5de;
  border-radius: 999px;
  padding: 0 12px;
  background: #f2f8f5;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.mode-menu {
  position: absolute;
  left: 0;
  bottom: 54px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(520px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mode-menu[hidden] {
  display: none;
}

.mode-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 70px;
  border-radius: 8px;
  padding: 10px;
  background: #f7faf8;
  color: var(--ink);
  text-align: left;
}

.mode-option:hover,
.mode-option.is-active {
  background: #d8eee5;
  color: #10251f;
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #10251f;
  color: #f6fbf8;
  font-size: 0.84rem;
  font-weight: 900;
}

.mode-option strong,
.mode-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-option strong {
  font-size: 0.95rem;
}

.mode-option small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

#sendBtn {
  min-width: 92px;
  min-height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

#sendBtn:hover {
  background: var(--accent-strong);
}

#sendBtn:disabled {
  cursor: wait;
  opacity: 0.6;
}

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

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

  .sidebar {
    min-height: auto;
    padding: 18px;
  }

  .history-list {
    display: flex;
    max-height: none;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .history-item {
    min-width: 180px;
  }

  .status-panel {
    padding-top: 12px;
  }

  .workspace {
    padding: 16px;
  }

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

  .composer-actions {
    align-items: center;
  }

  .mode-menu {
    grid-template-columns: 1fr;
    width: calc(100vw - 64px);
  }
}
