:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101114;
  color: #f4f4f5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #101114; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 280px; padding: 22px 16px; background: #18191d; border-right: 1px solid #2a2c32; display: flex; flex-direction: column; gap: 18px; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.new-chat { width: 100%; padding: 11px 14px; color: #fff; background: #2563eb; border: 0; border-radius: 9px; text-align: left; }
.new-chat:hover { background: #1d4ed8; }
.credential-card { display: flex; flex-direction: column; gap: 7px; padding: 12px; border: 1px solid #2f323a; border-radius: 10px; background: #202229; }
.credential-card label { color: #e4e4e7; font-size: 13px; font-weight: 600; }
.credential-card input { width: 100%; padding: 8px 9px; border: 1px solid #3a3d45; border-radius: 7px; color: #f4f4f5; background: #15161a; outline: none; }
.credential-card input:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px #7c3aed33; }
.credential-card span { color: #8b8b95; font-size: 11px; line-height: 1.45; }
.upload-card { display: flex; flex-direction: column; gap: 9px; padding: 12px; border: 1px solid #2f323a; border-radius: 10px; background: #202229; }
.upload-card label { color: #e4e4e7; font-size: 13px; font-weight: 600; }
.upload-card input { width: 100%; color: #a1a1aa; font-size: 12px; }
.upload-card button { padding: 8px 10px; color: #fff; background: #374151; border: 0; border-radius: 7px; }
.upload-card button:hover { background: #4b5563; }
.upload-card button:disabled { opacity: .5; cursor: wait; }
.upload-state { min-height: 16px; color: #86efac; font-size: 11px; line-height: 1.4; }
.conversation-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.conversation-item { padding: 10px 12px; border: 0; border-radius: 8px; color: #d4d4d8; background: transparent; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item:hover, .conversation-item.active { background: #272a33; color: #fff; }
.sidebar-foot { margin-top: auto; color: #71717a; font-size: 12px; }

.chat-panel { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 6vw; border-bottom: 1px solid #2a2c32; }
.chat-header h1 { margin: 0 0 6px; font-size: 20px; }
.connection-state { color: #86efac; font-size: 12px; }
.workspace-tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid #30323a; border-radius: 10px; background: #18191d; }
.workspace-tab { padding: 8px 12px; border: 0; border-radius: 7px; color: #a1a1aa; background: transparent; }
.workspace-tab:hover { color: #fff; }
.workspace-tab.active { color: #fff; background: #3730a3; }
.workspace-tab:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }
.workspace { flex: 1; min-height: 0; }
.chat-workspace { display: flex; flex-direction: column; }
.messages { flex: 1; min-height: 0; overflow-y: auto; width: min(900px, 92%); margin: 0 auto; padding: 30px 0 120px; }
.empty-state { margin-top: 20vh; text-align: center; color: #a1a1aa; }
.message { display: flex; gap: 14px; margin: 20px 0; line-height: 1.7; }
.message.user { justify-content: flex-end; }
.message-bubble { max-width: min(760px, 88%); padding: 13px 16px; border-radius: 14px; white-space: pre-wrap; }
.message.assistant .message-bubble { background: #1f2229; }
.message.user .message-bubble { background: #2563eb; }
.speak-button { align-self: flex-end; padding: 5px 7px; border: 1px solid #3a3d45; border-radius: 7px; color: #a1a1aa; background: transparent; font-size: 13px; }
.speak-button:hover { color: #fff; background: #2a2c32; }
.message.assistant .message-bubble p { margin: 0 0 14px; }
.message.assistant .message-bubble p:last-child { margin-bottom: 0; }
.message.assistant .message-bubble h1,
.message.assistant .message-bubble h2,
.message.assistant .message-bubble h3 { margin: 18px 0 8px; line-height: 1.35; }
.message.assistant .message-bubble h1 { font-size: 1.35em; }
.message.assistant .message-bubble h2 { font-size: 1.2em; }
.message.assistant .message-bubble h3 { font-size: 1.08em; }
.message.assistant .message-bubble ul,
.message.assistant .message-bubble ol { margin: 8px 0 14px; padding-left: 24px; }
.message.assistant .message-bubble li { margin: 5px 0; }
.message.assistant .message-bubble code { padding: 2px 5px; border-radius: 5px; background: #101114; color: #c4b5fd; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.message.assistant .message-bubble pre { overflow-x: auto; padding: 12px; border-radius: 8px; background: #101114; }
.message.assistant .message-bubble pre code { padding: 0; background: transparent; color: #e4e4e7; }
.message.assistant .message-bubble hr { border: 0; border-top: 1px solid #3a3d45; margin: 16px 0; }
.composer { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); width: min(820px, 82%); display: flex; gap: 10px; padding: 10px; background: #1b1d22; border: 1px solid #3a3d45; border-radius: 14px; box-shadow: 0 12px 40px #0008; }
.composer textarea { flex: 1; resize: none; max-height: 140px; padding: 10px; color: #fff; background: transparent; border: 0; outline: 0; }
.composer button { align-self: flex-end; padding: 10px 18px; color: #fff; background: #2563eb; border: 0; border-radius: 9px; }
.composer button:disabled { opacity: .5; cursor: wait; }

.agent-workspace { overflow: hidden; }
.agent-scroll { height: 100%; overflow-y: auto; width: min(900px, 92%); margin: 0 auto; padding: 40px 0 64px; }
.agent-intro { margin-bottom: 24px; }
.agent-intro .eyebrow { display: inline-block; margin-bottom: 9px; color: #c4b5fd; font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.agent-intro h2 { margin: 0 0 10px; font-size: clamp(24px, 3vw, 34px); }
.agent-intro p { max-width: 680px; margin: 0; color: #a1a1aa; line-height: 1.7; }
.agent-form { display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid #30323a; border-radius: 14px; background: #1b1d22; }
.agent-form label { font-weight: 650; }
.agent-form textarea { width: 100%; resize: vertical; min-height: 112px; padding: 12px 14px; border: 1px solid #3a3d45; border-radius: 10px; color: #f4f4f5; background: #111216; outline: none; line-height: 1.6; }
.agent-form textarea:focus { border-color: #7c3aed; box-shadow: 0 0 0 3px #7c3aed33; }
.agent-form textarea:disabled { opacity: .65; }
.agent-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.agent-actions span { color: #8b8b95; font-size: 12px; }
.agent-actions button { flex: none; padding: 10px 16px; border: 0; border-radius: 9px; color: #fff; background: #7c3aed; }
.agent-actions button:hover { background: #6d28d9; }
.agent-actions button:disabled { opacity: .55; cursor: wait; }
.agent-state { margin-top: 20px; }
.agent-empty, .agent-loading, .agent-error, .agent-result { padding: 20px; border: 1px solid #30323a; border-radius: 14px; background: #18191d; }
.agent-empty h2, .agent-loading h2, .agent-error h2, .agent-result h2 { margin: 0 0 8px; font-size: 17px; }
.agent-empty p, .agent-loading p, .agent-error p { margin: 0; color: #a1a1aa; line-height: 1.6; }
.agent-loading { border-color: #4c3b75; }
.agent-error { border-color: #7f1d1d; background: #211719; }
.agent-answer { margin: 14px 0 0; padding: 14px; border-radius: 10px; color: #e4e4e7; background: #111216; line-height: 1.7; white-space: pre-wrap; }
.agent-step { margin-top: 14px; padding: 14px; border: 1px solid #30323a; border-radius: 10px; background: #202229; }
.agent-step-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.agent-step-header h3 { margin: 0; font-size: 15px; }
.status-badge { padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status-badge.succeeded { color: #86efac; background: #14532d66; }
.status-badge.failed { color: #fca5a5; background: #7f1d1d66; }
.agent-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 14px 0 0; }
.agent-meta div { min-width: 0; }
.agent-meta dt { color: #8b8b95; font-size: 11px; }
.agent-meta dd { margin: 4px 0 0; overflow-wrap: anywhere; color: #e4e4e7; font-size: 13px; }
.agent-result-note { margin: 12px 0 0; color: #a1a1aa; font-size: 12px; line-height: 1.6; }

.deletion-workflow { margin-top: 32px; padding-top: 28px; border-top: 1px solid #30323a; }
.deletion-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.deletion-heading h2 { margin: 0; font-size: 22px; }
.eyebrow.danger { display: inline-block; margin-bottom: 8px; color: #fca5a5; font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.risk-badge { flex: none; padding: 5px 9px; border: 1px solid #991b1b; border-radius: 999px; color: #fecaca; background: #7f1d1d55; font-size: 11px; font-weight: 700; }
.deletion-description { max-width: 700px; margin: 10px 0 16px; color: #a1a1aa; line-height: 1.65; }
.deletion-form { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px 14px; padding: 18px; border: 1px solid #4b3034; border-radius: 14px; background: #1f181a; }
.deletion-form label { align-self: center; color: #e4e4e7; font-size: 13px; font-weight: 650; }
.deletion-form input,
.deletion-form textarea { width: 100%; padding: 10px 12px; border: 1px solid #4b4144; border-radius: 9px; color: #f4f4f5; background: #111216; outline: none; }
.deletion-form textarea { resize: vertical; line-height: 1.55; }
.deletion-form input:focus,
.deletion-form textarea:focus { border-color: #ef4444; box-shadow: 0 0 0 3px #ef444433; }
.deletion-form input:disabled,
.deletion-form textarea:disabled { opacity: .6; }
.deletion-form-actions { grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.deletion-form-actions span { color: #8b8b95; font-size: 11px; line-height: 1.45; }
.deletion-form-actions button { flex: none; padding: 10px 16px; border: 1px solid #7f1d1d; border-radius: 9px; color: #fecaca; background: #3a171b; }
.deletion-form-actions button:hover { background: #541c22; }
.deletion-form-actions button:disabled { opacity: .55; cursor: wait; }
.deletion-state { margin-top: 14px; }
.deletion-empty,
.deletion-loading,
.deletion-error,
.approval-card,
.deletion-terminal { padding: 18px; border: 1px solid #3b3437; border-radius: 14px; background: #18191d; }
.deletion-empty h3,
.deletion-loading h3,
.deletion-error h3,
.approval-card h3,
.deletion-terminal h3 { margin: 0 0 7px; font-size: 16px; }
.deletion-empty p,
.deletion-loading p,
.deletion-error p,
.deletion-terminal p { margin: 0; color: #a1a1aa; line-height: 1.6; }
.deletion-loading { border-color: #4c3b75; }
.deletion-error { border-color: #7f1d1d; background: #211719; }
.approval-card { border-color: #9a3412; background: #211a17; }
.approval-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.approval-card-header p { margin: 5px 0 0; color: #fca5a5; font-size: 12px; }
.approval-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 16px 0; }
.approval-meta div { min-width: 0; }
.approval-meta dt { color: #a1a1aa; font-size: 11px; }
.approval-meta dd { margin: 4px 0 0; overflow-wrap: anywhere; color: #f4f4f5; font-size: 13px; }
.approval-warning { margin: 0; padding: 11px 12px; border-radius: 8px; color: #fecaca; background: #7f1d1d44; font-size: 12px; line-height: 1.55; }
.approval-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.approval-actions button { min-height: 42px; padding: 9px 12px; border-radius: 9px; }
.approval-reject { border: 1px solid #4b5563; color: #e4e4e7; background: #272a33; }
.approval-modify { border: 1px solid #7c3aed; color: #ddd6fe; background: #312e8166; }
.approval-approve { grid-column: 1 / -1; border: 1px solid #dc2626; color: #fff; background: #b91c1c; font-weight: 700; }
.approval-approve:hover { background: #dc2626; }
.approval-actions button:disabled { opacity: .55; cursor: wait; }
.deletion-terminal.succeeded { border-color: #166534; background: #152019; }
.deletion-terminal.rejected { border-color: #4b5563; }
.deletion-terminal.failed { border-color: #7f1d1d; background: #211719; }

@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { width: 100%; max-height: 42vh; padding: 14px; overflow-y: auto; }
  .conversation-list { max-height: 100px; }
  .chat-panel { height: 58vh; min-height: 460px; }
  .chat-header { align-items: flex-start; padding: 14px 4vw; }
  .workspace-tabs { flex: none; }
  .workspace-tab { padding: 7px 9px; font-size: 12px; }
  .composer { bottom: 12px; width: 92%; }
  .agent-scroll { padding: 24px 0 40px; }
  .agent-actions { align-items: stretch; flex-direction: column; }
  .agent-actions button { width: 100%; }
  .agent-meta { grid-template-columns: 1fr; }
  .deletion-heading { align-items: flex-start; }
  .deletion-form { grid-template-columns: 1fr; }
  .deletion-form-actions { grid-column: 1; align-items: stretch; flex-direction: column; }
  .deletion-form-actions button { width: 100%; }
  .approval-meta { grid-template-columns: 1fr; }
  .approval-actions { grid-template-columns: 1fr; }
  .approval-approve { grid-column: 1; }
}

.credential-card button { padding: 8px 10px; border: 1px solid #515560; border-radius: 7px; color: #fff; background: #343743; }
.credential-card button:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }
