/* ════════════════════════════════════════════════════════════════
   AKASHIC RECORDS · hoja de estilos única
    1. Variables          6. Controles de la ficha
    2. Base               7. Ficha Rosetta (cabecera, pestañas, paneles)
    3. Estructura         8. Pestañas una a una
    4. Botones y avisos   9. Celdas originales
    5. Biblioteca        10. Pantallas pequeñas
   Regla de oro: las cuadrículas usan minmax(0,1fr) y los controles
   tienen tamaño fijo, así nada cambia de ancho al editar.
   Los ornamentos son imágenes de fondo o ::before/::after con
   pointer-events:none: nunca tapan un clic.
   ════════════════════════════════════════════════════════════════ */

/* ── 1. Variables ── */
:root {
  color-scheme: dark;
  --bg: #151417;
  --panel: #242122;
  --field: #1c1a1c;
  --line: #5c4832;
  --line-soft: #3d332c;
  --gold: #d5ad6a;
  --gold-bright: #f5d9a1;
  --label: #c9a86e;
  --text: #eee3d0;
  --muted: #b7a793;
  --faint: #8c7c6a;
  --placeholder: #6f6253;
  --pending: #e3a04f;
  --pending-bg: #4a3522;
  --ok: #8ebb9d;
  --danger: #e1a49a;
  --serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Cambria, Georgia, serif;
  --sans: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --radius: 5px;
  --gap: 14px;
  --topbar: 58px;
}

/* ── 2. Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: #5c4832 #151417; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
::selection { background: #8a6a40; color: #fff6e3; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 400; }
p { margin: 0; }
code { color: #d1af7d; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
button, .f, .tg, .ap, .chip, .tab, .nav { transition: background-color .15s, border-color .15s, color .15s, filter .15s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ── 3. Estructura: barra lateral + área de trabajo ── */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh;
  background: radial-gradient(ellipse at 70% 0, #392b2222, transparent 65%), var(--bg); }

.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  padding: 22px 12px 16px; background: linear-gradient(180deg, #1d1b1b, #111114); border-right: 1px solid #604931; scrollbar-width: thin; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 28px; }
.brand img { width: 46px; height: 46px; object-fit: contain; }
.brand strong { display: block; color: var(--gold-bright); font: 600 13px var(--serif); letter-spacing: .08em; }
.brand span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .06em; }
.side-caption { color: #bda67e; font-size: 10px; font-weight: 700; letter-spacing: .12em; margin: 0 6px 8px; }
.lib-caption { margin-top: 26px; padding-top: 22px;
  background: url(../img/rosetta-icons/ornaments/navigation-border-top.svg) center top / 24px 9px no-repeat,
    linear-gradient(90deg, transparent, #5a4630 30%, #5a4630 70%, transparent) center top 4px / 100% 1px no-repeat; }
.nav { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 42px; padding: 10px 12px; margin-bottom: 4px;
  background: none; border: 1px solid transparent; border-radius: var(--radius); color: #c7baa6; font-size: 13px; text-align: left; }
.nav:hover:not(:disabled) { background: #332a24; color: #ffe1a2; border-color: #54412c; }
.nav.active { color: #f7dea8; border-color: #665035; box-shadow: inset 3px 0 #d3a55b;
  background:
    url(../img/rosetta-icons/ornaments/select-corner-active-right-top.svg) right 2px top 2px / 8px no-repeat,
    url(../img/rosetta-icons/ornaments/select-corner-active-right-bottom.svg) right 2px bottom 2px / 8px no-repeat,
    linear-gradient(90deg, #51402b, #302820); }

/* Biblioteca en la barra lateral */
.lib-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.lib-row { display: flex; align-items: center; min-width: 0; border: 1px solid transparent; border-radius: var(--radius); }
.lib-row:hover, .lib-row.active { background: #332923; border-color: #755735; }
.lib-file { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 7px 8px; background: none; border: 0; text-align: left; }
.lib-file > span:last-child { min-width: 0; }
.lib-file b, .lib-file small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-file b { color: #eadbc5; font-size: 13px; }
.lib-file small { color: #a99983; font-size: 11px; }
.lib-btn { flex: none; width: 28px !important; height: 28px !important; margin-right: 2px; color: #a58d6c; }
.lib-unlink:hover { color: #eeb1a3 !important; }
@media (hover: hover) {   /* con ratón, los botones aparecen al pasar por encima */
  .lib-row .lib-btn { opacity: 0; }
  .lib-row:hover .lib-btn, .lib-row:focus-within .lib-btn { opacity: 1; }
}
.add-file { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 6px; padding: 10px; border-radius: var(--radius);
  background: none; border: 1px dashed #74604a; color: #ddbe85; font-size: 12px; }
.add-file:hover:not(:disabled) { background: #392d23; }
.side-footer { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 16px 6px 0; border-top: 1px solid #52412f; }
.side-footer strong { display: block; color: #ead7b8; font-size: 12px; }
.side-footer small { color: #aa9b85; font-size: 11px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #c69c59; display: inline-block; flex: none; }
.status-dot.online { background: var(--ok); box-shadow: 0 0 0 3px #8ebb9d22; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: var(--topbar);
  padding: 0 clamp(16px, 3vw, 40px); background: #1b191bf2; border-bottom: 1px solid #51402e; backdrop-filter: blur(6px); }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: #806b4f; font-size: 13px; }
.crumbs button { background: none; border: 0; color: #d7b777; padding: 6px 2px; }
.crumbs button:hover { text-decoration: underline; }
.crumbs strong { color: #efe1c9; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; min-width: 0; }
.pill { white-space: nowrap; font-size: 10px; letter-spacing: .06em; padding: 6px 10px; border-radius: 4px; color: #acdab6; background: #1e362d; border: 1px solid #49684e; }
.pill.demo { color: #ecd1a1; background: #3b3023; border-color: #765a33; }
.busy { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: #d3b27d; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spinner { width: 14px; height: 14px; border: 2px solid #6b5539; border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.topbar .menu-btn { display: none; }
.main { max-width: 1600px; padding: 22px clamp(16px, 3vw, 40px) 110px; }
.footer { margin-top: 30px; color: var(--faint); font-size: 10px; letter-spacing: .06em; }
.scrim { display: none; }

/* ── 4. Botones, avisos y ventanas ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 14px;
  border-radius: var(--radius); border: 1px solid transparent; font-size: 13px; font-weight: 600; white-space: nowrap; }
.btn.primary { background: linear-gradient(125deg, #b78745, #97703e); border-color: #d2a35e; color: #171414; box-shadow: inset 0 1px #f2cf8f66; }
.btn.primary:hover:not(:disabled) { background: #d0a263; }
.btn.secondary { background: #292523; border-color: #69543c; color: #e8d0a4; }
.btn.secondary:hover:not(:disabled) { background: #403127; border-color: #a47b49; color: #ffe3ae; }
.btn.ghost { background: none; border-color: #54432e; color: #d2b58a; }
.btn.ghost:hover:not(:disabled) { background: #332a24; color: #ffe1a8; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.btn.danger:hover { color: #eeb1a3; border-color: #864d46; }
label.btn { cursor: pointer; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: var(--radius);
  background: none; border: 1px solid transparent; color: #d1b182; }
.icon-btn:hover:not(:disabled) { background: #362c26; border-color: #785e3b; color: #f9e6c2; }

.msg { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin-bottom: 12px; border-radius: var(--radius); animation: appear .2s ease-out; }
.msg span { flex: 1; }
.msg button { background: none; border: 0; color: inherit; padding: 2px; }
.msg.info { background: #223329; color: #b7ddc0; border: 1px solid #486c53; }
.msg.error { background: #3a2424; color: #f2b9af; border: 1px solid #864d46; }
@keyframes appear { from { opacity: 0; transform: translateY(-4px); } }
.notice-demo { display: flex; align-items: center; gap: 9px; padding: 10px 13px; margin-bottom: 12px; border-radius: var(--radius);
  background: #30271e; color: #dcc49b; border: 1px solid #755c37; font-size: 13px; }
.settings-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; color: #d9c6a6; }
.settings-row .btn { margin-left: 8px; }

.save-dock { position: fixed; z-index: 40; right: 20px; bottom: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px; border-radius: var(--radius); background: #29221e; border: 1px solid #b78e55; color: #f5dfb7;
  box-shadow: 0 12px 30px #0009; animation: appear .2s ease-out; }
.save-dock > div { display: flex; gap: 8px; }
.dot-pending { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: var(--pending); box-shadow: 0 0 0 3px #e3a04f33; }

/* Avatares */
.avatar { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; overflow: hidden; border-radius: 4px; border: 1px solid #987a51; }
.avatar.large { width: 64px; height: 64px; }
.avatar .emoji-img { width: 74%; height: 74%; object-fit: contain; }
.avatar .avatar-photo { width: 100%; height: 100%; object-fit: cover; }
.avatar-letter { font: 22px var(--serif); }
.large .avatar-letter { font-size: 32px; }
.avatar-edit { display: block; padding: 0; background: none; border: 0; border-radius: 2px; }
.avatar-edit:hover .avatar { filter: brightness(1.15); }

/* Ventana de personalización (alias y avatar) */
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: #0b0b0ddd; backdrop-filter: blur(3px); animation: appear .15s ease-out; }
.dialog { position: relative; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; display: grid; gap: 12px; padding: 30px 22px 18px;
  border: 1px solid #b18b55; border-radius: var(--radius); box-shadow: 0 25px 80px #000a;
  background:
    url(../img/rosetta-icons/ornaments/card-top.svg) center top 2px / 170px auto no-repeat,
    linear-gradient(135deg, #2d2623, #1b1b1d); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dialog-head h2 { color: #f5dda9; font-size: 25px; margin-top: 4px; overflow-wrap: anywhere; }
.dialog-preview { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid #705538; border-radius: 4px; background: #342c26; }
.dialog-preview strong { display: block; color: #f4dfbb; font: 19px var(--serif); overflow-wrap: anywhere; }
.dialog-preview small { color: #b7a187; font-size: 12px; }
.kind-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.kind-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; border-radius: 4px; background: #262326; border: 1px solid #55422d; color: #bcac97; }
.kind-btn:hover { background: #433328; border-color: #aa8250; }
.kind-btn.selected { background: #59412a; color: #ffdc9d; border-color: #bd955b; box-shadow: inset 0 2px #ddb578; }
.emoji-picker { display: grid; gap: 8px; }
.emoji-cats { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-cat { width: 38px; height: 34px; padding: 4px; display: grid; place-items: center; border-radius: 4px; background: #302923; border: 1px solid #604d35; }
.emoji-cat.selected { background: #65503a; border-color: #dfb677; }
.emoji-cat .emoji-img { width: 22px; height: 22px; }
.emoji-head { display: flex; justify-content: space-between; color: var(--label); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; max-height: 240px; overflow-y: auto; padding: 2px; }
.emoji-btn { position: relative; height: 42px; padding: 5px; display: grid; place-items: center; border-radius: 4px; background: #2a2421; border: 1px solid #4a3c2c; }
.emoji-btn .emoji-img { width: 28px; height: 28px; }
.emoji-btn:hover, .emoji-btn.selected { background: #65503a; border-color: #dfb677; }
.emoji-btn.has-variants::after { content: ""; position: absolute; right: 3px; bottom: 3px; border: 4px solid transparent; border-right-color: #d0a765; border-bottom-color: #d0a765; }
.emoji-variants { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; border: 1px solid #6b5235; border-radius: 4px; background: #241f1d; color: var(--label); font-size: 12px; }
.emoji-variants .emoji-btn { width: 42px; }
.emoji-more { justify-self: center; }
.photo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.colors input[type=color] { width: 100%; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid #4a3b2c; }
.dialog-foot > div { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── 5. Biblioteca y configuración ── */
.eyebrow { color: #cdac72; font-size: 10px; letter-spacing: .18em; font-weight: 700; }
.lib-heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 18px; }
.lib-heading h1 { color: #f5dfb7; font-size: clamp(28px, 3vw, 38px); margin: 6px 0; }
.lib-heading p { color: var(--muted); }
.lib-summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; padding: 12px 0; color: #d1b998; font-size: 12px;
  border-top: 1px solid #57422d; border-bottom: 1px solid #57422d; }
.lib-summary > span { display: inline-flex; align-items: center; gap: 8px; }
.lib-section { margin: 28px 0 12px; }
.lib-section h2 { color: #f3d8a6; font-size: 24px; }
.lib-section p { color: #a99882; font-size: 12px; margin-top: 4px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
/* Tarjetas: adorno de esquina arriba a la izquierda */
.char-card, .demo-card { position: relative; }
.char-card::before, .demo-card::before { content: ""; position: absolute; left: 2px; top: 2px; width: 46px; height: 46px; pointer-events: none;
  background: url(../img/rosetta-icons/ornaments/card-corner.svg) center / contain no-repeat; opacity: .9; }
.char-card { background: linear-gradient(145deg, #302823, #211f20); border: 1px solid #6b5234; border-radius: var(--radius); transition: border-color .15s, transform .15s, box-shadow .15s; }
.char-card:hover { border-color: #c09a61; transform: translateY(-2px); box-shadow: 0 10px 24px #0007; }
.char-card > button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 16px 16px 22px; background: none; border: 0; text-align: left; }
.char-card small { display: block; color: #b49a73; font-size: 9px; letter-spacing: .1em; }
.char-card strong { display: block; font: 21px/1.3 var(--serif); color: #f3dfbc; overflow-wrap: anywhere; }
.char-actions { display: flex; justify-content: space-between; border-top: 1px solid #513e2c; padding: 4px 10px; }
.char-actions button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 4px; background: none; border: 0; color: #bca784; font-size: 12px; }
.char-actions button:hover { color: #ffe1a8; }
.char-actions button[data-unlink]:hover { color: #e5a99e; }
.lib-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 20px; text-align: center; color: #d4b487;
  border: 1px dashed #685035; border-radius: var(--radius); background: linear-gradient(135deg, #302720, #221e1e); }
.lib-empty h3 { color: #f1d5a3; font-size: 20px; }
.lib-empty p { color: #bca992; font-size: 13px; max-width: 560px; }
.demo-card { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 13px 16px 13px 22px; background: #262123; border: 1px solid #56432e; border-radius: var(--radius); }
.demo-card > div { flex: 1; min-width: 140px; }
.demo-card strong { display: block; color: #f3daa8; font: 20px var(--serif); }
.demo-card span { color: #ad9882; font-size: 12px; }

/* ── 6. Controles de la ficha ── */

/* Campo: etiqueta pequeña arriba, valor o caja de texto debajo */
.f { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 7px 9px 8px; border-radius: 4px;
  background: var(--field); border: 1px solid var(--line-soft); }
.f:hover:not(.is-locked) { border-color: #5a4733; }
.f + .f, .f + .subheading, .grid-2 + .f, .grid-3 + .f, .f + .local-icon { margin-top: 8px; }
:is(.grid-2, .grid-3, .grid-4, .grid-5) > .f { margin-top: 0; }   /* en cuadrícula, el hueco lo pone «gap» */
.f-label { display: flex; align-items: center; gap: 4px; color: var(--label); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-label .ic { opacity: .7; }
.f-input { width: 100%; min-width: 0; padding: 2px 0; background: none; border: 0; border-bottom: 1px solid transparent; color: var(--text); font-size: 14px; }
.f-input:focus { outline: none; border-bottom-color: var(--gold); }
.f-input::placeholder { color: var(--placeholder); }
select.f-input { cursor: pointer; padding: 3px 0; }
select.f-input option { background: #221f20; color: var(--text); }
textarea.f-input { resize: vertical; line-height: 1.5; min-height: 42px; overflow: hidden; }
/* Campo activo: las cuatro esquinitas doradas de «control seleccionado» */
.f:focus-within { border-color: #8a6a40;
  background:
    url(../img/rosetta-icons/ornaments/select-corner-active-left-top.svg) left 1px top 1px / 8px no-repeat,
    url(../img/rosetta-icons/ornaments/select-corner-active-right-top.svg) right 1px top 1px / 8px no-repeat,
    url(../img/rosetta-icons/ornaments/select-corner-active-right-bottom.svg) right 1px bottom 1px / 8px no-repeat,
    url(../img/rosetta-icons/ornaments/select-corner-active-left-bottom.svg) left 1px bottom 1px / 8px no-repeat,
    var(--field); }
.f-value { color: #d9cbb4; font-size: 14px; min-height: 21px; overflow-wrap: anywhere; }
.f-value.is-empty { color: var(--placeholder); }
.f-notes .f-value { white-space: pre-wrap; }
.f.is-locked { background: #211f21; border-style: dashed; }
.f.is-pending, .counter.is-pending, .tg.is-pending, .ap.is-pending { border-color: var(--pending); background: var(--pending-bg); }

/* Variante numérica destacada (CA, PG, atributos…) */
.f-stat { align-items: center; text-align: center; }
.f-stat .f-input, .f-stat .f-value { text-align: center; font: 22px/1.2 var(--serif); color: var(--gold-bright); font-variant-numeric: lining-nums tabular-nums; }
.f-big .f-input, .f-big .f-value { font: 19px/1.3 var(--serif); color: #f3dfbc; }
.f-num { width: 74px; flex: none; }
.f-num .f-input { text-align: center; }

/* Casillas */
.tg { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 8px 3px 4px;
  border: 1px solid var(--line-soft); border-radius: 4px; background: var(--field); cursor: pointer; font-size: 12px; color: #d7c3a3; }
.tg:hover:not(.is-locked) { border-color: #6b5539; }
.tg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.tg-box { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid #8a6c45; border-radius: 3px; background: #141315; color: transparent; }
.tg input:checked + .tg-box { background: #b88a4b; border-color: #e0b675; color: #171310; }
.tg:has(input:checked) { border-color: #8a6c45; color: #f3d9a6; }
.tg:focus-within { outline: 2px solid var(--gold); outline-offset: 1px; }
.tg.is-locked { opacity: .55; cursor: default; }
.tg-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tg-wide { width: 100%; }

/* Contador ▲▼ */
.counter { display: grid; grid-template-columns: minmax(0, 1fr) auto 30px; align-items: center; gap: 8px; min-height: 48px; padding: 6px 6px 6px 10px;
  border: 1px solid var(--line-soft); border-radius: 4px; background: var(--field); }
.counter strong { font: 22px var(--serif); color: var(--gold-bright); min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.counter-btns { display: grid; gap: 2px; }
.counter-btns button { display: grid; place-items: center; height: 18px; padding: 0; border-radius: 3px; background: #302822; border: 1px solid #5d4935; color: #e1c592; }
.counter-btns button:hover:not(:disabled) { background: #4a382a; }

/* Selector de coste de acción: SIEMPRE 64×54 px, el desplegable invisible cubre todo el control */
.ap { position: relative; display: grid; place-items: center; flex: none; width: 64px; height: 54px; border-radius: 4px;
  background: var(--field); border: 1px solid #6b5539; cursor: pointer; }
.ap-icon { display: grid; place-items: center; width: 40px; height: 34px; pointer-events: none; }
.ap-icon img { max-width: 40px; max-height: 32px; object-fit: contain; }
.ap-icon span { font: 20px var(--serif); color: var(--muted); }
.ap > .ic { position: absolute; right: 3px; bottom: 3px; color: #b99a6c; pointer-events: none; }
.ap select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ap:hover { border-color: var(--gold); }
.ap:focus-within { outline: 2px solid var(--gold); outline-offset: 1px; }
.ap.is-locked { opacity: .5; }

/* ── 7. Ficha Rosetta ── */
.sheet-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; border-bottom: 1px solid #695338; }
.view-switch { display: flex; gap: 4px; }
.view-switch button { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; background: none; border: 0; border-bottom: 2px solid transparent; color: #ad9878; font-size: 13px; }
.view-switch button:hover:not(:disabled) { color: #ffe1a8; }
.view-switch button.selected { color: #f7d79e; border-bottom-color: #d0a15c; }
.sheet-buttons { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.demo-note { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; color: #cfb27f; font-size: 12px; white-space: nowrap; }

/* Contenedores con esquinas cortadas (la forma de mask-corner-1..4): marco de 1 px que sigue también
   la diagonal, y un triangulito dorado suelto en cada esquina. Se dibuja con ::before (marco) y
   ::after (relleno) recortados con clip-path, así el contenido nunca se recorta y funciona en todos
   los navegadores. Cada caja solo cambia --frame, --fill y --cut. */
.pane, .weapon, .action-card {
  --cut: 14px; --frame: #6a5337; --tri: #9a7848; --fill: linear-gradient(180deg, #2a2526, var(--panel));
  --shape: polygon(var(--cut) 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)),
                   calc(100% - var(--cut)) 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 var(--cut));
  position: relative; isolation: isolate; min-width: 0; border: 0;
  background:
    linear-gradient(135deg, var(--tri) 0 5px, transparent 5px) left top / 9px 9px no-repeat,
    linear-gradient(225deg, var(--tri) 0 5px, transparent 5px) right top / 9px 9px no-repeat,
    linear-gradient(315deg, var(--tri) 0 5px, transparent 5px) right bottom / 9px 9px no-repeat,
    linear-gradient(45deg, var(--tri) 0 5px, transparent 5px) left bottom / 9px 9px no-repeat; }
.pane::before, .weapon::before, .action-card::before,
.pane::after, .weapon::after, .action-card::after { content: ""; position: absolute; pointer-events: none; clip-path: var(--shape); }
.pane::before, .weapon::before, .action-card::before { inset: 0; z-index: -2; background: var(--frame); }
.pane::after, .weapon::after, .action-card::after { inset: 1px; z-index: -1; background: var(--fill); }
.pane { margin-bottom: var(--gap); }
/* Cabecera del panel: línea con puntas (divider_mask_left/right) y floritura central */
.pane-head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px 11px; }
.pane-head::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -3px; height: 6px; pointer-events: none;
  background: linear-gradient(90deg, #4a3a29, #8a6a43 50%, #4a3a29) center / 100% 1px no-repeat;
  -webkit-mask: url(../img/rosetta-icons/ornaments/divider_mask_left.svg) left center / 2000px 6px no-repeat,
                url(../img/rosetta-icons/ornaments/divider_mask_right.svg) right center / 2000px 6px no-repeat;
  -webkit-mask-composite: source-in;
  mask: url(../img/rosetta-icons/ornaments/divider_mask_left.svg) left center / 2000px 6px no-repeat,
        url(../img/rosetta-icons/ornaments/divider_mask_right.svg) right center / 2000px 6px no-repeat;
  mask-composite: intersect; }
.pane-head::before { content: ""; position: absolute; left: 50%; bottom: -4px; width: 24px; height: 9px; transform: translateX(-50%); z-index: 1; pointer-events: none;
  background: url(../img/rosetta-icons/ornaments/navigation-border-bottom.svg) center / contain no-repeat; }
.pane-head h3 { display: flex; align-items: center; gap: 8px; min-width: 0; color: #efd3a1; font-size: 17px; }
.pane-head h3 .ic { color: #cca66d; }
.pane-count { color: #a99178; font-size: 11px; white-space: nowrap; }
.pane-body { padding: 12px 14px 14px; container-type: inline-size; }
.subheading { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; color: #d9b980; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.subheading::after { content: ""; width: 34px; height: 7px; flex: none; background: url(../img/rosetta-icons/ornaments/divider-deco.svg) center / contain no-repeat; opacity: .8; }
.hint { color: #a89880; font-size: 12px; margin: 6px 0; }
.section-intro { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 12px; color: #b9a78d; font-size: 13px; }

/* Cuadrículas estables */
.grid-2, .grid-3, .grid-4, .grid-5 { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tight { gap: 8px; }
.grid-2 > .pane, .grid-3 > .pane, .grid-2 > div > .pane { margin-bottom: 0; }
.grid-2 > div > .pane + .pane { margin-top: var(--gap); }
.rs-content > .grid-2, .rs-content > .grid-3 { margin-bottom: var(--gap); }
.pane-body .grid-2 + .grid-2, .pane-body .grid-3 + .grid-3, .pane-body .grid-2 + .grid-3, .pane-body .grid-3 + .grid-2 { margin-top: 8px; }

/* Cabecera = bloque destacado: rayos arriba, arco central, esquinas finas abajo y rombo en la línea */
.hero { position: relative; margin-bottom: 14px; padding: 30px 22px 20px; border: 1px solid #6d5435; border-radius: var(--radius);
  background:
    url(../img/rosetta-icons/ornaments/card-top.svg) center top 2px / 190px auto no-repeat,
    url(../img/rosetta-icons/ornaments/corner-small-left-bottom.svg) left 4px bottom 4px / 34px no-repeat,
    url(../img/rosetta-icons/ornaments/corner-small-right-bottom.svg) right 4px bottom 4px / 34px no-repeat,
    radial-gradient(ellipse at 50% 0, #4a372533, transparent 60%),
    linear-gradient(145deg, #2f2724, #1f1c1d);
  box-shadow: 0 10px 30px #0005; }
.hero::before, .hero::after { content: ""; position: absolute; top: 3px; width: 64px; height: 64px; pointer-events: none;
  background: url(../img/rosetta-icons/ornaments/box-corner.svg) center / contain no-repeat; opacity: .85; }
.hero::before { left: 3px; }
.hero::after { right: 3px; transform: scaleX(-1); }
.hero-top { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) 110px; gap: 18px; align-items: center; padding-bottom: 16px; border-bottom: 1px solid #4a3b2c; }
.hero-top::after { content: ""; position: absolute; left: 50%; bottom: -13px; width: 76px; height: 26px; transform: translateX(-50%); pointer-events: none;
  background: url(../img/rosetta-icons/ornaments/box-diamond.svg) center / contain no-repeat, radial-gradient(closest-side, #262122 70%, transparent); }
.hero-top > * { position: relative; z-index: 1; }
.avatar-frame { padding: 5px; border: 1px solid #8f7048;
  background:
    url(../img/rosetta-icons/ornaments/corner-medium.svg) left top / 12px no-repeat,
    url(../img/ornament-variants/corner-medium-90.svg) right top / 12px no-repeat,
    url(../img/ornament-variants/corner-medium-180.svg) right bottom / 12px no-repeat,
    url(../img/ornament-variants/corner-medium-270.svg) left bottom / 12px no-repeat; }
.avatar-frame .avatar { width: 76px; height: 76px; border: 0; border-radius: 2px; }
.overline { color: #cdac72; font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.hero-name { display: block; width: 100%; margin: 4px 0; padding: 0; background: none; border: 0; border-bottom: 1px solid transparent;
  color: #f6e2bb; font: 32px/1.2 var(--serif); text-shadow: 0 2px 12px #0008; }
input.hero-name:hover { border-bottom-color: #6b5539; }
input.hero-name:focus { outline: none; border-bottom-color: var(--gold); }
input.hero-name.is-pending { color: var(--pending); }
.hero-main p { color: var(--muted); font-size: 13px; }
.hero-level { text-align: center; color: #cdac72; font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.hero-level .f { margin-top: 4px; border-color: #6b5539; }
.hero-level .f-label { display: none; }
.hero-level .f-stat .f-input, .hero-level .f-stat .f-value { font-size: 30px; }
.hero-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.hero-fact { position: relative; }
.hero-fact > .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #cfa96b; pointer-events: none; z-index: 1; }
.hero-fact .f { padding-left: 36px; }

/* Pestañas: se quedan pegadas arriba al bajar por la ficha */
.tabbar { position: sticky; top: var(--topbar); z-index: 15; display: flex; gap: 4px; overflow-x: auto; margin: 0 -4px 4px; padding: 6px 4px 0;
  background: linear-gradient(180deg, #151417f5 70%, #151417e6); border-bottom: 1px solid #5a4630; scrollbar-width: none; scroll-margin-top: var(--topbar); }
.tabbar::-webkit-scrollbar { display: none; }
/* Las 9 pestañas se reparten el ancho por igual (si no caben, se desliza la barra) */
.tab { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; flex: 1 1 0; min-width: 64px; padding: 8px 8px 7px;
  font-size: 12px !important; line-height: 1.2; text-align: center; background: none; border: 1px solid transparent; border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; color: #b5a287; font-size: 13px; }
.tab:hover { color: #ffe1a8; background: #2a2320; }
.tab.active { color: #f7dca5; border-color: #8d6c43;
  background:
    url(../img/rosetta-icons/ornaments/select-corner-active-left-top.svg) left 2px top 2px / 9px no-repeat,
    url(../img/rosetta-icons/ornaments/select-corner-active-right-top.svg) right 2px top 2px / 9px no-repeat,
    linear-gradient(180deg, #47362a, #2a2321); }
.chapter { display: flex; align-items: center; gap: 12px; margin: 16px 0 14px; }
.chapter-star { color: var(--gold); font-size: 18px; }
.chapter small { display: block; color: #b19773; font-size: 9px; letter-spacing: .14em; }
.chapter h2 { color: #f5dcac; font-size: 28px; }
/* Divisor del título: ocupa todo el ancho que queda. Línea dorada con puntas (divider_mask_left/right)
   y la trenza frame-decor centrada encima. */
.chapter > div { flex: none; }
.chapter-line { position: relative; flex: 1; height: 16px; min-width: 40px;
  background: url(../img/rosetta-icons/ornaments/frame-decor.svg) center / contain no-repeat; }
.chapter-line::before { content: ""; position: absolute; left: 0; right: 0; top: 5px; height: 6px; z-index: -1;
  background: linear-gradient(90deg, #6b5235, #c9a06a 30%, #e9cfa0 50%, #c9a06a 70%, #6b5235) center / 100% 2px no-repeat;
  -webkit-mask: url(../img/rosetta-icons/ornaments/divider_mask_left.svg) left center / 2000px 6px no-repeat,
                url(../img/rosetta-icons/ornaments/divider_mask_right.svg) right center / 2000px 6px no-repeat;
  -webkit-mask-composite: source-in;
  mask: url(../img/rosetta-icons/ornaments/divider_mask_left.svg) left center / 2000px 6px no-repeat,
        url(../img/rosetta-icons/ornaments/divider_mask_right.svg) right center / 2000px 6px no-repeat;
  mask-composite: intersect; }
.chapter-line { isolation: isolate; }
.bottom-help { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--faint); font-size: 12px; }

/* ── 8. Pestañas una a una ── */

/* Detalles */
.local-icon { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 10px; align-items: center; }
.local-icon img, .local-icon-empty { width: 46px; height: 46px; object-fit: contain; display: grid; place-items: center; color: var(--placeholder);
  border: 1px solid var(--line-soft); border-radius: 4px; background: var(--field); }
.abilities { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.ability { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line-soft); border-radius: 4px; background: linear-gradient(180deg, #252021, #1d1b1c); }
.ability-title { display: flex; align-items: center; gap: 7px; min-width: 0; color: #e7cf9f; font: 15px var(--serif); }
.ability-title img { width: 30px; height: 30px; object-fit: contain; flex: none; }
.ability-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Defensas */
.defense-strip { display: grid; grid-template-columns: 90px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.save-table { display: grid; gap: 6px; }
.save-head, .save-row { display: grid; grid-template-columns: 90px repeat(3, minmax(0, 1fr)); gap: 8px; align-items: center; }
.save-head { color: #a99178; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.save-row strong { color: #ecd3a4; font: 15px var(--serif); }
.save-row .f + .f { margin-top: 0; }
.pg-layout { display: grid; gap: 10px; }
.status-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.status-list .subheading { grid-column: 1 / -1; margin: 4px 0 0; }

/* Ataques */
.weapon-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.weapon { display: grid; gap: 8px; padding: 14px 12px; --cut: 12px; --frame: #5e4a33; --fill: #221f20; }
.weapon .f + .f { margin-top: 0; }
.weapon-top { display: flex; align-items: center; gap: 8px; color: #cfa96b; font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.weapon-nameplate { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 8px; align-items: stretch; }
.weapon-nameplate .ap { height: auto; min-height: 54px; }
.weapon-group { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 8px; align-items: center; }
.weapon-group img, .weapon-group-empty { width: 40px; height: 40px; object-fit: contain; }
.ammo-strip { max-width: 360px; margin-bottom: var(--gap); }

/* Acciones */
.action-col { display: grid; gap: 10px; align-content: start; }
.action-card { display: grid; gap: 8px; padding: 12px 10px; --cut: 12px; --frame: #5e4a33; --fill: #221f20; }
.action-card .f + .f { margin-top: 0; }
.action-title { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 8px; }

/* Magia */
.slot-grid { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 6px; }
.slot { display: grid; gap: 4px; align-content: start; text-align: center; }
.slot > span { color: #cfae76; font-size: 11px; font-weight: 700; }
.slot .f { padding: 5px 4px; }
.slot .f-label { justify-content: center; font-size: 9px; letter-spacing: .03em; }
.slot .f + .f { margin-top: 0; }
.slot .f-stat .f-input, .slot .f-stat .f-value { font-size: 18px; }
.spell-list { display: grid; gap: 10px; }
.spell-row { display: grid; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid #3a3029; }
.spell-row:last-child { border-bottom: 0; padding-bottom: 0; }
.spell-row .f + .f { margin-top: 0; }
.spell-attrs { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
.spell-attrs .f { flex: 1 1 110px; margin: 0; }
.spell-attrs .tg { align-self: center; }
.spell-checks { display: flex; flex-wrap: wrap; gap: 14px; }
.wip { display: inline-block; margin-bottom: 10px; padding: 6px 12px; border: 1px dashed var(--pending); color: var(--pending); font-weight: 700; letter-spacing: .12em; }

/* Habilidades: en dos líneas si el hueco es estrecho, en una sola si cabe */
.skill-col { display: grid; gap: 8px; align-content: start; container-type: inline-size; }
.skill { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name name" "ranks values"; gap: 6px 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 4px; background: linear-gradient(90deg, #232021, #1d1b1c); }
.skill:hover { border-color: #5a4733; }
.skill-name { grid-area: name; display: flex; align-items: center; gap: 8px; min-width: 0; }
.skill-name img { width: 30px; height: 30px; object-fit: contain; flex: none; }
.skill-name strong { min-width: 0; color: #ecd3a4; font: 16px var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-name small { color: #9f8b70; font-size: 10px; letter-spacing: .08em; }
.skill-name .tg { margin-left: auto; min-height: 26px; padding-right: 6px; font-size: 11px; }
.skill-values { grid-area: values; display: grid; grid-template-columns: 70px 70px; gap: 6px; }
.skill-values .f + .f { margin-top: 0; }
.skill-values .f { padding: 4px 6px; }
.skill-values .f-num { width: auto; }
.skill-values .f-stat .f-input, .skill-values .f-stat .f-value { font-size: 18px; }
.skill-ranks { grid-area: ranks; margin: 0; }
.skill-ranks .tg { min-width: 40px; height: 36px; justify-content: center; }
@container (min-width: 600px) {
  .skill { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name ranks values"; }
}

/* Equipo */
.coins > .f:nth-child(1) { --coin: #c27b4a; }
.coins > .f:nth-child(2) { --coin: #c9ced6; }
.coins > .f:nth-child(3) { --coin: #e7bd52; }
.coins > .f:nth-child(4) { --coin: #b9e2ea; }
.coins > .f { border-top: 2px solid var(--coin); }
.coins > .f .f-label::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff8, var(--coin) 55%); flex: none; }
.inv-list { display: grid; gap: 8px; }
.inv-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 110px; gap: 6px; align-items: stretch; }
.inv-row:has(.inv-invest), .inv-row:not(:has(> :nth-child(3))) { grid-template-columns: minmax(0, 1fr) 70px 74px; }
.inv-row .f + .f { margin-top: 0; }
.inv-row .counter { grid-template-columns: minmax(0, 1fr) auto 26px; min-height: 0; padding: 4px 4px 4px 8px; gap: 4px; }
.inv-row .counter strong { font-size: 18px; }
.inv-invest { display: grid; justify-items: center; gap: 2px; padding: 5px 4px; border: 1px solid var(--line-soft); border-radius: 4px; background: var(--field); }
.inv-invest .tg { padding: 3px; }

/* Biografía */
.portrait { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.portrait-preview { aspect-ratio: 3 / 4; display: grid; place-items: center; overflow: hidden; border: 1px solid #6b5539; border-radius: 4px; background: #1a1819; box-shadow: inset 0 0 30px #0008; }
.portrait-preview img { width: 100%; height: 100%; object-fit: cover; }
.portrait-empty { display: grid; justify-items: center; gap: 8px; color: var(--placeholder); text-align: center; padding: 10px; }
.portrait-controls { display: grid; gap: 8px; align-content: start; }

/* ── 9. Celdas originales ── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { padding: 7px 11px; border-radius: 4px; background: #252123; border: 1px solid #54432e; color: #b6a386; font-size: 12px; }
.chip:hover { color: #ffe1a8; border-color: #7d6040; }
.chip.active { color: #fde0b0; background: #503825; border-color: #aa8350; }
.grid-pane .pane-body { padding: 0; }
.pager { display: flex; align-items: center; gap: 6px; color: #e1c8a2; font-size: 13px; }
.grid-scroll { overflow: auto; max-height: 70vh; }
.cells { border-collapse: collapse; font-size: 12px; }
.cells th { position: sticky; top: 0; background: #3c3026; color: #e1c397; font-weight: 600; padding: 4px 6px; border: 1px solid #584532; }
.cells tbody th { position: sticky; left: 0; z-index: 1; }
.cells td { border: 1px solid #51412f; padding: 0; min-width: 90px; max-width: 220px; }
.cells td input { width: 100%; padding: 5px 6px; background: #242124; border: 0; color: #e4d5bd; }
.cells td input:focus { outline: 2px solid var(--gold); outline-offset: -2px; }
.cells td.locked { padding: 5px 6px; background: #2d2b2d; color: #8f8578; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cells td.is-pending input { background: var(--pending-bg); color: #ffe0ad; }
.grid-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 9px 14px; color: #bca883; font-size: 12px; }

/* ── 10. Pantallas medianas y pequeñas ── */
@media (max-width: 1250px) {
  .abilities { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .slot-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .weapon-grid { grid-template-columns: minmax(0, 1fr); }
  .rs-content > .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .menu-open .sidebar { transform: none; box-shadow: 10px 0 40px #000a; }
  .menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: #0009; }
  .topbar .menu-btn { display: inline-grid; }
  .rs-content .grid-2:not(.tight) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  :root { --gap: 10px; }
  .main { padding: 14px 16px 120px; }
  .pill { padding: 5px 7px; font-size: 9px; }
  .busy { max-width: 46vw; }
  .hero { padding: 26px 14px 14px; background-size: 140px auto, 26px, 26px, auto, auto; }
  .hero::before, .hero::after { width: 42px; height: 42px; }
  .hero-top { grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
  .hero-level { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
  .hero-level .f { margin: 0; flex: 1; padding: 2px 8px; }
  .hero-name { font-size: 25px; }
  .avatar-frame .avatar { width: 60px; height: 60px; }
  .hero-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .abilities { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chapter h2 { font-size: 23px; }
  .tab { flex-direction: row; min-width: 44px; padding: 10px 10px; }
  .tab span { display: none; }
  .tab.active { min-width: max-content; }
  .tab.active span { display: inline; }
  .pane-body { padding: 10px; }
  .pane-head { padding: 11px 14px 8px; }
  .save-dock { left: 10px; right: 10px; bottom: 10px; justify-content: space-between; }
  .sheet-actions { border-bottom: 0; }
  .view-switch { width: 100%; border-bottom: 1px solid #695338; }
  .view-switch button { flex: 1; justify-content: center; }
  .sheet-buttons { width: 100%; }
  .sheet-buttons .btn { flex: 1; }
  .sheet-buttons .btn.secondary { flex: none; width: 44px; padding: 0; }
  .sheet-buttons .btn.secondary span { display: none; }
  .skill { gap: 6px; padding: 8px; }
  .skill-values { grid-template-columns: 54px 54px; gap: 4px; }
  .skill-ranks { gap: 3px; }
  .skill-ranks .tg { min-width: 36px; padding: 2px 4px 2px 3px; gap: 3px; }
  .inv-row { grid-template-columns: minmax(0, 1fr) 60px 96px; }
}

/* Ajustes según el ancho del PANEL (no de la pantalla). Van al final para mandar sobre lo anterior. */
@container (max-width: 520px) {
  /* Las filas de solo números (PG, impedimenta…) mantienen sus 3 columnas; las de texto bajan a 2 */
  .grid-3.tight:has(> :not(.f-stat, .counter)), .grid-4.tight { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .slot-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .portrait { grid-template-columns: minmax(0, 1fr); }
}
@container (max-width: 380px) {
  .grid-2.tight { grid-template-columns: minmax(0, 1fr); }
  .slot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .save-head { display: none; }
  .save-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .save-row strong { grid-column: 1 / -1; }
  .defense-strip { grid-template-columns: 80px minmax(0, 1fr); }
  .defense-strip > :last-child { grid-column: 1 / -1; }
}
