/*
 * Spin the Wheel's page - only what's its own. The look (colours, fonts, buttons, fields,
 * switches, cards, dialogs, the page frame ...) comes from ui/ui.css (resorted-ui). The
 * overlay (overlay.html) has its own styles inside it.
 */

/* ---- Signed out: wheels spinning as examples, 2 + 2 (one column on phones) ---- */
.rui-hero .banner { width: min(100%, 560px); margin: 0 0 18px; text-align: left; }
.sw-demos h2 { margin: 0 0 4px; font: 600 20px var(--font-display); }
.sw-demos > .note { margin: 0 0 18px; }
.sw-demos-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.sw-demo { display: grid; gap: 8px; margin: 0; }
.sw-demo-scene {
  overflow: hidden; aspect-ratio: 1; border: 1px solid var(--line2); border-radius: 14px;
  background:
    radial-gradient(60% 80% at 85% 20%, rgba(255, 170, 90, 0.3), transparent 70%),
    radial-gradient(70% 90% at 10% 100%, rgba(80, 160, 255, 0.32), transparent 70%),
    linear-gradient(160deg, #263a4a, #1a2a24 55%, #2e2a3c);
}
.sw-demo-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; pointer-events: none; color-scheme: normal; }
.sw-demo figcaption { color: var(--muted); font-size: 14px; text-align: center; }

/* ---- Sidebar ---- */
#channels-block { margin-bottom: 22px; }
.sw-channel img { flex: none; width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.sw-channel span, .sw-wheel-link-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sw-wheel-nav { margin-bottom: 18px; }
.sw-mini { flex: none; width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.14); }
#nav-chat-dot { margin-left: auto; }
.rui-nav + .rui-side-label { margin-top: 18px; }
/* The label over the page menu only separates it from the streamers above (more than one); alone, under
   the service's name at the top of the sidebar, it would just repeat it. */
#channels-block[hidden] + .rui-side-label { display: none; }

/* ---- Shared bits ---- */
.sw-ic { display: inline-flex; }
.btn .sw-ic { margin-right: 2px; }
.sw-card-title { margin: 0 0 12px; font: 600 18px var(--font-display); }
.sw-card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.save-state { margin: 0; color: var(--faint); font-size: 13px; white-space: nowrap; }
.sw-head-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.sw-code { padding: 2px 8px; border-radius: 6px; background: var(--field); color: #bfe9ff; font-family: var(--font-mono); font-size: 13.5px; }
.sw-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.sw-avatar.small { width: 28px; height: 28px; }
details.help { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
details.help summary { color: var(--link); cursor: pointer; }
details.help p { margin: 8px 0; }
.card-foot { display: flex; margin-top: 18px; }
.card-foot .spacer { flex: 1; }

/* ---- Wheels: cards with a picture of each wheel ---- */
.sw-wheel-grid, .sw-preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.sw-wheel-card, .sw-preset { display: flex; flex-direction: column; gap: 10px; }
.sw-wheel-thumb { display: grid; place-items: center; padding: 8px 0 2px; border-radius: 12px; }
.sw-thumb { width: var(--size, 180px); max-width: 100%; aspect-ratio: 1; margin: 0 auto; }
.sw-thumb svg { display: block; width: 100%; height: 100%; }
.sw-wheel-thumb .sw-thumb { transition: transform 0.6s cubic-bezier(.2, .8, .3, 1); }
.sw-wheel-thumb:hover .sw-thumb { transform: rotate(40deg); }
.sw-wheel-info h2, .sw-preset h2 { margin: 0; font: 600 18px var(--font-display); }
.sw-wheel-info .note, .sw-preset .note { margin: 4px 0 0; }
.sw-wheel-obs { display: flex; align-items: center; gap: 8px; }
.sw-wheel-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: auto; }
.sw-wheel-actions .btn { justify-content: center; padding: 0 10px; }
.sw-new-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 300px;
  border-style: dashed; color: var(--text); text-align: center; text-decoration: none;
}
.sw-new-card:hover { border-color: var(--c1); }
.sw-new-card .sw-ic { color: var(--c1); }
.sw-preset .btn { align-self: center; min-width: 160px; justify-content: center; margin-top: auto; }
.sw-preset-foot { margin: 18px 0 0; }

/* ---- One wheel: tabs, then options on the left and the preview on the right (on top, on phones) ---- */
.sw-tabs { margin: 0 0 16px; }
.sw-tabs .tab { display: inline-flex; align-items: center; text-decoration: none; }
.sw-builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); align-items: start; gap: 18px; }
.sw-builder-side { position: sticky; top: 24px; display: grid; gap: 14px; }
.sw-tab .section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.section h2 { margin: 0 0 12px; font-size: 16px; }
.sw-tab .label { display: grid; gap: 6px; margin: 0; color: var(--muted); font-size: 14px; font-weight: 500; }
.sw-tab .label small, .toggle-note { font-size: 1em; opacity: 0.8; }
.sw-tab .label.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; font-size: 15px; cursor: pointer; }
.toggle > span { display: grid; gap: 2px; }
.toggle-note { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 24px; align-items: end; }
.seg { justify-self: start; align-self: start; max-width: 100%; }
.seg.small .seg-btn { min-height: 30px; padding: 0 10px; font-size: 13px; }
.slider-head { display: flex; justify-content: space-between; }
.slider output { color: var(--text); font-variant-numeric: tabular-nums; }
input[type='range'] { width: 100%; }
.color { width: 46px; height: 36px; padding: 3px; border: 1px solid var(--line2); border-radius: 10px; background: var(--field); cursor: pointer; }
.color:hover { border-color: var(--line3); }
.color:disabled { opacity: 0.4; cursor: default; }
.sw-inline { display: flex; align-items: center; gap: 10px; }
.sw-inline.wrap { flex-wrap: wrap; gap: 10px 24px; }
.sw-hub-pic { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--line2); }
/* Font picker: each font shown in itself, 4 per row (2 on phones) */
.font-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.font-btn {
  display: grid; gap: 2px; padding: 8px 11px; border: 1px solid var(--line2); border-radius: 12px; background: var(--field);
  color: var(--text); text-align: left; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.font-btn:hover { border-color: var(--line3); }
.font-btn[aria-checked='true'] { border-color: var(--c1); box-shadow: 0 0 0 1px var(--c1) inset, 0 0 18px -8px var(--c1); }
.font-name { overflow: hidden; font-family: var(--font); font-weight: 600; font-size: 12.5px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.font-sample { overflow: hidden; font-size: 20px; white-space: nowrap; text-overflow: ellipsis; }

/* ---- Options ---- */
.sw-opts-head { display: flex; align-items: baseline; justify-content: space-between; }
.sw-opts-head h2 { margin-bottom: 4px; }
.sw-opts { display: grid; gap: 8px; margin: 12px 0 14px; }
.sw-opt {
  display: grid; grid-template-columns: 26px 36px 48px minmax(0, 1fr) 118px auto 38px; align-items: center; gap: 8px;
  padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--card2, rgba(255, 255, 255, 0.02));
}
.sw-opt.dragging { position: relative; z-index: 2; border-color: var(--c1); box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--c1); }
.sw-handle { display: grid; place-items: center; width: 26px; height: 40px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--faint); cursor: grab; touch-action: none; }
.sw-handle:hover, .sw-handle:focus-visible { color: var(--text); background: var(--field); }
.sw-opt.dragging .sw-handle { cursor: grabbing; }
.sw-swatch { position: relative; display: block; width: 36px; height: 36px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); cursor: pointer; }
.sw-swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.sw-pic {
  display: grid; place-items: center; width: 48px; height: 48px; padding: 3px; border: 1px dashed var(--line2); border-radius: 10px;
  background: var(--field); color: var(--faint); cursor: pointer;
}
.sw-pic.has { border-style: solid; }
.sw-pic:hover { border-color: var(--c1); color: var(--text); }
.sw-pic img { width: 100%; height: 100%; object-fit: contain; }
.sw-opt .sw-label { height: auto; min-height: 42px; resize: none; overflow: hidden; line-height: 1.3; padding-top: 10px; padding-bottom: 10px; field-sizing: content; }
.sw-chance { display: flex; align-items: center; gap: 6px; }
.sw-weight { width: 64px; padding-left: 8px; padding-right: 4px; text-align: center; }
.sw-pct { min-width: 44px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.sw-more .sw-ic { transition: transform 0.2s; }
.sw-more.open .sw-ic { transform: rotate(180deg); }
.sw-remove { justify-content: center; padding: 0; width: 38px; }
.sw-opt-more { display: grid; grid-column: 1 / -1; gap: 12px; margin: 4px 0 2px; padding: 12px 8px 4px 34px; border-top: 1px solid var(--line); }
.sw-opts-foot { display: flex; flex-wrap: wrap; gap: 8px; }
.sw-palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sw-palette {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line2); border-radius: 12px;
  background: var(--field); color: var(--text); font: 500 14px var(--font); cursor: pointer;
}
.sw-palette:hover { border-color: var(--line3); }
.sw-swatches { display: flex; }
.sw-swatches i { width: 14px; height: 22px; }
.sw-swatches i:first-child { border-radius: 6px 0 0 6px; }
.sw-swatches i:last-child { border-radius: 0 6px 6px 0; }

/* ---- Picture picker ---- */
.sw-pics { width: min(680px, calc(100vw - 32px)); }
.sw-pics h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); }
.sw-drop {
  display: grid; justify-items: center; gap: 4px; padding: 22px 16px; border: 1px dashed var(--line3); border-radius: 14px;
  background: var(--field); text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.sw-drop:hover, .sw-drop.over, .sw-drop:focus-visible { border-color: var(--c1); background: rgba(79, 220, 255, 0.06); outline: none; }
.sw-drop.busy { opacity: 0.6; pointer-events: none; }
.sw-drop .sw-ic { color: var(--c1); }
.sw-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.sw-tiles > .note { grid-column: 1 / -1; margin: 0; }
.sw-tile { position: relative; }
.sw-tile-pick {
  display: block; width: 100%; aspect-ratio: 1; padding: 6px; border: 1px solid var(--line2); border-radius: 12px;
  background: repeating-conic-gradient(#202733 0 25%, #1a2029 0 50%) 0 0 / 14px 14px; cursor: pointer;
}
.sw-tile-pick:hover { border-color: var(--line3); }
.sw-tile.on .sw-tile-pick { border-color: var(--c1); box-shadow: 0 0 0 1px var(--c1); }
.sw-tile-pick img { width: 100%; height: 100%; object-fit: contain; }
.sw-tile-x {
  position: absolute; top: -6px; right: -6px; display: none; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 1px solid var(--line2); border-radius: 50%; background: var(--card); color: var(--bad); cursor: pointer;
}
.sw-tile:hover .sw-tile-x, .sw-tile-x:focus-visible { display: grid; }

/* ---- Preview + last spins ---- */
.preview-box { overflow: hidden; width: 100%; border: 1px solid var(--line2); border-radius: 12px; background: #06090d; }
.preview-box[data-bg='light'] { background: #e9eaef; }
.preview-box[data-bg='check'] { background: repeating-conic-gradient(#232a35 0 25%, #171d26 0 50%) 0 0 / 20px 20px; }
.preview-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; color-scheme: normal; }
.sw-preview-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.sw-preview-actions .btn { justify-content: center; }
.sw-preview-status { min-height: 1.4em; margin: 8px 0 0; }
.preview-under { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.sw-obs-count { margin: 10px 0 0; }
.sw-history { display: grid; gap: 10px; }
.sw-history > .note { margin: 0; }
.sw-hist { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: start; gap: 10px; }
.sw-hist-dot { width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12); }
.sw-hist-text { display: grid; min-width: 0; }
.sw-hist-text b { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.sw-hist-text small { color: var(--faint); }
.sw-hist-why { color: var(--muted) !important; }

/* ---- Chat ---- */
.sw-account { display: flex; align-items: center; gap: 12px; }
.sw-account-name { display: grid; flex: 1; min-width: 0; }
.sw-account-name small { color: var(--muted); }
.sw-account-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; }
.sw-account-line > span { display: flex; align-items: center; gap: 8px; }
.sw-account-line .btn { margin-left: auto; }
.sw-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.sw-tokens .chip { font-family: var(--font-mono); }
.sw-example { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--field); overflow-wrap: anywhere; }
.sw-example b { font-weight: 500; }
.sw-chat-line { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.sw-sub { margin: 6px 0 0; font-size: 15px; }
.sw-cmd-wheels { display: grid; gap: 8px; }
.sw-cmd-wheel { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.sw-cmd-wheel .note { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Connecting the chat account with a code */
.sw-signin { display: grid; gap: 12px; margin: 0 0 16px; padding: 16px; border: 1px solid rgba(79, 220, 255, 0.35); border-radius: 14px; background: rgba(79, 220, 255, 0.05); }
.sw-signin-steps { display: grid; gap: 14px; margin: 0; padding-left: 20px; }
.sw-signin-steps .sw-url { margin-top: 8px; }
.sw-signin-code { width: max-content; margin-top: 8px; padding: 8px 16px; border-radius: 10px; background: var(--field); color: #bfe9ff; font: 700 26px var(--font-mono); letter-spacing: 0.12em; }
.sw-signin-wait { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }

/* ---- OBS ---- */
.sw-url { display: flex; gap: 8px; }
.sw-url .field { flex: 1; min-width: 0; color: #bfe9ff; }
.sw-url .btn { flex: none; }
.sw-drag { cursor: grab; }
.sw-drag:active { cursor: grabbing; }
.sw-howto { display: grid; gap: 8px; margin: 0 0 14px; padding-left: 22px; }
.sw-tips { display: grid; gap: 8px; margin: 0; padding-left: 18px; color: var(--muted); }
.sw-tips b { color: var(--text); font-weight: 600; }

/* ---- Editors ---- */
.sw-add { display: flex; gap: 8px; margin-bottom: 14px; }
.sw-add .field { flex: 1; min-width: 0; }
.sw-editor-name { display: grid; flex: 1; min-width: 0; }
.sw-editor-name small { color: var(--faint); }

@media (max-width: 1180px) {
  .sw-builder { grid-template-columns: minmax(0, 1fr); }
  /* The preview first, the last spins after the options */
  .sw-builder-side { position: static; order: -1; grid-template-columns: minmax(0, 1fr); }
  .sw-preview { max-width: 520px; width: 100%; justify-self: center; }
  .sw-history-card { display: none; }
}
@media (max-width: 760px) {
  .sw-opt { grid-template-columns: 26px 36px 48px minmax(0, 1fr); }
  .sw-chance { grid-column: 2 / 4; grid-row: 2; }
  .sw-more { grid-column: 4; grid-row: 2; justify-self: start; }
  .sw-remove { grid-column: 4; grid-row: 2; justify-self: end; }
  .sw-opt-more { padding-left: 8px; }
  .font-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .sw-demos-grid { grid-template-columns: 1fr; }
  .sw-url { flex-direction: column; }
  /* Four choices: 2 + 2, never 3 + 1 */
  .seg.quad { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sw-add { flex-direction: column; }
  .sw-head-actions { justify-content: flex-start; }
  .sw-cmd-wheel { grid-template-columns: minmax(0, 1fr) auto; }
  .sw-cmd-wheel .note { display: none; }
}
