/* The staff console (/console/), laid out like the party platform's: a staff
   phone held upright. One DOM for phone, tablet and desktop: a single column,
   centred with a max width on wider screens. Colours come from the brand
   tokens in /styles/roll6.css; the glow marks the current focus and the one
   primary action. */

.cs-body {
  --cs-gap: 14px;
  --cs-target: 44px;
  --cs-dim: #C9CADA;
  --cs-placeholder: #6B6E85;
  --cs-danger-line: #5A2A33;
  margin: 0;
  overflow-x: hidden;
  background: var(--r6-night);
  color: var(--r6-pip);
  font: 400 16px/1.5 var(--r6-font-sans);
  -webkit-tap-highlight-color: transparent;
}

.cs-shell,
.cs-sheet,
.cs-shell *,
.cs-sheet * {
  box-sizing: border-box;
}

.cs-shell *,
.cs-sheet * {
  min-width: 0;
}

.cs-shell select,
.cs-shell textarea,
.cs-sheet textarea {
  width: 100%;
  min-height: var(--cs-target);
  padding: 0 12px;
  border: 1px solid var(--r6-line);
  border-radius: 12px;
  background: var(--r6-night);
  color: var(--r6-pip);
  font: inherit;
  font-size: 16px;
}

.cs-sheet textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

.cs-sheet textarea::placeholder {
  color: var(--cs-placeholder);
}

.cs-shell input[type="checkbox"],
.cs-sheet input[type="checkbox"] {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--r6-glow);
}

.cs-shell :focus-visible,
.cs-sheet :focus-visible {
  outline: 2px solid var(--r6-glow);
  outline-offset: 2px;
}

/* An author display rule (grid, flex) would otherwise beat [hidden]. */
.cs-shell [hidden],
.cs-sheet [hidden] {
  display: none !important;
}

/* Shell: one column, header / sticky bar / panels / sticky bottom bar. */

.cs-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--r6-night);
}

.cs-head {
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

.cs-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

.cs-mark {
  display: block;
  flex: none;
  width: 26px;
  height: 26px;
}

.cs-title {
  flex: none;
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
}

.cs-product {
  margin-left: auto;
  color: var(--r6-mist);
  font: 500 12px/1 var(--r6-font-display);
  letter-spacing: .3em;
}

/* The status line and the tabs stay on screen while a long list scrolls. */
.cs-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--r6-night);
}

.cs-statusline {
  display: flex;
  align-items: center;
  min-height: 20px;
  margin: 0;
  color: var(--r6-mist);
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.cs-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--r6-glow);
}

.cs-statusline[data-tone="error"] {
  color: var(--r6-danger-text);
  font-weight: 700;
}

.cs-statusline[data-tone="error"] .cs-dot {
  background: var(--r6-danger);
}

/* Segmented control. */
.cs-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--r6-face);
}

.cs-tab {
  min-height: var(--cs-target);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--r6-mist);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.cs-tab .r6-num {
  font-size: 12px;
}

.cs-tab[aria-selected="true"] {
  background: var(--r6-line);
  color: var(--r6-pip);
}

.cs-panels {
  flex: 1 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) 20px max(16px, env(safe-area-inset-left));
}

.cs-panel {
  display: grid;
  gap: var(--cs-gap);
  align-content: start;
}

/* Bottom bar: result line, companions, the big button, what it will do. */
.cs-dock {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 14px max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid var(--r6-line);
  background: var(--r6-face);
}

.cs-dock-status {
  max-height: 4.4em;
  overflow-y: auto;
  text-align: center;
}

.cs-secondary {
  display: flex;
  gap: 10px;
}

.cs-secondary:empty {
  display: none;
}

.cs-secondary-button {
  flex: 1 1 0;
  min-height: 48px;
  border-radius: 14px;
  font-size: 16px;
}

.cs-primary {
  width: 100%;
  min-height: 64px;
  padding: 8px 16px;
  border: 0;
  border-radius: 18px;
  background: var(--r6-glow);
  color: var(--r6-night);
  font: inherit;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.cs-primary:hover:not(:disabled) {
  background: var(--r6-glow-hover);
}

/* Nothing to press: the button is not lit. */
.cs-primary:disabled {
  background: var(--r6-face-2);
  color: var(--r6-mist);
  cursor: not-allowed;
}

/* A new step arrived under the finger: still lit, briefly not clickable. */
.cs-primary:disabled[data-settling] {
  background: var(--r6-glow);
  color: var(--r6-night);
  opacity: .55;
}

.cs-primary-hint {
  margin: 0;
  color: var(--r6-mist);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}

.cs-primary-hint:empty {
  display: none;
}

/* Cards (進階) */

.cs-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--r6-line);
  border-radius: 20px;
  background: var(--r6-face);
}

.cs-card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
}

.cs-hint,
.cs-note {
  margin: 4px 0 0;
  color: var(--r6-mist);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.cs-note:empty {
  display: none;
}

.cs-label {
  display: block;
  color: var(--r6-mist);
  font-size: 14px;
  font-weight: 700;
}

.cs-field {
  display: grid;
  gap: 4px;
  color: var(--r6-mist);
  font-size: 13px;
}

.cs-field > span {
  font-weight: 700;
}

.cs-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--cs-target);
  font-weight: 700;
}

.cs-count {
  color: var(--r6-mist);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.cs-count[data-tone="error"] {
  color: var(--r6-danger-text);
}

.cs-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cs-row--wrap {
  flex-wrap: wrap;
}

.cs-row--between {
  justify-content: space-between;
}

.cs-row--end {
  justify-content: flex-end;
}

/* Buttons: 44px targets everywhere, including the "small" ones. */

.cs-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: var(--cs-target);
  min-height: var(--cs-target);
  padding: 0 14px;
  border: 1px solid var(--r6-line);
  border-radius: 12px;
  background: var(--r6-face);
  color: var(--r6-pip);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.cs-button:hover:not(:disabled) {
  border-color: var(--r6-line-strong);
}

.cs-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.cs-button[aria-pressed="true"] {
  border-color: var(--r6-glow);
  background: var(--r6-glow-soft);
  color: var(--r6-glow-text);
}

/* The bottom bar's button is the one lit thing: a sheet's own main action is
   outlined in the glow, not filled. */
.cs-button--primary {
  border-color: var(--r6-glow);
  background: var(--r6-glow-soft);
  color: var(--r6-glow-text);
}

.cs-button--danger {
  border-color: var(--cs-danger-line);
  background: transparent;
  color: var(--r6-danger-text);
}

.cs-button--danger:hover:not(:disabled) {
  border-color: var(--r6-danger);
}

.cs-button--small {
  padding: 0 10px;
  font-size: 14px;
}

/* Result lines */

.cs-result {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.cs-result:empty {
  display: none;
}

.cs-result[data-tone="error"] {
  color: var(--r6-danger-text);
}

.cs-result[data-tone="ok"] {
  color: var(--r6-glow-text);
}

.cs-result[data-tone="pending"],
.cs-result[data-tone="info"] {
  color: var(--r6-mist);
}

.cs-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 3px 10px;
  border: 1px solid var(--r6-line);
  border-radius: 999px;
  color: var(--r6-mist);
  font-size: 13px;
  font-weight: 700;
}

.cs-badge.is-warn {
  border-color: color-mix(in srgb, var(--r6-spark) 55%, transparent);
  color: var(--r6-spark);
}

/* 節目 tab */

.cs-now {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--r6-line);
  border-radius: 20px;
  background: var(--r6-face);
}

.cs-now.is-lit {
  border-color: var(--r6-glow);
}

/* Which item of the programme is on, as a die face would say it. */
.cs-now-die {
  flex: none;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--r6-glow);
  color: var(--r6-night);
  font-size: 24px;
  font-weight: 800;
}

.cs-now-die.is-empty,
.cs-now:not(.is-lit) .cs-now-die {
  border: 2px solid var(--r6-line);
  background: transparent;
  color: var(--r6-mist);
}

.cs-now-text {
  flex: 1 1 auto;
  display: grid;
  gap: 2px;
}

.cs-now-kicker {
  margin: 0;
  color: var(--r6-glow-text);
  font-size: 13px;
  font-weight: 700;
}

.cs-now:not(.is-lit) .cs-now-kicker {
  color: var(--r6-mist);
}

.cs-now-name {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.cs-now-phase,
.cs-now-detail,
.cs-now-origin {
  margin: 0;
  color: var(--r6-mist);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.cs-now-phase:empty,
.cs-now-detail:empty,
.cs-now-origin:empty {
  display: none;
}

.cs-now-detail {
  color: var(--r6-glow-text);
  font-weight: 700;
}

.cs-now-origin {
  font-size: 13px;
}

.cs-block {
  display: grid;
  gap: 8px;
}

.cs-block-title {
  margin: 0;
  color: var(--r6-mist);
  font-size: 13px;
  font-weight: 700;
}

.cs-items {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A row: its number, its name and its button; under them how it is played,
   which level, and the tools that move it. */
.cs-item {
  display: grid;
  gap: 6px;
  padding: 6px 6px 8px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--r6-face);
}

.cs-item.is-current {
  border-color: var(--r6-glow);
}

.cs-item.is-off {
  opacity: .6;
}

.cs-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--cs-target);
}

.cs-item-no {
  flex: none;
  width: 1.6em;
  color: var(--r6-mist);
  font-size: 13px;
  font-weight: 700;
}

.cs-item.is-current .cs-item-no {
  color: var(--r6-glow);
}

.cs-item-name {
  flex: 1 1 auto;
  color: var(--cs-dim);
  font-size: 16px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.cs-item.is-current .cs-item-name {
  color: var(--r6-pip);
}

.cs-item-go {
  flex: none;
  background: transparent;
}

.cs-item-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding-left: calc(1.6em * 13 / 16 + 10px);
}

.cs-seg {
  display: flex;
  gap: 4px;
}

.cs-seg-button {
  flex: 1 1 0;
}

.cs-seg--small {
  flex: none;
}

.cs-seg--small .cs-seg-button {
  flex: none;
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.cs-shell select.cs-level {
  flex: 1 1 9em;
  width: auto;
  max-width: 14em;
  min-height: 36px;
  padding: 0 8px;
  font-size: 14px;
}

.cs-shell select:disabled {
  opacity: .45;
}

.cs-item-tools {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.cs-tool {
  display: grid;
  place-items: center;
  width: 40px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--r6-mist);
  cursor: pointer;
}

.cs-tool:hover:not(:disabled) {
  background: var(--r6-face-2);
  color: var(--r6-pip);
}

.cs-tool:disabled {
  opacity: .3;
  cursor: not-allowed;
}

.cs-tool .cs-icon {
  width: 18px;
  height: 18px;
}

.cs-add {
  border-style: dashed;
  border-color: var(--r6-line-strong);
  background: transparent;
}

.cs-empty-row {
  color: var(--r6-mist);
  font-size: 14px;
  list-style: none;
}

.cs-quick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.cs-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 68px;
  padding: 6px 4px;
  border: 1px solid var(--r6-line);
  border-radius: 16px;
  background: var(--r6-face);
  color: var(--r6-pip);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.cs-tile:hover:not(:disabled) {
  border-color: var(--r6-line-strong);
}

.cs-tile:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.cs-tile[aria-pressed="true"] {
  border-color: var(--r6-glow);
  background: var(--r6-glow-soft);
  color: var(--r6-glow-text);
}

.cs-tile-label {
  text-align: center;
  overflow-wrap: anywhere;
}

.cs-icon {
  display: block;
  flex: none;
  width: 22px;
  height: 22px;
}

.cs-volume {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--cs-target);
}

.cs-volume-label {
  flex: none;
  color: var(--r6-mist);
  font-size: 13px;
  font-weight: 700;
}

.cs-volume-range {
  flex: 1 1 auto;
  height: 44px;
  accent-color: var(--r6-glow);
}

.cs-volume-value {
  flex: none;
  width: 2.6em;
  font-size: 13px;
  text-align: right;
}

/* 玩家 tab */

.cs-team {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--r6-glow-soft);
  color: var(--r6-glow-text);
  font-weight: 700;
}

.cs-team:empty {
  display: none;
}

.cs-rows {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cs-player {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 4px 14px;
  border-radius: 14px;
  background: var(--r6-face);
}

.cs-swatch {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.cs-player-name {
  flex: 1 1 auto;
  font-weight: 700;
}

.cs-player-score {
  flex: none;
  color: var(--r6-mist);
  font-size: 14px;
}

.cs-player-score b {
  color: var(--r6-pip);
  font-size: 18px;
}

/* 進階 tab */

.cs-credit {
  font-weight: 700;
}

.cs-details summary {
  min-height: var(--cs-target);
  font-weight: 700;
  line-height: var(--cs-target);
  cursor: pointer;
}

.cs-games {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.cs-game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0 12px;
}

.cs-game-check {
  font-weight: 500;
}

/* Sheet: a bottom sheet on phones, a centred dialog on wider screens. */

.cs-sheet {
  width: 100%;
  max-width: 640px;
  max-height: calc(100dvh - 24px);
  margin: auto auto 0;
  padding: 20px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border: 1px solid var(--r6-line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--r6-face);
  color: var(--r6-pip);
  font-family: var(--r6-font-sans);
  overflow-y: auto;
}

.cs-sheet::backdrop {
  background: rgba(8, 9, 14, .7);
}

.cs-sheet form {
  display: grid;
  gap: 14px;
}

.cs-sheet h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.cs-sheet-body {
  display: grid;
  gap: 10px;
}

.cs-sheet-body p {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* The buttons stay in reach under a long list (加入遊戲). */
.cs-sheet-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  background: var(--r6-face);
}

.cs-sheet-actions .cs-button {
  flex: 1 1 auto;
  min-height: 48px;
  border-radius: 14px;
}

.cs-announce-current {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--r6-night);
  color: var(--r6-pip);
}

.cs-announce-current span:first-child {
  color: var(--r6-mist);
  font-size: 13px;
}

.cs-pick-group {
  margin: 6px 0 0;
  color: var(--r6-mist);
  font-size: 13px;
  font-weight: 700;
}

.cs-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.cs-pick {
  display: grid;
  gap: 2px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--r6-line);
  border-radius: 12px;
  background: var(--r6-night);
  color: var(--r6-pip);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cs-pick:hover {
  border-color: var(--r6-line-strong);
}

.cs-pick-name {
  font-weight: 700;
}

.cs-pick-no {
  color: var(--r6-mist);
  font-size: 12px;
}

.cs-pick-count {
  color: var(--r6-glow-text);
  font-size: 13px;
}

.cs-pick small {
  color: var(--r6-mist);
  font-size: 12px;
}

/* Tablet / desktop: the same column, and the sheet as a centred dialog. */
@media (min-width: 700px) {
  .cs-shell {
    border-right: 1px solid var(--r6-face);
    border-left: 1px solid var(--r6-face);
  }

  .cs-sheet {
    width: min(100% - 48px, 34rem);
    margin: auto;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--r6-line);
    border-radius: 22px;
  }
}

/* Short landscape phones: nothing but the bottom bar sticks, and the bar is
   compact, so the panels keep room to scroll. */
@media (max-height: 560px) {
  .cs-bar {
    position: relative;
    top: auto;
  }

  .cs-dock {
    gap: 6px;
    padding-top: 8px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .cs-primary {
    min-height: 52px;
    font-size: 19px;
  }

  .cs-secondary-button {
    min-height: var(--cs-target);
  }
}
