/* =====================================================================
   Portal Broadcast · v01
   Un sol full d'estils per al portal, les fitxes i l'admin.
   Sense fonts ni recursos externs.
   ===================================================================== */

:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel2: #1b232d;
  --line: #263140;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #ff5a47;
  --accent-ink: #1a0603;
  --ok: #3ecf8e;
  --warn: #f5b83d;
  --info: #4da3ff;
  --err: #ff6b6b;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9; --panel: #ffffff; --panel2: #eef1f5; --line: #d8dee7;
    --text: #141a22; --muted: #5d6b7d; --accent: #e5392a; --accent-ink: #ffffff;
    --ok: #0f9d63; --warn: #b37a05; --info: #1f6fd1; --err: #c62f2f;
    --shadow: 0 1px 2px rgba(20,26,34,.06), 0 8px 24px rgba(20,26,34,.06);
    color-scheme: light;
  }
}
/* Forçat per a l'exportació */
.theme-dark {
  --bg: #0d1117; --panel: #151b23; --panel2: #1b232d; --line: #263140;
  --text: #e6edf3; --muted: #8b98a9; --accent: #ff5a47; --accent-ink: #1a0603;
  --ok: #3ecf8e; --warn: #f5b83d; --info: #4da3ff; --err: #ff6b6b; --shadow: none;
}
.theme-light {
  --bg: #f4f6f9; --panel: #ffffff; --panel2: #eef1f5; --line: #d8dee7;
  --text: #141a22; --muted: #5d6b7d; --accent: #e5392a; --accent-ink: #ffffff;
  --ok: #0f9d63; --warn: #b37a05; --info: #1f6fd1; --err: #c62f2f; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
p { margin: 0 0 .9em; }
code { font-family: var(--mono); background: var(--panel2); padding: .1em .4em; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 4px; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-left: .25rem; }
.tally {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), 0 0 12px var(--accent);
  flex: none;
}

/* ---------- Botons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; line-height: 1.2;
}
.btn:hover { text-decoration: none; border-color: color-mix(in srgb, var(--text) 35%, var(--line)); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, var(--line)); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--err) 12%, transparent); }
.btn-sm { padding: .35rem .65rem; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: .75rem 1.25rem; font-size: 16px; }
.btn-disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Missatges ---------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid var(--line); background: var(--panel); }
.flash-ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); background: color-mix(in srgb, var(--ok) 10%, var(--panel)); }
.flash-err { border-color: color-mix(in srgb, var(--err) 55%, var(--line)); background: color-mix(in srgb, var(--err) 10%, var(--panel)); }
.flash-warn { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }

/* ---------- Insígnies ---------- */
.badges { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.badge, .pill {
  display: inline-flex; align-items: center; border-radius: 999px; font-size: 12px; font-weight: 600;
  padding: .15rem .6rem; border: 1px solid var(--line); color: var(--muted); background: transparent; white-space: nowrap;
}
.pill { font-size: 10.5px; padding: .05rem .45rem; letter-spacing: .04em; }
.est-idea { color: var(--muted); }
.est-desenvolupament { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.est-beta { color: var(--info); border-color: color-mix(in srgb, var(--info) 50%, var(--line)); }
.est-estable { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.est-aturat { color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, var(--line)); }
.niv-free { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.niv-subscripcio { color: var(--info); border-color: color-mix(in srgb, var(--info) 50%, var(--line)); }
.niv-especial { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--cat, var(--muted)); flex: none; display: inline-block; }
.ver { font-family: var(--mono); font-size: .55em; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: .1em .45em; vertical-align: middle; white-space: nowrap; }

/* =====================================================================
   Portal públic: menú lateral + contingut
   ===================================================================== */
.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line); padding: 1.1rem .9rem .9rem;
}
.side .brand { font-size: 17px; padding: 0 .35rem .9rem; }
.side-search input {
  width: 100%; padding: .55rem .75rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.tree { flex: 1; overflow: auto; margin: .8rem -.3rem 0; padding: 0 .3rem; scrollbar-width: thin; }
.tree-all { display: flex; justify-content: space-between; padding: .45rem .6rem; border-radius: 7px; color: var(--text); font-weight: 600; font-size: 14px; }
.tree-all:hover, .leaf:hover { background: var(--panel2); text-decoration: none; }
.tree-all.is-active { background: var(--panel2); }
.count { font-size: 11px; color: var(--muted); font-weight: 500; }
.grp { margin-top: .35rem; }
.grp > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .55rem;
  padding: .45rem .6rem; border-radius: 7px; font-weight: 600; font-size: 13.5px; user-select: none;
}
.grp > summary::-webkit-details-marker { display: none; }
.grp > summary::after { content: "▸"; margin-left: auto; color: var(--muted); font-size: 11px; transition: transform .15s; }
.grp[open] > summary::after { transform: rotate(90deg); }
.grp > summary:hover { background: var(--panel2); }
.grp > summary .count { margin-left: .25rem; }
.grp > summary::after { order: 3; }
.grp-t { flex: 0 1 auto; }
.grp-body { margin-left: 1.05rem; padding-left: .55rem; border-left: 2px solid color-mix(in srgb, var(--cat) 55%, var(--line)); }
.leaf { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .6rem; border-radius: 7px; color: var(--text); font-size: 14px; }
.leaf.is-active { background: color-mix(in srgb, var(--cat, var(--accent)) 16%, var(--panel2)); font-weight: 600; }
.grp-body .leaf.is-active { background: color-mix(in srgb, var(--cat) 18%, var(--panel2)); }
.leaf-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-empty { color: var(--muted); padding: .6rem; font-size: 14px; }
.side-foot { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .6rem; display: grid; gap: .6rem; }
.userbox { display: grid; gap: .1rem; font-size: 13.5px; padding: 0 .35rem; }
.userbox strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox .muted { font-size: 12.5px; }
.side-actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.side-actions form { margin: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.main-in { width: 100%; max-width: 1180px; margin: 0 auto; padding: 2rem 2rem 3rem; flex: 1; }
.topbar { display: none; }
.scrim { display: none; }
.foot { padding: 1.2rem 2rem; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.admin-strip { margin-bottom: 1rem; }

/* Inici */
.hero { padding: .5rem 0 2rem; }
.hero h1 { font-size: clamp(28px, 4vw, 42px); }
.lead { font-size: 17px; color: var(--muted); max-width: 62ch; margin: .6rem 0 0; }
.hero-stats { display: flex; gap: 1.5rem; margin: 1.2rem 0; color: var(--muted); font-size: 14px; }
.hero-stats b { color: var(--text); font-size: 20px; margin-right: .25rem; }
.hero-cta { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0 .7rem; }
.section { margin-top: 2rem; }
.section-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.section-head h2 { font-size: 18px; }
.section-head .more { margin-left: auto; font-size: 13px; }
.page-head { margin-bottom: 1.4rem; }
.page-head h1 { font-size: 28px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.card {
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow);
  border-top: 3px solid var(--cat, var(--line)); transition: transform .12s, border-color .12s;
}
.card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--cat, var(--line)); }
.card-img { aspect-ratio: 16 / 9; background: var(--panel2); overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.ph {
  width: 100%; height: 100%; display: grid; place-items: center; min-height: 120px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--cat) 28%, var(--panel2)), var(--panel2));
}
.ph span { font-size: 38px; font-weight: 800; color: color-mix(in srgb, var(--cat) 80%, var(--text)); letter-spacing: -.02em; }
.card-body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.card-title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.card-title h3 { font-size: 16px; }
.card-sum { color: var(--muted); font-size: 13.5px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .badges { margin-top: auto; padding-top: .5rem; }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty h1 { color: var(--text); margin-bottom: .6rem; }

/* =====================================================================
   FITXA (plantilla única)
   ===================================================================== */
.fitxa { --cat: #7a8aa0; }
.fitxa-head { padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; border-left: 4px solid var(--cat); padding-left: 1rem; }
.crumbs { display: flex; align-items: center; gap: .5rem; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: .5rem; }
.crumbs .sep { opacity: .6; }
.fitxa-head h1 { font-size: clamp(26px, 3.4vw, 38px); }
.fitxa-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 2rem; align-items: start; }
.fitxa-img { margin: 0 0 1.5rem; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--panel2); }
.fitxa-img img { width: 100%; height: auto; }
.fitxa-img .ph { min-height: 0; aspect-ratio: 16 / 9; }
.blk { margin-bottom: 1.6rem; }
.blk h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .7rem; }
.blk p { max-width: 70ch; }
.blk-notes { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--radius); padding: 1rem 1.1rem; }
.blk-notes p:last-child { margin-bottom: 0; }
.road { list-style: none; margin: 0; padding: 0 0 0 .4rem; position: relative; }
.road::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.road li { position: relative; display: grid; grid-template-columns: 62px 1fr auto; gap: .8rem; align-items: baseline; padding: .45rem 0 .45rem 1.6rem; }
.road li::before { content: ""; position: absolute; left: 5px; top: 1rem; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); }
.road li.st-fet::before { background: var(--ok); border-color: var(--ok); }
.road li.st-curs::before { background: var(--warn); border-color: var(--warn); }
.rv { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.rs { font-size: 12px; color: var(--muted); }
.st-fet .rs { color: var(--ok); }
.st-curs .rs { color: var(--warn); }
.fitxa-side { position: sticky; top: 1.2rem; display: grid; gap: 1rem; }
.cta { display: grid; gap: .6rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.cta:empty { display: none; }
.cta-note { color: var(--muted); font-size: 13.5px; margin: 0; }
.kv { display: grid; gap: .1rem; font-size: 13px; word-break: break-all; }
.kv span { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.meta { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .3rem 1rem; }
.meta div { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.meta div:last-child { border-bottom: 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; text-align: right; font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag { font-size: 12.5px; padding: .15rem .6rem; border-radius: 6px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
a.tag:hover { color: var(--text); text-decoration: none; border-color: var(--muted); }
.tabs-soon { display: flex; gap: .5rem; }
.tab-soon { font-size: 13px; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: .4rem .8rem; cursor: not-allowed; }

/* =====================================================================
   Autenticació / instal·lació
   ===================================================================== */
.auth { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: 1.4rem; padding: 2rem 1rem; }
.auth .brand { font-size: 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.6rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin-bottom: 1.1rem; }
.auth-alt { margin: 1rem 0 0; font-size: 14px; color: var(--muted); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* =====================================================================
   Formularis
   ===================================================================== */
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; font-size: 14px; }
.field > span { color: var(--muted); font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number],
input[type=date], input[type=search], input[type=color], select, textarea {
  width: 100%; padding: .6rem .75rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit;
}
input[type=color] { padding: .15rem; height: 40px; cursor: pointer; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--info); outline: none; }
.check { display: flex; gap: .55rem; align-items: center; font-size: 14px; }
.check input { width: 18px; height: 18px; }

/* =====================================================================
   Admin
   ===================================================================== */
.adm-top { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: .8rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.adm-nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.adm-nav a { padding: .4rem .8rem; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 14px; }
.adm-nav a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.adm-nav a.is-active { color: var(--text); background: var(--panel2); }
.adm-right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.adm-right form { margin: 0; }
.adm-main { max-width: 1280px; margin: 0 auto; padding: 1.6rem 1.5rem 4rem; }
.adm-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.adm-head h1 { font-size: 24px; }
.adm-head .push { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 150px; }
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .7rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.is-off td { opacity: .55; }
.tbl .thumb { width: 64px; height: 36px; border-radius: 6px; overflow: hidden; background: var(--panel2); border: 1px solid var(--line); }
.tbl .thumb img { width: 100%; height: 100%; object-fit: cover; }
.tbl .thumb .ph { min-height: 0; }
.tbl .thumb .ph span { font-size: 13px; }
.tbl .t-title { font-weight: 600; }
.tbl .t-slug { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.tbl .actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.tbl .actions form { margin: 0; }
.chip { display: inline-flex; align-items: center; gap: .4rem; font-size: 12.5px; padding: .12rem .55rem; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); }
.chip i { width: 9px; height: 9px; border-radius: 3px; background: var(--cat, var(--muted)); display: inline-block; }
.switch { display: inline-flex; align-items: center; gap: .4rem; font-size: 13px; }
.on { color: var(--ok); } .off { color: var(--muted); }

.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .9rem; }
.panel + .panel { margin-top: 1rem; }
.stack { display: grid; gap: 1rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.savebar { position: sticky; bottom: 0; margin-top: 1.4rem; padding: .8rem 0; display: flex; gap: .6rem; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.preview-img { margin-top: .6rem; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel2); }
.rm-row { display: grid; grid-template-columns: 110px 80px 1fr auto; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.rm-row input, .rm-row select { padding: .45rem .55rem; font-size: 14px; }
.hint { color: var(--muted); font-size: 12.5px; margin: .4rem 0 0; }
.errlist { margin: 0 0 1rem; padding: .8rem 1rem .8rem 2rem; border: 1px solid color-mix(in srgb, var(--err) 55%, var(--line)); background: color-mix(in srgb, var(--err) 10%, var(--panel)); border-radius: 8px; }
.inline-form { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input[type=date] { width: auto; padding: .3rem .5rem; font-size: 13px; }
.inline-form input[type=text], .inline-form input[type=number], .inline-form select { width: auto; padding: .3rem .5rem; font-size: 13px; }
.inline-form input[type=color] { width: 44px; height: 30px; }
.stats { display: flex; gap: 1.2rem; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-bottom: 1rem; }
.stats b { color: var(--text); }

/* Exportació */
.exp-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.2rem; }
.exp-bar select { width: auto; }
.exp-stage { overflow: auto; padding: 1rem; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); }
.export-sheet { width: 794px; margin: 0 auto; background: var(--bg); color: var(--text); padding: 36px 40px 28px; }
.export-sheet .fitxa-grid { grid-template-columns: minmax(0, 1fr) 250px; gap: 1.4rem; }
.export-sheet .fitxa-side { position: static; }
.export-sheet .fitxa-head h1 { font-size: 30px; }
.export-sheet .exp-foot { margin-top: 1.4rem; padding-top: .8rem; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 980px) {
  .fitxa-grid, .edit-grid { grid-template-columns: minmax(0, 1fr); }
  .fitxa-side { position: static; order: -1; }
  .edit-grid .side-col { order: -1; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(86vw, 330px);
    transform: translateX(-102%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
    padding-top: calc(1.1rem + env(safe-area-inset-top)); padding-bottom: calc(.9rem + env(safe-area-inset-bottom));
  }
  body.menu-open .side { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.menu-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .burger { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
  .main-in { padding: 1.2rem 1rem 2rem; }
  .foot { padding: 1rem; }
  .row2 { grid-template-columns: 1fr; }
  .rm-row { grid-template-columns: 1fr 1fr; }
  .rm-row .rm-text { grid-column: 1 / -1; }
  .road li { grid-template-columns: 52px 1fr; }
  .road li .rs { grid-column: 2; }
}
@media print {
  .side, .topbar, .adm-top, .exp-bar, .foot, .scrim { display: none !important; }
  .exp-stage { border: 0; padding: 0; background: none; overflow: visible; }
  .export-sheet { width: auto; }
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Textos llargs sense espais (URL, noms de fitxer…) no han de trencar el disseny */
.fitxa h1, .fitxa p, .fitxa li, .fitxa .tag, .fitxa dd, .card h3, .card-sum, .page-head h1, .leaf-t, .lead { overflow-wrap: anywhere; }

/* Els fills d'una graella o flex poden encongir-se: sense això un text llarg els eixampla */
.panel, .field, .cta, .fitxa-main, .fitxa-side, .card-body, .meta div > * { min-width: 0; }
.cta .btn { max-width: 100%; white-space: normal; text-align: center; overflow-wrap: anywhere; }
.meta dd { overflow-wrap: anywhere; }
.check span { min-width: 0; overflow-wrap: anywhere; }

/* PWA */
.pwa-install { width: 100%; justify-content: center; }
.pwa-ios { margin: 0; padding: 0 .35rem; }
.pwa-ios[hidden], .pwa-install[hidden] { display: none; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
@media (max-width: 860px) {
  .topbar { padding-top: calc(.7rem + env(safe-area-inset-top)); }
  .foot { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}
.adm-top { padding-top: calc(.8rem + env(safe-area-inset-top)); }
@media (display-mode: standalone) { body { overscroll-behavior-y: none; } }
button, .btn, summary, .leaf { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
