:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-accent: #00e5a4;
  --color-accent-dark: #00b87a;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 8px;

  --agent-coordinator: #3b82f6;
  --agent-researcher: #8b5cf6;
  --agent-writer: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* App Layout */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.app-header {
  text-align: center;
  padding: 20px 24px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.intro {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.intro a {
  color: var(--color-accent-dark);
  text-decoration: none;
  font-weight: 500;
}

.intro a:hover {
  text-decoration: underline;
}

.intro a.intro-github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: text-bottom;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  background: var(--color-border);
  border-radius: 50%;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition:
    background 0.15s,
    color 0.15s;
}

.intro a.intro-github-link:hover {
  background: var(--color-accent);
  color: white;
  text-decoration: none;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge--ready {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.status-badge--warn {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

/* Three-Column Workspace */
.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  transition: grid-template-columns 0.25s ease;
}

/* Panel Base */
.chat-panel,
.activity-panel,
.notepad-panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Panel Headers */
.chat-header,
.activity-header,
.notepad-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-header h2,
.activity-header h2,
.notepad-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.chat-header i,
.activity-header i,
.notepad-header i {
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

/* Chat Panel */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-empty,
.activity-empty,
.notepad-empty {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px 16px;
  font-style: italic;
}

/* Chat Suggestion Chips */
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.chat-suggestions-heading {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 4px;
}

.chat-suggestion-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--color-text);
  text-align: left;
  font-family: inherit;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.chat-suggestion-chip:hover {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(0, 229, 164, 0.12);
}

.chat-suggestion-chip:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.chat-suggestion-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-suggestion-chip i {
  color: var(--color-text-muted);
  font-size: 1rem;
  flex-shrink: 0;
}

.chat-bubble {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-bubble--user {
  align-self: flex-end;
  background: var(--color-accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-bubble--assistant {
  align-self: flex-start;
  background: var(--color-bg);
  border-bottom-left-radius: 4px;
}

.chat-agent-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--agent-coordinator);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.chat-bubble-text {
  white-space: pre-wrap;
  position: relative;
}

.chat-bubble-rendered {
  white-space: normal;
}

.chat-bubble-rendered a {
  color: var(--color-accent-dark);
  text-decoration: none;
}

.chat-bubble-rendered a:hover {
  text-decoration: underline;
}

.chat-bubble-rendered ul {
  margin: 4px 0;
  padding-left: 20px;
}

.chat-bubble-rendered li {
  margin-bottom: 2px;
}

.chat-bubble-rendered strong {
  font-weight: 600;
}

.chat-bubble-raw {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.82rem;
  margin: 0;
  background: var(--color-bg);
  padding: 8px;
  border-radius: 6px;
}

.chat-toggle-md {
  position: absolute;
  top: 2px;
  right: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.chat-toggle-md:hover {
  opacity: 1;
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

.chat-input-form {
  display: flex;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 4px 4px 4px 12px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.chat-input-wrapper:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 229, 164, 0.15);
}

.chat-input {
  flex: 1;
  padding: 6px 0;
  border: none;
  font-size: 0.85rem;
  font-family: inherit;
  resize: none;
  background: transparent;
}

.chat-input:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  color: var(--color-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  background: rgba(0, 229, 164, 0.1);
  transform: none;
  box-shadow: none;
}

.chat-send-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.chat-send-btn i {
  font-size: 1.1rem;
}

.chat-stop-btn {
  color: #ef4444;
  background: none;
}

.chat-stop-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  box-shadow: none;
}

.chat-stopped-label {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  letter-spacing: 0.03em;
}

.chat-bubble--stopped {
  opacity: 0.75;
}

.chat-stopped-empty {
  font-style: italic;
  color: var(--color-text-muted);
}

.chat-stopped-options {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
}

.chat-stopped-option-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chat-stopped-option-btn:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.chat-stopped-option--continue:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(0, 229, 164, 0.06);
}

.chat-stopped-option--restart:hover {
  border-color: #e55;
  color: #e55;
  background: #fff3f3;
}

/* Activity Log Panel */
.activity-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.activity-entry {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.4;
  transition: background 0.1s;
  cursor: pointer;
}

.activity-entry:hover {
  background: var(--color-bg);
}

.activity-time {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.activity-entry i {
  flex-shrink: 0;
  font-size: 0.85rem;
  margin-top: 1px;
}

.activity-agent {
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}

.activity-detail {
  color: var(--color-text-muted);
  word-break: break-word;
}

/* Agent colors */
.agent-coordinator .activity-agent,
.agent-coordinator i {
  color: var(--agent-coordinator);
}

.agent-researcher .activity-agent,
.agent-researcher i {
  color: var(--agent-researcher);
}

.agent-writer .activity-agent,
.agent-writer i {
  color: var(--agent-writer);
}

.agent-system .activity-agent,
.agent-system i {
  color: var(--color-text-muted);
}

/* Notepad Panel */
.notepad-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.notepad-rendered {
  font-size: 0.88rem;
  line-height: 1.7;
}

.notepad-rendered h1 {
  font-size: 1.2rem;
  margin: 0 0 8px;
}

.notepad-rendered h2 {
  font-size: 1.05rem;
  margin: 16px 0 6px;
}

.notepad-rendered h3 {
  font-size: 0.95rem;
  margin: 12px 0 4px;
}

.notepad-rendered ul {
  margin: 4px 0;
  padding-left: 20px;
}

.notepad-rendered li {
  margin-bottom: 2px;
}

.notepad-rendered a {
  color: var(--color-accent-dark);
  text-decoration: none;
}

.notepad-rendered a:hover {
  text-decoration: underline;
}

.notepad-rendered strong {
  font-weight: 600;
}

/* Notepad Header Layout */
.notepad-header {
  justify-content: space-between;
}

.notepad-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notepad-edit-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  transition: all 0.15s;
}

.notepad-edit-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.notepad-save-btn:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.notepad-cancel-btn:hover {
  color: #e55;
  border-color: #e55;
}

.notepad-edit-actions {
  display: flex;
  gap: 4px;
}

.notepad-description {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  padding: 6px 16px;
  border-bottom: 1px solid var(--color-border);
  font-style: italic;
}

.notepad-editor {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 0;
  background: transparent;
  color: var(--color-text);
}

/* Start Fresh inline button */
.chat-start-fresh {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.chat-start-fresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px dashed var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chat-start-fresh-btn:hover {
  border-color: #e55;
  color: #e55;
  background: #fff3f3;
}

/* Tool Status Bar */
.tool-status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.tool-status-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.tool-status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.tool-status-item:hover {
  background: var(--color-bg);
}

.tool-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tool-status-dot.connected {
  background: var(--color-accent);
  box-shadow: 0 0 4px rgba(0, 229, 164, 0.4);
}

.tool-status-dot.disconnected {
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}

.tool-status-name {
  font-family: "SF Mono", "Cascadia Code", monospace;
  font-size: 0.75rem;
}

.tool-status-none {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Status Bars Container */
.status-bars {
  display: flex;
  flex-direction: row;
  gap: 16px;
  margin-top: 16px;
  flex-shrink: 0;
}

.status-bars > * {
  flex: 1;
  margin-top: 0;
}

/* Agent Status Bar */
.agent-status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--color-border);
}

.agent-status-dot.idle {
  background: var(--color-border);
}

.agent-status-dot.active {
  background: var(--agent-color);
  box-shadow: 0 0 4px color-mix(in srgb, var(--agent-color) 50%, transparent);
  animation: agent-pulse 1.5s ease-in-out infinite;
}

.agent-status-dot.done {
  background: var(--agent-color);
  box-shadow: 0 0 4px color-mix(in srgb, var(--agent-color) 50%, transparent);
}

.agent-status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}

@keyframes agent-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

.agent-context-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.agent-context-badge--prev {
  opacity: 0.4;
  font-size: 0.55rem;
  font-weight: 400;
  margin-left: 1px;
  font-style: italic;
}

/* Agent Modal Tabs */
.agent-modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  padding: 0 16px;
}

.agent-modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
}

.agent-modal-tab:hover {
  color: var(--color-text);
}

.agent-modal-tab.active {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
}

.agent-modal-empty {
  color: var(--color-text-muted);
  font-style: italic;
  padding: 24px 0;
  text-align: center;
}

.agent-detail-prev {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
  opacity: 0.55;
  font-style: italic;
  white-space: pre-wrap;
}

/* Accordion History */
.agent-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: "SF Mono", "Cascadia Code", monospace;
  font-size: 0.8rem;
}

.agent-history-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
}

.agent-history-header:hover {
  background: var(--color-surface);
}

.agent-history-chevron {
  flex-shrink: 0;
  transition: transform 0.15s;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.agent-history-chevron.open {
  transform: rotate(90deg);
}

.agent-history-role {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.agent-history-user .agent-history-role {
  color: var(--color-accent-dark);
  background: rgba(0, 229, 164, 0.1);
}

.agent-history-answer .agent-history-role {
  color: var(--color-text-muted);
  background: var(--color-surface);
}

.agent-history-label {
  font-weight: 600;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.agent-history-time {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.agent-history-preview {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.agent-history-body {
  max-height: 400px;
  overflow-y: auto;
  border-left: 2px solid var(--color-accent);
  margin-left: 18px;
  padding: 4px 0 4px 10px;
}

.agent-history-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  line-height: 1.5;
}

/* Run Groups in History */
.agent-history-run-group {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 2px;
  margin-bottom: 2px;
}

.agent-history-run-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.agent-history-run-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.15s;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
}

.agent-history-run-header:hover {
  background: var(--color-surface);
}

.agent-history-run-chevron {
  flex-shrink: 0;
  transition: transform 0.15s;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.agent-history-run-chevron.open {
  transform: rotate(90deg);
}

.agent-history-run-label {
  font-weight: 700;
  font-size: 0.78rem;
}

.agent-history-run-summary {
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.agent-history-run-entries {
  padding-left: 8px;
}

/* Collapsible Panels */
.panel-collapsed {
  width: 48px;
  min-width: 48px;
  cursor: pointer;
  transition: background 0.15s;
  /* button reset */
  font: inherit;
  color: inherit;
  border: none;
  padding: 0;
  text-align: inherit;
}

.panel-collapsed:hover {
  background: var(--color-bg);
}

.panel-collapsed:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  background: var(--color-bg);
}

.panel-collapsed-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}

.panel-collapsed-inner i {
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

.panel-collapsed-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
}

.panel-collapsed-chevron {
  font-size: 0.85rem !important;
}

.panel-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  margin-left: auto;
  opacity: 0.5;
  transition:
    opacity 0.15s,
    background 0.15s;
}

.panel-toggle-btn:hover {
  opacity: 1;
  background: var(--color-bg);
}

.panel-toggle-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  margin-top: 16px;
  flex-shrink: 0;
}

.footer--minimized {
  padding: 6px 16px;
  text-align: right;
}

.banner-wrapper {
  position: relative;
  display: inline-block;
}

.banner-minimize-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  opacity: 0;
  transition:
    opacity 0.15s,
    background 0.15s;
}

.banner-wrapper:hover .banner-minimize-btn,
.banner-wrapper:focus-within .banner-minimize-btn {
  opacity: 1;
}

.banner-minimize-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.banner-minimize-btn:hover {
  background: white;
  color: var(--color-text);
}

.banner-mini-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  text-decoration: none;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.banner-mini-pill:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.banner-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.banner-restore-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.banner-restore-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.banner-restore-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.nearform-banner {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.nearform-banner:hover {
  box-shadow: var(--shadow-md);
}

/* Activity Detail Modal */
.activity-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.activity-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.activity-modal-header strong {
  font-size: 0.9rem;
}

.activity-modal-type {
  margin-left: 8px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.activity-modal-time {
  margin-left: 8px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.activity-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.activity-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.activity-modal-close:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.activity-modal-body {
  margin: 0;
  padding: 16px;
  overflow: auto;
  max-height: 70vh;
  font-family: "SF Mono", "Cascadia Code", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--color-bg);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Tool Detail Modal — two-pane layout */
.tool-modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 90%;
  max-width: 960px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.tool-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.tool-modal-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  min-width: 0;
}

.tool-modal-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tool-modal-right-header {
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tool-modal-copy-btn {
  position: relative;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  line-height: 1;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.tool-modal-copy-btn:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.tool-modal-copy-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--color-surface);
  color: var(--color-accent);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  border: 1px solid var(--color-border);
  pointer-events: none;
  text-transform: none;
  letter-spacing: normal;
}

.tool-modal-schema {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.tool-modal-description {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.tool-modal-properties {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.tool-modal-properties th {
  text-align: left;
  padding: 4px 8px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

.tool-modal-properties td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--color-bg);
}

.tool-modal-required {
  color: #ef4444;
  font-weight: 600;
  font-size: 0.7rem;
}

.tool-modal-form {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
}

.tool-modal-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tool-modal-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.tool-modal-input {
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: "SF Mono", "Cascadia Code", monospace;
  resize: vertical;
  transition: border-color 0.2s;
}

.tool-modal-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.tool-modal-actions {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.tool-modal-execute {
  padding: 6px 16px;
  background: linear-gradient(
    135deg,
    var(--color-accent),
    var(--color-accent-dark)
  );
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}

.tool-modal-execute:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 229, 164, 0.3);
}

.tool-modal-execute:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.tool-modal-result {
  margin: 0;
  padding: 16px;
  flex: 1;
  overflow: auto;
  font-family: "SF Mono", "Cascadia Code", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--color-bg);
  border-radius: 0 0 var(--radius) 0;
  color: var(--color-text-muted);
}

.tool-modal-source {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-weight: 500;
}

@media (max-width: 640px), (max-height: 500px) {
  .tool-modal-body {
    flex-direction: column;
  }

  .tool-modal-left {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .tool-modal-right {
    max-height: 250px;
  }
}

/* Platform Status Button */
.platform-status-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: text-bottom;
  width: 22px;
  height: 22px;
  margin-left: 4px;
  background: var(--color-border);
  border: none;
  border-radius: 50%;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  cursor: pointer;
  position: relative;
  transition:
    background 0.15s,
    color 0.15s;
}

.platform-status-btn:hover {
  background: var(--color-accent);
  color: white;
}

.platform-status-btn.has-issues::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--color-surface);
}

/* Platform Status Modal Body */
.platform-status-body {
  padding: 16px;
  overflow: auto;
  max-height: 70vh;
  font-size: 0.85rem;
  line-height: 1.6;
}

.platform-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.platform-status-row + .platform-status-row {
  border-top: 1px solid var(--color-border);
}

.platform-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.platform-status-dot.ok {
  background: #10b981;
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.4);
}

.platform-status-dot.warn {
  background: #f59e0b;
  box-shadow: 0 0 4px rgba(245, 158, 11, 0.4);
}

.platform-status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
}

.platform-status-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.platform-status-chrome-ver {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.platform-status-instructions {
  padding: 4px 0 12px 18px;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.platform-status-instructions p {
  margin: 0 0 6px;
}

.platform-status-instructions ol {
  margin: 0;
  padding-left: 18px;
}

.platform-status-instructions li {
  margin-bottom: 4px;
}

.platform-status-instructions code {
  font-family: "SF Mono", "Cascadia Code", monospace;
  font-size: 0.78rem;
  background: var(--color-bg);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Mobile Panel Tabs – hidden on desktop */
.mobile-panel-tabs {
  display: none;
}

/* Responsive – Tablet */
@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .chat-panel {
    grid-row: 1 / 3;
  }
}

/* Responsive – Phone (portrait narrow OR landscape short) */
@media (max-width: 640px), (max-height: 500px) {
  /* Viewport & container */
  .app-container {
    padding: 8px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Header condensed */
  .app-header {
    padding: 12px 16px;
    margin-bottom: 8px;
  }

  .app-header h1 {
    font-size: 1.15rem;
  }

  .intro {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  /* Mobile tab bar */
  .mobile-panel-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    flex-shrink: 0;
  }

  .mobile-panel-tab {
    flex: 1;
    padding: 8px 4px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 44px;
    transition:
      border-color 0.15s,
      color 0.15s,
      background 0.15s;
  }

  .mobile-panel-tab.active {
    border-color: var(--color-accent);
    color: var(--color-text);
    background: rgba(0, 229, 164, 0.06);
  }

  .mobile-panel-tab i {
    font-size: 1rem;
  }

  /* Workspace: flex column, one panel at a time */
  .workspace {
    display: flex !important;
    flex-direction: column;
    gap: 0;
  }

  /* Show only the active panel */
  .workspace.mobile-active-chat .activity-panel,
  .workspace.mobile-active-chat .notepad-panel,
  .workspace.mobile-active-activity .chat-panel,
  .workspace.mobile-active-activity .notepad-panel,
  .workspace.mobile-active-notepad .chat-panel,
  .workspace.mobile-active-notepad .activity-panel {
    display: none;
  }

  .chat-panel,
  .activity-panel,
  .notepad-panel {
    flex: 1;
    min-height: 0;
    max-height: none;
  }

  /* Hide desktop collapse controls */
  .panel-collapsed,
  .panel-toggle-btn {
    display: none;
  }

  /* Status bars: single row each, truncated names */
  .status-bars {
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
  }

  .agent-status-bar,
  .tool-status-bar {
    gap: 6px;
    padding: 6px 10px;
    font-size: 0.75rem;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .tool-status-name {
    font-size: 0.7rem;
    max-width: 10ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tool-status-item {
    padding: 2px 4px;
    min-height: 28px;
    flex-shrink: 1;
    min-width: 0;
  }

  .tool-status-label {
    flex-shrink: 0;
  }

  /* Hide panel headers – tabs serve as labels */
  .chat-header,
  .activity-header,
  .notepad-header {
    display: none;
  }

  /* Touch targets */
  .intro a.intro-github-link,
  .platform-status-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .chat-send-btn {
    width: 36px;
    height: 36px;
  }

  /* Modals: near full-screen */
  .activity-modal {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }

  .tool-modal {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }

  /* Hide footer banner */
  .footer {
    display: none;
  }
}

/* Landscape phone: extra-compact to maximize panel space */
@media (max-height: 500px) and (orientation: landscape) {
  .app-header {
    padding: 6px 16px;
    margin-bottom: 4px;
  }

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

  .intro {
    display: none;
  }

  .mobile-panel-tabs {
    margin-bottom: 4px;
  }

  .mobile-panel-tab {
    min-height: 32px;
    padding: 4px;
    font-size: 0.75rem;
  }

  /* Side-by-side status bars in landscape (more horizontal room) */
  .status-bars {
    flex-direction: row;
    gap: 4px;
    margin-top: 4px;
  }

  .tool-status-name {
    max-width: 8ch;
  }
}
