@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Fraunces:ital,opsz,wght@1,9..144,500&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #F4F3EE;
  --panel: #FFFFFF;
  --panel-soft: #EDEBE3;
  --ink: #1F3B38;
  --muted: #728482;
  --teal: #1F5C57;
  --teal-dim: rgba(31,92,87,0.18);
  --coral: #E0714C;
  --line: rgba(31,59,56,0.13);
  --radius: 3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  min-height: 100vh;
}

.brand { font-family: 'Bebas Neue', 'Inter', sans-serif; letter-spacing: 0.04em; text-transform: uppercase; }
.brand .accent { color: var(--teal); }
.brand .script { font-family: 'Fraunces', serif; font-style: italic; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--ink); }

/* ---------- LOGIN ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 40px 32px; max-width: 360px; width: 100%; text-align: center;
  box-shadow: 0 1px 0 rgba(31,59,56,0.03), 0 20px 45px rgba(31,59,56,0.08);
  position: relative;
}
.login-card::before {
  content: '';
  position: absolute; top: 0; left: 20px; right: 20px; height: 3px;
  background: repeating-linear-gradient(90deg, var(--teal-dim) 0 8px, transparent 8px 16px);
}
.login-icon { margin: 4px auto 10px; width: 40px; height: 40px; color: var(--coral); }
.login-card .brand { font-size: 2.4rem; margin: 0 0 2px; color: var(--teal); line-height: 1; }
.tagline { font-family: 'Fraunces', serif; font-style: italic; font-size: 1.05rem; color: var(--coral); margin: 0 0 18px; }

.login-features { text-align: left; margin: 0 0 24px; padding: 14px; background: var(--panel-soft); border-radius: 6px; }
.login-features .feature { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--ink); padding: 4px 0; }
.login-features .feature-icon { font-size: 1.1rem; flex-shrink: 0; width: 22px; text-align: center; }

.login-card label { display: block; text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 14px; }
.login-card input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-soft); font-size: 1rem; font-family: inherit; color: var(--ink);
}
.login-card input:focus { outline: 1px solid var(--teal); outline-offset: 1px; }
.login-card button {
  width: 100%; margin-top: 8px; padding: 12px; border: none; border-radius: var(--radius);
  background: var(--teal); color: #fff; font-size: 0.9rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; cursor: pointer; transition: background 0.15s ease;
}
.login-card button:hover { background: #17423e; }
.error { color: var(--coral); font-size: 0.85rem; min-height: 1.2em; margin-top: 10px; }

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: rgba(244,243,238,0.95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.topbar .brand { font-size: 1.5rem; color: var(--teal); margin: 0; }
.topbar-right { display: flex; align-items: baseline; gap: 14px; font-size: 0.85rem; }
.me { color: var(--muted); }
.linkbtn { background: none; border: none; color: var(--muted); font-family: inherit; font-size: 0.82rem; cursor: pointer; text-decoration: underline; padding: 0; }
.linkbtn:hover { color: var(--teal); }

/* ---------- FEED ---------- */
.feed { max-width: 600px; margin: 0 auto; padding: 24px 16px 80px; }

/* ---------- DASHBOARD (3 columnes) ---------- */
.dashboard {
  max-width: 1180px; margin: 0 auto; padding: 24px 16px 80px;
  display: grid; grid-template-columns: 210px minmax(0,1fr) 230px; gap: 22px; align-items: start;
}
.feed-col { min-width: 0; }
.panel-title { font-family: 'Fraunces', serif; font-size: 1rem; margin: 0 0 12px; color: var(--teal); }

.filters-panel, .rankings-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px;
  position: sticky; top: 78px;
}
.filters-panel select, .filters-panel input[type=text] {
  width: 100%; padding: 8px 9px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-soft); color: var(--ink); font-family: inherit; font-size: 0.85rem; margin-bottom: 12px;
}
.filters-panel .small-label { margin: 0 0 4px; }
.filters-toggle { display: none; }

.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-item { display: flex; align-items: center; gap: 8px; }
.rank-item .rank-num { font-family: 'Bebas Neue', sans-serif; font-size: 1.3rem; color: var(--coral); width: 18px; flex-shrink: 0; }
.rank-item img { width: 32px; height: 48px; object-fit: cover; border-radius: 2px; background: var(--panel-soft); flex-shrink: 0; }
.rank-item .rank-noposter { width: 32px; height: 48px; background: var(--panel-soft); border-radius: 2px; flex-shrink: 0; }
.rank-item .rank-title { font-size: 0.82rem; line-height: 1.2; }
.rank-item .rank-score { font-size: 0.74rem; color: var(--muted); }
.rank-empty { font-size: 0.8rem; color: var(--muted); font-style: italic; }

@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; }
  .filters-panel { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 30; border-radius: 0;
    overflow-y: auto; display: none; }
  .filters-panel.open { display: block; }
  .rankings-panel { position: static; order: 3; }
  .filters-toggle { display: inline; }
}

/* ---------- AFEGIR TÍTOL ---------- */
.add-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin-bottom: 32px; position: relative; }
#searchInput {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: inherit; font-size: 1rem; background: var(--panel-soft); color: var(--ink);
}
#searchInput::placeholder { color: var(--muted); }
.search-results { margin-top: 8px; }
.search-result-item {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 4px; cursor: pointer; background: var(--panel-soft); margin-bottom: 6px; border: 1px solid transparent;
}
.search-result-item:hover { border-color: var(--teal-dim); }
.search-result-item img { width: 36px; height: 54px; object-fit: cover; border-radius: 2px; background: var(--panel); flex-shrink: 0; }
.search-result-item .sr-noposter { width: 36px; height: 54px; background: var(--panel); border-radius: 2px; flex-shrink: 0; }
.search-result-item .sr-title { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.search-result-item .sr-meta { font-size: 0.78rem; color: var(--muted); }

.compose-body { display: flex; gap: 14px; margin-top: 10px; }
.compose-poster { width: 90px; height: 135px; object-fit: cover; border-radius: 3px; background: var(--panel-soft); flex-shrink: 0; box-shadow: 0 8px 20px rgba(31,59,56,0.12); }
.compose-info h3 { font-family: 'Fraunces', serif; margin: 0 0 2px; font-size: 1.2rem; color: var(--ink); }
.compose-meta { font-size: 0.78rem; color: var(--muted); margin: 0 0 6px; }
.compose-overview { font-size: 0.85rem; color: var(--ink); margin: 0 0 8px; max-height: 4.5em; overflow: hidden; opacity: 0.85; }
.small-label { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 10px 0 4px; }
.small-label .hint { text-transform: none; letter-spacing: 0; font-style: italic; }
.compose-info input, textarea#composeNote {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); font-family: inherit; font-size: 0.88rem; background: var(--panel-soft); color: var(--ink);
}
textarea#composeNote { resize: vertical; }
.score-picker { margin-top: 10px; }
.claps { font-size: 1.4rem; }
.claps button { background: none; border: none; cursor: pointer; opacity: 0.3; padding: 2px; filter: grayscale(1); }
.claps button.active { opacity: 1; filter: none; }
#submitEntry {
  margin-top: 12px; width: 100%; padding: 12px; border: none; border-radius: var(--radius);
  background: var(--teal); color: #fff; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; font-size: 0.88rem; cursor: pointer;
}
#submitEntry:hover { background: #17423e; }

/* ---------- ENTRY CARD ---------- */
.entry-card {
  background: var(--panel); padding: 16px; margin-bottom: 28px; border-radius: 5px;
  border: 1px solid var(--line);
  box-shadow: 0 16px 34px rgba(31,59,56,0.07);
  position: relative;
}
.entry-card::before {
  content: '';
  position: absolute; top: 0; left: 16px; right: 16px; height: 2px;
  background: repeating-linear-gradient(90deg, var(--teal-dim) 0 6px, transparent 6px 12px);
  opacity: 0.7;
}
.entry-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding-top: 6px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-family: 'Bebas Neue', sans-serif; font-weight: 700; flex-shrink: 0; }
.entry-head .signature { font-family: 'Fraunces', serif; font-style: italic; font-size: 1.1rem; line-height: 1; color: var(--ink); }
.entry-head .time { font-size: 0.72rem; color: var(--muted); margin-left: auto; }
.entry-head .recommends { font-size: 0.75rem; color: var(--muted); }

.entry-body { display: flex; gap: 14px; }
.entry-poster { width: 96px; height: 144px; object-fit: cover; border-radius: 3px; background: var(--panel-soft); flex-shrink: 0; box-shadow: 0 10px 20px rgba(31,59,56,0.12); }
.entry-info h3 { font-family: 'Fraunces', serif; margin: 0 0 2px; font-size: 1.25rem; color: var(--ink); }
.entry-meta { font-size: 0.76rem; color: var(--coral); margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.entry-overview { font-size: 0.85rem; margin: 0 0 6px; color: var(--ink); opacity: 0.85; }
.entry-cast { font-size: 0.76rem; color: var(--muted); }
.entry-note { font-family: 'Fraunces', serif; font-style: italic; font-size: 1.05rem; color: var(--ink); margin: 10px 0 0; opacity: 0.9; }

.platform-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.platform-pill { background: var(--coral); color: #fff; border-radius: 20px; padding: 3px 11px; font-size: 0.72rem; letter-spacing: 0.02em; }
.edit-platform-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.72rem; text-decoration: underline; }
.platform-edit-form { display: none; gap: 6px; margin-top: 6px; }
.platform-edit-form.visible { display: flex; }
.platform-edit-form input { flex: 1; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); font-family: inherit; font-size: 0.8rem; background: var(--panel-soft); color: var(--ink); }
.platform-edit-form button { border: none; background: var(--teal); color: #fff; border-radius: var(--radius); padding: 0 10px; cursor: pointer; font-size: 0.78rem; font-weight: 600; }

.ratings-section { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.avg-line { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.avg-line .clap-num { color: var(--coral); font-weight: 700; }
.my-rate-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.my-rate-row .claps button { font-size: 1.2rem; }
.rating-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.rating-chip { font-size: 0.74rem; background: var(--panel-soft); border: 1px solid var(--line); color: var(--ink); border-radius: 20px; padding: 3px 9px; }

.comments { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.comment { font-size: 0.88rem; margin-bottom: 5px; color: var(--ink); opacity: 0.9; }
.comment .who { font-weight: 600; color: var(--teal); opacity: 1; }
.comment-form { display: flex; gap: 6px; margin-top: 8px; }
.comment-form input { flex: 1; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); font-family: inherit; font-size: 0.85rem; background: var(--panel-soft); color: var(--ink); }
.comment-form button { border: none; background: var(--teal); color: #fff; padding: 0 12px; border-radius: var(--radius); cursor: pointer; font-weight: 700; }

.delete-btn { margin-top: 10px; background: none; border: none; cursor: pointer; font-size: 0.75rem; color: var(--muted); text-decoration: underline; }
.delete-btn:hover { color: var(--coral); }

.empty-state { text-align: center; color: var(--muted); font-family: 'Fraunces', serif; font-style: italic; font-size: 1.3rem; margin-top: 60px; }

@media (max-width: 480px) {
  .entry-body, .compose-body { flex-direction: column; }
  .entry-poster, .compose-poster { width: 130px; height: 195px; margin: 0 auto; }
}
