body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0 auto;
  max-width: 48rem;
  padding: 1rem;
  line-height: 1.4;
}
header { margin-bottom: 1rem; }
.status-line { color: #666; font-size: 0.9rem; }
.link-btn { background: none; border: none; color: #1a73e8; cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
#paused-banner { color: #b06a00; font-weight: 600; }
.error { background: #fdecea; border: 1px solid #f5c6cb; color: #b02a37; padding: 0.5rem; border-radius: 4px; }
section { margin-bottom: 1.5rem; }
.muted { color: #666; font-size: 0.85rem; }
.approval, .worker-list li, .event-list li { padding: 0.5rem 0; border-bottom: 1px solid #ddd; }
button { margin-right: 0.5rem; padding: 0.25rem 0.75rem; cursor: pointer; }
.approve { background: #d4edda; border: 1px solid #98c9a3; }
.reject { background: #fdecea; border: 1px solid #f5c6cb; }
.badge { display: inline-block; padding: 0 0.35rem; border-radius: 3px; font-size: 0.75rem; border: 1px solid #ccc; }
.badge.online { background: #d4edda; }
.badge.offline { background: #e2e3e5; }
.badge.stale { background: #fff3cd; }
.badge.ahead { background: #d1ecf1; }
.badge.approved { background: #d4edda; }
.badge.rejected { background: #fdecea; }
.badge.event { background: #fff3cd; }
.badge.warn { background: #fff3cd; }
.hub-response { background: #f0f7ff; border: 1px solid #b8daff; padding: 0.4rem 0.6rem; border-radius: 4px; font-size: 0.85rem; margin: 0.3rem 0; white-space: pre-wrap; word-break: break-word; max-height: 10rem; overflow: auto; }
.scrollbox { max-height: 12rem; overflow: auto; white-space: pre-wrap; word-break: break-word; background: #fafafa; border: 1px solid #ddd; padding: 0.4rem 0.6rem; border-radius: 4px; margin: 0.3rem 0; }
.lbl { color: #666; }

/* Activity selection UI */
.activity-controls {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.select-all-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9rem;
}
.event-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.event-checkbox {
  margin: 0;
  flex-shrink: 0;
}
.event-item .badge.event {
  flex-shrink: 0;
}
.event-item .muted {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.delete-single-btn {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
}

.badge.ongoing { background: #fff3cd; }
.badge.planned { background: #e2e3e5; }
.badge.complete { background: #d4edda; }
.badge.stable { background: #d4edda; }
.badge.blocked { background: #fdecea; }
.badge.deprecated { background: #e2e3e5; }
.badge.invalid { background: #fdecea; }
.section-list li { margin: 0.25rem 0; }

.scope-snippet { margin: 0.25rem 0 0.5rem; padding: 0.4rem; background: #f4f4f4; border-left: 3px solid #ccc; font-size: 0.8rem; white-space: pre-wrap; }
.project-sections-list > li { margin: 0.5rem 0; }

.ddev-block { margin: 0.35rem 0; padding: 0.35rem; background: #fafafa; border-left: 3px solid #6c9; }
.ddev-block a { word-break: break-all; }
.ddev-actions { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; }
.ddev-op { display: block; margin-top: 0.3rem; font-size: 0.85em; }
.ddev-op-state { margin-right: 0.3rem; }
.ddev-op-state.op-running { background: #fff3cd; }
.ddev-op-state.op-error { background: #fdecea; }
.ddev-op-state.op-ok { background: #d4edda; }
.badge.up { background: #d4edda; }
.badge.down { background: #e2e3e5; }
.badge.starting { background: #fff3cd; }
.badge.error { background: #fdecea; }

.sync-block { margin: 0.35rem 0; padding: 0.35rem; background: #f7faff; border-left: 3px solid #69c; }
.sync-target { margin: 0.2rem 0; }
.cmd-result { margin: 0.35rem 0 0; }
.cmd-result pre {
  margin: 0.25rem 0 0;
  padding: 0.4rem;
  background: #1e1e1e;
  color: #e6e6e6;
  max-height: 14rem;
  overflow: auto;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.op-status {
  margin: 0.25rem 0;
  padding: 0.25rem 0.4rem;
  background: #f4f4f4;
  border-left: 3px solid #69c;
  font-size: 0.8rem;
}
.op-status.op-ok { border-left-color: #2a9d4a; background: #eaf7ee; }
.op-status.op-error { border-left-color: #c33; background: #fdecea; }
.op-status.op-info { border-left-color: #69c; background: #f4f4f4; }
.op-status .op-msg { margin-left: 0.35rem; }
.op-status .op-stream {
  margin: 0.25rem 0 0;
  padding: 0.35rem;
  background: #1e1e1e;
  color: #e6e6e6;
  max-height: 12rem;
  overflow: auto;
  font-size: 0.72rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.sync-note { font-size: 0.72rem; margin: 0.15rem 0 0.35rem; }
li.busy .sync-actions button { opacity: 0.5; cursor: not-allowed; }
li.busy .sync-actions button:disabled { pointer-events: none; }

/* Forms: allow wrapping and sensible spacing on all screens */
form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
form input[type="text"], form select { flex: 1 1 12rem; min-width: 0; }

/* Confirm modal for plugin Deploy/Remove */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 6px; padding: 1.1rem 1.3rem;
  max-width: 28rem; box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.modal p { margin: 0 0 1rem; line-height: 1.4; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }

/* Mobile / small screens: stack controls, enlarge tap targets */
@media (max-width: 640px) {
  body { padding: 0.6rem; }
  header h1 { font-size: 1.3rem; }
  main { max-width: 100%; }
  section { margin-bottom: 1.1rem; }
  form { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  form input[type="text"], form select, form button { width: 100%; flex: 1 1 auto; }
  button { padding: 0.6rem 0.9rem; font-size: 1rem; margin: 0 0 0.3rem 0; }
  .sync-actions { display: flex; flex-direction: column; gap: 0.4rem; }
  .sync-actions form { flex-direction: column; }
  .sync-actions button { width: 100%; }
  .event-item { flex-wrap: wrap; }
  .hub-response, .cmd-result pre, .op-status .op-stream { max-height: 9rem; }
  .activity-controls { flex-direction: column; align-items: stretch; }
}

/* ---- Sites page ---- */

/* Top nav */
.top-nav { padding: 0.5rem 1rem; background: var(--card-bg, #f4f4f4); border-bottom: 1px solid #ddd; }
.top-nav a { margin-right: 1rem; font-weight: bold; text-decoration: none; }
.top-nav a:hover { text-decoration: underline; }

/* Notice banner (info, not error) */
.notice { padding: 0.6rem 0.8rem; border: 1px solid #c3d9ff; background: #e8f1ff; border-radius: 4px; margin: 0.5rem 0; }

/* Wizard form: stack labels + inputs vertically */
.new-project-form, .new-project-form label { display: flex; flex-direction: column; gap: 0.4rem; max-width: 40rem; }
.new-project-form input[type=text], .new-project-form input[type=password], .new-project-form select {
  padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; }
.new-project-form .checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }
.new-project-form .muted { font-weight: normal; font-size: 0.85rem; }

/* Queued commands list */
.queued-list { list-style: none; padding: 0; }
.queued-list li { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0; border-bottom: 1px solid #eee; flex-wrap: wrap; }
.queued-list pre { white-space: pre-wrap; word-break: break-word; margin: 0; }

/* Approval details (pending + decided) */
.approval-details {
  white-space: pre-wrap;
  font: inherit;
  font-size: 0.85rem;
  color: #555;
  background: #f7f7f7;
  border: 1px solid #eee;
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  margin: 0.35rem 0;
}

/* Worker offline warning under wizard */
.warn { color: #8a6d00; }

/* OpenCode prompt composer on the site page */
.prompt-form, .prompt-form label { display: flex; flex-direction: column; gap: 0.4rem; }
.prompt-form { max-width: 60rem; margin-bottom: 0.75rem; }
.prompt-form textarea {
  width: 100%;
  min-height: 8rem;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}
.prompt-actions { display: flex; gap: 0.5rem; align-items: center; }
.prompt-actions button { margin-right: 0; }

/* OpenCode live session panel */
.session-panel { max-width: 60rem; margin-bottom: 1rem; border: 1px solid #ddd; border-radius: 6px; padding: 0.6rem 0.75rem; }
.session-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.session-summary { margin-top: 0.5rem; }
.session-summary > span { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.session-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.5rem; flex-wrap: wrap; }
.badge.phase { text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.04em; }
.badge.phase-idle, .badge.phase-stopped { background: #e2e3e5; }
.badge.phase-working, .badge.phase-processing { background: #cfe2ff; }
.badge.phase-thinking { background: #e7d6ff; }
.badge.phase-compacting { background: #ffe8cc; }
.badge.phase-retrying { background: #fff3cd; }
.badge.phase-waiting { background: #ffe0b2; animation: pulse 1.4s ease-in-out infinite; }
.badge.phase-error { background: #fdecea; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.badge.phase.is-busy::before {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.35em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: middle;
  animation: hub-spin 0.7s linear infinite;
}
@keyframes hub-spin { to { transform: rotate(360deg); } }
#session-timer { font-variant-numeric: tabular-nums; min-width: 2.5em; display: inline-block; }

/* Project processes */
.processes { border-collapse: collapse; width: 100%; max-width: 60rem; }
.processes th, .processes td { text-align: left; padding: 0.3rem 0.6rem; border-bottom: 1px solid #eee; vertical-align: top; }
.processes th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: #666; }
.processes code { font-size: 0.8rem; word-break: break-all; }
.processes tr.duplicate { background: #fdecea; }

.result-panel { max-width: 60rem; margin-top: 1rem; }
.result-panel h3 { margin-bottom: 0.3rem; }

.interaction-panel { max-width: 60rem; margin-top: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.interaction-panel.has-interactions { border: 1px solid #f0ad4e; border-radius: 6px; padding: 0.75rem; background: #fffdf5; }
.interaction-panel .question, .interaction-panel .approval { border: 1px solid #ddd; border-radius: 6px; padding: 0.6rem 0.75rem; background: #fff; }
.interaction-title { font-weight: 600; margin: 0 0 0.25rem; }
.question-item, .interaction-field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.4rem 0; }
.question-item .choice, .interaction-option { display: flex; align-items: center; gap: 0.4rem; }
.custom-answer { padding: 0.35rem; border: 1px solid #ccc; border-radius: 4px; font: inherit; }

.model-panel { max-width: 60rem; margin-top: 1rem; }
.model-panel summary { cursor: pointer; }
