:root {
  --bg: #0e0f13;
  --bg-card: #181a21;
  --bg-card-hover: #1f222b;
  --border: #2a2d39;
  --text: #e6e8ee;
  --muted: #9aa0ad;
  --accent: #66c0f4;
  --accent-strong: #1b9eff;
  --error: #f08080;
  --ok: #84e184;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #0a0b0f;
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  color: var(--text);
  text-decoration: none;
}
.brand::before { content: "▶ "; color: var(--accent); }
nav { display: flex; align-items: center; gap: 16px; }
nav .nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
nav .nav-link:hover { color: var(--text); }
nav .user { color: var(--muted); }
.avatar { width: 22px; height: 22px; border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.hero { text-align: center; padding: 64px 0; }
.hero h1 { font-size: 44px; margin: 0 0 16px; }
.lede { color: var(--muted); max-width: 640px; margin: 0 auto 32px; font-size: 17px; }
.cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px; }
.fineprint { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--bg-card-hover); }
.btn-primary { background: var(--accent); color: #001624; border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); color: #001624; }
.btn-disabled { color: var(--muted); cursor: not-allowed; }
.btn-logo { font-size: 14px; }

/* Brand-colored sign-in buttons. Colors are pulled from the official
 * brand specs: Steam's primary dark blue (#1B2838) and Xbox's flagship
 * green (#107C10). White text + white SVG via currentColor. */
.btn-steam {
  background: #1B2838;
  color: #ffffff;
  border-color: transparent;
  font-weight: 600;
}
.btn-steam:hover { background: #2A475E; color: #ffffff; }
.btn-xbox {
  background: #107C10;
  color: #ffffff;
  border-color: transparent;
  font-weight: 600;
}
.btn-xbox:hover { background: #0E6A0E; color: #ffffff; }

/* SVG icons inherit currentColor by default so they sit on top of
 * brand-colored buttons in white. In chip contexts (muted background)
 * we re-tint via the chip-<provider> class. */
.provider-icon { vertical-align: -2px; }
.chip-steam .provider-icon { color: #66C0F4; }    /* Steam UI accent */
.chip-xbox .provider-icon  { color: #107C10; }    /* Xbox green */

.summary h1 { margin: 0 0 8px; }
.meta { color: var(--muted); font-size: 14px; }
.actions { margin: 16px 0; display: flex; align-items: center; gap: 12px; }
.htmx-indicator { display: none; color: var(--muted); }
/* htmx adds .htmx-request to the requesting element AND, when hx-indicator
 * targets a separate element, to the indicator itself. Cover both: the
 * indicator-as-descendant case and the indicator-as-sibling case. */
.htmx-request .htmx-indicator,
.htmx-indicator.htmx-request { display: inline-block; }
.htmx-request.disabled,
.htmx-request[disabled] { opacity: 0.6; cursor: progress; }

.progress-bar {
  display: inline-block;
  width: 220px;
  height: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
}
.progress-bar-fill {
  display: block;
  width: 30%;
  height: 100%;
  background: var(--accent);
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(420%); }
}

.account-chips { list-style: none; padding: 0; margin: 12px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
  margin: 2px 4px 2px 0;
}
.chip .meta { color: var(--muted); font-size: 11px; }
.chip a { color: var(--muted); text-decoration: none; padding-left: 4px; }
.chip a:hover { color: var(--error); }

.prose { max-width: 720px; }
.prose h2 { margin-top: 32px; }
.prose ul { padding-left: 20px; }
.prose code {
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13px;
}

.confirm-page { max-width: 540px; margin: 48px auto; }
.confirm-page h1 { margin-top: 0; }
.confirm-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.btn-danger { background: var(--error); color: #1a0606; border-color: transparent; font-weight: 600; }
.btn-danger:hover { background: #d76060; color: #1a0606; }

.linked-accounts { margin-top: 36px; }
.provider-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.provider-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.provider-name { font-weight: 600; width: 140px; }
.provider-accounts { color: var(--muted); }
.provider-action { text-align: right; width: 160px; }
.btn-small { padding: 5px 12px; font-size: 13px; }

.recommendations { margin-top: 48px; }
.rec-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.rec-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.rec-card:hover { background: var(--bg-card-hover); }
.rec-icon { width: 40px; height: 40px; border-radius: 4px; }
.rec-body { display: flex; flex-direction: column; }
.rec-name { font-weight: 600; }
.rec-score { color: var(--muted); font-size: 12px; }

.library { margin-top: 48px; }
.games { width: 100%; border-collapse: collapse; margin-top: 12px; }
.games th, .games td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.games th { color: var(--muted); font-weight: 500; font-size: 13px; }
.games td.num, .games th.num { text-align: right; font-variant-numeric: tabular-nums; }
.game-icon { width: 24px; height: 24px; border-radius: 4px; }

.sortable-header {
  cursor: pointer;
  user-select: none;
}
.sortable-header:hover { color: var(--text); }
.sortable-header.sort-asc::after { content: " ▲"; font-size: 10px; color: var(--accent); }
.sortable-header.sort-desc::after { content: " ▼"; font-size: 10px; color: var(--accent); }

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.pagination .meta { color: var(--muted); font-size: 13px; }

.manual-add {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}
.manual-add input[type="text"] {
  flex: 1;
  min-width: 220px;
  padding: 8px 10px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.manual-add select {
  padding: 8px 10px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.rating-cell { white-space: nowrap; }
.rating-buttons { display: inline-flex; gap: 4px; margin-right: 6px; vertical-align: middle; }
.rate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  padding: 0;
}
.rate-btn:hover { background: var(--bg-card-hover); color: var(--text); }
.rate-like.active   { background: #1c4a23; color: #b9f0c2; border-color: #266a31; }
.rate-dislike.active{ background: #4a1c1c; color: #f0bcbc; border-color: #6a2626; }
.rate-exclude.active{ background: #3a3a1c; color: #f0e7bc; border-color: #5a5326; }

.llm-fallback {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-top: 12px;
}
.llm-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--muted);
}
.llm-controls label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.llm-controls input[type="range"] { flex: 1; max-width: 320px; min-width: 180px; }
.llm-controls strong { color: var(--text); }
.llm-cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.llm-prompt summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}
.llm-prompt summary:hover { color: var(--text); }
.llm-prompt pre {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  color: var(--text);
}

.empty {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 16px;
  color: var(--muted);
}
.error { color: var(--error); }
.ok { color: var(--ok); }

.error-page {
  max-width: 540px;
  margin: 64px auto;
  text-align: center;
}
.error-code {
  font-size: 80px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -2px;
  line-height: 1;
}
.error-page h1 {
  margin: 8px 0 16px;
  font-weight: 500;
}
.error-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--muted);
  text-align: left;
  margin: 16px 0 24px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-word;
}
.error-page .btn { margin: 0 4px; }

.footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
}

/* Wrap wide tables so they scroll within their column instead of
 * forcing the whole page to scroll horizontally on small viewports. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 720px) {
  .topbar {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  nav { gap: 10px; flex-wrap: wrap; }
  /* The persona is also visible on the dashboard summary; hiding the
   * topbar copy buys nav some room on narrow screens. */
  nav .user { display: none; }

  .container { padding: 20px 14px 48px; }

  .hero { padding: 40px 0 32px; }
  .hero h1 { font-size: 32px; }
  .lede { font-size: 15px; }

  .summary h1 { font-size: 26px; }
  .recommendations h2,
  .linked-accounts h2,
  .library h2 { font-size: 20px; }

  /* Provider table stacks: each provider becomes a card-like block
   * so chips and the link button don't fight for a 3-column grid. */
  .provider-table,
  .provider-table tbody,
  .provider-table tr,
  .provider-table td { display: block; width: auto; }
  .provider-table tr {
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
  }
  .provider-table td { border-bottom: none; padding: 4px 0; }
  .provider-name { width: auto; }
  .provider-action { text-align: left; width: auto; }

  /* Sync action: button + indicator + status share rows instead of
   * a too-wide single line. */
  .actions { flex-wrap: wrap; }
  .progress-bar { width: 160px; }

  /* Manual-add: stack so the input gets the full width. */
  .manual-add input[type="text"] { min-width: 0; width: 100%; }
}
