/* ══════════════════════════════════════════════════
   MAPLE STREAMER — stage editor (stream/index.html)
   Layout: app bar · [Layers | 16:9 stage | Properties]. Linked directly by
   the page (not @imported by main.css) — only this page uses it.
   Colours are tokens (styles/tokens.css); the stage preview backgrounds and
   the checkerboard stay literal (they stand in for the stream, not chrome).
   ══════════════════════════════════════════════════ */

body.streamer { height: 100vh; overflow: hidden; }

.ms-app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── App bar ── */
.ms-bar {
  display: flex; align-items: center; gap: var(--sp-4);
  height: 44px; padding: 0 var(--sp-5); flex-shrink: 0;
  background: var(--chrome); border-bottom: 1px solid var(--border);
}
.ms-wordmark { font-weight: 700; font-size: 13px; white-space: nowrap; }
.ms-badge {
  margin-left: 4px; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-text); background: var(--accent-tint);
}
.ms-bar-group { display: flex; align-items: center; gap: 2px; }
.ms-bar-spacer { flex: 1; }
.ms-tool {
  height: 28px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--r);
  background: none; color: var(--text); font: inherit; font-size: var(--fs-4); cursor: pointer;
}
.ms-tool:hover { background: var(--hover); }
.ms-tool[aria-pressed="true"] { background: var(--accent-tint); border-color: var(--accent); color: var(--accent-text); }
input[type="text"].ms-stage-name { width: 200px; height: 28px; padding: 0 8px; }
.ms-obs-btn { height: 30px; padding: 0 14px; white-space: nowrap; }

.ms-bar select,
.ms-panel select,
.ms-panel input[type="number"],
.ms-picker-tools select,
.ms-picker-tools input[type="search"],
.ms-obs input[type="text"] {
  height: 28px; padding: 0 8px; border: 1px solid var(--input-border); border-radius: var(--r);
  background: var(--input-bg); color: var(--text); font: inherit; font-size: var(--fs-4); outline: none;
}
.ms-panel select:focus, .ms-panel input:focus, .ms-picker-tools input:focus, .ms-obs input:focus { border-color: var(--accent); }
/* The site chevron (components.css) as a picture, Derek 2026-10-15: same mid
   grey as the Character FX blend picker, since a background image can't use
   the text colour. Replaces the browser's own select arrow. */
.ms-bar select,
.ms-panel select,
.ms-picker-tools select {
  -webkit-appearance: none; appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238a8f99' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5.5l5 5 5-5'/%3E%3C/svg%3E");
  background-size: 10px 10px;
  background-position: right 8px center;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* ── Work area ── */
.ms-work { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; }
.ms-panel { min-height: 0; overflow-y: auto; background: var(--chrome-lo); }
.ms-layers { display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.ms-inspector { border-left: 1px solid var(--border); padding-bottom: 24px; }

.ms-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 6px 12px; }
.ms-panel-head h2 { margin: 0; font-size: var(--fs-3); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mid); }
.ms-panel-tools { display: flex; gap: 2px; }
.ms-icon-btn {
  width: 26px; height: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r); background: none; color: var(--text-mid); cursor: pointer;
}
.ms-icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.ms-icon-btn:disabled { opacity: .35; cursor: default; }
.ms-add-me {
  margin: 0 10px 8px; padding: 6px 10px; border: 1px dashed var(--accent); border-radius: var(--r);
  background: var(--accent-tint); color: var(--accent-text); font: inherit; font-size: var(--fs-4); font-weight: 600; cursor: pointer;
}
.ms-add-me[hidden] { display: none; }

/* ── Your call (the Maple Streamer bot) ── */
.ms-call { margin: 10px 10px 4px; padding: 8px 10px; border: 1px solid var(--border-lo); border-radius: var(--r); background: var(--chrome); }
.ms-call:empty { display: none; }
.ms-call-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.ms-call-head h2 { margin: 0; flex: none; font-size: var(--fs-3); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mid); }
.ms-call-head span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--text-mid); }
.ms-call p { margin: 0 0 4px; font-size: 11.5px; line-height: 1.45; color: var(--text-mid); }
.ms-call-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ms-call-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.ms-call-row img { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--input-bg); }
.ms-call-name { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-call-name small { font-size: 10.5px; color: var(--text-dim); }
.ms-call-in { flex: none; font-size: 10.5px; color: var(--text-dim); }
.ms-call-row .btn--sm { flex: none; }
.ms-call-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; }
.ms-call-invite { font-size: 11px; color: var(--accent-text); }
.ms-call-preview { margin: 2px 0 6px; font-weight: 600; }
.ms-call-bot { padding: 4px 6px; border-radius: var(--r); background: var(--hover); }
.ms-call-bot[data-bot="in-call"] { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--text); }
.ms-call-bot[data-bot="busy"], .ms-call-bot[data-bot="no-permission"], .ms-call-bot[data-bot="full"], .ms-call-bot[data-bot="kicked"] { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--text); }
.ms-call-row img { box-shadow: 0 0 0 2px transparent; transition: box-shadow .08s; }
.ms-call-row.talking img { box-shadow: 0 0 0 2px var(--green); }

/* ── Layer groups: in this call / not in this call / stage ── */
.ms-group {
  display: flex; align-items: center; gap: 6px; margin: 10px 4px 4px; padding: 2px 4px;
  font-size: var(--fs-3); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mid);
  list-style: none;
}
.ms-group > span:last-child { margin-left: auto; font-weight: 600; letter-spacing: 0; color: var(--text-dim); }
.ms-group-toggle { cursor: pointer; border-radius: var(--r); }
.ms-group-toggle:hover { background: var(--hover); color: var(--text); }
.ms-group-name { flex: none; }
.ms-group-empty { margin: 2px 8px 6px; font-size: 11px; color: var(--text-dim); list-style: none; }

/* ── Layer rows ── */
.ms-layer-list { list-style: none; margin: 0; padding: 0 6px; flex: 1; }
.ms-row {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border: 1px solid transparent; border-radius: var(--r); cursor: pointer;
}
.ms-row:hover { background: var(--hover); }
.ms-row.sel { background: var(--accent-tint); border-color: var(--accent); }
.ms-row.hidden .ms-row-thumb, .ms-row.hidden .ms-row-text { opacity: .45; }
.ms-row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.ms-row.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.ms-row-key {
  flex: none; width: 22px; height: 22px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%; background: var(--chrome-hi);
  color: var(--text-mid); font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; user-select: none;
}
.ms-row-key--icon { cursor: default; border-style: dashed; }
.ms-row.talking .ms-row-key { background: var(--green); border-color: var(--green); color: var(--text-inv); }
.ms-row-thumb { flex: none; width: 40px; height: 40px; border-radius: 4px; background: var(--input-bg); image-rendering: pixelated; }
.ms-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ms-row-text b, .ms-row-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-row-text b { font-size: 12px; }
.ms-row-text small { font-size: 10.5px; color: var(--text-mid); }
.ms-row-btn {
  flex: none; width: 22px; height: 22px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 4px; background: none; color: var(--text-dim); cursor: pointer;
}
.ms-row-btn:hover { background: var(--hover); color: var(--text); }
.ms-panel-foot { margin: 0; padding: 8px 12px 12px; font-size: 10.5px; color: var(--text-dim); }

/* ── Stage ── */
.ms-stage-wrap { position: relative; min-width: 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; padding: 24px 24px 40px; }
.ms-stage-frame { margin: auto; line-height: 0; outline: 1px solid var(--border); box-shadow: var(--shadow); }
.ms-stage-frame[data-bg="checker"] {
  background-color: #fff;
  background-image: conic-gradient(#e4e4e4 25%, #fff 0 50%, #e4e4e4 0 75%, #fff 0);
  background-size: 24px 24px;
}
:root[data-theme="dark"] .ms-stage-frame[data-bg="checker"] {
  background-color: #2b2b2b;
  background-image: conic-gradient(#363636 25%, #2b2b2b 0 50%, #363636 0 75%, #2b2b2b 0);
}
.ms-stage-frame[data-bg="dark"] { background: #141414; }
.ms-stage-frame[data-bg="light"] { background: #f2f2f2; }
.ms-stage-frame[data-bg="green"] { background: #00b140; }
#ms-stage { display: block; image-rendering: pixelated; touch-action: none; }
#ms-stage.dragging { cursor: grabbing !important; }
/* sticky, not absolute: an absolute label scrolls into the middle of a zoomed-in stage */
.ms-stage-info {
  position: sticky; bottom: 0; align-self: flex-end; margin-top: 8px; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; color: var(--text-mid); background: var(--glass);
}

/* ── Inspector ── */
.ms-insp-head { padding: 12px 14px 8px; }
.ms-insp-head h2 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-insp-head p { margin: 4px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--text-mid); }
.ms-sec { padding: 10px 14px 4px; border-top: 1px solid var(--border-lo); }
.ms-sec h3 { margin: 0 0 8px; font-size: var(--fs-3); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mid); }
.ms-sec h4 { margin: 10px 0 4px; font-size: 12px; }
.ms-field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; font-size: 11px; color: var(--text-mid); }
.ms-field input, .ms-field select { width: 100%; }
.ms-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ms-check { display: flex; align-items: center; gap: 6px; margin: 2px 0 8px; font-size: 12px; color: var(--text); cursor: pointer; }
.ms-hint { margin: -4px 0 8px; font-size: 11px; line-height: 1.45; color: var(--text-dim); }
.ms-range { display: flex; align-items: center; gap: 8px; }
.ms-range input { flex: 1; }
.ms-range output { width: 50px; text-align: right; font-size: 11px; color: var(--text); }
.ms-look { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ms-look canvas { flex: none; width: 56px; height: 56px; border-radius: var(--r); background: var(--input-bg); image-rendering: pixelated; }
.ms-look b { display: block; font-size: 12.5px; }
.ms-look small { font-size: 11px; color: var(--text-mid); }
.ms-sec > .btn--sm { margin-bottom: 8px; }

/* ── Pose cards (idle + talking variants) ── */
.ms-poses { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.ms-pose-card { position: relative; }
.ms-pose-pick, .ms-pose-add {
  width: 82px; padding: 4px 4px 5px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid var(--border-lo); border-radius: var(--r); background: var(--input-bg);
  color: var(--text); font: inherit; cursor: pointer;
}
.ms-pose-pick:hover, .ms-pose-add:hover:not(:disabled) { border-color: var(--accent); }
.ms-pose-pick canvas { width: 56px; height: 56px; image-rendering: pixelated; }
.ms-pose-pick span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 600; }
.ms-pose-pick small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--text-mid); }
.ms-pose-add { justify-content: center; min-height: 92px; color: var(--text-mid); border-style: dashed; font-size: 11px; }
.ms-pose-add:disabled { opacity: .4; cursor: default; }
.ms-pose-del {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%; background: var(--chrome-hi); color: var(--text-mid); cursor: pointer;
}
.ms-pose-del:hover { color: var(--text); border-color: var(--accent); }

/* ── Pose gallery ── */
.ms-posepick { width: min(860px, calc(100vw - 32px)); height: min(720px, calc(100vh - 64px)); }
.ms-posepick[open] { display: flex; flex-direction: column; }
.ms-pose-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 16px; }
.ms-pose-emotes { display: flex; gap: 4px; overflow-x: auto; padding: 4px 0 10px; border-bottom: 1px solid var(--border-lo); margin-bottom: 6px; }
.ms-pose-emotes[hidden] { display: none; }
.ms-emo {
  flex: none; width: 60px; padding: 3px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid transparent; border-radius: var(--r); background: none; color: var(--text-mid); font: inherit; font-size: 10px; cursor: pointer;
}
.ms-emo canvas { width: 48px; height: 48px; image-rendering: pixelated; }
.ms-emo:hover { background: var(--hover); }
.ms-emo.sel { border-color: var(--accent); background: var(--accent-tint); color: var(--text); }
.ms-pose-row { padding: 8px 0; border-bottom: 1px solid var(--border-lo); }
.ms-pose-row h4 { margin: 0 0 6px; font-size: 12px; }
.ms-pose-row h4 small { margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 10px; font-weight: 700; color: var(--accent-text); background: var(--accent-tint); }
.ms-pose-cells { display: flex; flex-wrap: wrap; gap: 6px; min-height: 40px; }
.ms-pose-cell {
  width: 76px; padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid var(--border-lo); border-radius: var(--r); background: var(--input-bg);
  color: var(--text-mid); font: inherit; font-size: 10px; cursor: pointer;
}
.ms-pose-cell canvas { width: 64px; height: 64px; image-rendering: pixelated; }
.ms-pose-cell span { display: inline-flex; align-items: center; gap: 3px; }
.ms-pose-cell:hover { border-color: var(--accent); color: var(--text); }
.ms-pose-cell.sel { border-color: var(--accent); background: var(--accent-tint); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
.ms-pose-anim { border-style: dashed; }
.ms-pool { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ms-pool li { display: flex; align-items: center; gap: 8px; padding: 2px 4px; border-radius: var(--r); background: var(--input-bg); font-size: 12px; }
.ms-pool canvas { flex: none; width: 32px; height: 32px; image-rendering: pixelated; }
.ms-pool span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Dialogs ── */
.ms-dialog {
  /* margin: auto re-centres the modal — the global reset zeroes the UA margin */
  margin: auto; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0;
  border: 1px solid var(--border); border-radius: 10px; background: var(--chrome); color: var(--text);
  box-shadow: var(--shadow-strong);
}
.ms-dialog::backdrop { background: var(--scrim); }
.ms-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-lo); }
.ms-dialog-head h2 { margin: 0; font-size: 15px; }

.ms-picker { height: min(640px, calc(100vh - 64px)); }
.ms-picker[open] { display: flex; flex-direction: column; }
.ms-picker-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px 6px; }
.ms-picker-tools input[type="search"] { flex: 1; min-width: 160px; }
.ms-picker-tools select[hidden] { display: none; }
.ms-tabs { display: flex; gap: 2px; padding: 2px; border-radius: var(--r); background: var(--input-bg); }
.ms-tabs button {
  padding: 4px 12px; border: none; border-radius: 4px; background: none;
  color: var(--text-mid); font: inherit; font-size: 12px; cursor: pointer;
}
.ms-tabs button[aria-selected="true"] { background: var(--chrome-hi); color: var(--text); box-shadow: var(--shadow-soft); }
.ms-picker-note { min-height: 1.2em; margin: 0 16px 6px; font-size: 11.5px; color: var(--text-mid); }
.ms-picker-grid {
  flex: 1; min-height: 0; overflow-y: auto; padding: 2px 16px 16px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; align-content: start;
}
.ms-grid-head { grid-column: 1 / -1; margin: 6px 0 0; font-size: var(--fs-3); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mid); }
.ms-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px;
  border: 1px solid var(--border-lo); border-radius: var(--r); background: var(--chrome-hi);
  color: var(--text); font: inherit; cursor: pointer;
}
.ms-cell:hover { border-color: var(--accent); }
.ms-cell-art { width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; }
.ms-cell-art img, .ms-cell-art canvas { max-width: 72px; max-height: 72px; image-rendering: pixelated; }
.ms-cell-name {
  max-width: 100%; font-size: 11px; line-height: 1.2; text-align: center; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

.ms-obs { width: min(600px, calc(100vw - 32px)); }
.ms-obs p { font-size: 12.5px; }
.ms-radio { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 12.5px; cursor: pointer; }
.ms-rec { padding: 0 6px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-text); background: var(--accent-tint); }
.ms-linkbtn { padding: 0; border: none; background: none; color: var(--accent-text); font: inherit; text-decoration: underline; cursor: pointer; }

/* ── Guide ── */
.ms-guide { width: min(640px, calc(100vw - 32px)); }
.ms-guide-body { padding: 4px 20px 18px; overflow-y: auto; max-height: calc(100vh - 140px); font-size: 13px; line-height: 1.55; }
.ms-guide-body h3 { margin: 16px 0 6px; font-size: var(--fs-3); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mid); }
.ms-guide-body p { margin: 0 0 8px; }
.ms-guide-lead { margin-top: 12px !important; font-size: 13.5px; }
.ms-guide-steps { margin: 0 0 8px; padding-left: 22px; }
.ms-guide-steps li { margin: 0 0 8px; padding-left: 2px; }
.ms-guide-notes { margin: 0; padding-left: 18px; color: var(--text-mid); }
.ms-guide-notes li { margin: 0 0 6px; }
.ms-guide-notes b { color: var(--text); }
.ms-guide-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.ms-obs-lead { margin: 12px 16px 0; font-size: 12.5px; line-height: 1.5; color: var(--text-mid); }
.ms-steps { margin: 0; padding: 12px 16px 16px 36px; display: flex; flex-direction: column; gap: 14px; }
.ms-steps h3 { margin: 0 0 6px; font-size: 13px; }
.ms-steps p { margin: 0 0 6px; font-size: 12.5px; line-height: 1.5; }
.ms-steps .ms-hint { margin: 2px 0 6px; }
.ms-steps input[type="text"] { width: 100%; }
.ms-copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ms-copy-row input[type="text"] { flex: 1; min-width: 200px; width: auto; }

/* ── Narrow screens: stage first, panels stacked below ── */
@media (max-width: 1000px) {
  body.streamer { height: auto; overflow: auto; }
  .ms-bar { height: auto; flex-wrap: wrap; padding: 6px 12px; }
  .ms-work { grid-template-columns: 1fr; }
  .ms-stage-wrap { order: -1; height: 56vh; padding: 12px; }
  .ms-layers, .ms-inspector { border: none; border-top: 1px solid var(--border); overflow: visible; }
}
