:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f8fafc;
  color: #0f172a;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --surface-tint: #f0f9ff;
  --border: #cbd5e1;
  --border-soft: rgba(148, 163, 184, 0.32);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0284c7;
  --accent-dark: #075985;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #e0f2fe 0, rgba(224, 242, 254, 0) 280px),
    var(--bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: rgba(2, 132, 199, 0.16);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  padding: 0 14px;
  font-weight: 750;
  touch-action: manipulation;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

button:active {
  transform: translateY(1px);
}

a {
  color: inherit;
  touch-action: manipulation;
}

button,
a,
input,
textarea {
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease,
    transform 120ms ease;
}

button:hover {
  background: #1e293b;
}

a:hover {
  color: var(--accent-dark);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.34);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  z-index: 100;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  overflow: hidden;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 14px calc(18px + env(safe-area-inset-left));
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(18px);
}

.brand,
.panel-head,
.top-actions,
.capture-head,
.screen-actions,
.request-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--text);
  color: var(--surface);
  font-size: 20px;
  font-weight: 850;
}

.brand h1,
.panel-head h2,
.capture-head h2,
.auth-card h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.1;
  text-wrap: balance;
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions {
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
  font-size: 20px;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  font-weight: 750;
  text-decoration: none;
}

.ghost {
  border: 1px solid #e2e8f0;
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover,
.ghost:hover {
  border-color: #7dd3fc;
  background: var(--surface-tint);
  color: var(--accent-dark);
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.app-view {
  width: 100%;
}

.inbox-view {
  display: grid;
  gap: 14px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.inbox-view .metrics {
  margin-bottom: 0;
}

.metric {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 12px;
  min-width: 0;
}

.metric-value {
  display: block;
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-label {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.inbox-grid {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.inbox-panel,
.detail-panel,
.request-card,
.timeline,
.auth-card {
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
}

.inbox-panel {
  position: sticky;
  top: 84px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  height: calc(100vh - 102px);
  max-height: calc(100vh - 102px);
  overflow: hidden;
  padding: 14px;
}

.inbox-screen {
  position: static;
  top: auto;
  height: calc(100svh - 214px);
  max-height: none;
}

.panel-head,
.capture-head {
  justify-content: space-between;
  gap: 12px;
}

.screen-actions {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel-head h2,
.capture-head h2,
.auth-card h2 {
  font-size: 18px;
  line-height: 1.2;
  text-wrap: balance;
}

.compact h2 {
  font-size: 16px;
}

.count-pill {
  min-width: 34px;
  border-radius: 999px;
  background: #e0f2fe;
  color: var(--accent-dark);
  padding: 5px 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 11px 12px;
}

input:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

textarea {
  min-height: 142px;
  resize: vertical;
}

.segmented,
.preset-grid {
  display: grid;
  gap: 6px;
}

.segmented {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-radius: 9px;
  background: #e2e8f0;
  padding: 4px;
}

.segment {
  min-height: 34px;
  border-radius: 7px;
  background: transparent;
  color: #475569;
  padding: 0 6px;
  font-size: 12px;
}

.segment:hover {
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
}

.segment.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.issue-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.issue-item {
  display: grid;
  gap: 6px;
  width: 100%;
  height: auto;
  min-height: 110px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 11px;
  text-align: left;
  content-visibility: auto;
  contain-intrinsic-size: 112px;
}

.issue-item:hover {
  border-color: #bae6fd;
  background: var(--surface-tint);
}

.issue-item.is-selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.issue-topline,
.label-row,
.comment header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.issue-topline {
  justify-content: space-between;
}

.issue-number,
.issue-source,
.issue-updated,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.issue-number {
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.issue-title {
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1.35;
}

.issue-source,
.issue-updated {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-chip,
.label-badge {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.state-chip.fresh {
  background: #dcfce7;
  color: #166534;
}

.state-chip.research {
  background: #e0f2fe;
  color: #075985;
}

.state-chip.waiting {
  background: #fef3c7;
  color: #92400e;
}

.detail-panel {
  width: min(920px, 100%);
  margin: 0 auto;
  min-height: calc(100vh - 146px);
  padding: 14px;
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: 380px;
  text-align: center;
}

.capture {
  display: grid;
  gap: 14px;
}

.capture-head {
  align-items: flex-start;
}

.capture-head h2 {
  max-width: 900px;
  overflow-wrap: anywhere;
  font-size: 23px;
  text-wrap: balance;
}

.label-row {
  flex-wrap: wrap;
}

.label-badge {
  background: var(--surface-muted);
  color: #334155;
}

.markdown-body pre {
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.55;
}

.capture-body {
  overflow: auto;
  overflow-wrap: anywhere;
  max-height: 340px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: var(--bg);
  padding: 14px;
  font-size: 14px;
  line-height: 1.65;
  overscroll-behavior: contain;
}

.request-card,
.timeline {
  display: grid;
  gap: 12px;
  padding: 14px;
  box-shadow: none;
}

.preset-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.preset-grid button {
  border: 1px solid #bae6fd;
  background: var(--surface-tint);
  color: var(--accent-dark);
  font-size: 13px;
  min-width: 0;
}

.preset-grid button:hover {
  border-color: #38bdf8;
  background: #e0f2fe;
}

.request-actions {
  justify-content: space-between;
  gap: 10px;
}

.comments {
  display: grid;
  gap: 10px;
}

.comment {
  display: grid;
  gap: 8px;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
  content-visibility: auto;
  contain-intrinsic-size: 140px;
}

.comment:first-child {
  border-top: 0;
  padding-top: 0;
}

.comment header {
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.comment-meta {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  overflow-wrap: anywhere;
}

.comment-copy {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  min-height: 34px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: var(--surface);
  color: #475569;
  padding: 0;
}

.comment-copy:hover,
.comment-copy:focus {
  border-color: #7dd3fc;
  color: #075985;
}

.comment-copy svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.markdown-body {
  display: grid;
  gap: 10px;
  color: #1e293b;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  scroll-margin-top: 92px;
  text-wrap: pretty;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote {
  margin: 0;
}

.markdown-body ul,
.markdown-body ol {
  display: grid;
  gap: 6px;
  padding-left: 20px;
}

.markdown-body li {
  padding-left: 2px;
}

.markdown-body a {
  color: #0369a1;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-image-link {
  display: block;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
}

.markdown-image-link img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(520px, 70vh);
  object-fit: contain;
}

.markdown-body code {
  border-radius: 5px;
  background: #e2e8f0;
  color: var(--text);
  padding: 2px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown-body pre {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: var(--bg);
  padding: 12px;
  font-size: 12px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
}

.markdown-body blockquote {
  border-left: 3px solid #38bdf8;
  background: #f0f9ff;
  color: #334155;
  padding: 10px 12px;
}

.markdown-body hr {
  width: 100%;
  height: 1px;
  border: 0;
  background: #e2e8f0;
}

.list-empty {
  margin: 0;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.auth-dialog {
  width: min(480px, calc(100% - 28px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: transparent;
  overscroll-behavior: contain;
}

.auth-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.auth-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.auth-card header,
.auth-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

.repo-lock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px;
  color: #475569;
  min-width: 0;
}

.repo-lock strong {
  color: var(--text);
  overflow-wrap: anywhere;
  text-align: right;
}

.status {
  position: sticky;
  bottom: 0;
  z-index: 9;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255, 255, 255, 0.94);
  color: #334155;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  font-size: 13px;
  backdrop-filter: blur(14px);
  overflow-wrap: anywhere;
}

.status[data-error="true"] {
  color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 920px) {
  .inbox-grid {
    grid-template-columns: 1fr;
  }

  .inbox-panel {
    position: static;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    height: min(560px, calc(100svh - 120px));
    max-height: min(560px, calc(100svh - 120px));
  }

  .inbox-screen {
    height: calc(100svh - 214px);
    max-height: none;
  }

  .issue-list {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 12px calc(12px + env(safe-area-inset-left));
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .shell {
    padding: 10px max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left));
  }

  .metrics,
  .preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inbox-panel {
    height: min(520px, calc(100svh - 112px));
    max-height: min(520px, calc(100svh - 112px));
  }

  .capture-head,
  .screen-actions,
  .request-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .capture-head .secondary-button,
  .screen-actions .secondary-button,
  .request-actions button {
    width: 100%;
  }

  .repo-lock {
    align-items: flex-start;
    flex-direction: column;
  }

  .repo-lock strong {
    text-align: left;
  }
}
