:root {
  --bg: #ffffff;
  --fg: #0b0f17;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --card: #f7f8fa;
  --border: #e5e7eb;
  --error: #dc2626;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --fg: #f3f4f6;
    --muted: #9ca3af;
    --accent: #60a5fa;
    --accent-fg: #0b0f17;
    --card: #111827;
    --border: #1f2937;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  z-index: 10;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.35s cubic-bezier(.2,.8,.2,1);
}

main#root {
  position: relative;
  min-height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 22px 110px;
  max-width: 640px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.screen.leave-up {
  opacity: 0;
  transform: translateY(-20px);
}

.q-counter {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

h1.q-title {
  font-size: 26px;
  font-weight: 650;
  margin: 0 0 12px;
  line-height: 1.25;
}

.suggestion {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14.5px;
  color: var(--fg);
  margin: 8px 0 22px;
  box-shadow: var(--shadow);
}
.suggestion .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.options { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; max-height: 50vh; overflow-y: auto; padding-right: 4px; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--bg);
  transition: border-color .15s ease, background .15s ease, transform .05s ease;
  user-select: none;
}
.option:hover { border-color: var(--accent); }
.option:active { transform: scale(0.995); }
.option input { display: none; }
.option .marker {
  width: 22px; height: 22px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: border-color .15s ease, background .15s ease;
}
.option.cb .marker { border-radius: 6px; }
.option.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.option.selected .marker { border-color: var(--accent); background: var(--accent); }
.option.selected .marker::after {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent-fg);
}
.option.cb.selected .marker::after {
  content: "";
  width: 12px; height: 12px;
  border-radius: 2px;
  background: var(--accent-fg);
}

.other-input {
  margin-top: 8px;
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  background: var(--bg);
  color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s ease;
}
.other-input:focus { border-color: var(--accent); }

textarea.text-answer {
  width: 100%;
  min-height: 140px;
  padding: 14px 16px;
  font-size: 17px;
  font-family: inherit;
  background: var(--bg);
  color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  resize: vertical;
  transition: border-color .15s ease;
}
textarea.text-answer:focus { border-color: var(--accent); }

.error {
  color: var(--error);
  font-size: 14px;
  margin-top: 10px;
  min-height: 18px;
}

.controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}
.controls .spacer { flex: 1; }

button {
  font: inherit;
  border: none;
  cursor: pointer;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15.5px;
  transition: transform .05s ease, opacity .15s ease, background .15s ease;
}
button:active { transform: scale(0.98); }
button.primary {
  background: var(--accent);
  color: var(--accent-fg);
}
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
}
button.ghost:hover { color: var(--fg); }

.final {
  text-align: center;
}
.final .check {
  font-size: 64px;
  margin-bottom: 8px;
}

.spinner {
  width: 28px; height: 28px;
  margin: 0 auto 10px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

/* ---------------------------------------------------------------- */
/* Dev session view – Jira-like redesign                             */
/* ---------------------------------------------------------------- */

body.dev main#root { overflow: visible; }

.dev-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  min-height: 100dvh;
}

.dev-error { text-align: center; padding: 60px 20px; }
.dev-error-icon { font-size: 48px; margin-bottom: 8px; }
.dev-error-detail { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* Header */
.dev-header { margin-bottom: 20px; }
.dev-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.dev-title {
  font-size: 22px;
  margin: 0;
  font-weight: 650;
}
.dev-goal {
  color: var(--muted);
  font-size: 14.5px;
  margin: 6px 0 0;
}
.dev-progress { margin-top: 10px; }
.dev-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.dev-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width .3s ease;
}
.dev-stats {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 13px;
}
.dev-stat { font-weight: 500; }
.dev-stat.muted { color: var(--muted); }

/* Tabs */
.dev-tabs { display: flex; gap: 4px; }
.dev-tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
}
.dev-tab:hover { color: var(--fg); border-color: var(--accent); }
.dev-tab.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* ---- Board (Kanban) ---- */
.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  align-items: start;
}
@media (max-width: 900px) {
  .board {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}
.board-col {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 120px;
  display: flex;
  flex-direction: column;
}
.board-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.board-col-count {
  background: var(--border);
  color: var(--fg);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}
.board-col-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  max-height: 60vh;
  overflow-y: auto;
}

/* Board card */
.board-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.board-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(37,99,235,.12);
}
.board-card.priority-high { border-left: 3px solid #ef4444; }
.board-card-title {
  font-size: 14px;
  font-weight: 550;
  line-height: 1.35;
  margin-bottom: 6px;
}
.board-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.board-card-priority { font-weight: 500; }
.prio-high { color: #ef4444; }
.prio-low { color: var(--muted); }
.board-card-notes { color: var(--muted); }

/* Board add task */
.board-add-task { padding: 0; }
.board-add-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  background: transparent;
  color: var(--fg);
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s ease;
  box-sizing: border-box;
}
.board-add-input:focus { border-color: var(--accent); }

/* ---- List view ---- */
.list-view { margin-top: 4px; }
.list-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.list-row {
  display: grid;
  grid-template-columns: 140px 1fr 100px 50px;
  align-items: center;
  padding: 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-header {
  background: var(--card);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.list-header .list-cell { padding: 10px 12px; }
.list-row-data {
  cursor: pointer;
  transition: background .12s ease;
}
.list-row-data:hover { background: color-mix(in srgb, var(--accent) 5%, var(--bg)); }
.list-cell {
  padding: 12px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-cell-status { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.list-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-pending { background: #9ca3af; }
.status-dot-in_progress { background: #3b82f6; }
.status-dot-done { background: #10b981; }
.status-dot-blocked { background: #f59e0b; }
.status-dot-cancelled { background: #ef4444; }
.list-cell-title { font-weight: 550; }
.list-cell-notes { text-align: center; color: var(--muted); font-size: 13px; }
.list-prio { font-size: 12px; font-weight: 500; }
.list-add-input {
  margin-top: 12px;
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  background: var(--bg);
  color: var(--fg);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color .15s ease;
}
.list-add-input:focus { border-color: var(--accent); }

/* ---- Task detail panel ---- */
.task-detail {
  max-width: 720px;
}
.td-back {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 0;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 12px;
  display: inline-block;
}
.td-back:hover { color: var(--fg); }
.td-title {
  font-size: 24px;
  font-weight: 650;
  margin: 0 0 20px;
  outline: none;
  border-radius: 6px;
  padding: 4px 6px;
  margin-left: -6px;
}
.td-title:focus {
  background: var(--card);
  box-shadow: 0 0 0 2px var(--accent);
}
.td-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}
.td-field { margin-bottom: 16px; }
.td-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.td-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.td-desc-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color .15s ease;
  box-sizing: border-box;
}
.td-desc-input:focus { border-color: var(--accent); }
.td-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px;
}

/* Comments */
.td-comments {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.td-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  max-height: 50vh;
  overflow-y: auto;
}
.td-comment {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
}
.td-comment-agent { border-left: 3px solid var(--accent); }
.td-comment-user { border-left: 3px solid #10b981; }
.td-comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.td-comment-author {
  font-size: 12.5px;
  font-weight: 600;
}
.td-comment-time {
  font-size: 11px;
  color: var(--muted);
}
.td-comment-text {
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.td-comment-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.td-comment-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
  resize: none;
  min-height: 40px;
  transition: border-color .15s ease;
  box-sizing: border-box;
}
.td-comment-input:focus { border-color: var(--accent); }
.td-comment-send {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: opacity .15s ease;
}
.td-comment-send:disabled { opacity: .5; cursor: not-allowed; }

/* Task detail actions */
.td-actions {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.td-delete {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease;
}
.td-delete:hover { background: color-mix(in srgb, var(--error) 10%, var(--bg)); }

/* ---- Ending banner (Phase 4) ---- */
.ending-banner {
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.ending-icon { font-size: 32px; margin-bottom: 4px; }
.ending-title {
  font-size: 18px;
  font-weight: 650;
  margin: 0 0 10px;
}
.ending-summary {
  font-size: 14px;
  margin-bottom: 14px;
  color: var(--fg);
  line-height: 1.45;
}
.ending-summary-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ending-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  resize: vertical;
  min-height: 60px;
  margin-bottom: 12px;
  box-sizing: border-box;
  transition: border-color .15s ease;
}
.ending-input:focus { border-color: var(--accent); }
.ending-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ending-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: opacity .15s ease;
}
.ending-btn:disabled { opacity: .5; cursor: not-allowed; }
.ending-approve {
  background: #10b981;
  color: #fff;
}
.ending-comment {
  background: var(--accent);
  color: var(--accent-fg);
}
.ending-done {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  padding: 12px;
}

/* Reuse chips from old design */
.chip {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
}
.chip.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* ---------- Inbox ---------- */
body.inbox {
  background: var(--bg);
}
body.inbox main#root {
  position: relative;
  min-height: 100dvh;
  overflow: visible;
}
.inbox-loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px; color: var(--muted);
}
.ix-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.ix-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.ix-header-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ix-title { margin: 0; font-size: 22px; }
.ix-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.ix-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ix-dot.ok { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,0.18); }
.ix-dot.off { background: #9ca3af; }
.ix-badge {
  font-size: 12.5px; color: var(--muted); padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 999px;
}
.ix-section-title { margin: 0 0 10px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.ix-list { display: flex; flex-direction: column; gap: 12px; }
.ix-empty {
  padding: 22px; border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--muted); text-align: center;
}
.ix-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.ix-card-icon { font-size: 26px; text-align: center; }
.ix-card-body { min-width: 0; }
.ix-card-title { font-weight: 600; margin-bottom: 2px; }
.ix-card-text {
  color: var(--muted); font-size: 14.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ix-card-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.ix-tag { padding: 1px 8px; border-radius: 999px; background: var(--border); }
.ix-card-actions { display: flex; gap: 8px; }
.ix-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; font-size: 14px; font-weight: 500;
  border-radius: 10px; border: 1px solid var(--border);
  text-decoration: none; color: inherit; background: transparent;
  cursor: pointer; white-space: nowrap;
}
.ix-btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.ix-btn.ghost { background: transparent; }
.ix-btn:hover { transform: translateY(-1px); }
.ix-progress { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.ix-progress-bar { flex: 1; height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.ix-progress-fill { height: 100%; background: var(--accent); transition: width .3s ease; }
.ix-footer { color: var(--muted); font-size: 12.5px; text-align: center; padding-top: 8px; }

@media (max-width: 560px) {
  .ix-card { grid-template-columns: 36px 1fr; }
  .ix-card-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
