:root {
  --bg: #fff; --fg: #111; --muted: #6b6b6b; --line: #e4e4e4; --soft: #f5f5f3;
  --palma: #b5462f; --pla: #a07a12; --tram: #2f6b46; --accent: #2f6b46;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212; --fg: #ececec; --muted: #9a9a9a; --line: #2a2a2a; --soft: #1b1b1b;
    --palma: #e08a73; --pla: #d9b45a; --tram: #79c294; --accent: #79c294; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212; --fg: #ececec; --muted: #9a9a9a; --line: #2a2a2a; --soft: #1b1b1b;
  --palma: #e08a73; --pla: #d9b45a; --tram: #79c294; --accent: #79c294; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.top { border-bottom: 1px solid var(--line); padding: 40px 0 24px; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1; margin: 0 0 12px; letter-spacing: -0.02em; font-weight: 600; }
h1 em, h2 { font-family: "Times New Roman", Times, serif; font-style: italic; font-weight: 400; }
.sub { margin: 0; color: var(--muted); max-width: 60ch; }
.e-palma { color: var(--palma); } .e-pla { color: var(--pla); } .e-tram { color: var(--tram); }

.tools { position: sticky; top: 0; background: var(--bg); padding: 16px 0 8px; z-index: 2; border-bottom: 1px solid var(--line); }
#q { width: 100%; font: inherit; font-size: 1.1rem; padding: 12px 14px; border: 1px solid var(--fg); border-radius: 0; background: var(--bg); color: var(--fg); }
#q:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.group { display: flex; flex-wrap: wrap; gap: 4px; }
.chip, select, #reset { font: inherit; font-size: .85rem; padding: 6px 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 999px; cursor: pointer; }
select { border-radius: 4px; max-width: 220px; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip .n { color: var(--muted); margin-left: 4px; }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }
#reset { border-color: transparent; color: var(--muted); text-decoration: underline; }
.status { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }

.list { list-style: none; margin: 0; padding: 0; }
.item { border-bottom: 1px solid var(--line); padding: 16px 0; cursor: pointer; }
.item:hover h3 { text-decoration: underline; }
.item h3 { margin: 4px 0; font-size: 1.1rem; font-weight: 600; }
.meta { margin: 0; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.tag { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border: 1px solid currentColor; border-radius: 3px; }
.ent { font-weight: 600; }
.snip { margin: 4px 0 0; color: var(--fg); opacity: .85; font-size: .93rem; overflow-wrap: anywhere; }
mark { background: color-mix(in srgb, var(--accent) 25%, transparent); color: inherit; padding: 0 1px; }
.more { display: block; margin: 24px auto; font: inherit; padding: 10px 20px; border: 1px solid var(--fg); background: var(--bg); color: var(--fg); cursor: pointer; }

dialog { width: min(820px, 100vw - 24px); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog article { padding: 28px 24px 32px; overflow: auto; max-height: calc(100vh - 24px); }
dialog h2 { font-size: 1.8rem; line-height: 1.15; margin: 8px 0 12px; }
dialog a { color: var(--accent); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .97rem; line-height: 1.6; }
.close { position: absolute; top: 8px; right: 10px; font-size: 1.6rem; background: none; border: 0; color: var(--fg); cursor: pointer; }
.foot { color: var(--muted); font-size: .8rem; padding-top: 24px; padding-bottom: 40px; }
@media (max-width: 600px) { select { max-width: 100%; flex: 1 1 45%; } .top { padding-top: 24px; } }

/* pàgines de contingut */
.item h3 a { color: inherit; text-decoration: none; }
.bar { border-bottom: 1px solid var(--line); }
.bar .wrap { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; padding-bottom: 14px; gap: 12px; }
.bar a { color: var(--fg); font-size: .9rem; }
.brand { font-weight: 600; font-size: 1.2rem !important; text-decoration: none; }
.brand em { font-family: "Times New Roman", Times, serif; font-weight: 400; }
.doc { max-width: 760px; padding-top: 28px; }
.doc h1 { font-family: "Times New Roman", Times, serif; font-style: italic; font-weight: 400; font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.1; margin: 10px 0 20px; }
.content { font-size: 1.05rem; line-height: 1.65; overflow-wrap: anywhere; }
.content img, .hero img { max-width: 100%; height: auto; display: block; margin: 16px 0; }
.content iframe { width: 100%; aspect-ratio: 16/9; border: 0; }
.content table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
.content td, .content th { border: 1px solid var(--line); padding: 6px 8px; }
.content a, .doc a { color: var(--accent); }
.content blockquote { border-left: 3px solid var(--accent); margin: 16px 0; padding: 2px 16px; color: var(--muted); }
.hero { margin: 0 0 20px; }
.actions { display: flex; gap: 16px; align-items: center; margin: 0 0 24px; }
.btn { display: inline-block; padding: 10px 18px; background: var(--fg); color: var(--bg) !important; text-decoration: none; }
.small { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: inherit; font-style: normal; }
.pdftext { white-space: pre-wrap; font-size: .92rem; line-height: 1.55; overflow-wrap: anywhere; background: var(--soft); padding: 16px; max-height: 70vh; overflow: auto; }
.orig { margin-top: 32px; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.muted { color: var(--muted); }

/* blog */
.bar nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.bar nav a { text-decoration: none; }
.bar nav a:hover { text-decoration: underline; }
.item { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 22px 0; }
.item.has-img { grid-template-columns: 220px 1fr; }
.thumb img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; background: var(--soft); }
.item h3 { font-family: "Times New Roman", Times, serif; font-style: italic; font-weight: 400; font-size: 1.45rem; line-height: 1.2; }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 40px; border-top: 1px solid var(--line); padding-top: 16px; }
.pn a { text-decoration: none; color: var(--fg) !important; font-size: .95rem; }
.pn a:last-child { text-align: right; }
.pn small { display: block; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
@media (max-width: 600px) { .item.has-img { grid-template-columns: 1fr; } .bar .wrap { flex-direction: column; } }

/* targetes de blog */
.wrap { max-width: 1180px; }
.list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 32px 24px; padding: 28px 0 8px; }
.card a { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.card .pic { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--soft); }
.card .pic img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.card .pic img.pdf { object-fit: contain; object-position: top; padding: 12px; background: var(--soft); }
.card a:hover .pic img { transform: scale(1.03); }
.card a:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.ph { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 16px; color: #fff; font-family: "Times New Roman", Times, serif; font-style: italic; font-size: 1.6rem; line-height: 1.1; }
.e-bg-palma { background: var(--palma); } .e-bg-pla { background: var(--pla); } .e-bg-tram { background: var(--tram); }
.badge { position: absolute; top: 10px; left: 10px; background: var(--bg); color: var(--fg); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; }
.card .body { padding: 14px 0 0; display: flex; flex-direction: column; gap: 6px; }
.card h3 { margin: 0; font-family: "Times New Roman", Times, serif; font-style: italic; font-weight: 400; font-size: 1.45rem; line-height: 1.2; }
.card .snip { margin: 0; font-size: .92rem; color: var(--muted); }
.card .cats { margin: 0; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
@media (min-width: 900px) {
  .list > .card:first-child { grid-column: 1 / -1; }
  .list > .card:first-child a { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center; }
  .list > .card:first-child h3 { font-size: 2.4rem; }
  .list > .card:first-child .snip { font-size: 1rem; }
}
.top { padding: 32px 0 20px; }
.tools { padding: 12px 0; }

/* el bloc de cerca només queda fix en pantalles amples */
@media (max-width: 899px) { .tools { position: static; } }
