:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel-bg: #ffffff;
  --border: #e0e2e7;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #2563eb;
  --user-bubble: #2563eb;
  --user-bubble-text: #ffffff;
  --assistant-bubble: #e6f4ea;
  --error-bubble: #fdecea;
  --error-text: #b3261e;

  --json-key: #1d4ed8;
  --json-string: #15803d;
  --json-number: #b45309;
  --json-boolean: #7c3aed;
  --json-null: #6b7280;
}

* {
  box-sizing: border-box;
}

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

.app {
  max-width: 820px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 1.1rem;
  margin: 0;
}

.app-logo {
  height: 2rem;
  display: block;
}

.upload-button {
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.upload-button:hover {
  background: #eceef1;
}

.upload-button input[type="file"] {
  display: none;
}

.upload-status {
  min-height: 1.4rem;
  margin: 0;
  padding: 0.25rem 1.25rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}

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

.upload-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0 1.25rem;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message {
  display: flex;
}

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

.message-assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: 80%;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
}

.message-user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
}

.message-assistant .bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-assistant .bubble.bubble-error {
  background: var(--error-bubble);
  border-color: #f3c6c2;
  color: var(--error-text);
}

.bubble-json pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.json-key { color: var(--json-key); font-weight: 600; }
.json-string { color: var(--json-string); }
.json-number { color: var(--json-number); }
.json-boolean { color: var(--json-boolean); }
.json-null { color: var(--json-null); }

.bubble-json {
  max-width: 92%;
}

.plan-card {
  /* Reset the bubble's pre-wrap so stray whitespace in the generated
     markup doesn't show up as gaps between block elements. */
  white-space: normal;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.plan-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

.plan-mode {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: #eaf0fe;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.plan-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.plan-step {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.step-index {
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  margin-top: 0.1rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.step-body {
  flex: 1;
  min-width: 0;
}

.step-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
  font-size: 0.7rem;
}

.step-agent {
  font-weight: 700;
  color: var(--json-key);
  background: #eaf0fe;
  padding: 0.05rem 0.45rem;
  border-radius: 6px;
}

.step-capability {
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.05rem 0.45rem;
  border-radius: 6px;
}

.step-id {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.step-task {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
}

.plan-explanation {
  margin: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
}

.plan-raw summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--accent);
}

.plan-raw pre {
  margin-top: 0.5rem;
}

.chat-form {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.chat-form textarea {
  flex: 1;
  resize: none;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  font: inherit;
  max-height: 8rem;
}

.chat-form button {
  padding: 0 1.1rem;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.chat-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
