:root {
  --bg: #f3f6ec;
  --card: #ffffff;
  --ink: #232b1a;
  --muted: #6f7a62;
  --lime: #8cc63e;        /* in the owl logo; optional highlight only */
  --accent: #015219;      /* primary green — buttons, links, headings (from the LAPIS site gradient) */
  --accent-dark: #013912; /* button hover + dark-green accents */
  --line: #d9e1cc;
  --header-text: #eef4e2;
  --brand-gradient: linear-gradient(to right, #015219, #3cc063); /* header band — matches lapis.practomime.com */
  --code-font: "Courier New", monospace; /* secret codes: fixed-width serif — keep */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

header {
  background: var(--brand-gradient);
  color: var(--header-text);
  padding: 0.7rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 1.4rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  color: #fff;            /* white wordmark on the gradient (lime fails on the bright end) */
  text-decoration: none;
}

main {
  max-width: 1140px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.centered { max-width: 420px; margin: 3rem auto; text-align: center; }

.home-logo { width: 200px; max-width: 70%; height: auto; margin: 0 auto 0.5rem; }

h1 { margin: 0 0 0.5rem; }
h2 { margin: 0 0 0.75rem; color: var(--accent); border-bottom: 2px solid var(--line);
     padding-bottom: 0.3rem; }

.subtitle, .muted { color: var(--muted); }
.muted { font-size: 0.92rem; }

a { color: var(--accent); }

/* forms */
input, select, textarea, button {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}
textarea { width: 100%; resize: vertical; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 0.55rem 1rem;
}
button:hover { background: var(--accent-dark); }
button:disabled { background: #aab69a; cursor: not-allowed; }

.btn-danger { background: #a8321f; }
.btn-danger:hover { background: #842616; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

/* CSV export/download action on an <a>. Matches the app's standard solid
   button (green, 5px radius), sized like .btn-small. */
.btn-csv {
  display: inline-block;
  background: #3e8e41;            /* lighter green — distinct from the dark
                                     accent used by Copy link */
  color: #fff;
  border: 1px solid #3e8e41;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 5px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s;
}
.btn-csv:hover { background: #337036; border-color: #337036; color: #fff; text-decoration: none; }

.nav-links { display: flex; align-items: center; gap: 0.8rem; }

/* Notification bubble on a nav link (e.g. pending agent approvals on Roster). */
.nav-badge {
  display: inline-block;
  min-width: 1.15rem;
  margin-left: 0.3rem;
  padding: 0.1rem 0.4rem;
  background: #d6332a;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  border-radius: 999px;
  vertical-align: middle;
}

/* Header buttons sit on the green gradient — including the bright (#3cc063)
   right end — so a translucent/light treatment washes out. Use a solid white
   pill with forest-green text: high contrast across the whole gradient. */
.link-btn {
  background: #ffffff;
  color: var(--accent);
  padding: 0.35rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid #ffffff;
  border-radius: 5px;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.link-btn:hover {
  background: var(--header-text);
  color: var(--accent-dark);
  text-decoration: none;
}

.code-form { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1rem; }
.code-form input { text-align: center; letter-spacing: 0.12em; font-family: var(--code-font); }

.inline-form { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.8rem; }
.inline-form input, .inline-form select { flex: 1; min-width: 160px; }

.field-form { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.field-form label { display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.85rem; color: var(--muted); flex: 1; min-width: 200px; }
.field-form label.wide { flex-basis: 100%; }
.field-form button { align-self: flex-end; }
.checkbox-field { flex-basis: 100%; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem;
  margin-top: 0.3rem; }
.field-form .checkbox-row label { flex-direction: row; min-width: auto;
  align-items: center; gap: 0.35rem; color: var(--ink); font-size: 0.95rem; }
.checkbox-row input { width: auto; }

.nav-form { display: inline; }
.award-row { display: flex; flex-wrap: wrap; gap: 1.5rem; }

hr { border: none; border-top: 1px solid var(--line); margin: 1.4rem 0; }

/* flashes */
.flashes { margin-bottom: 1rem; }
.flash {
  background: #eef5dd;
  border: 1px solid var(--lime);
  border-left: 4px solid var(--lime);
  padding: 0.6rem 0.9rem;
  border-radius: 5px;
  margin-bottom: 0.5rem;
}

/* code chip */
.code-chip {
  display: inline-block;
  background: var(--accent-dark);
  color: var(--header-text);
  font-family: var(--code-font);  /* fixed-width serif — secret codes */
  letter-spacing: 0.1em;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.95rem;
}

/* character sheet */
.persona-head { display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem;
  margin: 1rem 0; }
.fields .wide { grid-column: 1 / -1; }
.fields .label, .label {
  display: block; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}

.resources { display: flex; gap: 1rem; flex-wrap: wrap; }
.resource {
  flex: 1; min-width: 130px; text-align: center;
  background: var(--bg); border-radius: 6px; padding: 0.7rem;
}
.resource strong { display: block; font-size: 1.8rem; color: var(--accent); }
.denarii-icon { width: 1.6rem; height: 1.6rem; vertical-align: -0.3rem;
  margin-right: 0.3rem; object-fit: contain; }
.resource span { font-size: 0.8rem; color: var(--muted); }

/* traits */
.trait { border: 1px solid var(--line); border-radius: 6px;
  padding: 0.8rem 1rem; margin-bottom: 0.8rem; }
.trait-top { display: flex; justify-content: space-between; align-items: baseline; }
.trait-name { font-size: 1.2rem; font-weight: bold; color: var(--accent); }
.rank-badge { background: var(--lime); color: var(--ink); padding: 0.15rem 0.6rem;
  border-radius: 12px; font-size: 0.85rem; font-weight: bold; }
.ability { margin: 0.5rem 0; }
.definition { font-size: 0.85rem; color: var(--muted); font-style: italic; }
.trait-foot { display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.6rem; flex-wrap: wrap; gap: 0.5rem; }
.maxed { color: var(--accent); font-weight: bold; }

/* gear */
.gear-list { list-style: none; padding: 0; margin: 0; }
.gear-list li { display: flex; gap: 0.8rem; padding: 0.7rem 0;
  border-bottom: 1px solid var(--line); }
.gear-icon { width: 48px; height: 48px; object-fit: contain; }
.gear-list p { margin: 0.2rem 0; font-size: 0.9rem; }
.slot { font-size: 0.75rem; background: var(--bg); padding: 0.1rem 0.4rem;
  border-radius: 3px; color: var(--muted); }
.phrase { color: var(--accent); font-style: italic; }

.rename-cohort { margin-top: 0.4rem; }
.rename-cohort summary { cursor: pointer; font-size: 0.85rem;
  display: inline-block; }
.rename-cohort summary:hover { color: var(--accent); }
.rename-cohort form { margin-top: 0.5rem; }

/* Admin impersonation banner */
.impersonate-banner {
  background: #fff4cc;
  border-bottom: 2px solid #e6c84a;
  color: #5a4400;
  padding: 0.45rem 1.2rem;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.9rem; font-weight: 600;
  gap: 1rem;
}
.impersonate-banner .link-btn {
  background: rgba(0, 0, 0, 0.06);
  color: #5a4400;
  border-color: rgba(0, 0, 0, 0.15);
}
.impersonate-banner .link-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  border-color: rgba(0, 0, 0, 0.28);
}
.admin-actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; }
.btn-primary {
  background: var(--accent); color: white;
  border: 1px solid var(--accent);
  padding: 0.35rem 0.9rem; border-radius: 5px;
  font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn-primary:hover { background: var(--accent-dark, #013912); }

/* Manage action — third action color (blue), distinct from copy-link (green)
   and delete (red). Styled for use on an <a>, sized to match .btn-small. */
.btn-manage {
  display: inline-block;
  background: #4a6fb5;
  color: #fff;
  border: 1px solid #4a6fb5;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 5px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s;
}
.btn-manage:hover { background: #36548c; color: #fff; text-decoration: none; }

/* Cohort header view switcher (Characters ↔ Operatives) */
.cohort-switch {
  display: inline-flex;
  gap: 0.25rem;
  margin-left: 0.6rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}
.cohort-switch-current,
.cohort-switch-other {
  padding: 0.25rem 0.7rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.cohort-switch-current {
  background: var(--accent);
  color: white;
  cursor: default;
}
.cohort-switch-other {
  color: var(--muted);
}
.cohort-switch-other:hover {
  background: white;
  color: var(--accent);
}

/* Dashboard count chips */
.dash-chips { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; }
.chip-btn {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.chip-btn-char {
  background: #eef4e3;
  color: #3d6614;
  border-color: #c8dfa6;
}
.chip-btn-char:hover {
  background: var(--accent); color: white; border-color: var(--accent);
}
.chip-btn-op {
  background: #e8eef9;
  color: #2a4173;
  border-color: #c2cee5;
}
.chip-btn-op:hover {
  background: #4a6fb5; color: white; border-color: #4a6fb5;
}

/* tab bar (character page: Arma / Traits / Memorātiō) */
.tabs {
  display: flex; gap: 0.3rem;
  border-bottom: 2px solid var(--accent);
  margin: 1rem 0 0;
  padding: 0 0.2rem;
}
.tab-btn {
  background: transparent;
  border: 2px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 0.55rem 1.2rem;
  font-size: 1rem; font-weight: 600;
  color: var(--muted); cursor: pointer;
  margin-bottom: -2px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.tab-btn.active {
  background: white;
  color: var(--accent);
  border-color: var(--accent);
}
.tab-btn.active:hover {
  /* Active tab: lighter accent hover so it doesn't look like an unstyled button */
  background: #f4f8ec;
  color: var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* trait summary row (quick-glance ranks under the resource cards) */
.trait-summary {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
  margin-top: 0.9rem;
}
.trait-pill {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid rgba(0,0,0,0.06);
}
.trait-pill-name { font-weight: 600; letter-spacing: 0.01em; }
.trait-pill-rank {
  font-weight: 700; font-size: 1.05rem;
  background: rgba(255,255,255,0.55);
  padding: 0.05rem 0.5rem; border-radius: 4px;
  min-width: 22px; text-align: center;
}
/* Pastel palette echoing the original spreadsheet */
.trait-auctoritas { background: #fad4e6; color: #6b1e3f; }
.trait-dignitas   { background: #fac4b8; color: #6e1f12; }
.trait-disciplina { background: #f7ecb0; color: #5d4a0a; }
.trait-fides      { background: #dadada; color: #333333; }
.trait-gravitas   { background: #c4dcf2; color: #1a3f6b; }
.trait-pietas     { background: #cce6c0; color: #1f5a18; }

@media (max-width: 760px) {
  .trait-summary { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 420px) {
  .trait-summary { grid-template-columns: repeat(2, 1fr); }
}

/* equipment screen */
.equipment-screen {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 280px) 1fr;
  gap: 1rem;
  align-items: stretch;
  margin: 1rem 0 1.5rem;
}
.equip-column { display: flex; flex-direction: column; gap: 0.5rem; }
.equip-body { display: flex; align-items: center; justify-content: center; }
.equip-body img { max-width: 100%; max-height: 420px; object-fit: contain; }

.equip-slot {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.3rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  min-height: 78px;
}
.equip-slot.filled { border-color: var(--accent); background: #f8fbf1; }
.equip-slot.empty { border-style: dashed; opacity: 0.85; }
.equip-slot-label { display: flex; justify-content: space-between;
  align-items: baseline; gap: 0.4rem; }
.equip-slot-label strong { font-size: 0.9rem; }
.equip-slot-label span { font-size: 0.7rem; color: var(--muted); }
.equip-slot-content { display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap; }
.equip-slot-content .gear-icon { width: 40px; height: 40px; }
.equip-slot-name { font-size: 0.85rem; font-weight: 600; flex: 1; }
.equip-slot-placeholder { color: var(--muted); font-size: 1.2rem; }
.link-button { background: none; border: none; color: var(--muted);
  font-size: 0.78rem; cursor: pointer; padding: 0; text-decoration: underline; }
.link-button:hover { color: var(--accent); }
.link-button.danger { color: #a33; }
.equip-slot-actions { display: flex; gap: 0.6rem; align-items: center;
  margin-left: auto; }

.equip-slot-hover { position: relative; display: flex; align-items: center;
  gap: 0.5rem; flex: 1; cursor: help; }
.equip-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 220px;
  max-width: 320px;
  padding: 0.6rem 0.8rem;
  background: #2a2a2a;
  color: #f4f4f4;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  font-size: 0.82rem;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.equip-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 18px;
  border: 6px solid transparent;
  border-top-color: #2a2a2a;
}
.equip-tooltip strong { display: block; margin-bottom: 0.25rem;
  color: var(--lime); }   /* bright lime — readable on the dark tooltip */
.equip-tooltip p { margin: 0.25rem 0; }
.equip-tooltip .phrase { color: #d8e9b9; font-style: italic; }
.equip-slot-hover:hover .equip-tooltip,
.equip-slot-hover:focus-within .equip-tooltip {
  opacity: 1; transform: translateY(0);
}
.saccus-actions { display: flex; gap: 0.5rem; align-items: center;
  flex-wrap: wrap; margin-top: 0.3rem; }

.saccus { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.saccus h3 { margin: 0 0 0.6rem; }
.saccus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.7rem;
}
.saccus-item { display: flex; gap: 0.6rem; padding: 0.6rem; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; }
.saccus-item-body { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.saccus-item p { margin: 0.1rem 0; font-size: 0.85rem; }
.saccus-item form { margin-top: 0.3rem; }

@media (max-width: 720px) {
  .equipment-screen { grid-template-columns: 1fr; }
  .equip-body img { max-height: 280px; }
}

/* memoratio */
.memo-grid { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.8rem 0; }
.memo-row { display: grid; grid-template-columns: 110px 1fr 1fr 1fr; gap: 0.4rem;
  align-items: start; }
.memo-mission { font-size: 0.85rem; font-weight: bold; padding-top: 0.4rem; }
.memo-cell { display: flex; flex-direction: column; gap: 0.25rem; }
.memo-view { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.4;
  border: 1px solid var(--line); border-radius: 5px; padding: 0.4rem 0.5rem;
  min-height: 2.4rem; background: #fff; transition: border-color 0.2s; }
.memo-view.empty { color: var(--muted); }
.memo-cell.saved .memo-view { border-color: var(--lime); }
.memo-edit-btn { align-self: flex-start; background: none; border: none;
  color: var(--accent); font-size: 0.78rem; padding: 0; cursor: pointer;
  text-decoration: underline; }
.memo-edit-btn:hover { background: none; color: var(--accent-dark); }
.memo-editor { display: flex; flex-direction: column; gap: 0.3rem; }
.memo-editor textarea { width: 100%; }
.memo-actions { display: flex; gap: 0.5rem; align-items: center; }
.memo-cancel-btn { background: none; border: none; color: var(--muted);
  font-size: 0.8rem; padding: 0; cursor: pointer; text-decoration: underline; }
.memo-cancel-btn:hover { background: none; color: var(--ink); }
.memo-err { color: #a8321f; font-size: 0.78rem; }

/* tables / lists */
.list { list-style: none; padding: 0; margin: 0.5rem 0; }
.list li { display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid var(--line); }

.roster { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.roster th, .roster td { text-align: left; padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line); }
.roster th { font-size: 0.78rem; text-transform: uppercase; color: var(--muted);
  letter-spacing: 0.05em; }

h2.flush { border: none; padding: 0; margin: 0; }
.roster-cohort { border: 1px solid var(--line); border-radius: 6px;
  padding: 0.8rem 1rem; margin-top: 0.9rem; }
.roster-cohort-head { display: flex; align-items: center; gap: 0.8rem;
  flex-wrap: wrap; }
.roster-head { display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.row-actions { display: flex; gap: 0.7rem; align-items: center; }

@media (max-width: 600px) {
  .fields { grid-template-columns: 1fr; }
  .memo-row { grid-template-columns: 1fr; }
}

/* operative LP grid */
.lp-grid { display: flex; flex-direction: column; gap: 0.4rem; }
.lp-row { border: 1px solid var(--line); border-radius: 6px;
  background: #fff; }
.lp-row summary { padding: 0.6rem 0.9rem; cursor: pointer;
  display: flex; gap: 0.8rem; align-items: baseline; }
.lp-row summary strong { min-width: 110px; }
.lp-row[open] summary { border-bottom: 1px solid var(--line); }
.lp-row-body { padding: 0.7rem 0.9rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.7rem; }
.lp-episodes { display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem; }
.lp-ep { display: flex; flex-direction: column; font-size: 0.8rem;
  gap: 0.2rem; }
.lp-ep input { padding: 0.3rem 0.4rem; }
.lp-checkrow { display: flex; gap: 1rem; align-items: center;
  flex-wrap: wrap; font-size: 0.85rem; }
.lp-checkrow-label { font-weight: 600; min-width: 90px; color: var(--muted); }
.lp-save { display: flex; align-items: center; gap: 0.8rem;
  margin-top: 0.2rem; padding-top: 0.6rem; border-top: 1px solid var(--line); }
.lp-save-btn { padding: 0.35rem 0.9rem; }
.lp-save-status { font-size: 0.85rem; font-weight: 600; }
.lp-save-status.dirty  { color: #9a6b00; }
.lp-save-status.saving { color: var(--muted); }
.lp-save-status.saved  { color: #1a7f37; }
.lp-save-status.failed { color: #c0392b; }
.examen-row { display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem; }
.custom-row { display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.7rem; }
.custom-cell { display: flex; flex-direction: column; gap: 0.3rem;
  padding: 0.6rem; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; }
.custom-cell input[type="text"] { font-weight: 600; }
.custom-cell input[type="number"] { font-variant-numeric: tabular-nums; }

/* Dynamic custom-LP awards (operative manage page) */
.award-list { display: flex; flex-direction: column; gap: 0.5rem;
  margin-bottom: 0.9rem; }
.award-item { display: flex; align-items: flex-end; gap: 0.6rem;
  flex-wrap: wrap; padding: 0.6rem; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; }
.award-row { display: flex; align-items: flex-end; gap: 0.6rem;
  flex-wrap: wrap; flex: 1; }
.award-name { flex: 1 1 160px; min-width: 140px; font-weight: 600; }
.award-field { display: flex; flex-direction: column; font-size: 0.78rem;
  gap: 0.2rem; color: var(--muted); }
.award-field input { width: 90px; font-variant-numeric: tabular-nums; }
.award-delete { margin-left: auto; }
.award-create { margin-top: 0.4rem; }
.award-create > summary { cursor: pointer; color: var(--accent);
  font-weight: 600; }
.award-create .field-form { margin-top: 0.7rem; }
.award-meta { display: flex; gap: 1rem; flex-wrap: wrap;
  align-items: flex-end; margin-bottom: 0.3rem; }
.award-meta label { display: flex; flex-direction: column; gap: 0.3rem;
  font-size: 0.85rem; font-weight: 600; }
.award-meta input[type="text"] { min-width: 240px; }
.award-meta input[type="number"] { width: 120px;
  font-variant-numeric: tabular-nums; }

.bulk-grade-input { width: 110px; padding: 0.3rem 0.5rem;
  font-variant-numeric: tabular-nums; font-weight: 600;
  font-size: 1rem; border: 1px solid var(--line); border-radius: 4px; }
.bulk-grade-input.lp-red,
.bulk-grade-input.lp-purple,
.bulk-grade-input.lp-blue,
.bulk-grade-input.lp-green { border-color: currentColor; }

/* Stylized bulk-action buttons (operatives roster page) */
.bulk-actions { display: flex; gap: 0.8rem; flex-wrap: wrap;
  margin-top: 0.6rem; }
.btn-action { display: inline-flex; flex-direction: column;
  padding: 0.8rem 1.2rem; border-radius: 8px;
  text-decoration: none; transition: transform 0.1s, box-shadow 0.1s;
  border: 2px solid transparent; min-width: 220px; }
.btn-action:hover { transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.btn-action-label { font-weight: 700; font-size: 1.05rem;
  letter-spacing: 0.02em; }
.btn-action-sub { font-size: 0.85rem; opacity: 0.9; margin-top: 0.15rem; }
.btn-action-tstt { background: var(--accent); color: white; }
.btn-action-tstt:hover { background: var(--accent-dark, #013912); }
.btn-action-attkt { background: #4a6fb5; color: white; }
.btn-action-attkt:hover { background: #36548c; }
.btn-action-custom { background: #8a5a14; color: white; }
.btn-action-custom:hover { background: #6e470f; }
.btn-action-carta { background: #6b4a8a; color: white; }
.btn-action-carta:hover { background: #543a6c; }

/* Operative dossier — top card header layout */
.dossier-head {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 1.2rem;
  row-gap: 0.4rem;
  align-items: start;
}
.dossier-name { grid-column: 1; margin: 0; }
.dossier-code { grid-column: 2; justify-self: end; align-self: center; }
.dossier-meta { grid-column: 1; }
.dossier-meta p { margin: 0.2rem 0; }
.dossier-cta {
  grid-column: 2; justify-self: end; align-self: start;
  margin-top: 0;            /* override default btn margin */
}
@media (max-width: 540px) {
  .dossier-head { grid-template-columns: 1fr; }
  .dossier-code,
  .dossier-cta { grid-column: 1; justify-self: start; }
}

/* Transmission pill on the operative dossier */
.transmission-pill {
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  background: #ece0fa;             /* light purple — matches lp-purple */
  border: 1px solid #d3b8f0;
  border-left: 4px solid #4a1d8a;
  border-radius: 8px;
}
.transmission-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4a1d8a;
  margin-bottom: 0.25rem;
}
.transmission-body {
  margin: 0;
  font-style: italic;
  color: #35235c;
  white-space: pre-wrap;
}

/* "Open my character sheet" CTA on the operative dossier */
.btn-open-character {
  display: inline-flex; align-items: center; gap: 0.6rem;
  margin-top: 0.6rem; padding: 0.8rem 1.4rem;
  background: var(--accent); color: white; text-decoration: none;
  font-weight: 700; font-size: 1.05rem; border-radius: 8px;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
}
.btn-open-character:hover {
  background: var(--accent-dark, #013912);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.14);
}
.btn-open-character-arrow {
  font-size: 1.2rem; transition: transform 0.15s;
}
.btn-open-character:hover .btn-open-character-arrow {
  transform: translateX(3px);
}

/* Attunement / key-text grid */
.attkt-table { font-variant-numeric: tabular-nums; }
.attkt-table th { text-align: center; }
.attkt-table th[rowspan] { text-align: left; vertical-align: middle; }
.attkt-table .group-att { background: #f3f6fc; }
.attkt-table .group-kt  { background: #faf3fc; }
.attkt-table thead .group-att { background: #dde6f5; }
.attkt-table thead .group-kt  { background: #ecd9f0; }
.attkt-table .check-cell { text-align: center; padding: 0.3rem 0.5rem; }
.attkt-table .check-cell input[type="checkbox"] {
  width: 20px; height: 20px; cursor: pointer; }

/* dossier */
.lp-progress { margin-top: 0.8rem; }
.lp-progress-bar { height: 10px; background: var(--bg);
  border-radius: 5px; overflow: hidden; position: relative;
  border: 1px solid var(--line); }
.lp-progress-bar::after { content: ""; position: absolute;
  top: 0; left: 0; height: 100%; width: var(--p, 0%);
  background: var(--accent); transition: width 0.3s; }
.mission-table td { font-variant-numeric: tabular-nums; }

/* LP value color-coding (per-episode / per-mission / per-exam) */
.lp-red    { background: #fde0e0; color: #8a1414; font-weight: 600; }
.lp-purple { background: #ece0fa; color: #4a1d8a; font-weight: 600; }
.lp-blue   { background: #d8e8ff; color: #143a8a; font-weight: 600; }
.lp-green  { background: #dff5d4; color: #2c5a14; font-weight: 600; }
/* Pill variant for resource-card values */
.lp-pill { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 4px; }
.row-selected { background: #f8fbf1; }
.check-list { list-style: none; padding: 0; margin: 0.3rem 0;
  display: flex; gap: 1rem; flex-wrap: wrap; }
.check-list li { font-family: monospace; }

/* ------------------------------------------------ Villa mission board */
.villa-header { display: flex; justify-content: space-between;
  align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.villa-header h1.flush { margin: 0 0 0.3rem 0; }
.villa-save-status { margin-left: 0.6rem; font-size: 0.85rem;
  font-style: italic; }
.villa-toolbar { display: flex; flex-wrap: wrap; gap: 0.4rem;
  align-items: center; }
.villa-toolbar strong { margin-right: 0.4rem; }
.villa-add-pc, .villa-add-guard, .villa-add-marcus, .villa-add-prop {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.6rem; font-size: 0.85rem;
  background: #f4ecd8; color: #3a2a14; border: 1px solid #c9b58a;
  border-radius: 4px; cursor: pointer;
}
.villa-add-pc:hover, .villa-add-guard:hover,
.villa-add-marcus:hover, .villa-add-prop:hover {
  background: #ebe0c0;
}
.villa-add-pc .villa-chip,
.villa-chip-guard, .villa-chip-marcus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--c); color: #fff7e8; font-weight: 700;
  font-size: 0.78rem; letter-spacing: 0;
}
.villa-chip-guard { background: #e0301e; }
.villa-chip-marcus { background: #7a2848; }
.villa-trash {
  margin-left: auto; padding: 0.3rem 0.8rem; font-size: 1.1rem;
  border: 2px dashed #c9b58a; border-radius: 6px; color: #6f5a3a;
  background: #faf3df;
}
.villa-trash.hover { background: #fde0e0; border-color: #a8321f;
  color: #8a1414; }

.villa-board {
  position: relative; width: 100%; max-width: 1100px; margin: 0 auto;
  user-select: none; touch-action: none;
}
.villa-bg {
  display: block; width: 100%; height: auto;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(60, 40, 10, 0.12);
}
.villa-tokens {
  position: absolute; inset: 0; pointer-events: none;
}

.villa-token {
  position: absolute; transform: translate(-50%, -50%);
  width: 2.4rem; height: 2.4rem; pointer-events: auto;
  cursor: grab; touch-action: none;
}
.villa-token.dragging { cursor: grabbing; z-index: 10;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.3)); }

/* PC token — parchment disc with colored ring, body silhouette and a
   centered letter pill at the bottom. */
.villa-token-pc {
  background: radial-gradient(circle at 35% 30%, #fff7e0, #ecd9a8 75%);
  border: 3px solid var(--c, #6f5a3a);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(60, 40, 10, 0.35);
  overflow: hidden;
}
.villa-token-pc .villa-body-img {
  width: 100%; height: 100%; object-fit: cover;
  object-position: center top;
}
.villa-token-pc .villa-letter {
  position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  background: var(--c, #6f5a3a); color: #fff7e8;
  border-radius: 999px; padding: 0 0.28rem;
  font-size: 0.55rem; font-weight: 700; line-height: 1.2;
  font-family: Georgia, 'Times New Roman', serif;
  border: 1px solid #fff7e8;
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.villa-token-pc[data-body="female"] .villa-letter { font-style: italic; }

/* Guard token — silhouette in a parchment disc with red ring,
   index label as a corner badge. */
.villa-token-guard {
  background: radial-gradient(circle at 35% 30%, #fff7e0, #ecd9a8 75%);
  border: 3px solid #e0301e;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(60, 40, 10, 0.35);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.villa-token-guard .villa-guard-img {
  width: 100%; height: 100%; object-fit: cover;
  object-position: center top;
}
.villa-token-guard .villa-letter-guard,
.villa-token-marcus .villa-letter-marcus {
  position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  background: #8a2a2a; color: #fff7e8;
  border-radius: 999px; padding: 0 0.28rem;
  font-size: 0.55rem; font-weight: 700; line-height: 1.2;
  border: 1px solid #fff7e8;
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.villa-token-marcus .villa-letter-marcus { background: #7a2848; }

/* Marcus token — mirror of guard, with burgundy ring. */
.villa-token-marcus {
  background: radial-gradient(circle at 35% 30%, #fff7e0, #ecd9a8 75%);
  border: 3px solid #7a2848;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(60, 40, 10, 0.35);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.villa-token-marcus .villa-guard-img {
  width: 100%; height: 100%; object-fit: cover;
  object-position: center top;
}

.villa-board-view .villa-token { cursor: default; }

/* Prop tokens (key, scroll, chests) — no disc, ~75% of a character
   token. Anything with a villa-prop-img child gets the prop sizing. */
.villa-token:has(.villa-prop-img) {
  width: 1.8rem; height: 1.8rem;
}
.villa-prop-img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

/* ---- teacher-UX affordances (onboarding, danger zones, code recovery) ---- */

/* Operative/dossier codes tint blue to match the operative chip palette;
   team (character) codes keep the default accent. */
.code-chip--op { background: #2a4173; }

/* "How this fits together" onboarding explainer on the dashboard */
.how-it-works { margin-bottom: 1rem; }
.how-it-works summary { cursor: pointer; color: var(--accent-dark); }
.how-it-works p, .how-it-works ol { margin: 0.5rem 0 0.25rem; }
.how-it-works ol { padding-left: 1.4rem; }

/* Destructive actions collapse behind a summary so daily scrolling
   never lands on a red button. */
.danger-zone summary { cursor: pointer; }
.danger-zone h2 { margin-top: 0.75rem; }

/* Forgot-code form on the Agent Console */
.recover-code { margin: 0.75rem 0; }
.recover-code summary { cursor: pointer; }
.recover-code form { margin-top: 0.5rem; }

/* Instant visible tooltips. Native title= needs a ~1s motionless hover,
   gives no hint it exists, and never fires on touch — so jargon terms
   carry data-tip instead: dotted underline signals "hover me", and the
   tip shows immediately on hover or keyboard focus. */
[data-tip] {
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  position: relative;
}
[data-tip]:hover::after, [data-tip]:focus::after {
  content: attr(data-tip);
  position: absolute; left: 0; top: 100%; margin-top: 0.35rem;
  background: var(--accent-dark); color: var(--header-text);
  padding: 0.45rem 0.6rem; border-radius: 4px;
  font-size: 0.8rem; font-weight: 400; letter-spacing: normal;
  width: max-content; max-width: 250px; white-space: normal;
  text-align: left; z-index: 60;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
/* Code chips keep their look — help cursor only, no underline. */
.code-chip[data-tip] { text-decoration: none; }

/* ---------------------------------------------------------------- Carta Collectionis */

.carta-cat {
  margin: 1.2rem 0 0.5rem;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.2rem;
}

.carta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 0.7rem;
}

.carta {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.55rem 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}
.carta:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); }
div.carta { cursor: default; }
div.carta:hover { transform: none; box-shadow: none; }

.carta-art {
  display: block;
  aspect-ratio: 700 / 1022;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}
.carta-art img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Locked: card back, art dimmed until the 50-form reveal. */
.carta-locked .carta-art img { filter: grayscale(0.9) brightness(0.85); opacity: 0.75; }
.carta-locked .carta-name { color: var(--muted); }

.carta-selected { outline: 3px solid var(--accent); outline-offset: 1px; }

.carta-name { font-weight: bold; font-size: 0.82rem; line-height: 1.2; }
.carta-target { font-size: 0.72rem; color: var(--accent); }
.carta-special .carta-target { color: #8a6d1a; }
.carta-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}
.carta-lp { color: var(--accent); font-weight: bold; }

.carta-bar {
  display: block;
  height: 7px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
}
.carta-bar-fill {
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: var(--brand-gradient);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Foil: animated light-band shimmer + gilded edge. */
.carta-foil {
  border-color: #d4b24a;
  box-shadow: inset 0 0 0 2px #d4b24a, 0 2px 12px rgba(180, 150, 40, 0.45);
}
.carta-foil::after,
.carta-modal-art.carta-foil-art::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 22%,
    rgba(255, 255, 255, 0.62) 40%,
    rgba(160, 255, 200, 0.48) 50%,
    rgba(255, 240, 160, 0.55) 60%,
    transparent 78%
  );
  /* One oversized, non-repeating band: without no-repeat the gradient
     tiles, and a second copy slides in at the end of each sweep. The
     wide position range lets the band fully exit before looping. */
  background-size: 250% 250%;
  background-repeat: no-repeat;
  animation: carta-shimmer 4s linear infinite;
  border-radius: 10px;
}
@keyframes carta-shimmer {
  0%   { background-position: 175% 175%; }
  100% { background-position: -75% -75%; }
}
/* Foil treatment for the modal's enlarged art. */
.carta-modal-art.carta-foil-art {
  position: relative;
  border-radius: 8px;
}
.carta-modal-art.carta-foil-art img {
  border-color: #d4b24a;
  box-shadow: inset 0 0 0 2px #d4b24a, 0 2px 12px rgba(180, 150, 40, 0.45);
}
.carta-modal-art.carta-foil-art::after { border-radius: 8px; }
@media (prefers-reduced-motion: reduce) {
  .carta-foil::after,
  .carta-modal-art.carta-foil-art::after { animation: none; }
  .carta, .carta:hover { transition: none; transform: none; }
}

/* Collection modal (opened by clicking a card) */
.carta-modal {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem;
  max-width: min(680px, 92vw);
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  background: var(--card);
  color: var(--ink);
}
.carta-modal::backdrop { background: rgba(20, 30, 15, 0.55); }
.carta-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.carta-modal-close:hover { color: var(--ink); }
.carta-modal-body {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
}
.carta-modal-art { flex: 0 0 180px; }
.carta-modal-art img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 700 / 1022;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.carta-modal-main { flex: 1 1 auto; min-width: 0; }
.carta-modal-main h3 { margin: 0 0 0.1rem; }
.carta-modal-progress { margin: 0.5rem 0 0.25rem; font-size: 0.9rem; }
.carta-modal-progress .muted { font-size: 0.8rem; }
.carta-modal-collected { margin-top: 0.9rem; }
.carta-modal-collected summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.carta-forms {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  max-height: 180px;
  overflow-y: auto;
  font-size: 0.85rem;
}
.carta-forms li { margin-bottom: 0.15rem; }
@media (max-width: 560px) {
  .carta-modal-body { flex-direction: column; }
  .carta-modal-art { flex-basis: auto; width: 140px; margin: 0 auto; }
}
.carta-submit-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: flex-end;
  margin-top: 0.6rem;
}
.carta-submit-fields[hidden] { display: none; }
.carta-submit-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
  flex: 1 1 180px;
}
.carta-submit-fields input {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
}
.carta-feedback { min-height: 1.4em; margin: 0.6rem 0 0; font-weight: bold; }
.carta-feedback.carta-yes { color: var(--accent); }
.carta-feedback.carta-no { color: #a33; }
.carta-feedback.carta-wait { color: var(--muted); }

.carta-recent { margin-top: 1rem; }
.carta-recent summary { cursor: pointer; color: var(--accent); }

/* Carta settings page: one collection per line inside each category. */
.carta-settings-row { flex-direction: column; gap: 0.35rem; align-items: flex-start; }
.carta-settings-row label { display: flex; align-items: baseline; gap: 0.45rem; }

/* Suggested-mission tag on the collection-settings list — informational,
   deliberately quiet so it doesn't read as a prerequisite. */
.carta-mission-tag {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Special-card row actions on the manage table. */
.carta-special-actions { white-space: nowrap; }
.carta-special-actions form { margin-left: 0.3rem; }
