/* Social Buddy studio, Make a Scene and Buddy posts.
   Colours come from the tokens at the top of styles.css; only the three stage backdrops
   (aurora, sunset, midnight) keep their own gradients because they are part of the scene. */

.buddy-studio { max-width: 1260px; margin: auto; padding: 6px 0 36px; }

/* Heading */
.buddy-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; padding: 12px 0 28px; }
.buddy-eyebrow {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border-radius: var(--r-pill); background: var(--coral-soft); color: var(--coral-ink);
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
}
.buddy-heading h1 {
  margin: 14px 0 14px;
  font-size: clamp(34px, 4.2vw, 56px); line-height: 1.04; letter-spacing: -.045em; font-weight: 850;
  color: var(--text);
}
.buddy-heading p { max-width: 520px; margin: 0; font-size: 15.5px; line-height: 1.65; color: var(--muted); }
.buddy-heading .button { white-space: nowrap; }
.buddy-tag {
  padding: 10px 16px; border-radius: var(--r-pill);
  border: 1.5px dashed var(--primary-line); background: var(--primary-soft); color: var(--primary-strong);
  font-size: 12px; font-weight: 700; white-space: nowrap;
  transform: rotate(-2deg);
}

/* Studio layout */
.buddy-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, 1fr); gap: 24px; align-items: start; }
.buddy-preview { overflow: hidden; padding: 0 !important; position: sticky; top: calc(var(--topbar-h) + 24px); border-radius: var(--r-xl); }

/* Stage */
.buddy-scene { position: relative; overflow: hidden; isolation: isolate; border-radius: var(--r-xl); min-width: 0; }
.buddy-preview .buddy-scene { border-radius: var(--r-xl) var(--r-xl) 0 0; }
.buddy-bg-aurora { background: radial-gradient(ellipse at 20% 10%, #d5fff1 0, transparent 60%), linear-gradient(130deg, #bbd5e0, #9bb7d0 60%, #b7aece); }
.buddy-bg-sunset { background: radial-gradient(ellipse at 20% 10%, #fff3d7 0, transparent 60%), linear-gradient(130deg, #f5c9b9, #dba4b9 60%, #acafd2); }
.buddy-bg-midnight { background: radial-gradient(ellipse at 20% 10%, #285f6c 0, transparent 60%), linear-gradient(130deg, #1d3048, #393158); }
.buddy-canvas { width: 100%; height: 420px; min-width: 0; }
.buddy-canvas canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.buddy-canvas:focus-visible { outline: 3px solid var(--violet); outline-offset: -4px; border-radius: var(--r-xl); }
.buddy-scene-label {
  position: absolute; top: 18px; left: 18px; z-index: 2;
  padding: 7px 12px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .82); color: #1b1440;
  font-size: 10.5px; font-weight: 800; letter-spacing: .12em;
  box-shadow: 0 4px 12px rgba(27, 20, 64, .12);
}
.buddy-caption {
  position: absolute; bottom: 20px; left: 7%; right: 7%;
  max-height: 100px; overflow: auto; pointer-events: none;
  padding: 12px 16px; border-radius: var(--r-lg);
  background: rgba(27, 20, 64, .86); border: 1px solid rgba(255, 255, 255, .18); color: #fff;
  font-size: 14px; font-weight: 500; line-height: 1.5; text-align: center; overflow-wrap: anywhere;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.buddy-preview .buddy-canvas[data-loading=true]::after {
  content: 'Loading your Buddy…';
  position: absolute; top: 25%; left: 10%; right: 10%;
  font-size: 13px; font-weight: 700; text-align: center; color: #1b1440;
}
.buddy-webgl-error { padding: 100px 25px; font-size: 14px; line-height: 1.6; }

.buddy-preview-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 18px 18px 10px; }
.buddy-preview-tools .button { font-size: 12.5px; padding: 8px 14px; min-height: 38px; }
.buddy-footnote { margin: 12px 20px 20px !important; font-size: 12px !important; line-height: 1.6 !important; color: var(--muted) !important; }
.buddy-hint { padding: 0 18px 6px; }
.buddy-job { margin: 10px 18px; padding: 12px 14px; border-radius: var(--r-md); background: var(--primary-soft); color: var(--primary-strong); font-size: 12.5px; font-weight: 600; }
.buddy-job:empty { display: none; }

/* Emotes */
.buddy-emotes { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 18px 10px; }
.buddy-emote {
  padding: 7px 13px; border-radius: var(--r-pill); cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line-strong); color: var(--text-2);
  font: inherit; font-size: 12px; font-weight: 700;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--spring);
}
.buddy-emote:hover { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-strong); transform: translateY(-2px); }
.buddy-emote:active { transform: scale(.92); }
.buddy-emote:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; }

/* Script map */
.buddy-script-map { display: flex; gap: 8px; padding: 0 18px; overflow: auto; }
.buddy-script-map > span {
  flex: 0 0 140px; padding: 10px 12px;
  border-radius: var(--r-md); background: var(--surface-2); border: 1.5px solid var(--line);
  font-size: 11px; font-weight: 800; text-transform: capitalize; color: var(--text-2);
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.buddy-script-map small { display: block; margin-top: 4px; font-size: 11px; font-weight: 500; text-transform: none; color: var(--muted); }
.buddy-script-map .active { border-color: var(--primary); background: var(--primary-soft); }

/* Controls */
.buddy-controls { padding: 24px !important; }
.buddy-controls .form-grid { gap: 16px; }
.buddy-tabs {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 22px; padding-bottom: 16px;
  border-bottom: 1.5px dashed var(--line-strong);
  font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--muted);
}
.buddy-tabs > * { padding: 5px 11px; border-radius: var(--r-pill); background: var(--surface-3); }
.buddy-tabs > :first-child { background: var(--primary); color: var(--on-primary); }
.buddy-controls .field { overflow: hidden; }
.buddy-controls input, .buddy-controls select, .buddy-controls textarea { min-width: 0; width: 100%; font-family: inherit; }
.buddy-controls textarea { resize: vertical; min-height: 105px; }
.buddy-controls select { text-transform: capitalize; text-overflow: ellipsis; }
.buddy-colors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.buddy-colors .field { font-size: 12px; }
.buddy-colors input[type=color] {
  height: 44px; padding: 4px; cursor: pointer;
  border-radius: var(--r-pill); border: 1.5px solid var(--line-strong); background: var(--surface);
}
.buddy-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.buddy-video-panel {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 16px 18px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--tint-violet), var(--tint-coral));
}
.buddy-video-panel > div { flex: 1 1 220px; min-width: 0; }
.buddy-video-panel strong { font-size: 16px; font-weight: 800; color: var(--text); }
.buddy-video-panel p { margin: 5px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--text-2); }
.buddy-video-panel .buddy-length { font-weight: 700; color: var(--text); }
.buddy-video-panel .buddy-length:empty { display: none; }
.buddy-video-panel .buddy-length.warn { color: var(--warn-ink); }
.buddy-video-panel > .buddy-inline-note { flex: 1 1 100%; }

/* Save as video dialog */
.buddy-rec { display: grid; grid-template-columns: minmax(180px, 250px) minmax(0, 1fr); gap: 20px; align-items: start; }
.buddy-rec-frame { aspect-ratio: 9 / 16; border-radius: var(--r-lg); overflow: hidden; background: var(--media-bg); display: grid; place-items: center; }
.buddy-rec-frame > * { grid-area: 1 / 1; }
.buddy-record-canvas, .buddy-rec-video { width: 100%; height: 100%; display: block; object-fit: contain; background: var(--media-bg); }
.buddy-rec-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; color: rgba(255, 255, 255, .78); font-size: 12.5px; font-weight: 600; }
.buddy-rec-empty svg { width: 28px; height: 28px; }
.buddy-rec-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.buddy-rec-side > p, .buddy-rec-side form > p { margin: 0; }
.buddy-rec-length { font-size: 14px; }
.buddy-rec-dest { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.buddy-rec-dest legend { margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.buddy-rec-option { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.buddy-rec-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.buddy-rec-option.too-long { cursor: not-allowed; background: var(--warn-soft); border-color: var(--warn-line); }
.buddy-rec-option input { margin-top: 3px; accent-color: var(--primary); }
.buddy-rec-option span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.buddy-rec-option small { font-size: 12px; color: var(--muted); }
.buddy-rec-warn { font-style: normal; font-size: 12px; font-weight: 600; color: var(--warn-ink); }
.buddy-rec-status { font-weight: 700; }
.buddy-rec-bar { margin: 0; }
.buddy-rec-bar span { transition: transform .2s linear; }
.buddy-rec-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.buddy-rec-actions .button { flex: 1 1 auto; }

.buddy-controls .stack { gap: 8px; flex-wrap: wrap; }
.buddy-controls .stack .button { flex: 1; font-size: 13px; white-space: normal; }
.buddy-controls .buddy-footnote { margin: 16px 0 0 !important; }
.buddy-controls button:disabled { opacity: .55; cursor: not-allowed; }
.buddy-inline-note { margin: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.buddy-character-details { padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--r-lg); }
.buddy-character-details summary { cursor: pointer; font-size: 13px; font-weight: 800; color: var(--primary-strong); border-radius: var(--r-xs); }
.buddy-character-details[open] summary { margin-bottom: 18px; }

/* Make a Scene */
.buddy-scene-form { display: grid; gap: 16px; }
.buddy-template-row { display: flex; flex-wrap: wrap; gap: 7px; }
.buddy-template-row .button { min-height: 32px; padding: 6px 12px; font-size: 12px; }
.buddy-beats { display: grid; gap: 14px; }
.buddy-beat {
  display: grid; gap: 10px; padding: 16px;
  border: 1.5px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2);
}
.buddy-beat:nth-child(3n+1) { border-left: 5px solid var(--violet); }
.buddy-beat:nth-child(3n+2) { border-left: 5px solid var(--coral); }
.buddy-beat:nth-child(3n) { border-left: 5px solid var(--mint); }
.buddy-beat-title { display: flex; justify-content: space-between; align-items: center; }
.buddy-beat-title strong { font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--primary-strong); }
.buddy-beat-title .button { padding: 0; font-size: 12px; }
.buddy-beat textarea { min-height: 65px; }

/* Performance direction: one row per beat with editable chips */
.buddy-direction { display: grid; gap: 10px; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--r-lg); }
.buddy-direction:empty { display: none; }
.buddy-direction-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.buddy-direction-head > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.buddy-direction-head strong { font-size: 13px; font-weight: 800; color: var(--primary-strong); }
.buddy-direction-head .button { padding: 0; font-size: 12px; }
.buddy-direction-source { padding: 2px 9px; border-radius: var(--r-pill); background: var(--tint-violet); color: var(--text); font-size: 11px; font-weight: 700; }
.buddy-direction-notice { margin: 0; padding: 8px 12px; border: 1px solid var(--warn-line); border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn-ink); font-size: 12px; line-height: 1.5; }
.buddy-direction mark { padding: 0 2px; border-radius: 4px; background: var(--tint-sun); color: var(--text); font-weight: 700; }
.buddy-dir-beats { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.buddy-dir-beat { display: grid; gap: 7px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.buddy-dir-line { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; }
.buddy-dir-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.buddy-chip { position: relative; display: inline-flex; border: 1.5px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface); }
.buddy-chip:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.buddy-chip select { min-height: 30px; padding: 4px 10px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.buddy-chip select:focus { outline: none; }
.buddy-controls .buddy-chip select { width: auto; min-height: 30px; padding: 4px 30px 4px 12px; text-transform: none; }
.buddy-chip[data-emotion="happy"], .buddy-chip[data-emotion="laughing"] { background: var(--tint-sun); }
.buddy-chip[data-emotion="excited"] { background: var(--tint-coral); }
.buddy-chip[data-emotion="calm"] { background: var(--tint-mint); }
.buddy-chip[data-emotion="serious"], .buddy-chip[data-emotion="sad"] { background: var(--tint-blue); }
.buddy-chip[data-emotion="curious"] { background: var(--tint-violet); }

/* Collection */
.buddy-collection { margin-top: 36px; }
.buddy-collection-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.buddy-collection-title h2 { margin: 8px 0; font-size: 28px; font-weight: 800; letter-spacing: -.03em; color: var(--text); }
.buddy-collection-title .button { font-size: 13px; }
.buddy-collection-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
/* A tile per Buddy: the still picture of its real character (or, until it has one, its initial and an honest
   status), its name, and a small menu. */
.buddy-tile { position: relative; display: flex; flex-direction: column; gap: 0; min-width: 0; padding: 0 !important; overflow: visible; text-align: left; }
.buddy-tile.selected { border: 2px solid var(--primary); }
.buddy-tile-open { display: block; width: 100%; padding: 0; border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; background: none; cursor: pointer; overflow: hidden; }
.buddy-tile-open:focus-visible { outline: 3px solid var(--violet); outline-offset: -3px; }
.buddy-tile-picture { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 5; overflow: hidden; transition: transform var(--base) var(--spring); }
.buddy-tile-open:hover .buddy-tile-picture { transform: scale(1.03); }
.buddy-tile-picture img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 62%; }
.buddy-tile-initial {
  display: grid; place-items: center; width: 64px; height: 64px;
  border-radius: 42% 58% 55% 45% / 50% 45% 55% 50%;
  background: rgba(255, 255, 255, .55); color: #1b1440; font-size: 30px; font-weight: 800;
}
.buddy-bg-midnight .buddy-tile-initial { background: rgba(255, 255, 255, .16); color: #fff; }
.buddy-tile-info { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 14px 14px; min-width: 0; }
.buddy-tile-name { max-width: 100%; font-size: 16px; font-weight: 800; overflow-wrap: anywhere; }
.buddy-tile-status { font-size: 12px; line-height: 1.4; color: var(--muted); }
.buddy-tile-menu { position: absolute; top: 8px; right: 8px; z-index: 3; }
.buddy-tile-menu > summary {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  list-style: none; cursor: pointer; background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.15));
}
.buddy-tile-menu > summary::-webkit-details-marker { display: none; }
.buddy-tile-menu > summary:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.buddy-tile-menu > summary svg { width: 18px; height: 18px; }
.buddy-tile-menu-list {
  position: absolute; right: 0; top: 40px; z-index: 5; display: grid; min-width: 150px; padding: 6px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-lg);
}
.buddy-menu-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 0; border-radius: var(--r-sm, 8px); background: none; color: var(--text); font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; }
.buddy-menu-item svg { width: 16px; height: 16px; }
.buddy-menu-item:hover, .buddy-menu-item:focus-visible { background: var(--surface-3); }
.buddy-menu-item.danger-text { color: var(--danger); }
.buddy-rename { display: grid; gap: 6px; width: 100%; }
.buddy-rename input { width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; }
.buddy-rename-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.buddy-rename .form-error:empty { display: none; }

/* The preview sheet */
#modal.buddy-sheet-dialog { width: min(560px, calc(100vw - 20px)); }
.buddy-sheet { display: grid; gap: 14px; }
.buddy-sheet-stage { display: grid; place-items: center; height: min(44dvh, 380px); border-radius: var(--r-lg); }
.buddy-sheet-stage .buddy-canvas { position: absolute; inset: 0; height: 100%; }
.buddy-sheet-stage .buddy-caption:empty { display: none; }
.buddy-sheet-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.buddy-sheet-show { position: relative; z-index: 2; }
.buddy-sheet-unmade { max-width: 320px; padding: 18px; text-align: center; color: #1b1440; }
.buddy-bg-midnight .buddy-sheet-unmade { color: #fff; }
.buddy-sheet-unmade p { margin: 6px 0 12px; font-size: 13.5px; }
.buddy-sheet-hear { display: grid; gap: 6px; }
.buddy-sheet-hear .buddy-inline-note { margin: 0; }
.buddy-sheet-name { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.buddy-sheet-name > div { display: grid; gap: 2px; min-width: 0; }
.buddy-sheet-name strong { font-size: 18px; font-weight: 800; overflow-wrap: anywhere; }
.buddy-sheet-name .buddy-rename { flex: 1; }
.buddy-sheet-actions { margin-top: 0; }
.buddy-delete-facts { display: grid; gap: 8px; margin: 0 0 4px; padding-left: 20px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.buddy-empty { grid-column: 1 / -1; padding: 24px !important; }
.buddy-empty p { margin: 8px 0 0; font-size: 13.5px; color: var(--muted); }

/* Buddy posts in the feed */
.composer-bottom { flex-wrap: wrap; }
.buddy-post { margin: 8px 0 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-lg); }
.post .buddy-post { margin: 4px 20px 14px; }
.buddy-post .buddy-scene { border-radius: 0; }
.buddy-post .buddy-canvas { height: 330px; }
.buddy-post .buddy-caption { z-index: 2; font-size: 12.5px; }
/* The poster (a still of the real character, or a neutral shimmer while there is none) shows first; the
   live stage fades in over it once the character has loaded. */
.buddy-post .buddy-canvas { position: relative; z-index: 1; opacity: 0; transition: opacity .45s var(--ease); }
.buddy-post .is-live .buddy-canvas, .buddy-post .no-3d .buddy-canvas { opacity: 1; }
.buddy-post .no-3d:has(.buddy-poster img) .buddy-canvas, .buddy-post .is-failed .buddy-canvas { opacity: 0; }
.buddy-poster { position: absolute; inset: 0; z-index: 0; display: flex; pointer-events: none; transition: opacity .45s var(--ease); }
.buddy-post .is-live .buddy-poster { opacity: 0; }
/* Behind an open dialog the live stage is paused and hidden, and the poster shows instead. */
.buddy-post .is-covered .buddy-canvas { visibility: hidden; }
.buddy-post .is-covered .buddy-poster { opacity: 1; }
.buddy-poster img { flex: 1 1 0; min-width: 0; height: 100%; object-fit: cover; object-position: center; }
.buddy-poster .buddy-poster-set { position: absolute; inset: 0; width: 100%; height: 100%; }
.buddy-poster.is-set > :not(.buddy-poster-set) { position: relative; }
.buddy-poster-wait { position: relative; flex: 1 1 0; min-width: 0; overflow: hidden; }
.buddy-poster-wait::before {
  content: ''; position: absolute; left: 50%; bottom: 13%; width: min(46%, 220px); height: 18%; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(closest-side, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
}
.buddy-poster-wait::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .28) 50%, rgba(255, 255, 255, 0) 70%);
  background-size: 250% 100%; animation: buddy-shimmer 1.6s linear infinite;
}
.is-failed .buddy-poster-wait::after { animation: none; background: none; }
@keyframes buddy-shimmer { from { background-position: 125% 0; } to { background-position: -125% 0; } }
.buddy-sound {
  position: absolute; top: 14px; right: 14px; z-index: 2; display: grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: 50%; background: rgba(27, 20, 64, .6); color: #fff; cursor: pointer;
  transition: background-color var(--fast) var(--ease);
}
.buddy-sound:hover { background: #6847f5; }
.buddy-sound svg { width: 19px; height: 19px; }
.buddy-sound:focus-visible, .buddy-load:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.buddy-load {
  position: absolute; top: 50%; left: 50%; z-index: 2; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: 0; border-radius: var(--r-pill);
  background: rgba(27, 20, 64, .82); color: #fff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.buddy-load svg { width: 16px; height: 16px; }
.buddy-post .buddy-emotes { padding: 0 16px 14px; background: var(--surface-2); }
.buddy-emotes[hidden] { display: none; }
.buddy-post-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: var(--surface-2); }
.buddy-post-title { min-width: 0; }
.buddy-post-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.buddy-emotes-toggle { max-width: 100%; }
.buddy-emotes-toggle[aria-expanded=true] { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-strong); }
.buddy-post-foot strong { font-size: 14px; font-weight: 800; }
.buddy-post-foot small { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.scene-credits { margin: 0; padding: 0 16px 10px; font-size: 12px; color: var(--muted); background: var(--surface-2); }
.scene-credits .scene-credit { padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--text); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.scene-credits small { font-size: inherit; }
#scene-join-stage .buddy-caption:empty { display: none; }
.scene-join-closed { padding: 24px; display: grid; gap: 14px; justify-items: start; }
.scene-join-closed p { margin: 0; }
.scene-join-fixed { padding: 12px 18px 16px; margin: 0; }
.scene-join-line { display: grid; gap: 10px; }
.scene-join-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px; background: var(--surface-2); }
.buddy-poster.is-group img, .buddy-poster.is-group .buddy-poster-wait { object-position: center 30%; }

@media (max-width: 1100px) {
  .buddy-layout { grid-template-columns: minmax(0, 1fr); }
  .buddy-preview { position: relative; top: auto; }
  .buddy-canvas { height: 390px; }
  .buddy-heading { align-items: start; }
  .buddy-tag { display: none; }
  .buddy-collection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .buddy-heading { display: block; padding-bottom: 22px; }
  .buddy-heading h1 { font-size: 36px; letter-spacing: -.035em; }
  .buddy-heading p { font-size: 13.5px; }
  .buddy-heading .button { margin-top: 15px; }
  .buddy-controls { padding: 18px !important; }
  .buddy-canvas { height: 370px; }
  .buddy-collection-title { align-items: start; }
  .buddy-collection-title .button { padding: 8px 12px; }
  .buddy-tile-info { padding: 10px 11px 12px; }
  .buddy-tile-name { font-size: 15px; }
  .buddy-sheet-stage { height: min(40dvh, 320px); }
  .buddy-caption { font-size: 12.5px; }
  .buddy-preview-tools { gap: 6px; padding: 14px 12px; }
  .buddy-preview-tools .button { font-size: 12px; padding: 8px 11px; }
  .buddy-colors { gap: 8px; }
  .buddy-selects { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .buddy-post-foot { flex-wrap: wrap; }
  .buddy-post-actions { justify-content: flex-start; }
  .buddy-post .buddy-canvas { height: 310px; }
  .post .buddy-post { margin: 4px 14px 12px; }
  .buddy-studio { padding-bottom: 50px; }
  .buddy-emotes { padding: 2px 12px 10px; }
  .buddy-emote { padding: 8px 11px; }
  .buddy-rec { grid-template-columns: minmax(0, 1fr); }
  .buddy-rec-frame { width: min(100%, 180px); justify-self: center; }
}

/* Two-Buddy Scenes: second-character picker and per-beat speaker. */
.buddy-cast { display: grid; gap: 8px; padding: 16px; border: 1.5px dashed var(--line); border-radius: var(--r-lg); background: var(--surface-3); }
.buddy-cast .buddy-inline-note { margin: 0; }
.buddy-studio [data-cast-only][hidden] { display: none; }

/* Buddy from a photo */
.buddy-photo-panel {
  display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--r-lg);
  border: 1.5px dashed var(--line-strong); background: var(--tint-violet);
}
.buddy-photo-panel strong { font-size: 14px; font-weight: 800; color: var(--text); }
.buddy-photo-panel input[type=file] { font-size: 13px; }
.buddy-consent { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.5; color: var(--text); cursor: pointer; }
.buddy-consent input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }

/* Design a voice */
.buddy-voice-designer { display: grid; gap: 16px; }
.buddy-voice-designer > p { margin: 0; line-height: 1.6; color: var(--text-2); }
.buddy-voice-previews fieldset { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.buddy-voice-previews legend { margin-bottom: 8px; font-weight: 800; color: var(--text); }
.buddy-voice-option {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-lg); border: 1.5px solid var(--line-strong); background: var(--surface);
}
.buddy-voice-option:has(input:checked) { border-color: var(--primary); background: var(--tint-violet); }
.buddy-voice-option label { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); cursor: pointer; }
.buddy-voice-option input { accent-color: var(--primary); }
.buddy-voice-option audio { width: 100%; min-width: 0; height: 36px; }
.buddy-voice-saved h3 { margin: 0 0 8px; font-size: 15px; }
.buddy-voice-saved ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.buddy-voice-saved li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--r-lg); background: var(--surface-2, var(--surface)); border: 1px solid var(--line); }
.buddy-voice-saved li span { display: grid; gap: 2px; min-width: 0; }
.buddy-voice-saved li small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .buddy-voice-option { grid-template-columns: 1fr; } }
.buddy-voice-link { display: flex; margin-top: -6px; }

/* ── Guided setup: Look → Voice → Say something ── */
.buddy-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; }
.buddy-step-tab {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 10px;
  border: 1.5px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.buddy-step-tab:hover { border-color: var(--primary-line); color: var(--text); }
.buddy-step-tab:focus-visible { outline: none; box-shadow: var(--ring); }
.buddy-step-tab[aria-current="step"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.buddy-step-num { display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); color: var(--text); font-size: 12px; }
.buddy-step-tab[aria-current="step"] .buddy-step-num { background: var(--primary); color: var(--on-primary); }
.buddy-step { display: grid; gap: 16px; }
.buddy-step[hidden] { display: none; }
.buddy-step-title { margin: 0; font-size: 20px; line-height: 1.25; letter-spacing: -.01em; }
.buddy-step-title:focus { outline: none; }
.buddy-step-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.buddy-share-row { display: flex; gap: 8px; flex-wrap: wrap; }
.buddy-share-row .button { flex: 1 1 140px; }

.buddy-looks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.buddy-looks legend { margin-bottom: 8px; padding: 0; font-size: 13px; font-weight: 700; }
.buddy-look {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: var(--r-md); background: var(--surface); cursor: pointer; min-width: 0;
}
.buddy-look:hover { border-color: var(--primary-line); }
.buddy-look input { position: absolute; opacity: 0; pointer-events: none; }
.buddy-look:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.buddy-look:has(input:focus-visible) { box-shadow: var(--ring); }
.buddy-look-text { display: grid; gap: 2px; min-width: 0; }
.buddy-look-text strong { font-size: 13px; color: var(--text); }
.buddy-look-text small { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.buddy-look-swatch { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.buddy-look-everyday { background: linear-gradient(135deg, #c88d67 0 40%, #4ed9c3 40% 100%); }
.buddy-look-sporty { background: linear-gradient(135deg, #8d5a3b 0 40%, #ff7a59 40% 100%); }
.buddy-look-smart { background: linear-gradient(135deg, #e0b48f 0 40%, #2b3a67 40% 100%); }
.buddy-look-cozy { background: linear-gradient(135deg, #f1c7a5 0 40%, #e0a526 40% 100%); }
.buddy-look-bold { background: linear-gradient(135deg, #6f4a33 0 40%, #7c5cff 40% 100%); }
.buddy-make { display: grid; gap: 8px; }
.buddy-make .button { justify-self: start; }

.buddy-more { padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-lg); }
.buddy-more summary { cursor: pointer; font-size: 13px; font-weight: 800; color: var(--primary-strong); border-radius: var(--r-xs); }
.buddy-more summary:focus-visible { outline: none; box-shadow: var(--ring); }
.buddy-more[open] summary { margin-bottom: 14px; }
.buddy-more .buddy-photo-panel { margin: 0; }

.buddy-voice-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.buddy-voice-card { display: grid; gap: 2px; padding: 4px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface); min-width: 0; }
.buddy-voice-card:has([aria-pressed="true"]) { border-color: var(--primary); background: var(--primary-soft); }
.buddy-voice-choose { display: grid; gap: 2px; padding: 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; min-width: 0; }
.buddy-voice-choose:focus-visible { outline: none; box-shadow: var(--ring); }
.buddy-voice-choose strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buddy-voice-choose small { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.buddy-voice-card .button { justify-self: start; }

.buddy-count { margin: -10px 0 0; font-size: 12px; color: var(--muted); text-align: right; }
.buddy-count.warn { color: var(--warn-ink); font-weight: 700; }
.buddy-limit { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.buddy-limit:empty { display: none; }
.buddy-limit.empty { padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text); font-weight: 600; }

/* Generation progress */
.buddy-job { display: grid; gap: 4px; }
.buddy-job span { font-weight: 500; color: var(--text); }
.buddy-job progress { width: 100%; height: 8px; margin-top: 4px; border: 0; border-radius: var(--r-pill); overflow: hidden; background: var(--surface); appearance: none; }
.buddy-job progress::-webkit-progress-bar { background: var(--surface); border-radius: var(--r-pill); }
.buddy-job progress::-webkit-progress-value { background: var(--primary); border-radius: var(--r-pill); }
.buddy-job progress::-moz-progress-bar { background: var(--primary); border-radius: var(--r-pill); }
.buddy-job .buddy-job-leave { font-size: 11.5px; color: var(--muted); }

/* "Let my Buddy say this" in the post composer */
.buddy-say[hidden] { display: none; }
.buddy-say { display: grid; gap: 8px; }
.buddy-say-toggle > span { display: grid; gap: 2px; }
.buddy-say-toggle small { font-size: 12px; font-weight: 500; color: var(--muted); }
.buddy-say-options { display: grid; gap: 10px; }
.buddy-say-options[hidden] { display: none; }
.buddy-say-note { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.buddy-say-note.warn { color: var(--warn-ink); font-weight: 700; }
.image-input.disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 520px) {
  .buddy-step-tab { flex-direction: column; gap: 3px; padding: 6px 4px; font-size: 11.5px; border-radius: var(--r-md); }
  .buddy-step-title { font-size: 18px; }
  .buddy-looks, .buddy-voice-cards { grid-template-columns: 1fr 1fr; }
}

/* Make a Scene prefilled from a text post: where it came from, and any text that didn't fit. */
.buddy-from-post { flex-direction: column; gap: 10px; margin-bottom: 12px; }
.buddy-from-post strong { color: var(--text); }
.buddy-leftover {
  margin: 0; padding: 10px 12px; max-height: 160px; overflow: auto;
  border-left: 3px solid var(--primary-line); background: var(--surface, transparent);
  font-size: 13px; line-height: 1.55; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere;
}
.buddy-scene-form .topic-picker { margin-top: 14px; }

/* ── Make a Scene: "Where does it take place?" ── */
.scene-location { display: grid; gap: 10px; margin: 0; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.scene-location legend { padding: 0 6px; font-size: 15px; font-weight: 800; color: var(--text); }
.scene-location-ideas { display: flex; flex-wrap: wrap; gap: 7px; }
.scene-location-ideas .button { min-height: 32px; padding: 6px 12px; font-size: 12px; }
.scene-location-ideas .button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.scene-location-none { margin: 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); font-size: 12.5px; color: var(--muted); }
.scene-location-current { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px; border-radius: var(--r-md); background: var(--surface-2); }
.scene-location-picture { aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--r-sm, 10px); background: var(--surface-3); }
.scene-location-picture img, .scene-location-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.scene-location-about { display: grid; gap: 4px; min-width: 0; font-size: 12.5px; line-height: 1.5; }
.scene-location-about > span:not(.buddy-job-leave):not(.scene-location-error) { color: var(--text-2); overflow-wrap: anywhere; }
.scene-location-about progress { width: 100%; height: 8px; }
.scene-location-error { color: var(--danger, #b42318); font-weight: 600; }
.scene-location-thumb-wait { display: block; width: 100%; height: 100%; background: linear-gradient(110deg, var(--surface-3) 30%, var(--surface-2) 50%, var(--surface-3) 70%); background-size: 220% 100%; animation: scene-location-wait 1.6s linear infinite; }
@keyframes scene-location-wait { to { background-position: -220% 0; } }
@media (prefers-reduced-motion: reduce) { .scene-location-thumb-wait { animation: none; } }
.scene-location-mine-title { margin: 4px 0 0; font-size: 13px; font-weight: 800; }
.scene-location-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; max-height: 260px; overflow-y: auto; }
.scene-location-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: var(--r-md); }
.scene-location-item.chosen { border-color: var(--primary); }
.scene-location-item label { display: flex; flex: 1 1 auto; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.scene-location-item input:disabled + .scene-location-thumb { opacity: .5; }
.scene-location-thumb { flex: 0 0 64px; height: 36px; overflow: hidden; border-radius: 6px; background: var(--surface-3); }
.scene-location-text { display: grid; min-width: 0; font-size: 12px; }
.scene-location-text strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.scene-location-text small { color: var(--muted); }
@media (max-width: 520px) { .scene-location-current { grid-template-columns: 1fr; } }
.scene-location-item input[type="radio"] { flex: 0 0 auto; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; }
.scene-location-text strong { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
