*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Rethink Sans', sans-serif;
  background: #0e0f11;
  color: #f0f0f0;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Library ── */
.container { max-width: 1100px; margin: 0 auto; padding: 2.5rem 2.5rem 2rem; }

/* ── Stats ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 2rem;
}
.stat-card {
  border-radius: 10px;
  padding: 16px 20px;
  border: 1px solid transparent;
}
.stat-card.total        { background: #16181c; border-color: rgba(255,255,255,0.07); }
.stat-card.finished     { background: rgba(62,207,142,0.07); border-color: rgba(62,207,142,0.22); }
.stat-card.not-finished { background: rgba(255,107,107,0.07); border-color: rgba(255,107,107,0.22); }
.stat-card.in-library   { background: #16181c; border-color: rgba(255,255,255,0.07); }

.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; font-weight: 600; }
.stat-card.total        .stat-label { color: #555; }
.stat-card.finished     .stat-label { color: rgba(62,207,142,0.65); }
.stat-card.not-finished .stat-label { color: rgba(255,107,107,0.65); }
.stat-card.in-library   .stat-label { color: #555; }

.stat-value { font-weight: 800; font-size: 28px; }
.stat-card.total        .stat-value { color: #f0f0f0; }
.stat-card.finished     .stat-value { color: #3ecf8e; }
.stat-card.not-finished .stat-value { color: #ff6b6b; }
.stat-card.in-library   .stat-value { color: #888; }

/* ── Controls ── */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; pointer-events: none; opacity: 0.3;
  stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.search-wrap input {
  width: 100%;
  background: #16181c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0 12px 0 38px;
  height: 40px;
  font-family: 'Rethink Sans', sans-serif;
  font-size: 13px;
  color: #f0f0f0;
  outline: none;
  transition: border-color 0.2s;
}
.search-wrap input::placeholder { color: #555; }
.search-wrap input:focus { border-color: #7750C7; }
.filter-select {
  background: #16181c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0 32px 0 14px;
  height: 40px;
  font-family: 'Rethink Sans', sans-serif;
  font-size: 13px;
  color: #f0f0f0;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s;
}
.filter-select:focus { border-color: #7750C7; }

/* ── Pagination ── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: 1rem 0;
}
.page-info    { order: 1; }
.page-controls{ order: 2; }
.goto-wrap    { order: 3; }
.page-info { font-size: 12px; color: #555; min-width: 120px; }
.page-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn {
  background: #16181c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #888;
  font-family: 'Rethink Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.page-btn:hover:not([disabled]):not(.active) { border-color: #7750C7; color: #7750C7; }
.page-btn[disabled] { opacity: 0.28; cursor: default; }
.page-btn.active { background: #7750C7; border-color: #7750C7; color: #fff; cursor: default; }
.page-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.page-ellipsis { color: #444; font-size: 13px; padding: 0 3px; }

/* Go to page — no spinners */
.goto-wrap { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #555; }
.goto-wrap input[type="text"] {
  width: 52px;
  height: 32px;
  background: #16181c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  text-align: center;
  font-family: 'Rethink Sans', sans-serif;
  font-size: 12px;
  color: #f0f0f0;
  outline: none;
  transition: border-color 0.2s;
}
.goto-wrap input[type="text"]:focus { border-color: #7750C7; }
.goto-btn {
  height: 32px;
  padding: 0 10px;
  background: #16181c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  font-family: 'Rethink Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.goto-btn:hover { border-color: #7750C7; color: #7750C7; }

/* ── Table ── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: #16181c; border-bottom: 1px solid rgba(255,255,255,0.09); }
th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #555;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}
th:hover { color: #7750C7; }
th.sorted { color: #7750C7; }
.sort-arrow { margin-left: 3px; font-size: 10px; }

tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.028); }
tbody tr:hover { background: rgba(255,255,255,0.06); }
td { padding: 10px 14px; vertical-align: middle; }

.col-no     { width: 50px; color: #444; font-size: 12px; }
.col-title  { font-weight: 700; font-size: 13px; }
.col-status { width: 130px; }
.col-appid  { width: 110px; color: #555; font-size: 12px; }
.col-db     { width: 110px; }
.col-exp    { min-width: 140px; font-size: 12px; }

/* Status badge */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 7px;
  white-space: nowrap;
}

/* Experience badge — uses exact Google Sheets colors converted to dark-mode safe versions */
.exp-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 7px;
  white-space: nowrap;
}
/* Dear  → #D6EAF8 bg / #21618C text */
.exp-dear    { background: rgba(86, 170, 230, 0.1); color: #7ec8f7; border: 1px solid rgba(214,234,248,0.2); }
/* Love  → #FCF3CF bg / #B7950B text */
.exp-love    { background: rgba(214, 194, 83, 0.1); color: #e8c040; border: 1px solid rgba(252,243,207,0.18); }
/* Neutral → grey */
.exp-neutral { background: rgba(136,136,136,0.1);  color: #888;    border: 1px solid rgba(136,136,136,0.15); }
/* Hate  → #FADBD8 bg / #C0392B text */
.exp-hate    { background: rgba(194, 85, 85, 0.1); color: #f07070; border: 1px solid rgba(250,219,216,0.18); }
/* fallback */
.exp-default { color: #666; font-size: 12px; }

.db-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #555;
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}
.db-link:hover { color: #7750C7; }
.db-link svg { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.empty { text-align: center; padding: 4rem 2rem; color: #555; font-size: 13px; }

/* ── Loading state ── */
#loading-msg { text-align: center; padding: 6rem 2rem; color: #555; font-size: 14px; }

/* ── Back to top ── */
#back-top {
  position: fixed;
  bottom: 2rem; right: 2rem;
  background: #7750C7;
  border: none; border-radius: 50%;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.2s;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(119,80,199,0.3);
}
#back-top.visible { opacity: 1; pointer-events: auto; }
#back-top:hover { transform: translateY(-2px); }
#back-top svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 99px; }

/* ── Mobile responsive ── */
@media (max-width: 640px) {
  .container { padding: 1.5rem 1.25rem 1.5rem; }

  .stats-bar {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }
  .stat-label { margin-bottom: 0; }
  .stat-value { font-size: 22px; }

  .controls { flex-direction: column; align-items: stretch; }
  .search-wrap { min-width: 0; }

  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .page-controls { justify-content: center; }
  .goto-wrap { justify-content: center; }
  .page-info { text-align: center; }

  /* Top bar: info moves below the buttons/goto, right above the table */
  #pag-top .page-controls { order: 1; }
  #pag-top .goto-wrap { order: 2; }
  #pag-top .page-info { order: 3; }

  /* Bottom bar: keep original reading order (info, then controls, then goto) */
  #pag-bot .page-info { order: 1; }
  #pag-bot .page-controls { order: 2; }
  #pag-bot .goto-wrap { order: 3; }
}
