:root {
  --bg: #faf9f7;
  --bg-elevated: #ffffff;
  --bg-sunken: #f2f1ee;
  --text: #1a1a17;
  --text-muted: #71716a;
  --text-faint: #a3a39a;
  --border: #e5e3dd;
  --border-strong: #d3d1c8;
  --accent: #4550b0;
  --accent-hover: #383f92;
  --accent-soft: #eceeff;
  --critical: #a8433a;
  --critical-soft: #f7e9e7;
  --warning: #a4762f;
  --warning-soft: #f6efe1;
  --info: #5f6570;
  --info-soft: #ececee;
  --fixed: #4a7a55;
  --fixed-soft: #e9f0ea;
  --wontfix: #8b8a80;
  --radius: 8px;
  --shadow-card: 0 1px 2px rgba(20, 20, 15, 0.04);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171713;
    --bg-elevated: #1e1e1a;
    --bg-sunken: #131311;
    --text: #ececE5;
    --text-muted: #9a9a90;
    --text-faint: #6c6c62;
    --border: #2c2c26;
    --border-strong: #38382f;
    --accent: #7885e6;
    --accent-hover: #8f9aef;
    --accent-soft: #24284a;
    --critical: #d98a80;
    --critical-soft: #372422;
    --warning: #d3ab6c;
    --warning-soft: #362c1c;
    --info: #a7abb4;
    --info-soft: #26262a;
    --fixed: #8fc09a;
    --fixed-soft: #21301f;
    --wontfix: #7c7b71;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.topbar__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand__logo {
  width: 22px; height: 22px;
  display: block;
}
.brand__name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.topbar__status {
  font-size: 12px;
  color: var(--text-muted);
}

/* Layout */

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.view-header__actions { display: flex; gap: 8px; flex-shrink: 0; }
.view-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.view-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}
.project-title-input {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 4px 8px;
  margin-bottom: 4px;
  min-width: 260px;
}
.project-title-input:not([hidden]) { display: block; }
.project-urls {
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.project-urls:not([hidden]) { display: flex; }
.project-urls__sep { color: var(--text-faint); }
.project-urls-edit { margin-top: 6px; }
.project-urls-edit__rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.project-urls-edit__row { display: flex; align-items: center; gap: 6px; }
.project-urls-edit__row .input { flex: 1; }

/* Buttons */

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 14px;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn--small { padding: 6px 10px; font-size: 12px; }
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--secondary:hover { border-color: var(--accent); }
.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn--ghost:hover { color: var(--text); border-color: var(--border-strong); }

.back-link { margin-bottom: 16px; }

/* Inputs */

.input, .select {
  font-family: inherit;
  font-size: 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text);
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Setup view */

#view-setup:not([hidden]) { display: flex; justify-content: center; padding-top: 60px; }
.setup-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px;
}
.setup-card__title { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.setup-card__hint { font-size: 13px; color: var(--text-muted); margin: 0 0 24px; }
.setup-step { margin-bottom: 20px; }
.setup-step__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.setup-step__row { display: flex; gap: 8px; }
.setup-step__row .input { flex: 1; }
.setup-step__done { font-size: 12px; color: var(--fixed); font-weight: 500; }
.setup-card__error { font-size: 12px; color: var(--critical); margin: 12px 0 0; }

/* How-it-works panel */

.howto {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-card);
  margin-top: 24px;
}
.howto__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.howto__chevron {
  color: var(--text-faint);
  font-size: 11px;
  transition: transform 150ms ease;
}
.howto[data-collapsed="true"] .howto__chevron { transform: rotate(-90deg); }
.howto[data-collapsed="true"] .howto__steps { display: none; }
.howto__steps {
  display: flex;
  align-items: flex-start;
  padding: 2px 20px 22px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.howto__step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-right: 20px;
}
.howto__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.howto__icon svg { width: 17px; height: 17px; }
.howto__step-title { font-size: 13px; font-weight: 600; color: var(--text); }
.howto__step-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
@media (max-width: 720px) {
  .howto__steps { flex-direction: column; gap: 18px; }
  .howto__step { padding-right: 0; }
}

/* Project grid */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: border-color 150ms ease;
}
.project-card:hover { border-color: var(--border-strong); }
.project-card__name { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.project-card__url { font-size: 12px; color: var(--text-muted); margin: 0 0 16px; }
.project-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 14px;
}
.project-card__chips { display: flex; gap: 6px; flex-wrap: wrap; }
.project-card__trend { font-size: 12px; margin-top: 8px; color: var(--text-muted); }

/* Chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 12px;
  line-height: 1.4;
}
.chip--critical { background: var(--critical-soft); color: var(--critical); }
.chip--warning { background: var(--warning-soft); color: var(--warning); }
.chip--info { background: var(--info-soft); color: var(--info); }
.chip--fixed { background: var(--fixed-soft); color: var(--fixed); }
.chip--wontfix { background: var(--bg-sunken); color: var(--wontfix); }
.chip--open { background: var(--bg-sunken); color: var(--text-muted); }
.chip--acknowledged { background: var(--warning-soft); color: var(--warning); }
.chip--new { background: var(--accent-soft); color: var(--accent); }
.chip--resolved { background: var(--fixed-soft); color: var(--fixed); }
.chip--persisting { background: var(--bg-sunken); color: var(--text-muted); }

/* Version tabs */

.version-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.version-tab {
  font-size: 13px;
  padding: 8px 4px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  font-family: inherit;
}
.version-tab--active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Toolbar */

.toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 12px; color: var(--text-muted); }
.toolbar__spacer { flex: 1; }
.export-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Issue table */

.issue-table-wrap { overflow-x: auto; }
.issue-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.issue-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.issue-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.issue-table tr:last-child td { border-bottom: none; }
.col-check { width: 32px; }
.col-severity { width: 90px; }
.col-badge { width: 90px; }
.col-page { width: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-muted); }
.col-shot { width: 60px; }
.col-status { width: 210px; }

.status-select { font-weight: 500; width: 100%; }
.status-select--open { color: var(--text-muted); border-color: var(--border-strong); background: var(--bg-elevated); }
.status-select--fixed { color: var(--fixed); border-color: var(--fixed); background: var(--fixed-soft); }
.status-select--acknowledged { color: var(--warning); border-color: var(--warning); background: var(--warning-soft); }
.status-select--wont-fix { color: var(--wontfix); border-color: var(--border-strong); background: var(--bg-sunken); }

.note-input {
  width: 100%;
  margin-top: 6px;
  font-size: 12px;
  padding: 5px 8px;
}
.note-input::placeholder { color: var(--text-faint); }
.issue-desc { color: var(--text); }
.issue-note { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

.shot-thumb {
  width: 48px; height: 32px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  display: block;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 0;
}

/* Lightbox */

.lightbox {
  position: fixed; inset: 0;
  z-index: 100;
}
.lightbox:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox__backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 10, 8, 0.72);
}
.lightbox__content {
  position: relative;
  max-width: 90vw; max-height: 86vh;
}
.lightbox__img {
  max-width: 90vw; max-height: 86vh;
  border-radius: 6px;
  display: block;
}
.lightbox__close {
  position: absolute; top: -14px; right: -14px;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.view[hidden] { display: none; }
