:root {
  color-scheme: light;
  --bg: #f7f3ed;
  --panel: #fffaf3;
  --ink: #1f2933;
  --muted: #687282;
  --line: #dfd6c9;
  --accent: #0d746b;
  --accent-strong: #084f49;
  --assistant: #ffffff;
  --user: #e7f3f0;
  --danger: #a43e32;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
  overflow-y: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.fieldGroup {
  display: grid;
  gap: 8px;
}

.fieldLabel {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  resize: vertical;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 116, 107, 0.16);
}

.actions,
.composerBar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

button,
.fileButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.fileButton:hover {
  border-color: var(--accent);
}

.smallButton {
  min-height: 30px;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 12px;
}

#send {
  margin-left: auto;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

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

.fileButton input {
  display: none;
}

.status {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status.error {
  color: var(--danger);
}

.storageStatus {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.storageStatus.error {
  color: var(--danger);
}

.debugBox {
  margin: 0;
  border: 1px solid rgba(164, 62, 50, 0.28);
  border-radius: 8px;
  background: #fff4f1;
  color: var(--danger);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chatList {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.chatListItem {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 6px;
  align-items: stretch;
  width: 100%;
  min-height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0;
}

.chatOpenButton {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: auto;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  text-align: left;
}

.chatDeleteButton {
  align-self: center;
  justify-self: center;
  width: 24px;
  min-height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.chatOpenButton span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatOpenButton small,
.chatListEmpty {
  color: var(--muted);
  font-size: 12px;
}

.chatListItem.selected {
  border-color: rgba(13, 116, 107, 0.34);
  background: #e7f3f0;
}

.chatListItem:hover .chatDeleteButton,
.chatDeleteButton:hover {
  background: #fff4f1;
  color: var(--danger);
}

.chatListEmpty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
}

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

.dropOverlay {
  position: absolute;
  inset: 18px;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(231, 243, 240, 0.86);
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
}

.chat.draggingFile .dropOverlay {
  display: flex;
}

.chat.draggingFile .composer {
  box-shadow: inset 0 0 0 2px rgba(13, 116, 107, 0.28);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px min(6vw, 64px);
  min-height: 0;
  overflow-y: auto;
}

.empty {
  margin: auto;
  max-width: 520px;
  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}

.message {
  display: grid;
  grid-template-columns: 84px minmax(0, 760px);
  gap: 14px;
  align-items: start;
}

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

.role {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding-top: 12px;
  text-align: right;
}

.bubble {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--assistant);
  padding: 14px 16px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.messageContent {
  min-width: 0;
}

.message.user .messageContent,
.assistantText {
  white-space: pre-wrap;
}

.assistantText:empty {
  display: none;
}

.copyableBlock {
  margin: 12px 0;
  border: 1px solid #d9d6d0;
  border-radius: 8px;
  overflow: hidden;
  background: #f7f6f3;
}

.copyableBlock:first-child {
  margin-top: 0;
}

.copyableBlock:last-child {
  margin-bottom: 0;
}

.copyableBlockHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 5px 8px 5px 14px;
  border-bottom: 1px solid #dfddd8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #eeece7;
}

.blockCopyButton {
  flex: 0 0 auto;
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
  background: #fff;
}

.blockCopyButton:hover {
  border-color: #b9d5d1;
  color: var(--accent-strong);
  background: #e7f3f0;
}

.copyableBlockContent {
  margin: 0;
  padding: 14px;
  max-height: 520px;
  overflow: auto;
  color: var(--ink);
  font: inherit;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.messageActions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.editButton {
  min-height: 28px;
  border-radius: 6px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
}

.editButton:hover {
  color: var(--accent-strong);
  background: #fff;
}

.stopButton {
  border-color: rgba(164, 62, 50, 0.4);
  color: var(--danger);
}

.stopButton:hover {
  background: #fff4f1;
}

.message.error .bubble {
  border-color: rgba(164, 62, 50, 0.4);
  background: #fff4f1;
  color: var(--danger);
}

.bubble img {
  display: block;
  max-width: 280px;
  max-height: 220px;
  margin: 0 0 10px;
  border-radius: 8px;
  object-fit: cover;
}

.composer {
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 243, 0.94);
  padding: 16px min(6vw, 64px);
}

.composer textarea {
  min-height: 86px;
  max-height: 220px;
  margin-bottom: 12px;
}

.promptWrap {
  position: relative;
}

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

.attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
}

.attachment.muted {
  color: #87909d;
}

.attachment button {
  min-height: 24px;
  width: 24px;
  border-radius: 50%;
  padding: 0;
}

.attachments.compact {
  margin-bottom: 0;
}

.activeSkills {
  margin-bottom: 10px;
}

.activeSkill {
  border-color: rgba(13, 116, 107, 0.3);
  background: #e7f3f0;
  color: var(--accent-strong);
  font-weight: 800;
}

.slashMenu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 10;
  width: min(420px, 100%);
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(31, 41, 51, 0.16);
  padding: 6px;
}

.slashItem {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: auto;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 9px 10px;
  text-align: left;
}

.slashItem strong {
  color: var(--ink);
  font-size: 14px;
}

.slashItem span,
.slashEmpty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.slashItem.selected,
.slashItem:hover {
  background: #e7f3f0;
}

.slashEmpty {
  padding: 10px;
}

.fileBadge {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
    overflow: visible;
  }

  .chat {
    height: auto;
    min-height: 70vh;
    overflow: visible;
  }

  .message {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .role {
    text-align: left;
    padding-top: 0;
  }
}
