/* ============================================================
   Design system — variables
   ============================================================ */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --bg:        #f7f7f5;
  --surface:   #ffffff;
  --border:    #e8e8e4;
  --border-2:  #d1d1cb;
  --text:      #1a1a18;
  --text-2:    #6b6b64;
  --text-3:    #a3a39a;

  --accent:       #1a1a18;
  --accent-hover: #3a3a36;

  --radius-s:  5px;
  --radius:    8px;
  --radius-l:  12px;

  --shadow-s:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 16px rgba(0,0,0,.08);

  --h-navbar:  52px;
}

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, select, input { font-family: var(--font); }

/* ============================================================
   Layout helpers
   ============================================================ */
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--h-navbar);
  display: flex;
  align-items: center;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.navbar-brand {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.2px;
  color: var(--text);
}

.navbar-brand span {
  color: var(--text-2);
  font-weight: 400;
}

.navbar-links { display: flex; gap: 2px; }

.nav-link {
  padding: 5px 11px;
  border-radius: var(--radius-s);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: background .12s, color .12s;
}

.nav-link:hover { background: var(--bg); color: var(--text); }

.nav-link.active {
  background: var(--bg);
  color: var(--text);
}

/* ============================================================
   Page header
   ============================================================ */
.page-header {
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
  line-height: 1.25;
}

.page-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-2);
}

/* ============================================================
   Panel
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 18px 20px;
  margin-bottom: 14px;
}

.panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ============================================================
   Inputs & selects
   ============================================================ */
input:not([type="checkbox"]), select {
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}

input:not([type="checkbox"]):focus, select:focus {
  border-color: var(--border-2);
}

input::placeholder { color: var(--text-3); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23a3a39a' d='M5 6 0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
  cursor: pointer;
}

.input-search {
  flex: 1;
  min-width: 240px;
}

.input-tag-filter {
  width: 100%;
  margin-bottom: 12px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-s);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-2);
}

/* ============================================================
   Tags
   ============================================================ */
.tag-groups { padding: 4px 0 8px; }

.chapter { margin-bottom: 12px; }

.chapter-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-3);
  margin-bottom: 6px;
}

.tags { display: flex; flex-wrap: wrap; gap: 5px; }

.tag {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
  display: inline-flex;
  align-items: center;
}

.tag:hover { border-color: var(--border-2); color: var(--text); }

.tag.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================
   Filters row + status bar
   ============================================================ */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.status-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.count-label {
  flex: 1;
  font-size: 13px;
  color: var(--text-2);
}

.inline-check {
  display: flex;
  gap: 7px;
  align-items: center;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.inline-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.sel-count {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 6px;
}

/* ============================================================
   Results grid & cards
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
  padding-bottom: 32px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: border-color .15s, box-shadow .15s;
}

.card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-s);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  line-height: 1.45;
}

.card-meta {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 2px;
}

.card-raw {
  font-size: 13px;
  color: var(--text);
  margin: 6px 0 0;
  line-height: 1.5;
  flex: 1;
}

.card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.card-actions .btn { height: 30px; font-size: 12px; padding: 0 11px; }

.card-actions select {
  height: 30px;
  font-size: 12px;
  padding: 0 28px 0 9px;
}

/* ============================================================
   Generator specific
   ============================================================ */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.results-title { font-size: 15px; font-weight: 600; }

.points-total { font-size: 13px; font-weight: 600; color: var(--text-2); }

.coverage { font-size: 13px; color: var(--text-2); margin-bottom: 14px; }

/* ============================================================
   Stats page
   ============================================================ */
.stats-summary {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 16px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}

.stats-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f2f2ef;
  font-size: 13px;
  vertical-align: middle;
}

.stats-table tr:last-child td { border-bottom: none; }

.stats-table tbody tr:hover td { background: var(--bg); }

.bar-wrap {
  width: 160px;
  height: 8px;
  background: #ededea;
  border-radius: 4px;
  overflow: hidden;
}

.bar {
  height: 8px;
  border-radius: 4px;
  background: var(--accent);
  transition: width .3s;
}

.stats-zero { color: var(--text-3); }
