:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e6e6e2;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --user: #eef3ff;
  --assistant: #ffffff;
  --danger: #b42318;
  font-family:
    'Segoe UI',
    -apple-system,
    BlinkMacSystemFont,
    'Apple SD Gothic Neo',
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

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

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(145deg, #2563eb, #0f172a);
}

.brand strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.brand p {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

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

.desktop-badge {
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.desktop-badge.online {
  background: #ecfdf3;
  border-color: #abefc6;
  color: #067647;
}

.desktop-badge.offline {
  background: #fef3f2;
  border-color: #fecdca;
  color: #b42318;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.45;
  background: var(--assistant);
}

.bubble.user {
  background: var(--user);
  border-color: #dbe4ff;
  align-self: flex-end;
}

.bubble.system {
  background: #f3f4f6;
  color: var(--muted);
  font-size: 12px;
}

.composer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selection-chip {
  align-self: flex-start;
  max-width: 100%;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #175cd3;
  background: #eff8ff;
  border: 1px solid #b2ddff;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selection-chip.empty {
  color: var(--muted);
  background: #f9fafb;
  border-color: var(--line);
  font-weight: 500;
}

.selection-chip.error {
  color: var(--danger);
  background: #fef3f2;
  border-color: #fecdca;
}

#prompt {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  max-height: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  font-size: 13px;
  background: #fff;
}

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

.composer-row select {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  background: #fff;
  font-size: 12px;
}

#prompt.busy {
  opacity: 0.65;
  cursor: wait;
}

button {
  font: inherit;
}

button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.status {
  margin: 0;
  min-height: 16px;
  font-size: 11px;
  color: var(--muted);
}

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

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 12px;
}

.cite {
  display: inline;
  margin: 0 1px;
  padding: 0 4px;
  border: none;
  border-radius: 4px;
  background: #eff8ff;
  color: #175cd3;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cite:hover {
  background: #d1e9ff;
}

.confirm-bar {
  border: 1px solid #b2ddff;
  background: #f5faff;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.confirm-warning {
  margin: 0;
  font-size: 12px;
  color: #b54708;
  background: #fffaeb;
  border: 1px solid #fedf89;
  border-radius: 8px;
  padding: 8px 10px;
}

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

.confirm-yes,
.confirm-no {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.confirm-yes {
  border: none;
  background: var(--accent);
  color: #fff;
}

.confirm-no {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.confirm-yes:hover {
  filter: brightness(0.95);
}

.confirm-no:hover {
  background: #f9fafb;
}

.attach-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attach-tray[hidden],
.drop-overlay[hidden] {
  display: none;
}

.attach-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 4px 3px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  font-size: 11px;
}

.attach-chip img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 5px;
}

.attach-chip .attach-kind {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: #fef3f2;
  color: var(--danger);
  font-size: 9px;
  font-weight: 700;
}

.attach-chip .attach-name {
  min-width: 0;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip.busy {
  opacity: 0.6;
}

.attach-chip button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}

.drop-overlay {
  position: fixed;
  inset: 8px;
  z-index: 50;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: rgba(239, 246, 255, 0.92);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

#btnAttach {
  flex: none;
  height: 34px;
}
