:root {
  /* Colors tretes de la capçalera i la icona de @Qunnum */
  --bg: #000000;
  --panel: #050d22;
  --panel-2: #0a1a3d;
  --line: #13244a;
  --text: #eef3ff;
  --muted: #8794b4;
  --accent: #4b8fe8;
  --accent-2: #2967ba;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* Capçalera */
.top {
  position: sticky; top: 0; z-index: 5;
  background: rgba(0, 0, 0, .78); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-in { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.menu { position: relative; }
.menu-btn {
  position: relative; width: 20px; height: 20px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 50%;
}
/* zona de toc una mica més gran que la icona, perquè al mòbil es pugui prémer bé */
.menu-btn::before { content: ""; position: absolute; inset: -8px; }
.menu-btn:hover { color: var(--text); }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--panel-2); border-color: var(--line); }
.menu-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 20; min-width: 120px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
}
.menu-panel[hidden] { display: none; }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px; border-radius: 6px; font-size: 11px; color: var(--muted); cursor: pointer; }
.menu-item:hover { background: var(--panel-2); }
.menu-item input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 22px; height: 12px; border-radius: 999px; background: var(--line); transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.menu-item input:checked + .switch { background: var(--accent-2); }
.menu-item input:checked + .switch::after { transform: translateX(10px); background: #fff; }
.menu-item input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Fletxa per anar a dalt / a baix */
.jump {
  position: fixed; left: 50%; bottom: 20px; z-index: 15; transform: translateX(-50%);
  width: 46px; height: 46px; display: grid; place-items: center; cursor: pointer;
  background: rgba(10, 26, 61, .92); color: var(--text); border: 1px solid var(--accent-2); border-radius: 50%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity .2s, transform .2s;
}
.jump[hidden] { display: none; }
.jump:hover { background: var(--accent-2); }
.jump.up svg { transform: rotate(180deg); }
/* Quan es puja, la fletxa va a dalt (just sota la barra superior) */
.jump.up { bottom: auto; top: 72px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.mark { width: 34px; height: 34px; border-radius: 50%; display: block; box-shadow: 0 0 0 1px var(--line); }
.word { font-weight: 800; font-size: 22px; letter-spacing: .5px; }
.refresh {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--text); color: var(--bg); border: 0; border-radius: 999px;
  padding: 8px 16px; font: inherit; font-weight: 700; font-size: 15px;
}
.refresh:hover { background: #fff; }
.refresh .ico-stop { display: none; }
.refresh.loading { background: #ff6b6b; color: #fff; }
.refresh.loading .ico-stop { display: inline; }
.refresh.loading .ico-refresh { display: none; }
.actions { display: flex; align-items: center; gap: 10px; }
.count { position: relative; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.count-btn {
  display: inline-flex; align-items: center; gap: 4px; min-width: 70px; justify-content: space-between;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 10px 7px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.count-btn:hover, .count-btn[aria-expanded="true"] { border-color: var(--accent); }
.count-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; margin: 0; padding: 4px; list-style: none;
  min-width: 84px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
}
.count-menu[hidden] { display: none; }
.count-menu li { padding: 7px 12px; border-radius: 8px; color: var(--text); font-size: 14px; cursor: pointer; text-align: right; }
.count-menu li:hover, .count-menu li.focus { background: var(--panel-2); }
.count-menu li[aria-selected="true"] { color: var(--accent); font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Capçalera: la mateixa imatge que el perfil d'X */
.hero { position: relative; max-width: 1500px; margin: 0 auto; overflow: hidden; }
/* En pantalles més amples que la imatge, els laterals es fonen amb el negre */
@media (min-width: 1500px) {
  .hero img { -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
}
.hero img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; min-height: 150px; max-height: 300px; object-fit: cover; object-position: center 40%; }
.hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 35%; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }

.intro { padding: 10px 0 6px; }
.intro h1 { margin: 0 0 4px; font-size: 24px; }
.intro p { margin: 0; color: var(--muted); font-size: 15px; }

.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; padding: 14px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.status.busy .dot { animation: pulse 1.2s ease-in-out infinite; }
.status.done .dot { background: #3ecf8e; }
@keyframes pulse { 50% { opacity: .25; } }

/* Targetes */
.feed { display: flex; flex-direction: column; }
.card { padding: 14px 0 18px; border-top: 1px solid var(--line); }
.card-title { font-size: 16px; line-height: 1.4; margin: 0; font-weight: 500; color: var(--text); }
.card-title a { color: var(--text); }
.card-title > a:hover { color: #fff; text-decoration: none; }
.card:hover .thumb { border-color: var(--accent-2); }
.who { color: var(--accent); }
.who a { color: var(--accent); }
.who .nolink { color: #b9c3dc; }   /* nom de l'autor sense compte d'X: no és un enllaç */
.when { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.when b { color: var(--text); font-weight: 700; }
.when .src { font-weight: 700; }
.when a.src { color: var(--accent); }   /* mitjà enllaçat al seu compte d'X */
.when .site { color: var(--muted); }
.when .site:hover { color: var(--accent); }
.thumb {
  display: block; margin-top: 10px; border: 1px solid var(--line); transition: border-color .2s; border-radius: var(--radius);
  overflow: hidden; background: var(--panel); position: relative; aspect-ratio: 1.91 / 1;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .cap {
  position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px);
  background: rgba(0, 0, 0, .72); color: #fff; font-size: 13px; padding: 2px 8px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb.noimg { aspect-ratio: auto; padding: 14px 16px; background: var(--panel-2); }
.thumb.noimg .cap { position: static; background: none; padding: 0; white-space: normal; font-size: 15px; }
.from { color: var(--muted); font-size: 13px; margin-top: 6px; }

.more {
  display: block; width: 100%; margin: 4px 0 24px; padding: 14px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-weight: 700; font-size: 15px;
}
.more[hidden] { display: none; }
.more-refresh { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--text); color: var(--bg); border-color: var(--text); }
.more-refresh[hidden] { display: none; }
.more.more-refresh:hover { background: #fff; color: var(--bg); }
.more:hover { border-color: var(--accent); color: #fff; box-shadow: 0 0 18px rgba(75, 143, 232, .25); }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.foot { color: var(--muted); font-size: 13px; padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--line); margin-top: 8px; }
.foot p { margin: 0 0 6px; }

@media (max-width: 370px) {
  .word { display: none; }
}
@media (max-width: 480px) {
  .word { font-size: 20px; }
  .left { gap: 4px; }

  .refresh span { display: none; }
  .refresh { padding: 9px; }
  .actions { gap: 8px; }
  .count-btn { min-width: 64px; padding: 7px 8px 7px 12px; }
}

/* Mode diagnòstic (?debug) */
.srclog { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.srclog summary { cursor: pointer; color: var(--text); }
.srclog ul { margin: 8px 0 0; padding-left: 18px; }
.srclog li { margin: 2px 0; }
.srclog i { color: var(--accent-2); font-style: normal; }
