/* The application shell's *structure* -- a title bar over a sidebar (step nav + resource panel)
   and one content pane (WP97-99). It does not restyle the forms/tables inside a step.

   WP100: this file defines no token values at all. Every colour, font, rule weight, alignment and
   accent below is a `var(--...)` supplied by the linked theme (`static/themes/<slug>.css`, chosen
   in the title bar -- see chummer5.web.prefs). A theme is a complete token set for both colour
   schemes and nothing else; `tests/unit/test_web_themes.py` checks both halves of that: every
   token used here is defined by every theme, and no theme contains anything but token
   declarations. To restyle the furniture, write a theme. To change the layout, edit this file.

   Every rule selects on a semantic class hook (.app-shell__*, .step-nav__*, .resource-panel__*,
   .page*, .page-tabs__*, .subpage, .panel*), never on ids or tag structure. Live constraints:
   nothing may set `display` on a `tr` (WP84: the step filters toggle `hidden`) or on `.subpage`
   (WP98: inactive tabs are `hidden`), and light/dark stay handled by `color-scheme` here plus each
   theme's own `prefers-color-scheme` block. */

:root {
  color-scheme: light dark;
}

body {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.45;
  color: var(--page-fg);
  background: var(--page-bg);
}

/* --- The shell -------------------------------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "titlebar titlebar"
    "sidebar main"
    "footer footer";
  min-height: 100vh;
}

.app-shell__titlebar {
  grid-area: titlebar;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.5rem 1.25rem;
  color: var(--titlebar-fg);
  background: var(--titlebar-bg);
}

.app-shell__title {
  flex: 1 1 auto;
  font-family: var(--font-title);
  font-size: var(--title-size);
  font-weight: var(--title-weight);
  text-align: var(--title-align);
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
}

/* The display-preference pickers (theme; WP101 adds the language). */
.app-shell__prefs {
  display: flex;
  gap: 0.75rem;
  margin: 0;
  font-size: 0.85rem;
}

.app-shell__pref select {
  margin-left: 0.3rem;
}

/* WP137: hosted mode's username and logout button. */
.app-shell__account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.app-shell__account a {
  color: inherit;
}

.app-shell__account form {
  margin: 0;
}

.app-shell__sidebar {
  grid-area: sidebar;
  border-top: var(--frame-width) solid var(--frame-color);
  border-left: var(--frame-width) solid var(--frame-color);
  border-right: var(--frame-width) solid var(--frame-color);
  color: var(--sidebar-fg);
  background: var(--sidebar-bg);
}

.app-shell__main {
  grid-area: main;
  min-width: 0;
  padding: 1rem 1.25rem 4rem;
  border-top: var(--frame-width) solid var(--frame-color);
  background: var(--main-bg);
}

.app-shell__main > .page {
  max-width: 72rem;
}

/* The theme's "Fonts?" hint: a tooltip opened by hovering or focusing its button (a tap focuses
   it on touch screens). Hidden with `visibility`, so `aria-describedby` still reaches its text. */
.font-hint {
  position: relative;
}

.font-hint__toggle {
  padding: 0;
  border: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline dotted;
  background: none;
  cursor: help;
}

.font-hint__tip {
  position: absolute;
  z-index: 10;
  top: calc(100% + 0.4rem);
  right: 0;
  width: min(24rem, 90vw);
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--frame-color);
  font-family: var(--font-body);
  text-align: left;
  color: var(--page-fg);
  background: var(--page-bg);
  box-shadow: 0 0.2rem 0.6rem rgb(0 0 0 / 30%);
  visibility: hidden;
}

.font-hint:hover .font-hint__tip,
.font-hint:focus-within .font-hint__tip {
  visibility: visible;
}

.font-hint__intro {
  margin: 0 0 0.4rem;
}

.font-hint__source {
  margin: 0.4rem 0 0;
}

.font-hint__list {
  margin: 0;
}

.font-hint__list dt {
  margin-top: 0.3rem;
  font-weight: 600;
}

.font-hint__list dd {
  margin-left: 0.8rem;
}

/* --- The step nav ----------------------------------------------------------------------------- */

.step-nav__list {
  margin: 0;
  padding: var(--nav-list-padding) 0;
  list-style: none;
}

.step-nav__entry {
  position: relative;
}

.step-nav__entry + .step-nav__entry {
  border-top: var(--nav-item-rule-width) solid var(--nav-rule-color);
}

/* The sketch's chevron connector between two steps, pointing down into the next one: a V hung
   from the rule, drawn only by tokens -- `--nav-chevron-size: 0` (Classic) draws nothing. */
.step-nav__entry:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 100%;
  left: 50%;
  width: calc(var(--nav-chevron-size) * 2);
  height: var(--nav-chevron-size);
  transform: translateX(-50%);
  background: var(--nav-chevron-color);
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 45%, 50% 100%, 0 45%);
  pointer-events: none;
}

.step-nav__item {
  display: block;
  padding: 0.35rem 1rem;
  border-left: var(--nav-item-accent-width) solid transparent;
  font-family: var(--font-nav);
  text-align: var(--nav-item-align);
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
  color: var(--nav-item-fg);
  text-decoration: none;
}

a.step-nav__item:hover {
  background: var(--nav-item-hover-bg);
}

.step-nav__item--current {
  font-weight: 600;
  color: var(--nav-item-current-fg);
  border-left-color: var(--nav-item-current-accent);
  background: var(--nav-item-current-bg);
}

a.step-nav__item--current:hover {
  background: var(--nav-item-current-bg);
}

.step-nav__item--disabled {
  color: var(--nav-item-disabled-fg);
  cursor: not-allowed;
}

.step-nav__marker {
  color: var(--warning-fg);
}

/* --- The remaining-resources panel (WP99) ------------------------------------------------------ */

.resource-panel {
  margin: 0 0.75rem 1rem;
  padding-top: 0.5rem;
  border-top: var(--frame-width) solid var(--frame-color);
  font-size: 0.9rem;
}

.resource-panel__heading {
  margin: 0 0 0.35rem;
  font-family: var(--font-nav);
  font-size: 0.95rem;
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
  color: var(--sidebar-heading-fg);
}

.resource-panel__list {
  margin: 0;
}

.resource-panel__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 0.5rem;
  padding: 0.1rem 0;
}

.resource-panel__label {
  color: var(--nav-item-fg);
}

/* `auto` keeps the figure right-aligned even when a long label wraps it onto its own line. */
.resource-panel__value {
  margin: 0 0 0 auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.resource-panel__of {
  font-weight: normal;
  color: var(--panel-muted-fg);
}

.resource-panel__row--over .resource-panel__value {
  color: var(--panel-over-fg);
}

.resource-panel__empty {
  margin: 0;
  color: var(--panel-muted-fg);
}

/* Narrow screens: the nav becomes a wrapping row above the page instead of a column beside it. */
@media (max-width: 40rem) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "titlebar"
      "sidebar"
      "main"
      "footer";
  }

  .app-shell__sidebar {
    border-right: var(--frame-width) solid var(--frame-color);
  }

  .step-nav__list {
    display: flex;
    flex-wrap: wrap;
  }

  /* A row has no "next step below" for a chevron to point at, nor a rule between items. */
  .step-nav__entry + .step-nav__entry {
    border-top: 0;
  }

  .step-nav__entry:not(:last-child)::after {
    content: none;
  }
}

/* --- A page, its tabs, and its step panels ---------------------------------------------------- */

/* `--page-heading-clip` lets a theme cut the heading's box into a banner shape (SR5's chamfered
   corners); `none` leaves it a plain heading. */
.page__heading {
  margin-top: 0;
  padding: var(--page-heading-padding);
  font-family: var(--font-title);
  font-size: 1.3rem;
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
  color: var(--page-heading-fg);
  background: var(--page-heading-bg);
  clip-path: var(--page-heading-clip);
}

/* WP98: a composite page's tab strip (Skills, Magic, Equipment) -- one section showing at a time,
   the others `hidden` (nothing here may set `display` on .subpage, or `hidden` stops working). */
.page-tabs {
  margin-bottom: 0.75rem;
  border-bottom: var(--tab-rule-width) solid var(--rule);
}

.page-tabs__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.page-tabs__item {
  display: block;
  margin-bottom: calc(-1 * var(--tab-rule-width));
  padding: 0.35rem 0.8rem;
  border-bottom: var(--tab-accent-width) solid transparent;
  font-family: var(--font-nav);
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
  color: var(--tab-fg);
  text-decoration: none;
}

a.page-tabs__item:hover {
  background: var(--tab-hover-bg);
}

.page-tabs__item--current {
  font-weight: 600;
  border-bottom-color: var(--tab-current-accent);
  background: var(--tab-current-bg);
}

.page-tabs__item--disabled {
  color: var(--tab-disabled-fg);
  cursor: not-allowed;
}

.page-tabs__marker {
  color: var(--warning-fg);
}

/* One box per step fragment. A single-section page shows one; a composite page shows one per tab.
   Neighbours (should a page ever stack several again) are told apart by alternating tint.
   `--panel-clip` is the panel's outline (a chamfer, say); `none` keeps the plain box. */
.panel {
  padding: 0.75rem 1rem;
  border-top: var(--panel-rule-width) solid var(--rule);
  border-left: var(--panel-accent-width) solid var(--section-accent);
  background: var(--section-bg-a);
  clip-path: var(--panel-clip);
}

.panel:nth-child(even of .panel) {
  background: var(--section-bg-b);
}

.panel:last-child {
  border-bottom: var(--panel-rule-width) solid var(--rule);
}

/* A panel's own <summary> is its heading; the nested ones (skill categories, gear/cyberware
   groups) are deliberately left plain so the two levels don't compete. */
.panel__heading {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 600;
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
  color: var(--summary-fg);
  cursor: pointer;
}

details[open] > .panel__heading {
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}

.panel summary {
  cursor: pointer;
}

/* Sub-sections inside a panel (skill categories, gear groups, cyberware slots). */
.panel details details {
  margin: 0.35rem 0;
  padding-left: 0.6rem;
  border-left: 2px solid var(--rule);
}

/* The status classes the templates already emit (error/warning/info). */
.error,
.warning,
.info {
  margin: 0.5rem 0;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
}

.error {
  color: var(--error-fg);
  background: var(--error-bg);
}

.warning {
  color: var(--warning-fg);
  background: var(--warning-bg);
}

.info {
  color: var(--info-fg);
  background: var(--info-bg);
}

/* Just enough table styling that a panel's rows read as rows against the panel tint. WP139: the
   character list's table too. */
.page table,
.character-list table,
.admin-page table {
  border-collapse: collapse;
}

.page th,
.page td,
.character-list th,
.character-list td,
.admin-page th,
.admin-page td {
  padding: 0.15rem 0.4rem;
  text-align: left;
}

.page thead th,
.character-list thead th,
.admin-page thead th {
  border-bottom: 1px solid var(--rule);
  color: var(--table-head-fg);
  background: var(--table-head-bg);
}

/* Body-row banding (SR4's alternating green rows); `transparent` in themes that don't band. Only a
   background -- never `display` on a `tr` (WP84). A filtered-out (hidden) row still counts toward
   `nth-child`, so banding under an active filter can show two like rows together. */
.page tbody tr:nth-child(odd),
.character-list tbody tr:nth-child(odd),
.admin-page tbody tr:nth-child(odd) {
  background: var(--table-row-bg-a);
}

.page tbody tr:nth-child(even),
.character-list tbody tr:nth-child(even),
.admin-page tbody tr:nth-child(even) {
  background: var(--table-row-bg-b);
}

/* WP134: the Bio page -- short fields two to a row where there is room, long ones full width. */
.bio-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.5rem 1rem;
}

.bio-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.bio-form__field--long {
  grid-column: 1 / -1;
}

.bio-form__field--long textarea {
  width: 100%;
  box-sizing: border-box;
}

.sheet-bio {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 1rem;
}

/* WP137: the account pages (login, registration, password) -- the title bar over one centred
   panel, no step nav. */
.auth-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.auth-shell__main {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--main-bg);
}

.auth-form {
  width: 100%;
  max-width: 26rem;
}

.auth-form .panel__heading {
  cursor: default;
  margin: 0 0 0.75rem;
}

.auth-form__fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.auth-form__field small {
  opacity: 0.8;
}

.auth-form__fields button {
  align-self: flex-start;
}

.auth-form__alt {
  margin-top: 1rem;
}

/* WP138: the open character in the title bar, and the notice a refused change shows. */
.open-character {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.open-character__name {
  font-weight: 600;
}

.open-character__list {
  color: inherit;
}

.stale-notice__reload {
  font-weight: 600;
}

/* WP139: the character list -- the shell's title bar over one panel, no step nav. Table, button
   and panel looks come from the theme, as on every step page. */
.list-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.list-shell__main {
  flex: 1 1 auto;
  padding: 1.5rem 1.25rem;
  background: var(--main-bg);
}

.list-shell__back {
  color: inherit;
  font-size: 0.9rem;
}

.character-list .panel__heading {
  cursor: default;
  margin: 0 0 0.75rem;
}

.character-list__filter input {
  margin-left: 0.4rem;
}

.character-list__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0;
}

.character-list__table {
  width: 100%;
}

.character-list__badge {
  margin-left: 0.4rem;
  font-size: 0.8rem;
  opacity: 0.8;
}

.character-list__open td:first-child {
  font-weight: 600;
}

.character-list__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* WP140: the list's upload control and its per-file results. */
.character-list__upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.character-list__results {
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
}

/* Phase α: the admin pages -- the character list's frame, a facts list over a table. */
.admin-page .panel__heading {
  cursor: default;
  margin: 0 0 0.75rem;
}

.admin-page__table {
  width: 100%;
}

.admin-page__badge {
  margin-left: 0.4rem;
  font-size: 0.8rem;
  font-weight: normal;
  opacity: 0.8;
}

.admin-page__aside {
  opacity: 0.8;
}

/* WP154: the invites section sits under the users panel; the reset and mint controls. */
.admin-page + .admin-page {
  margin-top: 1rem;
}

.admin-page__mint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0;
}

.admin-page__mint input {
  width: 6rem;
  margin-left: 0.4rem;
}

.admin-page__reset {
  margin: 0 0 1rem;
}

.admin-page__secret {
  font-size: 1.1rem;
  user-select: all;
}

.admin-page__facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 1rem;
  margin: 0 0 1rem;
}

.admin-page__facts dd {
  margin: 0;
}

/* The legal footer (GPL section 5(d)): copyright, license, source link, trademark notice. Below
   the content on every full-page layout; a grid area of its own in the chargen shell. */
.legal-footer {
  grid-area: footer;
  padding: 0.75rem 1.25rem;
  border-top: var(--frame-width) solid var(--frame-color);
  font-size: 0.75rem;
  color: var(--panel-muted-fg);
  background: var(--main-bg);
}

.legal-footer p {
  margin: 0.15rem 0;
}

.legal-footer a {
  color: inherit;
}

/* --- Priorities page (WP143, Phase Z) ---------------------------------------------------------
   spec/plan/phase-z-page-redesigns.md: one centred column of comfortable width (heading, method
   dropdown, panel), top-aligned; on a phone it is the content pane's full width. Messages sit at
   the bottom, under every control, and Revert keeps its space while hidden, so nothing a player
   is about to click ever moves. */
.priority-page {
  max-width: 30rem;
  margin-inline: auto;
}

.priority-page__method {
  display: block;
  width: 100%;
  margin-bottom: 0.75rem;
  font: inherit;
}

.priority-panel {
  border-bottom: var(--panel-rule-width) solid var(--rule);
}

.priority-panel__intro {
  margin: 0 0 1rem;
  color: var(--panel-muted-fg);
}

/* Priority: the fixed letters A-E beside the five category tiles. Both lists share one row
   height, so each letter lines up with whichever tile is in its row. */
.priority-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.75rem;
}

.priority-grid__letters,
.priority-grid__tiles {
  display: grid;
  grid-auto-rows: 2.5rem;
  row-gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.priority-grid__letter {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  font-family: var(--font-title);
  font-size: 1.6rem;
  line-height: 1;
  color: var(--summary-fg);
}

.priority-tile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.75rem;
  border: 1px solid var(--frame-color);
  border-radius: var(--radius);
  background: var(--section-bg-b);
  cursor: grab;
  user-select: none;
}

.priority-tile:focus-visible {
  outline: 2px solid var(--section-accent);
  outline-offset: 2px;
}

.priority-tile__handle {
  color: var(--panel-muted-fg);
}

/* WP144: SortableJS's states -- the placeholder left in the list while dragging (ghost), and the
   tile being held (chosen). */
.priority-tile--ghost {
  opacity: 0.4;
}

.priority-tile--chosen {
  border-color: var(--section-accent);
  cursor: grabbing;
}

.priority-panel__hint {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--panel-muted-fg);
}

/* Read aloud, never shown: the reorder announcements. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Sum-to-Ten: label, dot leader, value; a closing total row. */
.sum-to-ten__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
}

.sum-to-ten__leader {
  flex: 1;
  align-self: end;
  margin-bottom: 0.6rem;
  border-bottom: 2px dotted var(--rule);
}

.sum-to-ten__spinner {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.sum-to-ten__value {
  min-width: 3.5em;
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sum-to-ten__value:focus-visible {
  outline: 2px solid var(--section-accent);
  outline-offset: 1px;
}

.sum-to-ten__step {
  min-width: 1.9rem;
  min-height: 1.9rem;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
}

.sum-to-ten__row--total {
  margin-top: 0.25rem;
  padding: 0 0.3rem;
  border-top: 1px solid var(--rule);
  border-radius: var(--radius);
  font-weight: 600;
}

.sum-to-ten__row--total abbr {
  text-decoration: none;
}

.sum-to-ten__total {
  font-variant-numeric: tabular-nums;
}

.sum-to-ten__row--off {
  color: var(--error-fg);
  background: var(--error-bg);
}

/* The Metatype field, then the status line (a fixed two-line height, so its changing text never
   moves the buttons), then Revert and CONFIRM. */
.priority-panel__metatype {
  margin-top: 1rem;
}

.priority-panel__metatype label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.priority-panel__metatype select {
  width: 100%;
  font: inherit;
}

.priority-status {
  display: flex;
  align-items: center;
  height: 2.9em;
  margin: 0.5rem 0 0.25rem;
  overflow: hidden;
  color: var(--panel-muted-fg);
}

.priority-status--confirmed {
  color: var(--info-fg);
}

.priority-status--changed {
  color: var(--warning-fg);
}

.priority-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.5rem;
}

.priority-actions button {
  min-height: 2.5rem;
  padding: 0.3rem 1rem;
  font: inherit;
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
}

.priority-actions__revert--idle {
  visibility: hidden;
}

/* What each placed priority gives -- always the form's current selection. */
.priority-summary {
  margin: 1rem 0 0;
}

.priority-summary__row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.2rem 0;
}

.priority-summary__row + .priority-summary__row {
  border-top: 1px solid var(--rule);
}

.priority-summary dt {
  color: var(--panel-muted-fg);
}

.priority-summary dd {
  margin: 0;
}

.priority-summary__row--changed dd {
  font-weight: 600;
  color: var(--warning-fg);
}

/* WP145: the leave-with-unconfirmed-changes dialog. */
.priority-leave {
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 1rem 1.25rem;
  border: var(--frame-width) solid var(--frame-color);
  border-left: var(--panel-accent-width) solid var(--section-accent);
  border-radius: var(--radius);
  color: var(--page-fg);
  background: var(--section-bg-a);
}

.priority-leave::backdrop {
  background: color-mix(in srgb, var(--page-fg) 45%, transparent);
}

.priority-leave__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-title);
  font-size: 1.1rem;
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
  color: var(--summary-fg);
}

.priority-leave__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.priority-leave__actions button {
  min-height: 2.25rem;
  padding: 0.3rem 0.9rem;
  font: inherit;
}

/* --- Attributes page (WP146, Phase Z) ----------------------------------------------------------
   spec/plan/phase-z-page-redesigns.md: the same centred column as Priorities, wider because the
   table has five columns. The budget boxes are the shared ones below. Messages sit under the
   table. */
.attribute-page {
  max-width: 40rem;
  margin-inline: auto;
}

.attribute-table {
  overflow-x: auto;
}

/* WP169: the Talent is the page's second tab. The tab strip and the Talent tab sit in the same
   centred column as the attributes (standing rule 2, user ruling 2026-10-31). */
.page--attributes .page-tabs,
.talent-page {
  max-width: 40rem;
  margin-inline: auto;
}

/* --- Budget boxes (WP146, shared since WP147) ---------------------------------------------------
   A row of "remaining/budget" boxes above a redesigned page's controls (Attributes, Qualities).
   The boxes stay in one row at every width, as equal columns, and labels wrap inside them. An
   overspent pool's box takes the Sum-to-Ten off-target colours. */
.budget-boxes {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.budget-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  padding: 0.4rem 0.3rem;
  border: var(--panel-rule-width) solid var(--rule);
  border-radius: var(--radius);
  text-align: center;
}

.budget-box__label {
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.budget-box__hint {
  display: block;
  color: var(--panel-muted-fg);
}

.budget-box__value {
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.budget-box--over,
.view-counter--over {
  color: var(--error-fg);
  background: var(--error-bg);
}

.budget-box--over .budget-box__hint {
  color: inherit;
}

/* --- Qualities page (WP147, Phase Z) -----------------------------------------------------------
   spec/plan/phase-z-page-redesigns.md, "Redesign 3": the Attributes column and budget boxes, then
   a full-width category dropdown styled like the Priorities method dropdown, and the chosen
   category's table, which scrolls sideways on its own if a phone is too narrow. The Mentor Spirit
   fieldset follows under Positive; messages sit under it. */
.quality-page {
  max-width: 40rem;
  margin-inline: auto;
}

.quality-section {
  margin-bottom: 1rem;
}

.quality-page__view {
  display: block;
  width: 100%;
  margin-bottom: 0.75rem;
  font: inherit;
}

.quality-table {
  overflow-x: auto;
}

.quality-table input[type="text"] {
  max-width: 100%;
}

/* --- View-tab strip (WP148, shared since WP151, Phase Z) ----------------------------------------
   `_view_tabs.html`: the Skills page's strip of angled tabs, also the Spells sub-tab's. Every tab
   is a parallelogram: a box skewed about its bottom edge, so the bottoms line up as a plain row
   and each top leans one strip-height to the right. The label is unskewed and turned to run up the
   slant. The filler is one more parallelogram that takes the remaining width, so the tabs stay at
   the left however wide the window. The start counters sit in the triangle left free above the
   first tab; the end counters at the filler's bottom right. The strip is 5rem high and a tab
   2.2rem wide; the 5rem recurs below wherever a top's lean is allowed for. The strip scrolls
   sideways inside itself, never the page; a page that renders the narrow block swaps the strip
   for it with its own container query (WP150), sized to where its strip stops fitting. */
.view-tabs {
  margin-bottom: 0.75rem;
  overflow-x: auto;
}

.view-tabs__strip {
  position: relative;
  display: flex;
  min-width: max-content;
  height: 5rem;
  padding-right: 5rem;
  border-bottom: var(--tab-rule-width) solid var(--rule);
}

.view-tabs__list {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.view-tab,
.view-tabs__filler {
  transform-origin: bottom left;
  transform: skewX(-45deg);
  border: 1px solid var(--frame-color);
  border-bottom: 0;
}

.view-tab {
  position: relative;
  display: block;
  width: 2.2rem;
  height: 5rem;
  margin-left: -1px;
  font-family: var(--font-nav);
  font-size: 0.8rem;
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
  color: var(--tab-fg);
  text-decoration: none;
}

.view-tab__label {
  position: absolute;
  bottom: 0.3rem;
  left: calc(50% + 0.3rem);
  transform-origin: bottom left;
  transform: skewX(45deg) rotate(-45deg);
  white-space: nowrap;
}

a.view-tab:hover {
  background: var(--tab-hover-bg);
}

a.view-tab:focus-visible {
  outline: 2px solid var(--section-accent);
  outline-offset: -3px;
}

.view-tab--current {
  font-weight: 600;
  background: var(--tab-current-bg);
  box-shadow: inset 0 calc(-1 * var(--tab-accent-width)) 0 var(--tab-current-accent);
}

.view-tab--disabled {
  color: var(--tab-disabled-fg);
  cursor: not-allowed;
}

.view-tab__marker {
  color: var(--warning-fg);
}

.view-tabs__filler {
  flex: 1 0 9rem;
  margin-left: -1px;
  background: var(--section-accent);
}

.view-counters {
  position: absolute;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.view-counters--start {
  top: 0;
  left: 0;
}

.view-counters--end {
  right: 5.4rem;
  bottom: 0.25rem;
  display: flex;
  gap: 0.4rem;
}

.view-counter {
  display: flex;
  gap: 0.3em;
  padding: 0 0.25em;
  border-radius: var(--radius);
}

.view-counters--end .view-counter:not(.view-counter--over) {
  color: var(--page-fg);
  background: var(--page-bg);
}

.view-counter__label,
.view-counter__value {
  margin: 0;
}

.view-counter__label abbr {
  text-decoration: none;
}

/* WP150, shared since WP152: a view across every section (Filtered, Rated, Known) puts each
   section under a small heading, with Filtered's field on top. */
.view-heading {
  margin: 1rem 0 0.4rem;
  font-family: var(--font-title);
  font-size: 1rem;
  text-transform: var(--display-transform);
  letter-spacing: var(--display-letter-spacing);
  color: var(--summary-fg);
}

.view-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.view-filter__input {
  flex: 1;
  min-width: 0;
  font: inherit;
}

/* WP150: the narrow block -- every counter as one row of equal cells over a dropdown of the tabs.
   Hidden until a page's container query shows it. */
.view-tabs__narrow {
  display: none;
}

.view-counters--row {
  position: static;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.view-counters--row .view-counter {
  justify-content: center;
  padding: 0.2rem;
  border: var(--panel-rule-width) solid var(--rule);
}

.view-tabs__select {
  display: block;
  width: 100%;
  font: inherit;
}

/* --- Skills page (WP148, Phase Z) --------------------------------------------------------------
   spec/plan/phase-z-page-redesigns.md, "Redesign 4", sketch examples/ui/skills.png: the widest
   centred column so far (a category tab's table has eight columns), a strip of angled tabs over
   one panel at a time, messages under the panel. Each table scrolls sideways on its own when the
   pane is too narrow; so does the strip (until WP150's portrait dropdown), never the page. */
.page--skills {
  max-width: 54rem;
  margin-inline: auto;
  /* WP150: the strip swaps for a dropdown by the column's own width (below), not the window's:
     the sidebar nav takes a varying share of a wide window. */
  container-type: inline-size;
}

/* The panels. Nothing here may set `display` on .skills-panel or a row: inactive panels are
   `hidden`. */
.skills-table {
  overflow-x: auto;
}

.skills-table input[type="number"] {
  width: 3.5em;
}

.skills-table input[type="text"] {
  width: 9em;
  max-width: 100%;
}

.skills-spec {
  white-space: nowrap;
}

.skills-panel__help {
  color: var(--panel-muted-fg);
}

.skills-add {
  display: block;
  width: 100%;
  min-height: 2.25rem;
  margin-bottom: 0.75rem;
  font: inherit;
}

/* The specialization toggle: a switch whose "on" means Karma pays. The real checkbox lies over
   the drawn track, invisible, so it keeps its keyboard and form behaviour. */
.spec-toggle {
  position: relative;
  display: inline-flex;
  margin-right: 0.3rem;
  vertical-align: middle;
  cursor: pointer;
}

.spec-toggle__input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}

.spec-toggle__track {
  position: relative;
  width: 2.1rem;
  height: 1.15rem;
  border: 1px solid var(--frame-color);
  border-radius: 0.6rem;
  background: var(--section-bg-b);
}

.spec-toggle__track::after {
  content: "";
  position: absolute;
  top: 0.1rem;
  left: 0.1rem;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--panel-muted-fg);
  transition: transform 0.15s;
}

.spec-toggle__input:checked + .spec-toggle__track {
  background: var(--section-accent);
}

.spec-toggle__input:checked + .spec-toggle__track::after {
  background: var(--page-bg);
  transform: translateX(0.95rem);
}

.spec-toggle__input:focus-visible + .spec-toggle__track {
  outline: 2px solid var(--section-accent);
  outline-offset: 2px;
}

.spec-toggle__input:disabled + .spec-toggle__track {
  opacity: 0.55;
}

.spec-toggle:has(.spec-toggle__input:disabled) {
  cursor: not-allowed;
}

/* --- Skills page: narrow widths (WP150, Phase Z) -----------------------------------------------
   Where the strip (twelve 2.2rem tabs, the 5rem lean and a 9rem filler: about 41rem) no longer
   fits the column, it is hidden and the dropdown shows instead, with the four counters as one row
   of equal cells above it. (The views' headings and filter field are shared since WP152.) */
@container (max-width: 41rem) {
  .page--skills .view-tabs__strip {
    display: none;
  }

  .page--skills .view-tabs__narrow {
    display: block;
  }
}

/* --- Spells page (WP151, Phase Z) --------------------------------------------------------------
   spec/plan/phase-z-page-redesigns.md, "Redesign 5": the Magic page's Spells sub-tab in the Skills
   page's style -- the shared view-tab strip (above) over one spell category at a time, messages
   under it. Six columns fit the Attributes/Qualities column; below it the column fills the pane
   and the table scrolls sideways on its own, never the page. WP152: where the strip (eight 2.2rem
   tabs, the 5rem lean and a 9rem filler: about 32rem) no longer fits the column, the dropdown and
   the counter row replace it, as on Skills. */
.spells-page {
  max-width: 40rem;
  margin-inline: auto;
  container-type: inline-size;
}

.spells-table {
  overflow-x: auto;
}

@container (max-width: 32rem) {
  .spells-page .view-tabs__strip {
    display: none;
  }

  .spells-page .view-tabs__narrow {
    display: block;
  }
}
