:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface-raised: #202020;
  --border: #2a2a2a;
  --primary: #5e6ad2;
  --primary-strong: #7580e8;
  --cyan: #26b5ce;
  --text: #efefef;
  --text-muted: #888888;
  --success: #30a46c;
  --warning: #f5a623;
  --danger: #e5484d;
  --radius: 8px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  background: rgba(13, 13, 13, 0.96);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 720;
}

h2 {
  font-size: 22px;
  font-weight: 720;
}

h3 {
  font-size: 15px;
  font-weight: 700;
}

p {
  color: var(--text-muted);
  line-height: 1.5;
}

.connection-row,
.topbar-actions,
.button-row,
.output-toolbar,
.modal-header {
  display: flex;
  align-items: center;
}

.connection-row {
  gap: 8px;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.14);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(48, 164, 108, 0.14);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.14);
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #111111;
  padding: 16px 10px;
}

.nav-item {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--surface);
  color: var(--text);
}

.nav-icon {
  width: 20px;
  color: var(--primary-strong);
  text-align: center;
}

.main-content {
  padding: 24px;
  min-width: 0;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.view-header p {
  margin-top: 6px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--text);
  padding: 0 14px;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.primary-button {
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button,
.icon-button {
  background: var(--surface);
  border-color: var(--border);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: #3a3a3a;
  background: var(--surface-raised);
}

.danger-button {
  background: rgba(229, 72, 77, 0.14);
  border-color: rgba(229, 72, 77, 0.42);
}

.danger-button:hover {
  background: rgba(229, 72, 77, 0.22);
}

.icon-button {
  width: 38px;
  padding: 0;
  display: grid;
  place-items: center;
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.board-columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.board-column {
  min-width: 220px;
  background: #121212;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.column-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.issue-card {
  width: 100%;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  padding: 12px;
  margin-bottom: 10px;
}

.issue-card:hover,
.issue-card.selected {
  border-color: var(--primary);
  background: #20212d;
}

.issue-id {
  color: var(--text-muted);
  font-size: 12px;
}

.issue-title {
  margin-top: 6px;
  line-height: 1.35;
  font-weight: 650;
}

.issue-footer,
.label-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 2px 8px;
  color: var(--text);
  background: #141414;
  font-size: 12px;
}

.badge.muted {
  color: var(--text-muted);
}

.detail-panel,
.form-panel,
.prompt-output,
.session-banner {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.detail-panel {
  min-height: 420px;
  padding: 18px;
  position: sticky;
  top: 100px;
}

.detail-panel h3 {
  font-size: 19px;
  line-height: 1.3;
}

.detail-description {
  margin: 14px 0;
  white-space: pre-wrap;
}

.detail-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  text-align: center;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: #101010;
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
}

.chat-messages {
  height: calc(100vh - 276px);
  min-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #101010;
  padding: 18px;
}

.message {
  max-width: 78%;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  line-height: 1.5;
}

.message.user {
  margin-left: auto;
  background: var(--primary);
}

.message.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: 14px;
  align-items: end;
}

.session-banner {
  padding: 14px;
  margin-bottom: 14px;
  border-color: rgba(94, 106, 210, 0.42);
  background: rgba(94, 106, 210, 0.1);
}

.prompt-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.form-panel,
.prompt-output {
  padding: 18px;
}

.form-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.flat-panel {
  border: 0;
  padding: 0;
  background: transparent;
}

.prompt-output {
  min-width: 0;
}

.output-toolbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

#issueTitle {
  margin-left: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

pre {
  min-height: 430px;
  max-height: 58vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0f0f0f;
  color: #dedede;
  padding: 16px;
  line-height: 1.5;
}

.metadata-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.metadata-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.metadata-block strong {
  display: block;
  margin-bottom: 8px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 18px;
}

.button-row {
  gap: 10px;
}

.danger-panel {
  border-color: rgba(229, 72, 77, 0.36);
}

.setup-result {
  color: var(--text-muted);
  line-height: 1.5;
}

.checklist {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.checklist li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: #121212;
}

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 40;
}

.toast {
  width: min(360px, calc(100vw - 40px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.toast.error {
  border-color: rgba(229, 72, 77, 0.46);
}

.toast.success {
  border-color: rgba(48, 164, 108, 0.46);
}

dialog {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 18px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-content {
  display: grid;
  gap: 14px;
  max-height: 70vh;
  overflow: auto;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .board-layout,
  .prompt-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    padding: 16px;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-item {
    min-width: 120px;
  }

  .main-content {
    padding: 16px;
  }

  .board-columns,
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .chat-form,
  .view-header {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .message {
    max-width: 100%;
  }
}
