/* === CSS Custom Properties === */
:root {
  --header-h: 48px;
  --main-tabs-h: 44px;
  --kanban-tabs-h: 40px;
  --bg-primary: #0d1117;
  --bg-card: #161b22;
  --bg-header: #161b22;
  --border: #30363d;
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --accent-selected: #1f6feb;
  --success: #238636;
  --success-hover: #2ea043;
  --error: #da3633;
  --warning: #d29922;
  --stopped: #484f58;
}

@media (min-width: 768px) {
  :root {
    --header-h: 56px;
  }
}

/* === Reset === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* === Login === */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-dialog h1 {
  color: var(--accent);
  font-size: 24px;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-dialog form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-dialog input {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 16px;
  min-height: 44px;
}

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

.login-dialog button {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  min-height: 44px;
}

.login-dialog button:hover { background: var(--success-hover); }
.login-dialog button:disabled { background: #21262d; color: var(--stopped); cursor: not-allowed; }

.login-error { color: #f85149; font-size: 13px; }
.setup-warning { color: var(--warning); font-size: 14px; margin-bottom: 8px; }
#setup-message { margin-bottom: 16px; }
#setup-message code {
  display: block;
  background: var(--bg-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
}

/* === App Bar === */
header {
  background: var(--bg-header);
  height: var(--header-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

header h1 { font-size: 18px; color: var(--accent); white-space: nowrap; }
.subtitle { color: var(--text-secondary); font-size: 14px; display: none; }

.daemon-info {
  display: none;
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.header-actions {
  display: none;
  align-items: center;
  gap: 12px;
  margin-left: 16px;
}

.admin-name { font-size: 13px; color: var(--text-secondary); }

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.logout-btn:hover { border-color: var(--error); color: #f85149; }

/* Status dot (mobile) */
.status-dot {
  margin-left: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  background: var(--error);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  position: relative;
}

.status-dot::before { content: ''; position: absolute; inset: -16px; }
.status-dot.connected { background: var(--success); }

/* Daemon popover */
.daemon-popover {
  display: none;
  position: absolute;
  top: calc(var(--header-h) - 4px);
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  z-index: 50;
  line-height: 1.8;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  white-space: nowrap;
}

.daemon-popover.open { display: block; }

.popover-logout {
  display: block;
  width: 100%;
  margin-top: 8px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.popover-logout:hover { border-color: var(--error); color: #f85149; }

/* Desktop: show full info, hide dot */
@media (min-width: 768px) {
  header { padding: 0 24px; gap: 12px; }
  header h1 { font-size: 20px; }
  .subtitle { display: inline; }
  .daemon-info { display: block; }
  .header-actions { display: flex; }
  .status-dot { display: none; }
  .daemon-popover { display: none !important; }
}

/* === Main Tab Bar (CREATE / KANBAN) === */
.main-tab-bar {
  display: flex;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  height: var(--main-tabs-h);
}

.main-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--main-tabs-h);
  transition: color 0.15s, border-color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

/* === Views === */
.view { display: none; }
.view.active { display: block; }

#view-kanban.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - var(--main-tabs-h));
  overflow: hidden;
}

#view-kanban .kanban-container { flex: 1; min-height: 0; }

/* === CREATE View === */
.create-view-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px;
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.create-form label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.create-form textarea,
.create-form input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}

.create-form textarea {
  resize: vertical;
  min-height: 120px;
}

.create-form textarea:focus,
.create-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.create-form button {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
}

.create-form button:hover { background: var(--success-hover); }
.create-form button:disabled { background: #21262d; color: var(--stopped); cursor: not-allowed; }

/* === Kanban Tab Bar === */
.tab-bar {
  display: flex;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  height: var(--kanban-tabs-h);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 4px;
  min-height: var(--kanban-tabs-h);
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

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

.tab-count {
  font-size: 10px;
  background: var(--border);
  color: var(--text-secondary);
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.tab.active .tab-count {
  background: var(--accent-selected);
  color: #fff;
}

.tab-count-error {
  background: var(--error) !important;
  color: #fff !important;
}

@media (min-width: 768px) {
  .tab { font-size: 13px; gap: 6px; padding: 0 8px; }
  .tab-count { font-size: 11px; padding: 1px 6px; min-width: 20px; }

  /* Desktop: static column headers instead of tabs */
  .tab-bar {
    display: grid;
    grid-template-columns: repeat(var(--kanban-cols, 4), 1fr);
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
  }

  .tab {
    justify-content: center;
    cursor: default;
    border-bottom-color: transparent !important;
    color: var(--text-primary);
    font-weight: 600;
  }

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

/* === Kanban Container === */
.kanban-container {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.kanban-container::-webkit-scrollbar { display: none; }
.kanban-container.is-dragging { scroll-snap-type: none; overflow-x: hidden; }

.kanban-phase {
  flex: 0 0 100vw;
  scroll-snap-align: start;
  overflow-y: auto;
  height: 100%;
  padding: 12px;
}

.phase-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Desktop: dynamic column grid */
@media (min-width: 768px) {
  .kanban-container {
    display: grid;
    grid-template-columns: repeat(var(--kanban-cols, 4), 1fr);
    overflow-x: visible;
    scroll-snap-type: none;
    max-width: 1600px;
    margin: 0 auto;
  }

  .kanban-phase {
    flex: none;
    width: auto;
    min-width: 0;
    height: 100%;
    border-right: 1px solid var(--border);
    scroll-snap-align: unset;
  }

  .kanban-phase:last-child { border-right: none; }
}

/* === Empty State === */
.empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 48px 16px;
  font-size: 14px;
  line-height: 1.6;
}

/* === Proposal Card (kanban) === */
.proposal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.proposal-card:hover { border-color: var(--accent); }

.proposal-card .proposal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.proposal-card .proposal-submitter {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proposal-card .proposal-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  text-transform: uppercase;
  flex-shrink: 0;
}

.proposal-card .proposal-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proposal-card .proposal-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.proposal-card .btn-approve-small {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px;
}

.proposal-card .btn-approve-small:hover { background: var(--success-hover); }

.proposal-card .btn-view-small {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px;
}

.proposal-card .btn-view-small:hover { border-color: var(--accent); color: var(--accent); }

.status-proposal-processing { background: #388bfd; color: #fff; }
.status-proposal-pending { background: #9e6a03; color: #fff; }
.status-proposal-approved { background: var(--success); color: #fff; }
.status-proposal-rejected { background: var(--error); color: #fff; }
.status-proposal-in_development { background: #0d9488; color: #fff; }
.status-proposal-done { background: #166534; color: #fff; }
.status-proposal-done::before { content: '\2713 '; }
.status-proposal-awaiting_input { background: #f0883e; color: #fff; }

.proposal-type {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.type-bug { background: #da3633; color: #fff; }
.type-feature { background: #388bfd; color: #fff; }

.auto-resolving {
  font-size: 12px;
  color: var(--success);
  font-style: italic;
  margin-top: 4px;
}

/* === Issue Card (Backlog) === */
.issue-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  gap: 8px;
  transition: border-color 0.15s;
}

.issue-card.selected { border-color: var(--accent-selected); }
.issue-card.selected.first-selected { box-shadow: 0 0 0 1px var(--accent-selected); }

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

.issue-card-title {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 4px;
}

.issue-number { color: var(--text-secondary); font-size: 13px; flex-shrink: 0; }

.issue-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.issue-labels { display: flex; flex-wrap: wrap; gap: 4px; }

.issue-label {
  background: var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

/* Drag handle */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  cursor: grab;
  color: var(--text-secondary);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.drag-handle:active { cursor: grabbing; }

.drag-dots {
  font-size: 20px;
  line-height: 1;
  letter-spacing: 2px;
  opacity: 0.5;
}

.drag-handle:hover .drag-dots { opacity: 1; }

/* Drag states */
.issue-card.dragging {
  position: fixed;
  z-index: 100;
  opacity: 0.9;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: none;
}

.drag-placeholder {
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: rgba(88,166,255,0.05);
}

/* Mannequin select button */
.issue-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  font-size: 14px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}

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

.issue-btn.mannequin-btn { font-size: 18px; min-height: 40px; min-width: 40px; align-self: center; }

.issue-card.selected .mannequin-btn {
  background: var(--accent-selected);
  border-color: var(--accent-selected);
  color: #fff;
}

/* Pending issue card */
.issue-card.pending {
  border-left: 3px solid #6e7681;
  opacity: 0.85;
}

.issue-card.pending .issue-card-body { pointer-events: none; }

.pending-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.pending-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.pending-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  min-height: 28px;
  margin-left: auto;
  flex-shrink: 0;
}

.pending-cancel:hover { border-color: var(--error); color: #f85149; }

/* === Agent Card === */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.agent-card:hover { border-color: var(--accent); }

.agent-card .header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.agent-card .name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.agent-card .status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  text-transform: uppercase;
  flex-shrink: 0;
}

.status-pending { background: #6e7681; color: #fff; }
.status-queued { background: #9e6a03; color: #fff; }
.status-setting_up { background: #1f6feb; color: #fff; }
.status-working { background: #388bfd; color: #fff; }
.status-creating_pr { background: #8957e5; color: #fff; }
.status-creating_issue { background: #8957e5; color: #fff; }
.status-done { background: var(--success); color: #fff; }
.status-error { background: var(--error); color: #fff; }
.status-stopped { background: var(--stopped); color: #fff; }
.status-waiting_for_input { background: #9e6a03; color: #fff; }
.status-watching_ci { background: #d29922; color: #fff; }

.type-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
  flex-shrink: 0;
}

.type-resolve { background: #1f6feb22; color: var(--accent); border: 1px solid #1f6feb44; }
.type-create { background: #8957e522; color: #bc8cff; border: 1px solid #8957e544; }
.type-propose { background: #d2992222; color: var(--warning); border: 1px solid #d2992244; }

.agent-card .issue {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-card .details {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 4px;
}

.agent-card .pr-link, .pr-link { color: var(--accent); text-decoration: none; }
.agent-card .pr-link:hover, .pr-link:hover { text-decoration: underline; }

.agent-card .issue-links { color: var(--text-secondary); font-size: 12px; }
.agent-card .issue-links .pr-link { margin: 0 2px; }

.agent-card .error-msg {
  color: #f85149;
  font-size: 12px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.agent-card .error-msg:hover { color: #ff7b72; }

.agent-card .actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.agent-card .actions button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  min-height: 36px;
  transition: border-color 0.15s, color 0.15s;
}

.agent-card .actions button:hover { border-color: var(--accent); color: var(--accent); }
.agent-card .actions button.stop { border-color: var(--error); color: #f85149; }
.agent-card .actions button.stop:hover { background: rgba(218,54,51,0.1); }
.agent-card .actions button.retry { border-color: #9e6a03; color: var(--warning); }
.agent-card .actions button.retry:hover { background: rgba(158,106,3,0.1); }

/* Done agent card variants */
.agent-card.done-card { border-left: 3px solid var(--success); }
.agent-card.error-card { border-left: 3px solid var(--error); }
.agent-card.stopped-card { border-left: 3px solid var(--stopped); }

/* === FAB === */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: background 0.15s, transform 0.1s;
  min-height: 48px;
}

.fab:hover { background: var(--success-hover); }
.fab:active { transform: scale(0.96); }

/* === Log Panel === */
.log-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.log-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 48px;
}

.log-header h2 {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.log-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 12px;
}

.log-close:hover { border-color: var(--text-primary); color: var(--text-primary); }

.log-output {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.log-output .log-line { padding: 1px 0; }
.log-output .log-time { color: var(--stopped); }
.log-output .log-tool { color: var(--accent); }
.log-output .log-status { color: var(--warning); }
.log-output .log-error { color: #f85149; }
.log-output .log-result { color: #3fb950; }

.log-output .log-user-message {
  background: #1c2333;
  border-left: 3px solid var(--accent);
  padding: 4px 8px;
  margin: 4px 0;
  border-radius: 0 4px 4px 0;
}

.log-output .log-user-label { color: var(--accent); font-weight: 600; }

/* Chat input */
.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.chat-input input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  min-height: 44px;
}

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

.chat-input button {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
}

.chat-input button:hover { background: var(--success-hover); }
.chat-input button:disabled { background: #21262d; color: var(--stopped); cursor: not-allowed; }

@media (min-width: 768px) {
  .log-overlay {
    inset: 5vh 10vw;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  }

  .log-output { font-size: 13px; }
}

/* === Proposal Detail Modal === */
#proposal-overlay {
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  inset: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}
#proposal-overlay > .proposal-dialog {
  max-width: 700px;
  width: 90vw;
  height: auto;
  max-height: 85vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.proposal-detail-content { padding: 16px; overflow-y: auto; flex: 1; }
.proposal-section { margin-bottom: 16px; }
.proposal-section label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; }
.proposal-section p { font-size: 14px; line-height: 1.5; }
.proposal-description { background: var(--bg-primary); padding: 8px 12px; border-radius: 6px; white-space: pre-wrap; font-size: 13px; }

.proposal-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.proposal-input:focus { outline: none; border-color: var(--accent); }
.proposal-input:disabled { opacity: 0.5; cursor: not-allowed; }
textarea.proposal-input { resize: vertical; min-height: 100px; }

.proposal-actions { display: flex; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.btn-save { background: var(--border); color: var(--text-primary); border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; min-height: 44px; }
.btn-save:hover { background: var(--stopped); }
.btn-approve { background: var(--success); color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; min-height: 44px; }
.btn-approve:hover { background: var(--success-hover); }
.btn-reject { background: var(--error); color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; min-height: 44px; }
.btn-reject:hover { background: #f85149; }
.proposal-section a { color: var(--accent); text-decoration: none; }
.proposal-section a:hover { text-decoration: underline; }

/* === Issue Detail Modal === */
#issue-overlay {
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  inset: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}
#issue-overlay > .issue-dialog {
  max-width: 700px;
  width: 90vw;
  height: auto;
  max-height: 85vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.issue-detail-content { padding: 16px; overflow-y: auto; flex: 1; }
.issue-detail-labels { margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px; }
.issue-detail-body { font-size: 14px; line-height: 1.6; color: var(--text-primary); }
.issue-detail-body p { margin-bottom: 8px; }
.issue-detail-body h2, .issue-detail-body h3, .issue-detail-body h4 { margin: 16px 0 8px; color: var(--text-primary); }
.issue-detail-body pre { background: var(--bg-primary); padding: 12px; border-radius: 6px; overflow-x: auto; margin: 8px 0; }
.issue-detail-body code { background: var(--bg-primary); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.issue-detail-body pre code { background: none; padding: 0; }
.issue-detail-body ul { padding-left: 20px; margin: 8px 0; }
.issue-detail-body li { margin-bottom: 4px; }
.issue-detail-body a { color: var(--accent); text-decoration: none; }
.issue-detail-body a:hover { text-decoration: underline; }
.issue-github-link { display: inline-block; margin-top: 16px; padding: 8px 16px; background: var(--border); color: var(--text-primary); border-radius: 6px; text-decoration: none; font-size: 14px; }
.issue-github-link:hover { background: var(--stopped); }

/* === Community View === */
#view-community.active {
  display: block;
  height: calc(100vh - var(--header-h) - var(--main-tabs-h));
  overflow-y: auto;
}

.community-view-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 16px;
}

.community-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.sort-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.sort-btn {
  background: var(--bg-primary);
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.sort-btn:not(:last-child) { border-right: 1px solid var(--border); }
.sort-btn:hover { color: var(--text-primary); }
.sort-btn.active { background: #21262d; color: var(--accent); }

.community-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.community-card:hover { border-color: var(--accent); }

.community-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.community-issue-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.community-card-date {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

.community-card-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.community-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.community-card-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid #21262d;
}

.community-stat {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Admin Comments === */
.proposal-comments-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.proposal-comments-section h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

.admin-comment-item {
  background: var(--bg-primary);
  border: 1px solid #21262d;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.admin-comment-item.comment-admin {
  border-left: 3px solid #f0883e;
  background: #f0883e0a;
}

.admin-comment-item.comment-agent {
  border-left: 3px solid var(--accent);
}

.admin-comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.admin-comment-date {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

.admin-comment-content {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.comment-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.comment-badge-admin {
  background: #f0883e33;
  color: #f0883e;
}

.comment-badge-agent {
  background: #58a6ff33;
  color: var(--accent);
}

.comment-author-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.admin-comment-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #21262d;
}

.admin-comment-form textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  margin-bottom: 8px;
}

.admin-comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.admin-comment-form button {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  min-height: 36px;
}

.admin-comment-form button:hover { background: var(--success-hover); }
.admin-comment-form button:disabled { background: #21262d; color: var(--stopped); cursor: not-allowed; }

/* === Toast === */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--error);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.toast.toast-out { animation: toast-out 0.3s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-12px); }
}
