/* ------------------------------------------------------------------------------------------------------------
   App shell: one frame for every screen outside the board (campaign HQ, chat, office holders, rankings, my
   characters, the character maker and the admin pages). The same top bar, the same menu on the side (a strip of
   tabs on phones) and the page in the middle. Loaded after theme.css.
   ------------------------------------------------------------------------------------------------------------ */
html[data-theme] .mandat-app.mandat-shell {
  display: flex; flex-direction: column; min-height: 100dvh; height: auto; max-width: none; margin: 0; padding-top: 0; overflow: visible;
}
.mandat-shell > .mandat-top { flex: none; padding-inline: clamp(12px, 2vw, 28px); }
.shell-body {
  flex: 1; min-height: 0; display: grid; align-items: start;
  grid-template-columns: clamp(176px, 14vw, 224px) minmax(0, 1fr);
  gap: clamp(14px, 1.6vw, 24px); padding: clamp(14px, 1.8vh, 22px) clamp(14px, 2vw, 28px);
}
.shell-rail { position: sticky; top: 14px; align-content: start; }
.shell-main { min-width: 0; outline: none; }
.shell-nav button { position: relative; }
.shell-nav button > span:first-of-type { flex: 1; }
.shell-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center;
  background: #e5383b; color: #fff; font-size: 11px; font-weight: 900; line-height: 1; box-shadow: 0 2px 0 #9b1d20;
}

/* A page heading: small label, title and one line of help, with an optional button on the end. */
.shell-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.shell-heading p { color: var(--app-accent); font-size: 12px; font-weight: 850; margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.shell-heading p svg { width: 15px; height: 15px; }
.shell-heading h1 { font-size: clamp(23px, 3vw, 34px); letter-spacing: -.04em; line-height: 1.12; color: var(--app-ink); overflow-wrap: anywhere; }
.shell-heading span { display: block; color: var(--app-text); font-size: 13px; font-weight: 600; margin-top: 4px; max-width: 70ch; }
.shell-heading > .mandat-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding-inline: 14px; }
.shell-heading > .mandat-btn svg { width: 16px; height: 16px; }

/* ---- Campaign HQ ----------------------------------------------------------------------------------------- */
.shell-hq .mandat-hq { display: flex; flex-direction: column; gap: 14px; }
.shell-hq .mandat-greeting { margin-bottom: 0; }
.shell-hq .mandat-hero { min-height: 340px; }
.hq-quicks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.hq-quick {
  display: flex; align-items: center; gap: 10px; min-height: 74px; padding: 12px 14px; text-align: start; position: relative;
  background: var(--app-card); color: var(--app-ink); border: 2px solid var(--app-line); border-radius: 18px; box-shadow: 0 4px 0 var(--g-edge);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.hq-quick:hover { transform: translateY(-2px); border-color: var(--app-accent); }
.hq-quick:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--g-edge); }
.hq-quick > span:nth-child(2) { flex: 1; min-width: 0; }
.hq-quick b { display: block; font-size: 14px; font-weight: 900; }
.hq-quick small { display: block; color: var(--app-text); font-size: 11.5px; font-weight: 600; margin-top: 2px; line-height: 1.35; }
.hq-quick > svg:last-child { width: 16px; height: 16px; color: var(--app-text); flex: none; }
.hq-quick-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; color: #fff;
  background: linear-gradient(180deg, var(--g-purple), var(--g-purple-deep)); box-shadow: 0 3px 0 var(--g-purple-edge); }
.hq-quick-icon svg { width: 22px; height: 22px; }
.hq-quick:first-child .hq-quick-icon { background: linear-gradient(180deg, #5bd27b, var(--g-green-deep)); box-shadow: 0 3px 0 var(--g-green-edge); }
.hq-quick:nth-child(4) .hq-quick-icon { background: linear-gradient(180deg, var(--g-gold), var(--g-gold-deep)); box-shadow: 0 3px 0 var(--g-gold-edge); color: #3d2a00; }
.hq-quick .shell-badge { position: absolute; top: 8px; inset-inline-end: 10px; }

/* ---- Chat page ---------------------------------------------------------------------------------------------- */
.shell-chat { display: grid; grid-template-columns: minmax(0, 1fr) clamp(250px, 24vw, 330px); gap: 16px; align-items: start; }
.shell-chat .social-home { min-height: 520px; display: flex; flex-direction: column; }
.shell-chat .chat-widget { flex: 1; }
.shell-chat .chat-feed { height: auto; flex: 1; min-height: 300px; }
.shell-chat .chat-expand { display: none; }
.shell-chat .chat-heading { display: none; }

/* ---- My characters and the character maker: the old full screens, now a framed panel ------------------------ */
.mandat-shell .slots-layout, .mandat-shell .creator-layout {
  border: 2px solid var(--app-line); border-radius: 22px; overflow: hidden; box-shadow: var(--app-shadow); background: var(--app-card);
}
.mandat-shell .slots-panel .account-lock-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 6px; }
.mandat-shell .slots-panel .lock-pill { display: inline-flex; font-size: 12px; }
.mandat-shell .slots-panel .lock-pill .icon { width: 15px; height: 15px; }

/* ---- Admin and staff -------------------------------------------------------------------------------------- */
.mandat-shell .mandat-operations-body { max-width: none; margin: 0; padding: 0; }
.mandat-shell .admin-main { max-width: none; margin: 0; padding: 0; }
.mandat-shell .admin-title h1 { color: var(--app-ink); margin-top: 0; }

/* ---- Office holders and rankings ---------------------------------------------------------------------------- */
.dir-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 12px; width: max-content; max-width: 100%;
  background: var(--app-soft); border: 2px solid var(--app-line); border-radius: 14px; }
.dir-tabs button { min-height: 40px; padding: 6px 16px; border: 0; border-radius: 10px; background: transparent; color: var(--app-text); font: inherit; font-weight: 850; cursor: pointer; }
.dir-tabs button[aria-selected="true"] { background: linear-gradient(180deg, var(--g-purple), var(--g-purple-deep)); color: #fff; box-shadow: 0 2px 0 var(--g-purple-edge); }
.dir-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.dir-field { display: grid; gap: 4px; font-size: 12px; min-width: 170px; }
.dir-field > span { color: var(--app-text); font-weight: 800; }
.dir-search { flex: 1; min-width: 220px; grid-template-columns: auto 1fr; align-items: center; }
.dir-search > span { font-size: 16px; }
html[data-theme] .mandat-shell .dir-field :is(select, input) { min-height: 42px; padding: 8px 12px; }
.dir-body.is-loading { opacity: .55; pointer-events: none; transition: opacity .2s; }
.dir-status { padding: 22px; text-align: center; color: var(--app-text); font-weight: 800; }
.dir-note { margin-top: 10px; color: var(--app-text); font-size: 12px; font-weight: 650; line-height: 1.6; }
.dir-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dir-wide { grid-column: 1 / -1; }
.dir-card { background: var(--app-card); border: 2px solid var(--app-line); border-radius: 20px; box-shadow: var(--app-shadow); padding: 14px 16px; min-width: 0; color: var(--app-ink); }
.dir-card h2 { font-size: 16px; font-weight: 900; margin-bottom: 8px; }
.dir-card h3 { font-size: 14px; font-weight: 900; margin-bottom: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.dir-card h3 small, .dir-state summary small { color: var(--app-text); font-size: 11px; font-weight: 800; }
.dir-card h3 .mandat-btn { min-height: 32px; padding: 3px 10px; font-size: 11px; margin-inline-start: auto; }
.dir-card h3 .mandat-btn[aria-pressed="true"] { background: var(--app-lilac); color: var(--app-lilac-ink); }
.dir-list { list-style: none; margin: 0; padding: 0; display: grid; }
.dir-cols { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); column-gap: 18px; }
.dir-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px; border-top: 2px dashed var(--app-line); min-width: 0; }
.dir-list > .dir-row:first-child { border-top: 0; }
.dir-cols > .dir-row { border-top: 0; border-bottom: 2px dashed var(--app-line); }
.dir-post { min-width: 0; font-size: 13px; font-weight: 750; color: var(--app-ink); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dir-post small { display: block; width: 100%; color: var(--app-text); font-size: 11px; font-weight: 600; }
.dir-holder { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 4px 6px; text-align: end; min-width: 0; font-size: 13px; }
.dir-holder b { font-weight: 900; color: var(--g-purple-deep); overflow-wrap: anywhere; }
html[data-theme=dark] .dir-holder b { color: var(--app-accent); }
.dir-holder em { font-style: normal; font-size: 10px; font-weight: 900; padding: 1px 6px; border-radius: 99px; background: var(--app-soft); color: var(--app-text); border: 1px solid var(--app-line); }
.dir-holder.is-vacant { color: var(--app-text); font-style: italic; font-weight: 700; }
.dir-party { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 2px; border-radius: 99px; font-size: 10.5px; font-weight: 900;
  background: var(--app-soft); border: 1px solid var(--app-line); color: var(--app-ink); white-space: nowrap; }
.dir-party img { width: 18px; height: 18px; border-radius: 50%; object-fit: contain; background: #fff; }
.dir-party i { font-style: normal; padding: 0 5px; border-radius: 99px; background: var(--bloc, #888); color: #fff; font-size: 9px; }
.dir-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--app-soft); border: 2px solid var(--app-line); margin-bottom: 8px; }
.dir-bar i { width: var(--w); background: var(--c); }
.dir-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); display: inline-block; }
.dir-blocs .dir-row b { font-size: 15px; }
.dir-pm .dir-row { padding-block: 12px; }
.dir-pm .dir-holder { font-size: 16px; }
.dir-state { margin-bottom: 10px; background: var(--app-card); border: 2px solid var(--app-line); border-radius: 18px; box-shadow: 0 3px 0 var(--g-edge); }
.dir-state > summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; font-size: 15px; font-weight: 900; list-style: none; }
.dir-state > summary::-webkit-details-marker { display: none; }
.dir-state > summary::after { content: '▾'; color: var(--app-text); transition: transform .15s; }
.dir-state[open] > summary::after { transform: rotate(180deg); }
.dir-state[open] > summary { border-bottom: 2px dashed var(--app-line); }
.dir-seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; padding: 12px; }
.dir-seat { box-shadow: 0 3px 0 var(--g-edge); padding: 10px 12px; }
.dir-party-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 10px 14px; background: var(--app-card); border: 2px solid var(--app-line); border-radius: 18px; }
.dir-party-head img { width: 46px; height: 46px; object-fit: contain; border-radius: 12px; background: #fff; }
.dir-party-head b { display: block; font-size: 18px; font-weight: 900; }
.dir-party-head span { color: var(--app-text); font-size: 12px; font-weight: 650; }
.dir-body > .dir-card + .dir-card { margin-top: 12px; }

.lead-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; align-items: start; }
.lead-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.lead-card > header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--app-soft); border-bottom: 2px solid var(--app-line); }
.lead-card > header h2 { margin: 0; font-size: 16px; }
.lead-card > header p { color: var(--app-text); font-size: 11.5px; font-weight: 650; }
.lead-emoji { width: 40px; height: 40px; flex: none; display: grid; place-items: center; font-size: 22px; border-radius: 13px; background: var(--app-card); border: 2px solid var(--app-line); }
.lead-list { list-style: none; margin: 0; padding: 4px 10px; flex: 1; }
.lead-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 7px 2px; border-top: 2px dashed var(--app-line); }
.lead-row:first-child { border-top: 0; }
.lead-rank { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-weight: 900; font-size: 12px; background: var(--app-soft); color: var(--app-text); border: 2px solid var(--app-line); }
.lead-row.top-1 .lead-rank { background: linear-gradient(180deg, #ffe27a, #f2a900); color: #3d2a00; border-color: #b47600; }
.lead-row.top-2 .lead-rank { background: linear-gradient(180deg, #f2f4f7, #c3c9d2); color: #3b4350; border-color: #9aa3b1; }
.lead-row.top-3 .lead-rank { background: linear-gradient(180deg, #ffd0a6, #d98b4a); color: #4a2600; border-color: #a5622a; }
.lead-who { min-width: 0; }
.lead-who b { display: block; font-size: 13px; font-weight: 900; overflow-wrap: anywhere; }
.lead-who b em { font-style: normal; font-size: 10px; padding: 1px 6px; border-radius: 99px; background: linear-gradient(180deg, var(--g-purple), var(--g-purple-deep)); color: #fff; }
.lead-who b em.ai { background: var(--app-soft); color: var(--app-text); border: 1px solid var(--app-line); }
.lead-who small { display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 3px; color: var(--app-text); font-size: 10.5px; font-weight: 650; }
.lead-value { font-weight: 900; font-size: 13px; white-space: nowrap; color: var(--g-green-deep); }
.lead-risk .lead-value, .lead-debt .lead-value { color: #c4320a; }
html[data-theme=dark] .lead-value { color: #8ee6a8; }
html[data-theme=dark] :is(.lead-risk, .lead-debt) .lead-value { color: #ff9c7a; }
.lead-row.is-me { background: var(--app-lilac); border-radius: 12px; border-top-color: transparent; }
.lead-mine { padding: 9px 14px; border-top: 2px solid var(--app-line); background: var(--app-soft); font-size: 12px; font-weight: 750; color: var(--app-text); }
.lead-mine b { color: var(--app-ink); }

/* ---- Laptops and desktops: one screen, the page scrolls inside the frame --------------------------------- */
@media (min-width: 951px) and (min-height: 560px) {
  html[data-theme] .mandat-app.mandat-shell { height: 100vh; height: 100dvh; overflow: hidden; }
  .shell-body { align-items: stretch; }
  .shell-rail { position: static; overflow-y: auto; min-height: 0; }
  .shell-main { overflow-y: auto; min-height: 0; overscroll-behavior: contain; padding-bottom: 6px; padding-inline-end: 2px; }
  .shell-hq .shell-main, .shell-hq .mandat-hq { min-height: 0; }
  .shell-hq .mandat-hq { height: 100%; }
  .shell-hq .mandat-hero { flex: 1 0 auto; }
  /* Pages that fill the frame: my characters, the maker and chat. */
  :is(.slots-shell, .creator-shell, .shell-chat-page) .shell-main { overflow: hidden; display: flex; flex-direction: column; }
  :is(.slots-shell, .creator-shell) .shell-main > :is(.slots-layout, .creator-layout) { flex: 1; min-height: 0; }
  .shell-chat-page .shell-chat { flex: 1; min-height: 0; align-items: stretch; }
  .shell-chat-page .shell-chat > * { min-height: 0; }
  .shell-chat-page .social-home { min-height: 0; }
  .shell-chat-page .mandat-voice { align-self: start; }
}
@media (min-width: 951px) and (max-width: 1180px) {
  .mandat-shell .slots-layout { grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr); }
  .mandat-shell .wizard-shell .wizard-layout, .mandat-shell.wizard-shell .wizard-layout { grid-template-columns: minmax(0, 1fr) minmax(380px, 1.1fr); }
  .hq-quicks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Tablets and phones: the menu becomes a strip of tabs that stays at the top ---------------------------- */
@media (max-width: 950px) {
  .shell-body { grid-template-columns: minmax(0, 1fr); align-content: start; padding: 0 12px 28px; gap: 12px; }
  .shell-rail { position: sticky; top: 0; z-index: 30; margin-inline: -12px; padding: 8px 12px; display: block;
    background: var(--app-bg); border-bottom: 2px solid var(--app-line); box-shadow: 0 3px 0 rgba(160, 110, 40, .08); }
  .shell-rail .mandat-player, .shell-rail .mandat-signout { display: none; }
  .shell-nav { display: flex !important; flex-wrap: nowrap !important; gap: 6px !important; overflow-x: auto; scrollbar-width: none; padding-block: 2px; }
  .shell-nav::-webkit-scrollbar { display: none; }
  .shell-rail .shell-nav button { flex: none; width: auto; min-height: 40px; padding: 6px 12px; gap: 6px; white-space: nowrap;
    background: var(--app-card); border: 2px solid var(--app-line); box-shadow: 0 2px 0 var(--g-edge); font-size: 12.5px; }
  .shell-nav button > span:first-of-type { flex: none; }
  .shell-nav button svg { width: 17px; height: 17px; }
  .shell-hq .mandat-hero { min-height: 300px; }
  .hq-quicks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell-chat { grid-template-columns: minmax(0, 1fr); }
  .shell-chat .social-home { min-height: 0; }
  .shell-chat .chat-feed { height: min(58dvh, 520px); flex: none; }
  .dir-grid { grid-template-columns: minmax(0, 1fr); }
  /* My characters and the maker keep their app layout: the 3D stage on top, the choices below. */
  html[data-theme] .mandat-shell.game-shell { height: auto; overflow: visible; }
  .mandat-shell .slots-layout { display: flex; flex-direction: column; }
  .mandat-shell .slots-preview { flex: 0 0 clamp(280px, 42dvh, 400px); border-width: 0 0 3px; }
  .mandat-shell .creator-layout { display: flex; flex-direction: column; height: calc(100dvh - 150px); min-height: 540px; }
}
@media (max-width: 700px) {
  .shell-heading { flex-wrap: wrap; align-items: start; margin-bottom: 10px; }
  .shell-heading span { font-size: 12px; }
  .dir-tabs { width: 100%; }
  .dir-tabs button { flex: 1; padding-inline: 8px; }
  .dir-field { min-width: 0; flex: 1 1 140px; }
  .dir-search { flex-basis: 100%; }
  .dir-row { flex-wrap: wrap; }
  .dir-holder { justify-content: start; text-align: start; }
  .dir-card { padding: 12px; border-radius: 16px; }
  .dir-seats { padding: 8px; }
  .hq-quick { min-height: 64px; padding: 10px; gap: 8px; }
  .hq-quick-icon { width: 36px; height: 36px; border-radius: 12px; }
  .hq-quick small { display: none; }
  .mandat-shell .slots-layout, .mandat-shell .creator-layout { border-radius: 16px; }
  .mandat-shell .creator-layout { height: calc(100dvh - 128px); min-height: 500px; }
}
.mandat-shell .editor-empty h2, .mandat-shell .editor-heading h2 { color: var(--app-ink); }
.mandat-shell .editor-empty p { color: var(--app-text); }
.mandat-shell .editor-empty > .icon { color: var(--g-purple); }
