/* Crimson Flower — guia vivo
   The look borrows from the game's menus: night-blue panels with a thin gold frame, Cinzel capitals
   for titles, crimson for the Adrestian side, and parchment pages for the monthly notes. The only
   game art is the character portraits (img/portraits); everything else is drawn here. */

@layer reset, tokens, base, layout, components, views, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
  ul, ol { padding: 0; }
  img, svg { display: block; max-width: 100%; }
  input, select, textarea, button { font: inherit; color: inherit; }
  table { border-collapse: collapse; }
}

@layer tokens {
  :root {
    color-scheme: dark;

    --bg: #0b0e15;
    --bg-2: #0f131c;
    --panel: #121824;
    --panel-hi: #182030;
    --panel-2: #1c2536;
    --field: #0e131d;
    --line: rgb(214 180 106 / 0.2);
    --line-strong: rgb(214 180 106 / 0.45);
    --line-soft: rgb(236 230 216 / 0.08);

    --gold: #d6b46a;
    --gold-hi: #f0d898;
    --gold-lo: #8d6a2c;
    --crimson: #b3203a;
    --crimson-hi: #e2566c;
    --crimson-lo: #5c0f1e;

    --ink: #ece6d8;
    --ink-2: #cbc3b2;
    --muted: #9a917f;

    --ok: #5cc79d;
    --ok-bg: rgb(92 199 157 / 0.12);
    --warn: #e9b450;
    --warn-bg: rgb(233 180 80 / 0.12);
    --bad: #f07385;
    --bad-bg: rgb(240 115 133 / 0.12);
    --info: #86b6e6;
    --info-bg: rgb(134 182 230 / 0.12);

    --parch: #efe5ca;
    --parch-2: #e5d7b3;
    --parch-ink: #2a2117;
    --parch-muted: #6c5a40;
    --parch-line: rgb(90 66 30 / 0.2);
    --parch-accent: #8c1b2e;

    --house-crimson: #c62f47;
    --house-blue: #4482d8;
    --house-yellow: #e2b443;
    --house-violet: #9077d6;
    --house-green: #51ab82;
    --house-grey: #8d929c;
    --house-gold: #d6b46a;

    --radius: 12px;
    --radius-sm: 8px;
    --ring: 0 0 0 3px rgb(240 216 152 / 0.22);
    --pop-bg: #161d2b;
    --pop-shadow: 0 22px 48px -14px rgb(0 0 0 / 0.9), 0 0 0 1px rgb(0 0 0 / 0.35);
    --gap: clamp(14px, 2.2vw, 22px);
    --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 18px 40px -24px rgb(0 0 0 / 0.8);

    --font: "Alegreya Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --display: "Cinzel", "Trajan Pro", "Times New Roman", Georgia, serif;
  }
}

@layer base {
  html {
    background: var(--bg);
    scroll-padding-top: 72px;
    scrollbar-color: rgb(214 180 106 / 0.35) var(--bg);
  }

  /* house colours, for portraits and the cards that carry them */
  [data-house] { --c: var(--house-gold); }
  [data-house="crimson"] { --c: var(--house-crimson); }
  [data-house="blue"] { --c: var(--house-blue); }
  [data-house="yellow"] { --c: var(--house-yellow); }
  [data-house="violet"] { --c: var(--house-violet); }
  [data-house="green"] { --c: var(--house-green); }
  [data-house="grey"] { --c: var(--house-grey); }

  body {
    min-height: 100dvh;
    color: var(--ink);
    font: 400 1.0625rem/1.55 var(--font);
    font-variant-numeric: lining-nums tabular-nums;
    background:
      radial-gradient(1200px 520px at 12% -8%, rgb(179 32 58 / 0.22), transparent 62%),
      radial-gradient(900px 480px at 100% 0%, rgb(214 180 106 / 0.1), transparent 60%),
      linear-gradient(180deg, var(--bg-2), var(--bg) 420px);
    background-color: var(--bg);
    overflow-x: hidden;
  }

  h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: 0.02em; line-height: 1.2; }
  a { color: var(--gold-hi); text-decoration-color: rgb(240 216 152 / 0.4); text-underline-offset: 3px; }
  a:hover { text-decoration-color: currentColor; }
  strong { font-weight: 800; color: #fff6e2; }
  small { font-size: 0.85em; }
  :focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; border-radius: 4px; }
  ::selection { background: rgb(179 32 58 / 0.6); color: #fff; }
}

@layer layout {
  .wrap {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  }

  .sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

  .sky {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
      radial-gradient(1px 1px at 12% 22%, rgb(255 240 210 / 0.5), transparent),
      radial-gradient(1px 1px at 34% 8%, rgb(255 240 210 / 0.35), transparent),
      radial-gradient(1.5px 1.5px at 72% 14%, rgb(255 240 210 / 0.45), transparent),
      radial-gradient(1px 1px at 88% 30%, rgb(255 240 210 / 0.3), transparent),
      radial-gradient(1px 1px at 55% 26%, rgb(255 240 210 / 0.25), transparent);
    mask-image: linear-gradient(180deg, #000, transparent 40%);
  }

  .mast { padding-block: 18px 12px; }
  .mast-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

  .brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
  .sigil { width: 58px; height: 58px; flex: none; filter: drop-shadow(0 4px 14px rgb(179 32 58 / 0.35)); }
  .brand-text { display: grid; line-height: 1.05; }
  .eyebrow { font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
  .title {
    font-family: var(--display);
    font-size: clamp(1.6rem, 4.6vw, 2.3rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    background: linear-gradient(180deg, #fff2c8 10%, var(--gold) 55%, var(--gold-lo));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .subtitle { font-size: 0.85rem; color: var(--ink-2); font-style: italic; }

  .plate {
    padding: 7px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: linear-gradient(180deg, rgb(179 32 58 / 0.25), rgb(92 15 30 / 0.35));
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--gold-hi);
    white-space: nowrap;
  }
  .plate:empty { display: none; }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgb(11 14 21 / 0.82);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border-block: 1px solid var(--line);
  }
  .tabs-row {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
  }
  .tabs-row::-webkit-scrollbar { display: none; }
  .tabs a {
    flex: none;
    scroll-snap-align: start;
    padding: 13px 14px 11px;
    font-family: var(--display);
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--ink-2);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
  }
  .tabs a:hover { color: var(--gold-hi); }
  .tabs a[aria-current="page"] { color: var(--gold-hi); border-bottom-color: var(--crimson-hi); }

  main { padding-block: 26px 48px; }
  main:focus { outline: none; }

  .view { display: grid; gap: var(--gap); }
  .view-head { display: grid; gap: 6px; max-width: 78ch; }
  .view-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); color: var(--gold-hi); }
  .kicker { font-size: 0.78rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--crimson-hi); font-weight: 800; }
  .lead { color: var(--ink-2); font-size: 1.05rem; }

  .cols { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }

  .foot { border-top: 1px solid var(--line); padding-block: 22px 36px; color: var(--muted); font-size: 0.9rem; }
  .foot p + p { margin-top: 6px; }

  .skip {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 50;
    padding: 10px 14px;
    background: var(--gold);
    color: #1a1208;
    border-radius: 8px;
    font-weight: 800;
  }
  .skip:focus { top: 12px; }
}

@layer components {
  /* panels with the thin gold frame */
  .card, .unit-card, .recruit-card, .para-card, .tile {
    position: relative;
    background: linear-gradient(180deg, var(--panel-hi), var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .card::before, .unit-card::before, .recruit-card::before, .para-card::before, .tile::before {
    content: "";
    position: absolute;
    inset: -1px 18% auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-hi), transparent);
    opacity: 0.55;
  }
  .card { padding: clamp(16px, 2.4vw, 22px); display: grid; gap: 12px; align-content: start; min-width: 0; }
  .card-title { font-size: 1.12rem; color: var(--gold-hi); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .card-title .count { margin-left: auto; font-family: var(--font); font-weight: 800; color: var(--ink-2); font-size: 0.95rem; }
  .card-lead { color: var(--ink-2); font-size: 0.97rem; }
  .sub { font-size: 0.92rem; color: var(--ink-2); letter-spacing: 0.08em; text-transform: uppercase; font-family: var(--font); font-weight: 800; }
  .more { font-size: 0.95rem; }
  .hint { color: var(--muted); font-size: 0.9rem; }
  .muted { color: var(--muted); }
  .warn { color: var(--warn); }
  .good { color: var(--ok); }
  .bad { color: var(--bad); }
  .empty { color: var(--muted); font-style: italic; }

  /* tiles */
  .tiles { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
  .tile { padding: 16px 18px; display: grid; gap: 2px; overflow: hidden; }
  .tile::after {
    content: "";
    position: absolute;
    right: -26px;
    bottom: -26px;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    border: 1px solid var(--line);
    box-shadow: 0 0 0 10px rgb(214 180 106 / 0.03), 0 0 0 22px rgb(214 180 106 / 0.02);
  }
  .tile-label { font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
  .tile-value { font-family: var(--display); font-size: 2.1rem; font-weight: 700; color: var(--gold-hi); line-height: 1.1; }
  .tile-value .of { font-size: 1.1rem; color: var(--muted); margin-left: 2px; }
  .tile-sub { color: var(--ink-2); font-size: 0.92rem; }
  .tile-sub.stack { display: flex; padding-top: 4px; }
  .tile-sub.stack a { display: block; border-radius: 50%; }
  .tile-sub.stack a + a { margin-left: -6px; }

  /* icons, ranks, chips */
  .ico { width: 1.05em; height: 1.05em; flex: none; display: inline-block; vertical-align: -0.15em; color: var(--gold); }
  .skill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

  .rk {
    display: inline-grid;
    place-items: center;
    min-width: 2.1em;
    padding: 1px 6px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--ink);
    background: var(--panel-2);
    border: 1px solid var(--line-soft);
  }
  .rk.need { color: var(--gold-hi); border-color: var(--line-strong); background: rgb(214 180 106 / 0.08); }
  .rk.unknown { color: var(--muted); border-style: dashed; border-color: rgb(154 145 127 / 0.5); background: transparent; }
  .arrow { color: var(--muted); margin-inline: 4px; }

  .chip, .tag, .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid var(--line-soft);
    background: var(--panel-2);
    color: var(--ink-2);
  }
  .chip.ability { border-color: var(--line-strong); color: var(--gold-hi); cursor: help; }
  .chip.art { border-color: rgb(226 86 108 / 0.5); color: #ffc2cb; cursor: help; }
  .chip .lock { font-size: 0.8em; }
  .chip .dot { width: 7px; height: 7px; margin-right: 2px; }
  button.chip { font-size: 0.8rem; transition: border-color 0.15s, background-color 0.15s; }
  button.chip:hover { border-color: currentColor; }
  button.chip:focus-visible { outline: none; box-shadow: var(--ring); }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .chips-label, .goals-label { font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin-right: 4px; }

  .tag { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 8px; }
  .tag-recrutar { background: rgb(144 119 214 / 0.16); color: #cfc2f4; border-color: rgb(144 119 214 / 0.4); }
  .tag-classe { background: rgb(214 180 106 / 0.12); color: var(--gold-hi); border-color: var(--line-strong); }
  .tag-social { background: rgb(226 86 108 / 0.12); color: #ffc2cb; border-color: rgb(226 86 108 / 0.35); }
  .tag-treino { background: var(--info-bg); color: var(--info); border-color: rgb(134 182 230 / 0.35); }
  .tag-paralogue { background: var(--ok-bg); color: var(--ok); border-color: rgb(92 199 157 / 0.35); }
  .tag-rota { background: rgb(179 32 58 / 0.3); color: #ffd7dd; border-color: rgb(226 86 108 / 0.6); }
  .tag-info, .tag-batalha { background: var(--panel-2); color: var(--ink-2); }
  .tag-ok { background: var(--ok-bg); color: var(--ok); border-color: rgb(92 199 157 / 0.35); }

  .badge.ok { background: var(--ok-bg); color: var(--ok); border-color: rgb(92 199 157 / 0.4); }
  .badge.miss { background: var(--bad-bg); color: var(--bad); border-color: rgb(240 115 133 / 0.4); }
  .badge.info { background: var(--info-bg); color: var(--info); border-color: rgb(134 182 230 / 0.35); }

  .role-titular { color: var(--gold-hi); border-color: var(--line-strong); background: rgb(214 180 106 / 0.1); }
  .role-rotacao { color: #ffc2cb; border-color: rgb(226 86 108 / 0.4); }
  .role-reserva { color: var(--info); }
  .role-utilitario, .role-temporaria, .role-ignorar { color: var(--muted); }

  /* portraits in a ring of the house colour; the initial shows if the image is missing */
  .avatar {
    --size: 44px;
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    overflow: hidden;
    background:
      radial-gradient(circle at 50% 28%, color-mix(in oklab, var(--c) 62%, white 12%) 0%, color-mix(in oklab, var(--c) 58%, black) 78%);
    box-shadow:
      0 0 0 2px var(--bg),
      0 0 0 3.5px color-mix(in oklab, var(--c) 50%, var(--gold)),
      0 8px 18px -8px rgb(0 0 0 / 0.9);
  }
  .avatar::before {
    content: attr(data-initial);
    grid-area: 1 / 1;
    font-family: var(--display);
    font-weight: 700;
    font-size: calc(var(--size) * 0.44);
    color: #fff8e6;
    text-shadow: 0 1px 2px rgb(0 0 0 / 0.5);
  }
  .avatar:has(img)::before { content: none; }
  .avatar img {
    grid-area: 1 / 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.2s;
  }
  .avatar.dim img { filter: grayscale(0.9) brightness(0.72) contrast(0.95); }
  .avatar.dim { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px rgb(154 145 127 / 0.45), 0 8px 18px -8px rgb(0 0 0 / 0.9); }
  .avatar.xs { --size: 22px; box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--c) 55%, var(--gold)); }
  .avatar.sm { --size: 30px; box-shadow: 0 0 0 1.5px var(--bg), 0 0 0 2.5px color-mix(in oklab, var(--c) 55%, var(--gold)); }
  .avatar.md { --size: 40px; }
  .avatar.lg { --size: 54px; }
  .avatar.xl {
    --size: clamp(88px, 16vw, 128px);
    box-shadow:
      0 0 0 3px var(--bg),
      0 0 0 5px color-mix(in oklab, var(--c) 45%, var(--gold-hi)),
      0 0 0 9px rgb(214 180 106 / 0.08),
      0 20px 40px -14px rgb(0 0 0 / 0.9);
  }
  .avatar.xs.dim, .avatar.sm.dim { box-shadow: 0 0 0 1.5px rgb(154 145 127 / 0.45); }
  a:hover > .avatar:not(.dim), a:focus-visible > .avatar:not(.dim) {
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--gold-hi), 0 8px 18px -8px rgb(0 0 0 / 0.9);
  }

  .person { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
  .people { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
  a.person { text-decoration: none; }
  a.person:hover { text-decoration: underline; }

  /* forms */
  .field { display: grid; gap: 5px; min-width: 0; align-content: start; }
  .field.grow { flex: 1 1 200px; }
  .field.block { width: 100%; }
  .field-label { font-size: 0.78rem; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 6px; }
  .field-label .skill { gap: 5px; }
  .field-label .ico { color: var(--gold-lo); }
  input[type="text"], input[type="number"], textarea {
    width: 100%;
    min-height: 42px;
    line-height: 1.3;
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--field);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  input[type="text"]:hover, input[type="number"]:hover, textarea:hover { border-color: var(--line-strong); }
  input::placeholder, textarea::placeholder { color: rgb(154 145 127 / 0.7); }
  textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
  input[type="text"]:focus-visible, input[type="number"]:focus-visible, textarea:focus-visible {
    outline: none;
    border-color: var(--gold-hi);
    box-shadow: var(--ring);
  }
  input[type="number"] { appearance: textfield; -moz-appearance: textfield; font-weight: 700; }
  input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  .form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
  .form-row > .field:not(.grow) { flex: 0 1 160px; }
  .form-grid { display: grid; gap: 10px; }
  .form-grid.stats { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .form-grid.stats input { text-align: center; }
  .form-grid.ranks { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }

  /* number with − and + */
  .stepper-box {
    display: flex;
    align-items: stretch;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--field);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .stepper-box:hover { border-color: var(--line-strong); }
  .stepper-box:focus-within { border-color: var(--gold-hi); box-shadow: var(--ring); }
  .stepper-box input[type="number"] { flex: 1; min-width: 0; min-height: 40px; border: 0; border-radius: 0; text-align: center; background: transparent; box-shadow: none; }
  .stepper-box input[type="number"]:focus-visible { box-shadow: none; }
  .step-btn {
    flex: none;
    width: 38px;
    display: grid;
    place-items: center;
    border: 0;
    background: rgb(255 255 255 / 0.03);
    color: var(--gold);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
  }
  .step-btn:hover { background: rgb(214 180 106 / 0.12); color: var(--gold-hi); }
  .step-btn:active { background: rgb(214 180 106 / 0.2); }
  .step-btn:focus-visible { outline: none; background: rgb(214 180 106 / 0.16); color: var(--gold-hi); }
  .step-btn .ico { color: inherit; width: 16px; height: 16px; }

  /* select: a button that opens a listbox (js/controls/select.js) */
  .sel-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 6px 10px 6px 12px;
    line-height: 1.3;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgb(255 255 255 / 0.03), transparent 60%), var(--field);
    color: var(--ink);
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
  }
  .sel-trigger:hover { border-color: var(--line-strong); }
  .sel-trigger[aria-expanded="true"] { border-color: var(--gold); box-shadow: var(--ring); }
  .sel-trigger:focus-visible { outline: none; border-color: var(--gold-hi); box-shadow: var(--ring); }
  .sel-value { display: inline-flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; }
  .sel-value .sel-opt-label { overflow: hidden; text-overflow: ellipsis; }
  .sel-placeholder { color: var(--muted); font-weight: 400; }
  .sel-chev { width: 16px; height: 16px; flex: none; color: var(--muted); transition: color 0.15s; }
  .sel-trigger:hover .sel-chev, .sel-trigger[aria-expanded="true"] .sel-chev { color: var(--gold-hi); }
  .sel.sm .sel-trigger { min-height: 32px; padding: 3px 8px 3px 11px; gap: 6px; font-size: 0.86rem; border-radius: 999px; }
  .sel.sm .sel-chev { width: 14px; height: 14px; }

  .sel-pop {
    position: fixed;
    inset: auto;
    margin: 0;
    min-width: 168px;
    padding: 5px;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: var(--pop-bg);
    color: var(--ink);
    box-shadow: var(--pop-shadow);
    scrollbar-width: thin;
    scrollbar-color: rgb(214 180 106 / 0.35) transparent;
  }
  .sel-pop:not([data-side]) { visibility: hidden; }
  .sel-pop[data-side="top"] { transform-origin: 50% 100%; }
  .sel-group + .sel-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line-soft); }
  .sel-group-label {
    padding: 6px 10px 4px;
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 800;
  }
  .sel-opt {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 14px;
    min-height: 36px;
    padding: 6px 10px 6px 12px;
    border-radius: 7px;
    cursor: pointer;
    user-select: none;
  }
  .sel-opt-main { grid-column: 1; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
  .sel-opt-hint { grid-column: 1; font-size: 0.8rem; line-height: 1.3; color: var(--muted); }
  .sel-check { grid-column: 2; grid-row: 1 / span 2; width: 16px; height: 16px; color: var(--gold-hi); visibility: hidden; }
  .sel-opt[aria-selected="true"] .sel-check { visibility: visible; }
  .sel-opt[aria-selected="true"] .sel-opt-main { color: var(--gold-hi); }
  .sel-opt.active { background: rgb(214 180 106 / 0.12); }
  .sel-opt.active::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 9px;
    bottom: 9px;
    width: 2px;
    border-radius: 2px;
    background: var(--crimson-hi);
  }
  .sel-opt[aria-disabled="true"] { opacity: 0.45; cursor: default; }
  @media (pointer: coarse) {
    .sel-opt { min-height: 44px; }
  }

  .dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
  .dot.role-titular { background: var(--gold-hi); }
  .dot.role-rotacao { background: var(--crimson-hi); }
  .dot.role-reserva { background: var(--info); }
  .dot.role-utilitario, .dot.role-temporaria { background: var(--muted); }
  .dot.role-ignorar { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

  /* tooltip (js/controls/tooltip.js) */
  .tip {
    position: fixed;
    inset: auto;
    margin: 0;
    max-width: min(300px, calc(100vw - 16px));
    padding: 7px 11px;
    border: 1px solid rgb(90 66 30 / 0.4);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--parch), var(--parch-2));
    color: var(--parch-ink);
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 14px 30px -10px rgb(0 0 0 / 0.85);
    pointer-events: none;
    overflow: visible;
  }
  [data-tip] { cursor: help; }
  a[data-tip] { cursor: pointer; }

  /* confirmation dialog (js/controls/dialog.js) */
  .dialog {
    width: min(460px, calc(100vw - 32px));
    max-width: none;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    overflow: visible;
  }
  .dialog::backdrop { background: rgb(4 6 10 / 0.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
  .dialog-box {
    position: relative;
    display: grid;
    gap: 10px;
    padding: clamp(18px, 4vw, 26px);
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: linear-gradient(180deg, var(--panel-hi), var(--panel));
    box-shadow: var(--pop-shadow);
  }
  .dialog-box::before {
    content: "";
    position: absolute;
    inset: -1px 20% auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-hi), transparent);
  }
  .dialog-title { font-size: 1.2rem; color: var(--gold-hi); }
  .dialog-body { color: var(--ink-2); }
  .dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 10px; }

  /* switch */
  .switch { display: inline-flex; align-items: center; gap: 10px; min-height: 42px; cursor: pointer; font-weight: 700; color: var(--ink-2); user-select: none; }
  .switch:hover { color: var(--ink); }
  input[role="switch"] {
    appearance: none;
    flex: none;
    width: 42px;
    height: 24px;
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: radial-gradient(circle, #d9cfb9 0 7.5px, transparent 8.5px) 0 50% / 22px 22px no-repeat var(--panel-2);
    cursor: pointer;
    transition: background-position 0.18s ease, background-color 0.18s, border-color 0.18s;
  }
  input[role="switch"]:checked {
    border-color: var(--gold-hi);
    background-color: var(--crimson);
    background-image: radial-gradient(circle, #fff6df 0 7.5px, transparent 8.5px);
    background-position: 100% 50%;
  }
  input[role="switch"]:focus-visible { outline: none; box-shadow: var(--ring); }

  /* checkbox: a diamond, like the game's markers */
  input[type="checkbox"]:not([role="switch"]) {
    appearance: none;
    flex: none;
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    border: 1.5px solid var(--line-strong);
    border-radius: 4px;
    background: linear-gradient(var(--gold-hi), var(--gold-hi)) center / 0 0 no-repeat var(--field);
    transform: rotate(45deg) scale(0.86);
    cursor: pointer;
    transition: background-size 0.15s ease, background-color 0.15s, border-color 0.15s;
  }
  input[type="checkbox"]:not([role="switch"]):hover { border-color: var(--gold); }
  input[type="checkbox"]:not([role="switch"]):checked { border-color: var(--gold-hi); background-color: rgb(179 32 58 / 0.5); background-size: 8px 8px; }
  input[type="checkbox"]:not([role="switch"]):focus-visible { outline: none; box-shadow: var(--ring); }

  .toolbar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; }
  .toolbar .field { flex: 0 1 200px; }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: linear-gradient(180deg, rgb(255 255 255 / 0.04), transparent), var(--panel-2);
    color: var(--gold-hi);
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  }
  .btn:hover { background-color: #222c40; border-color: var(--gold); }
  .btn:active { transform: translateY(1px); }
  .btn:focus-visible { outline: none; box-shadow: var(--ring); }
  .btn.primary {
    background: linear-gradient(180deg, #c62a46, var(--crimson-lo));
    border-color: rgb(240 216 152 / 0.6);
    color: #fff3d6;
    box-shadow: 0 1px 0 rgb(255 255 255 / 0.18) inset, 0 8px 18px -10px rgb(179 32 58 / 0.9);
  }
  .btn.primary:hover { background: linear-gradient(180deg, #d23350, #6e1426); }
  .btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line-soft); }
  .btn.ghost:hover { color: var(--ink); border-color: var(--line-strong); background: rgb(255 255 255 / 0.03); }
  .btn.danger { background: linear-gradient(180deg, #a3192f, #4f0c19); border-color: rgb(240 115 133 / 0.6); color: #fff; }
  .btn.danger:hover { background: linear-gradient(180deg, #b81f37, #5c0f1e); }
  .btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

  /* lists */
  .checks { list-style: none; display: grid; gap: 8px; }
  .check { display: flex; gap: 12px; align-items: flex-start; padding: 8px 10px; border-radius: var(--radius-sm); background: rgb(255 255 255 / 0.02); border: 1px solid var(--line-soft); }
  .check label { cursor: pointer; }
  .check.done label { color: var(--muted); }
  .check.done strong { color: var(--ink-2); }
  .check .tag { margin-right: 4px; }

  .steps { list-style: none; counter-reset: s; display: grid; gap: 8px; }
  .step {
    counter-increment: s;
    display: block;
    padding: 9px 12px 9px 40px;
    position: relative;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft);
    background: rgb(255 255 255 / 0.02);
  }
  .step::before {
    content: counter(s);
    position: absolute;
    left: 10px;
    top: 9px;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 800;
    background: var(--panel-2);
    color: var(--ink-2);
  }
  .step.p1 { border-color: rgb(226 86 108 / 0.45); background: rgb(179 32 58 / 0.1); }
  .step.p1::before { background: var(--crimson); color: #fff; }
  .step .tag { margin-right: 8px; vertical-align: 1px; }
  .step a { color: var(--ink); text-decoration: none; }
  .step a:hover { color: var(--gold-hi); text-decoration: underline; }

  .note-list, .nb-points, .para-list, .todo, .advice { padding-left: 1.2em; display: grid; gap: 6px; }
  .todo .good { color: var(--ok); }

  details.more-box > summary, details.spoiler > summary { cursor: pointer; color: var(--gold-hi); font-weight: 700; }
  details.more-box[open] > summary { margin-bottom: 8px; }

  /* tables */
  .table-wrap { position: relative; overflow-x: auto; max-width: 100%; border-radius: var(--radius-sm); }
  .data { width: 100%; font-size: 0.95rem; }
  .data th, .data td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
  .data thead th { font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 800; border-bottom-color: var(--line); white-space: nowrap; }
  .data tbody th { font-weight: 800; color: var(--ink); }
  .data.compact th, .data.compact td { padding: 5px 8px; }
  .data tr:hover td, .data tr:hover th { background: rgb(255 255 255 / 0.02); }

  .toast {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translate(-50%, 140%);
    max-width: calc(100vw - 32px);
    padding: 11px 18px 11px 15px;
    border-radius: 12px;
    background: linear-gradient(180deg, #222b3e, #182030);
    border: 1px solid var(--line-strong);
    color: var(--ink);
    font-weight: 700;
    box-shadow: var(--pop-shadow);
    transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  }
  .toast-mark { flex: none; width: 10px; height: 10px; transform: rotate(45deg); background: var(--crimson); border: 1.5px solid var(--gold-hi); border-radius: 2px; }
  .toast:not(.show) { visibility: hidden; transition: transform 0.25s ease, visibility 0s 0.25s; }
  .toast.show { transform: translate(-50%, 0); }
}

@layer views {
  /* overview */
  .train { list-style: none; display: grid; gap: 12px; }
  .train li { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
  .train li:last-child { border-bottom: 0; padding-bottom: 0; }
  .train-head { display: flex; align-items: center; gap: 6px; }
  .train-for { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ink-2); font-size: 0.93rem; }
  .train-who { font-size: 0.93rem; color: var(--ink-2); }

  .deadlines, .bdays, .bday-all { list-style: none; display: grid; gap: 6px; }
  .deadlines li, .bdays li, .bday-all li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
  .deadlines li { display: grid; grid-template-columns: 92px 1fr; align-items: baseline; }
  .deadlines li .tag { grid-column: 2; justify-self: start; }
  .bdays li { align-items: center; }
  .deadlines .when, .bdays .date, .bday-all .date {
    flex: none;
    min-width: 92px;
    font-weight: 800;
    font-size: 0.86rem;
    color: var(--gold);
  }
  .deadlines .later a { color: var(--ink-2); }
  .deadlines .closing .when { color: var(--crimson-hi); }
  .bdays .gifts { flex-basis: 100%; padding-left: 102px; color: var(--muted); font-size: 0.88rem; }
  .bdays .today a { color: #fff; font-weight: 800; }
  .bdays .past a { color: var(--muted); }
  .bday-all { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .bday-all .date { min-width: 48px; }

  .progress-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
  .progress-row .field { flex: 0 1 180px; }

  /* squad */
  .lineup { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 2px 6px; }
  .lineup a { display: block; border-radius: 50%; }
  .comp-cells { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
  .comp-cells li { display: grid; justify-items: center; gap: 2px; padding: 10px 8px 8px; border-radius: var(--radius-sm); background: rgb(255 255 255 / 0.025); border: 1px solid var(--line-soft); }
  .comp-cells .ico { width: 18px; height: 18px; color: var(--gold-lo); }
  .comp-cells .n { font-family: var(--display); font-weight: 700; font-size: 1.6rem; color: var(--gold-hi); line-height: 1.1; }
  .comp-cells .l { font-size: 0.8rem; color: var(--muted); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

  .group { display: grid; gap: 12px; }
  .group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
  .group-head h2 { font-size: 1rem; display: flex; align-items: center; gap: 8px; }
  .group-head h2 .chip { font-size: 0.85rem; padding: 3px 12px; }
  .group-count { color: var(--muted); font-family: var(--font); font-weight: 800; }
  .group-head p { color: var(--muted); font-size: 0.93rem; }

  .unit-grid, .recruit-grid, .para-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
  .recruit-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); align-items: start; }
  .unit-card, .recruit-card {
    padding: 16px;
    display: grid;
    gap: 10px;
    align-content: start;
    container-type: inline-size;
    background:
      radial-gradient(320px 140px at 0 0, color-mix(in oklab, var(--c, var(--gold)) 15%, transparent), transparent 70%),
      linear-gradient(180deg, var(--panel-hi), var(--panel));
    transition: border-color 0.2s, transform 0.2s;
  }
  .unit-card:hover, .recruit-card:hover { border-color: var(--line-strong); }
  .unit-card.pending { background: linear-gradient(180deg, #151a25, #10141d); border-style: dashed; }
  .unit-head { display: flex; align-items: center; gap: 14px; }
  .unit-portrait { display: block; flex: none; border-radius: 50%; }
  .unit-id { min-width: 0; flex: 1; }
  .unit-id h3 { font-size: 1.1rem; }
  .unit-id h3 a { color: var(--gold-hi); text-decoration: none; }
  .unit-id h3 a:hover { text-decoration: underline; }
  .unit-meta { color: var(--muted); font-size: 0.9rem; display: flex; gap: 4px 8px; align-items: center; flex-wrap: wrap; }
  .unit-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.7; }
  .unit-meta .pending-note { font-style: italic; }
  .unit-head .role-field { margin-left: auto; flex: none; }
  .unit-line { color: var(--ink-2); font-size: 0.97rem; }

  .goals { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .goal { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: 0.86rem; font-weight: 700; }
  .goal .rk { font-size: 0.75rem; min-width: 1.8em; padding: 0 4px; }
  .unit-open { justify-self: start; font-weight: 800; font-size: 0.92rem; text-decoration: none; }
  @container (max-width: 300px) {
    .unit-head { flex-wrap: wrap; }
    .unit-head .role-field { margin-left: 0; flex-basis: 100%; }
  }

  /* unit sheet */
  .crumb { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--muted); }
  .crumb a { text-decoration: none; font-weight: 700; color: var(--ink-2); }
  .crumb a:hover { color: var(--gold-hi); }
  .crumb [aria-current] { color: var(--gold); font-weight: 700; }

  .hero {
    position: relative;
    display: grid;
    gap: 18px;
    padding: clamp(18px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background:
      radial-gradient(560px 280px at 0 0, color-mix(in oklab, var(--c) 30%, transparent), transparent 70%),
      linear-gradient(180deg, var(--panel-hi), var(--panel));
    box-shadow: var(--shadow);
  }
  .hero::before {
    content: "";
    position: absolute;
    inset: -1px 18% auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-hi), transparent);
    opacity: 0.55;
  }
  .hero-main { display: flex; align-items: center; gap: clamp(18px, 3.4vw, 30px); }
  .hero-text { display: grid; gap: 6px; min-width: 0; max-width: 72ch; }
  .hero h1 { font-size: clamp(1.9rem, 5vw, 2.7rem); color: var(--gold-hi); }
  .hero-meta { display: flex; flex-wrap: wrap; gap: 6px; }
  .hero-meta .chip { font-size: 0.84rem; }
  .hero-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
  .hero-controls .field { flex: 0 1 220px; }
  .advice { padding-left: 0; list-style: none; }
  .advice li { padding: 8px 12px; border-radius: var(--radius-sm); border-left: 3px solid var(--line-strong); background: rgb(255 255 255 / 0.025); }
  .advice .adv-certify { border-left-color: var(--ok); background: var(--ok-bg); color: #d7f6ea; font-weight: 700; }
  .advice .adv-master { border-left-color: var(--gold); }
  .advice .adv-missing, .advice .adv-wait { border-left-color: var(--info); }
  .goal-box { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgb(214 180 106 / 0.05); display: grid; gap: 6px; }
  .goal-list { list-style: none; display: grid; gap: 6px; }
  .goal-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }

  .stages { list-style: none; display: grid; gap: 0; }
  .stage { display: grid; grid-template-columns: 22px 1fr; gap: 12px; position: relative; padding-bottom: 16px; }
  .stage:last-child { padding-bottom: 0; }
  .stage::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 22px;
    bottom: -2px;
    width: 2px;
    background: linear-gradient(180deg, var(--line-strong), var(--line));
  }
  .stage:last-child::before { display: none; }
  .stage-mark {
    width: 16px;
    height: 16px;
    margin: 5px 3px 0;
    transform: rotate(45deg);
    border: 2px solid var(--line-strong);
    background: var(--panel);
    position: relative;
    z-index: 1;
  }
  .stage.current .stage-mark { background: var(--crimson); border-color: var(--gold-hi); box-shadow: 0 0 0 4px rgb(179 32 58 / 0.25); }
  .stage.done .stage-mark { background: var(--gold); border-color: var(--gold); }
  .stage.optional .stage-mark { border-style: dashed; }
  .stage-body { display: grid; gap: 6px; min-width: 0; }
  .stage-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  .stage-name { font-family: var(--display); font-size: 1.05rem; color: var(--gold-hi); }
  .stage.done .stage-name { color: var(--ink-2); }
  .stage-why { color: var(--ink-2); font-size: 0.95rem; }
  .stage-level { color: var(--info); font-size: 0.92rem; }

  .reqs { list-style: none; display: grid; gap: 6px; }
  .req { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 5px 10px; border-radius: var(--radius-sm); background: rgb(255 255 255 / 0.025); border: 1px solid var(--line-soft); }
  .req .req-state { margin-left: auto; font-size: 0.86rem; font-weight: 800; color: var(--muted); }
  .req.ok { border-color: rgb(92 199 157 / 0.3); }
  .req.ok .req-state { color: var(--ok); }
  .req.miss .req-state { color: var(--warn); }
  .req.unknown .req-state { color: var(--info); }
  .req-ranks { display: inline-flex; align-items: center; }

  .mastery-list { list-style: none; display: grid; gap: 8px; }
  .mastery-list li { display: flex; gap: 12px; align-items: flex-start; }
  .mastery-list label { cursor: pointer; }

  .learn { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .learn-col ul { list-style: none; display: grid; gap: 3px; margin-top: 6px; }
  .learn-col li { display: flex; gap: 8px; align-items: baseline; font-size: 0.95rem; }
  .learn-col li.got { color: var(--muted); text-decoration: line-through; text-decoration-color: rgb(154 145 127 / 0.6); }
  .learn-col li.kind-art { color: #ffc2cb; }
  .learn-col li.kind-ability { color: var(--gold-hi); }
  .learn-col li.got.kind-art, .learn-col li.got.kind-ability { color: var(--muted); }
  .learn-skill { display: flex; align-items: center; gap: 8px; font-weight: 800; }
  .rk-mini { min-width: 2em; font-size: 0.78rem; font-weight: 800; color: var(--muted); }

  .likes, .glossary, .activities { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
  .likes dt, .glossary dt, .activities dt { font-weight: 800; color: var(--gold); }
  .likes dd, .glossary dd, .activities dd { color: var(--ink-2); }

  /* recruitment */
  .tiers { width: 100%; font-size: 0.95rem; }
  .tiers th, .tiers td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line-soft); }
  .tiers thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
  .tiers tr.current { background: rgb(214 180 106 / 0.08); }
  .tiers tr.current th { color: var(--gold-hi); }
  .tiers tr.ok td:last-child { color: var(--ok); font-weight: 800; }
  .tiers .good { color: var(--ok); }
  .tiers .bad { color: var(--ink-2); }
  .tiers small { color: var(--muted); }
  .you { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--crimson-hi); font-weight: 800; }
  .roster { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 8px; }
  .roster a {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-soft);
    background: rgb(255 255 255 / 0.02);
    color: var(--ink);
    text-decoration: none;
    transition: border-color 0.15s, background-color 0.15s;
  }
  .roster a:hover { border-color: var(--line-strong); background: rgb(214 180 106 / 0.05); }
  .roster .avatar { grid-row: span 2; }
  .roster-name { font-weight: 800; color: var(--gold-hi); line-height: 1.2; }
  .roster small { color: var(--muted); line-height: 1.2; }

  /* chapter notebooks */
  .chapter-jump { display: flex; flex-wrap: wrap; gap: 6px; }
  .chapter-jump a {
    min-width: 40px;
    padding: 6px 10px;
    text-align: center;
    border-radius: 8px;
    border: 1px solid var(--line);
    text-decoration: none;
    font-weight: 800;
    color: var(--ink-2);
  }
  .chapter-jump a.on { background: var(--crimson); color: #fff; border-color: var(--gold-hi); }
  .chapter-jump a.locked { opacity: 0.55; }
  .notebooks { display: grid; gap: var(--gap); }
  .notebook {
    position: relative;
    padding: clamp(18px, 3vw, 30px) clamp(18px, 3.4vw, 34px) clamp(18px, 3vw, 28px) clamp(26px, 4.4vw, 46px);
    border-radius: 6px var(--radius) var(--radius) 6px;
    color: var(--parch-ink);
    background:
      linear-gradient(90deg, rgb(140 27 46 / 0.22) 0 6px, transparent 6px),
      repeating-linear-gradient(180deg, transparent 0 29px, var(--parch-line) 29px 30px),
      linear-gradient(180deg, var(--parch), var(--parch-2));
    box-shadow: 0 1px 0 rgb(255 255 255 / 0.4) inset, 0 20px 40px -24px rgb(0 0 0 / 0.9);
    display: grid;
    gap: 10px;
    scroll-margin-top: 72px;
  }
  .notebook::after {
    content: "";
    position: absolute;
    left: 14px;
    top: 0;
    bottom: 0;
    border-left: 1px solid rgb(140 27 46 / 0.35);
  }
  .notebook a { color: var(--parch-accent); }
  .notebook strong { color: #1a120a; }
  .notebook h2 { font-size: 1.45rem; color: var(--parch-accent); }
  .notebook h3 { font-size: 0.9rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--parch-muted); margin-top: 6px; font-family: var(--font); font-weight: 800; }
  .nb-kicker { font-size: 0.76rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--parch-muted); font-weight: 800; }
  .nb-intro { font-size: 1.05rem; }
  .notebook .away { font-size: 0.92rem; color: var(--parch-muted); font-style: italic; }
  .notebook .check { background: rgb(255 255 255 / 0.35); border-color: var(--parch-line); }
  .notebook .check.done label { color: var(--parch-muted); }
  .notebook .check.done strong { color: var(--parch-muted); }
  .notebook input[type="checkbox"]:not([role="switch"]) { background-color: #fffaf0; background-image: linear-gradient(#ffeac2, #ffeac2); border-color: rgb(140 27 46 / 0.55); }
  .notebook input[type="checkbox"]:not([role="switch"]):checked { background-color: var(--parch-accent); border-color: var(--parch-accent); }
  .notebook .tag { background: rgb(255 255 255 / 0.5); color: var(--parch-muted); border-color: var(--parch-line); }
  .notebook .tag-rota { background: var(--parch-accent); color: #ffeac2; border-color: var(--parch-accent); }
  .notebook .data th, .notebook .data td { border-bottom-color: var(--parch-line); }
  .notebook .data thead th { color: var(--parch-muted); }
  .notebook .data tbody th { color: var(--parch-ink); }
  .notebook .data tr:hover td, .notebook .data tr:hover th { background: rgb(255 255 255 / 0.25); }
  .notebook details.spoiler { padding: 10px 12px; border: 1px dashed rgb(140 27 46 / 0.5); border-radius: 8px; }
  .notebook details.spoiler > summary { color: var(--parch-accent); }
  .notebook details.spoiler p { margin-top: 6px; }
  .notebook.current { outline: 2px solid var(--gold); outline-offset: 3px; }
  .notebook.sealed { background: linear-gradient(180deg, #2a2722, #1d1b18); color: var(--ink-2); }
  .notebook.sealed h2 { color: var(--muted); }
  .notebook.sealed .nb-kicker { color: var(--muted); }
  .notebook.sealed::after { border-left-color: rgb(214 180 106 / 0.2); }
  .notebook .btn { justify-self: start; }

  /* paralogues */
  .para-card { padding: 16px; display: grid; gap: 10px; align-content: start; }
  .para-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .para-head h2 { font-size: 1.08rem; color: var(--gold-hi); }
  .para-meta { color: var(--ink-2); font-size: 0.93rem; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
  .para-meta .when { font-weight: 800; color: var(--gold); }
  .who { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 2px; border-radius: 999px; border: 1px solid var(--line-soft); font-size: 0.86rem; background: rgb(255 255 255 / 0.02); }
  .who.ok { color: var(--ok); border-color: rgb(92 199 157 / 0.35); }
  .who .ico { color: var(--ok); width: 14px; height: 14px; }
  .para-meta { gap: 6px 8px; }
  .para-meta .when { margin-right: 4px; }
  .para-star { font-size: 0.97rem; }
  .para-list.tips { margin-top: 8px; color: var(--ink-2); }
  .phase-closing { border-color: rgb(226 86 108 / 0.55); }
  .phase-done, .phase-missed { opacity: 0.7; }

  /* classes */
  .classes td { min-width: 120px; }
  .classes .innate { color: var(--muted); font-size: 0.88rem; min-width: 160px; }
  .req-inline { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; white-space: nowrap; }
  .gender { color: var(--crimson-hi); }
  .flag { display: inline-flex; vertical-align: -2px; }
  .flag .ico { color: var(--info); }
  .classes .chips { gap: 4px; }
  .ready-list { display: flex; gap: 4px; flex-wrap: wrap; }
  .ready-list a { text-decoration: none; display: block; border-radius: 50%; }

  /* monastery */
  .faculty th, .faculty td { text-align: center; vertical-align: middle; }
  .faculty thead th:first-child { text-align: left; }
  .faculty tbody th { text-align: left; white-space: nowrap; }
  .faculty .note { display: block; font-weight: 400; font-size: 0.78rem; white-space: normal; max-width: 220px; }
  .faculty .pip { display: inline-block; width: 9px; height: 9px; border-radius: 2px; transform: rotate(45deg); background: var(--gold); box-shadow: 0 0 8px rgb(214 180 106 / 0.45); }
  .faculty tbody th .person { white-space: normal; align-items: center; }
  .faculty tr.off th, .faculty tr.off td { opacity: 0.45; }
  .faculty thead th .ico { width: 1.3em; height: 1.3em; margin-inline: auto; }
  .gt { list-style: none; display: grid; gap: 10px; }
  .gt li { display: grid; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
  .gt li:last-child { border-bottom: 0; padding-bottom: 0; }
  .gt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
  .gt-head .skill { color: var(--ink-2); font-size: 0.93rem; }

  .sunday-who { margin: 2px 0 12px; }
  .sunday .step strong { color: var(--ink); }
  .sunday .step { line-height: 1.5; }
  .activities.more { margin-top: 14px; }
  .meal-pairs { margin: 6px 0 0; padding-left: 1.1em; display: grid; gap: 3px; color: var(--ink-2); }
  .meals td { min-width: 140px; }
  .meals th small { display: block; font-weight: 600; margin-top: 2px; }

  .tea-sub { margin: 16px 0 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
  .tea-sub .muted { text-transform: none; letter-spacing: 0; font-weight: 600; }
  .topics { list-style: none; columns: 3 200px; column-gap: 24px; color: var(--ink-2); }
  .topics li { break-inside: avoid; padding: 3px 0 3px 14px; position: relative; }
  .topics li::before { content: ''; position: absolute; left: 2px; top: 0.85em; width: 5px; height: 5px; transform: rotate(45deg); background: var(--gold); opacity: 0.7; }
  .finals td:first-child { color: var(--ink); }
  .chip.answer { font-weight: 800; }
  .hidden-rank { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px dotted currentColor; cursor: help; }

  /* Atualizar: once-per-chapter review */
  .tabs a .nav-badge {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--crimson);
    color: #fff3d6;
    font-family: var(--font);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0;
    vertical-align: 1px;
  }
  .tabs a .nav-badge[hidden] { display: none; }
  .callout { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; border-color: rgb(226 86 108 / 0.55); background: linear-gradient(135deg, rgb(179 32 58 / 0.16), transparent 60%), var(--panel); }
  .callout-body { flex: 1 1 320px; display: grid; gap: 6px; }
  .callout .btn { flex: none; }
  .review-top { display: grid; gap: 14px; }
  .review-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
  .review-progress progress { flex: 1 1 180px; height: 8px; appearance: none; border: 0; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
  .review-progress progress::-webkit-progress-bar { background: var(--panel-2); border-radius: 999px; }
  .review-progress progress::-webkit-progress-value { background: linear-gradient(90deg, var(--crimson), var(--gold)); border-radius: 999px; }
  .review-progress progress::-moz-progress-bar { background: linear-gradient(90deg, var(--crimson), var(--gold)); border-radius: 999px; }
  .review-progress .good { color: var(--ok); font-weight: 700; }
  .review-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); align-items: start; }
  .review-card {
    display: grid;
    gap: 12px;
    padding: 14px 16px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    border-left: 3px solid var(--c, var(--line-strong));
    background: var(--panel);
  }
  .review-card.seen { border-color: var(--line-soft); border-left-color: color-mix(in srgb, var(--c, var(--line-strong)) 45%, transparent); background: color-mix(in srgb, var(--panel) 80%, transparent); }
  .review-head { display: flex; align-items: center; gap: 12px; }
  .review-head .unit-id { flex: 1; min-width: 0; }
  .review-head h3 { font-size: 1.05rem; }
  .review-head h3 a { color: var(--gold-hi); text-decoration: none; }
  .review-head .badge .ico { width: 0.9em; height: 0.9em; margin-right: 4px; }
  .review-card .form-grid.ranks { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .btn.sm { min-height: 34px; padding: 5px 14px; font-size: 0.86rem; }
  .check.auto input:disabled { opacity: 0.85; cursor: default; }
  .check.auto label { cursor: default; }
  .auto-note { display: flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 0.8rem; font-weight: 700; color: var(--ok); }
  .auto-note .ico { width: 0.95em; height: 0.95em; }
  .notebook .auto-note { color: #2f7d5c; }

  .sources { padding-left: 1.2em; display: grid; gap: 4px; columns: 2 280px; }
  .danger-zone { padding-top: 10px; border-top: 1px dashed var(--line-soft); }
}

@layer utilities {
  .sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  @media (max-width: 560px) {
    body { font-size: 1rem; }
    .sigil { width: 46px; height: 46px; }
    .plate { font-size: 0.84rem; padding: 5px 12px; }
    .hero-main { flex-direction: column; align-items: flex-start; }
    .hero-controls .field { flex: 1 1 100%; }
    .likes, .glossary, .activities { grid-template-columns: 1fr; gap: 2px; }
    .likes dd, .glossary dd, .activities dd { margin-bottom: 8px; }
    .bdays .gifts { padding-left: 0; }
    .tile { padding: 12px 14px; }
    .tile-value { font-size: 1.7rem; }
    .tile-sub { font-size: 0.85rem; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  }

  @media print {
    .tabs, .foot, .toast, .sky, .btn, .sel, .stepper-box button { display: none !important; }
    body { background: #fff; color: #000; }
  }
}

@media (prefers-reduced-motion: no-preference) {
  main.enter > .view { animation: enter 0.22s ease-out; }
  .sel-pop[data-side] { animation: pop-in 0.14s ease-out; }
  .tip[data-side] { animation: fade-in 0.12s ease-out; }
  .dialog[open] .dialog-box { animation: pop-in 0.18s ease-out; }
  .dialog[open]::backdrop { animation: fade-in 0.18s ease-out; }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes enter {
  from { opacity: 0.35; transform: translateY(4px); }
}
