/* Play dialogs inherit the active script's paper, ink and accent, including author skins. */
body.mivo-play-design {
    --sheet-paper: var(--main-bg-color, Canvas);
    --sheet-canvas: var(--body-bg-color, Canvas);
    --sheet-ink: var(--main-color, CanvasText);
    --sheet-tone: var(--focus-color, Highlight);
    --sheet-on-tone: var(--beauty-on-accent, HighlightText);
    --sheet-rule: var(--main-border-color, GrayText);
    --sheet-secondary: var(--muted-color, CanvasText);
    --sheet-soft: var(--sheet-paper);
    --sheet-well: var(--sheet-canvas);
    --sheet-lip: var(--sheet-rule);
    --sheet-grain: rgb(125 125 125 / 9%);
    --sheet-glint: rgb(255 255 255 / 32%);
    --sheet-face: linear-gradient(175deg, rgb(255 255 255 / 9%), transparent 52%, rgb(0 0 0 / 6%));
    --sheet-lines: repeating-linear-gradient(168deg, transparent 0 20px, var(--sheet-grain) 20px 21px);
    --sheet-frame: inset 0 1px 0 var(--sheet-glint), inset 0 -2px 0 var(--sheet-lip),
        2px 4px 0 var(--sheet-lip), 0 18px 48px rgb(0 0 0 / 23%);
    --sheet-raised: inset 0 1px 0 var(--sheet-glint), 0 3px 0 var(--sheet-lip), 0 4px 6px rgb(0 0 0 / 15%);
    --sheet-pressed: inset 0 2px 3px rgb(0 0 0 / 24%), 0 1px 0 var(--sheet-glint);
    --sheet-inset: inset 1px 2px 3px rgb(0 0 0 / 13%), 0 1px 0 var(--sheet-glint);
    --sheet-screen: 100vh;
    --sheet-action-height: 34px;
    --sheet-pad: clamp(12px, 3vw, 18px);
    --sheet-width: min(414px, calc(100% - 28px));
    --sheet-top: var(--mivo-cutout-top, env(safe-area-inset-top, 0px));
    --sheet-bottom: var(--mivo-cutout-bottom, env(safe-area-inset-bottom, 0px));
}
@supports (height: 100dvh) {
    body.mivo-play-design { --sheet-screen: 100dvh; }
}
@supports (color: color-mix(in srgb, red, white)) {
    body.mivo-play-design {
        --sheet-soft: color-mix(in srgb, var(--sheet-tone) 9%, var(--sheet-paper));
        --sheet-well: color-mix(in srgb, var(--sheet-paper) 93%, var(--sheet-ink));
        --sheet-lip: color-mix(in srgb, var(--sheet-rule) 62%, var(--sheet-tone));
        --sheet-grain: color-mix(in srgb, var(--sheet-tone) 8%, transparent);
    }
}
.mivo-play-design :is(#script-dialog, .ot-avatar-sheet, .mivo-phone-new-menu)::backdrop {
    background: rgb(19 17 29 / 43%);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}
.mivo-play-design :is(#script-dialog, .ot-avatar-sheet, .mivo-phone-new-menu, .sw-graph-sheet) {
    overscroll-behavior: contain;
    scrollbar-width: none;
}
.mivo-play-design :is(#script-dialog, .ot-avatar-sheet, .mivo-phone-new-menu, .sw-graph-sheet) :focus-visible {
    outline: 2px solid var(--focus-color, currentColor);
    outline-offset: 2px;
}
.mivo-play-design :is(#script-dialog, .ot-avatar-sheet, .mivo-phone-new-menu, .sw-graph-sheet) :is(button, label, summary) {
    touch-action: manipulation;
}
.mivo-play-design :is(#script-dialog, .ot-avatar-sheet, .mivo-phone-new-menu) :where(*) { scrollbar-width: none; }
.mivo-play-design :is(#script-dialog, .ot-avatar-sheet, .mivo-phone-new-menu)::-webkit-scrollbar,
.mivo-play-design :is(#script-dialog, .ot-avatar-sheet, .mivo-phone-new-menu) *::-webkit-scrollbar { display: none; }

/* All play cards use the same inset frame; map and graph keep their own interaction surface. */
body.mivo-play-design :is(#script-dialog.script-dialog[open], #script-dialog.script-dialog.is-ot-portrait[open][aria-describedby]) {
    --sheet-limit: min(572px, 75vh, calc(var(--sheet-visible, var(--sheet-screen)) - 24px - var(--sheet-top) - var(--sheet-bottom)));
    position: fixed;
    inset: var(--sheet-top) 0 max(var(--sheet-keyboard, 0px), var(--sheet-bottom));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: var(--sheet-width);
    min-width: 0;
    max-width: none;
    height: fit-content;
    max-height: var(--sheet-limit);
    margin: auto;
    padding: 0;
    color: var(--sheet-ink);
    background: var(--sheet-lines), var(--sheet-paper);
    border: 2px solid var(--sheet-lip);
    border-radius: 12px;
    box-shadow: var(--sheet-frame);
    overflow: hidden;
}
body.mivo-play-design.has-play-palette #script-dialog.script-dialog[open].is-script-map {
    width: min(680px, calc(100% - 28px));
}
body.mivo-play-design.has-play-palette #script-dialog.script-dialog[open][aria-describedby~="ot-cast-met-count"] {
    inset: var(--sheet-top) 0 max(var(--sheet-keyboard, 0px), var(--sheet-bottom));
    width: var(--sheet-width); height: var(--sheet-limit); margin: auto; padding: 0;
    border: 2px solid var(--sheet-lip); border-radius: 12px;
}
.mivo-play-design #script-dialog.script-dialog:not(:where(.is-script-map,.is-script-discovery,.is-ot-portrait,[aria-describedby~="ot-cast-met-count"])) > .script-dialog-head {
    flex: none;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    min-height: 0; margin: 0;
    align-items: center;
    padding: 6px var(--sheet-pad);
    background: var(--sheet-lines), var(--sheet-soft);
    border-bottom: 3px double var(--sheet-lip);
}
.mivo-play-design #script-dialog.script-dialog:not(:where(.is-script-map,.is-script-discovery,.is-ot-portrait,[aria-describedby~="ot-cast-met-count"])) > .script-dialog-head h2 {
    grid-column: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 7px;
    color: var(--sheet-ink);
    margin: 0; font-size: 16px;
    font-weight: 650;
    line-height: 1.4;
}
#script-dialog-title > .creation-icon:first-child {
    flex: none;
    box-sizing: content-box;
    width: 16px;
    height: 16px;
    padding: 0;
    color: var(--sheet-tone);
}
.mivo-play-design #script-dialog[open]:not(:where(.is-script-map,.is-script-discovery,.is-ot-portrait)) .script-dialog-head > button[data-dialog-close] {
    --main-color: inherit;
    position: static; inset: auto; transform: none;
    width: 34px; min-width: 34px;
    height: 34px; min-height: 34px;
    grid-column: 3;
    border: 1px solid var(--sheet-lip);
    border-radius: 8px;
    background: var(--sheet-face), var(--sheet-paper);
    color: var(--sheet-ink);
}
.mivo-play-design #script-dialog:not(:where(.is-script-map,.is-script-discovery,.is-script-event,.is-ot-portrait,
    [aria-describedby~="ot-cast-met-count"],.is-phone-profile,.is-phone-entry)) > #script-dialog-content {
    min-height: 0;
    padding: 10px var(--sheet-pad);
    overflow: auto;
    overscroll-behavior: contain;
}
.mivo-play-design #script-dialog-content > :first-child { margin-block-start: 0; }
.mivo-play-design #script-dialog-content > :last-child { margin-block-end: 0; }
.mivo-play-design #script-dialog :is(.script-input,.script-field select) {
    border-color: var(--sheet-rule);
    color: var(--sheet-ink);
    background-color: var(--sheet-well);
    box-shadow: var(--sheet-inset);
}
.mivo-play-design #script-dialog .script-input:focus {
    background-color: var(--sheet-paper);
    border-color: var(--sheet-tone);
}
.mivo-play-design #script-dialog :is(.script-inline-actions, .sw-row, .play-dialog-footer) > .but:not(.c-red):not(.c-red-2) {
    --main-color: inherit;
    min-height: var(--sheet-action-height);
    margin: 0;
    border-radius: 9px;
    font-weight: 600;
    white-space: normal;
}
.mivo-play-design #script-dialog .play-dialog-footer {
    flex: none;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin: 0;
    padding: 7px var(--sheet-pad) 9px;
    border-top: 3px double var(--sheet-lip);
    background: var(--sheet-paper);
}
.mivo-play-design #script-dialog .play-dialog-footer > .but { flex: none; min-height: 34px; padding: 4px 14px; font-size: 13px; }
.mivo-play-design #script-dialog .play-dialog-footer > .but.c-theme { min-width: min(96px,100%); }
.mivo-play-design #script-dialog .play-dialog-footer > .but:disabled {
    opacity: 1;
    color: var(--sheet-secondary);
    background: var(--sheet-soft);
    border-color: var(--sheet-rule);
}
.play-selection-count { margin-inline-end: auto; font-size: 13px; color: var(--sheet-secondary); }
.play-dialog-empty { margin: 0; padding: 13px 4px; text-align: center; color: var(--sheet-secondary); }

.mivo-play-design #script-dialog .sw-import-list { gap: 7px; max-height: none; overflow: visible; }
.mivo-play-design #script-dialog .sw-import-list label {
    min-height: 44px;
    margin: 0;
    padding: 5px 9px;
    gap: 9px;
    border: 1px solid var(--sheet-rule);
    border-radius: 9px;
    background: var(--sheet-paper);
    cursor: pointer;
}
.sw-import-list :is(img, .play-initial) {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
}
.sw-import-list .play-initial { display: grid; place-items: center; background: var(--sheet-soft); color: var(--sheet-ink); font-style: normal; }
.sw-import-list label > span { min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; }
.sw-import-list input[type="checkbox"] { flex: none; width: 19px; height: 19px; margin: 0; accent-color: var(--sheet-tone); }
.mivo-play-design #script-dialog .sw-import-list label.is-selected { border-color: var(--sheet-tone); background: var(--sheet-soft); }
.mivo-play-design #script-dialog .sw-import-list label.is-present { box-shadow: none; cursor: default; color: var(--sheet-secondary); }

.play-person-form { --npc-control: 36px; --npc-label: 6em; display: grid; min-width: 0; gap: 12px; }
.play-person-form .script-field { min-width: 0; margin: 0; gap: 5px; }
.play-person-form .script-field > span, .npc-field-label { font-size: 12px; line-height: 1.4; font-weight: 550; color: var(--sheet-ink); }
.mivo-play-design :is(#script-dialog,.sp-editor) .play-person-form .script-input { box-sizing: border-box; height: var(--npc-control); min-height: var(--npc-control); margin: 0; padding: 5px 9px; font-size: 16px; line-height: 1.4; }
.mivo-play-design :is(#script-dialog,.sp-editor) .play-person-form textarea.script-input { height: 54px; min-height: 48px; }
.play-person-identity { display: grid; grid-template-columns: clamp(70px, 21%, 82px) minmax(0,1fr); align-items: start; gap: 11px; }
.play-person-photo, .play-person-names { display: grid; gap: 6px; min-width: 0; }
.play-person-photo { padding-top: 3px; }
.play-person-names .script-field { gap: 3px; }
.play-person-identity .sw-edit-avatar { display: grid; place-items: center; box-sizing: border-box; width: 100%; aspect-ratio: 1; border: 3px double var(--sheet-tone); border-radius: 9px; overflow: hidden; background: var(--sheet-soft); color: var(--sheet-tone); }
.play-person-identity .sw-edit-avatar > svg { width: 30px; height: 30px; }
.play-person-identity .sw-avatar { width: 100%; height: 100%; object-fit: cover; }
.mivo-play-design #script-dialog .play-person-identity .but, .mivo-play-design .sp-editor .play-person-identity .but {
    --this-color: var(--sheet-ink);
    display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 2px 3px; gap: 3px;
    font-size: 12px; white-space: nowrap; color: var(--sheet-ink);
    border: 1px solid var(--sheet-lip); border-radius: 8px; background: var(--sheet-face), var(--sheet-soft);
}
.play-person-identity .but svg { width: 15px; height: 15px; }
.play-person-form .play-field-group { display: grid; gap: 7px; min-width: 0; margin: 0; padding: 0; border: 0; }
.play-person-form .play-field-group > h3 {
    width: 100%; margin: 0; padding: 0 0 4px;
    border: 0; border-bottom: 1px solid var(--sheet-lip); color: var(--sheet-ink); font-size: 15px; font-weight: 650;
}
.play-field-pair { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.play-person-form .play-romance {
    display: grid; grid-template-columns: auto minmax(0,1fr) minmax(0,1fr); align-items: center; gap: 7px;
    min-width: 0; margin: 0; padding: 0; border: 0;
}
.play-romance-caption { padding-inline-end: 4px; font-size: 13px; font-weight: 550; }
.play-romance label { position: relative; margin: 0; cursor: pointer; }
.play-romance input[type=radio] { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.play-romance label > span {
    display: grid; place-items: center; min-height: 32px; padding: 3px 7px;
    border: 1px solid var(--sheet-rule); border-radius: 8px; color: var(--sheet-ink);
    background: var(--sheet-face), var(--sheet-paper); box-shadow: var(--sheet-raised);
}
.play-romance input:checked + span {
    color: var(--sheet-on-tone); background: var(--sheet-tone); border-color: var(--sheet-tone); box-shadow: var(--sheet-pressed);
}
.play-romance input:focus-visible + span { outline: 2px solid var(--sheet-tone); outline-offset: 2px; }
.play-person-form .sp-visit-list .sw-row > .script-field { min-width: 0; }
.play-person-form .sp-visit-list .sw-row { grid-template-columns: minmax(0,1fr) 68px auto; }

.play-ledger { font-variant-numeric: tabular-nums; }
.play-ledger-balance {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 9px 12px; border: 1px solid var(--sheet-rule); border-radius: 10px; background: var(--sheet-soft);
}
.play-ledger-balance > span, .play-ledger-balance > strong { display: inline-flex; align-items: center; gap: 7px; }
.play-ledger-balance > span { color: var(--sheet-secondary); font-size: 13px; }
.play-ledger-balance > strong { color: var(--sheet-ink); font-size: 20px; letter-spacing: -.03em; }
.play-ledger-balance small { font-size: 12px; font-weight: 500; letter-spacing: normal; }
.play-ledger-day { margin: 12px 0 0; }
.play-ledger-day h3 { margin: 0; padding: 0 0 6px; color: var(--sheet-secondary); font-size: 13px; font-weight: 600; }
.play-ledger .gs-ledger { align-items: center; min-height: 42px; padding: 5px 0; border-color: var(--sheet-rule); }
.play-ledger .gs-ledger:last-child { border-bottom: none; }
.play-ledger-copy { display: grid; gap: 2px; min-width: 0; font-size: 14px; }
.play-ledger-copy small { font-size: 12px; color: var(--sheet-secondary); }
.play-ledger .gs-ledger b { flex: none; font-size: 16px; }
.play-ledger .is-credit { color: var(--sheet-tone); }
@supports (color: color-mix(in srgb, red, blue)) {
    .play-ledger .is-credit { color: color-mix(in srgb, var(--sheet-tone) 44%, var(--sheet-ink)); }
}

/* Keep touch controls usable inside the graph inspector, portrait sheets and contact panels. */
.mivo-play-design .sw-graph-page .sw-graph-sheet > header h3 { margin: 0; font-size: 17px; }
.mivo-play-design .sw-graph-page .sw-sheet-footer > .but,
.mivo-play-design #script-dialog .ot-avatar-actions > .but,
.mivo-play-design #script-dialog .ot-avatar-close { min-height: 34px; min-width: 34px; }
.mivo-play-design #script-dialog .ot-avatar-close { color: var(--sheet-ink); background: var(--sheet-soft); }
.mivo-play-design #script-dialog .ot-avatar-sheet > header { padding-block: 6px; border-bottom: 1px solid var(--sheet-rule); }
.mivo-play-design #script-dialog :is(.script-field select, .sw-sheet-body input, .sw-sheet-body textarea) { font-size: 16px; }
.mivo-play-design #script-dialog-content > .but { min-height: 34px; border-radius: 8px; }
.mivo-play-design #script-dialog .mivo-phone-group-member { min-height: 40px; }
@media (hover: hover) {
    .mivo-play-design #script-dialog .sw-import-list label:not(:has(:disabled)):hover,
    .mivo-play-design #script-dialog .play-dialog-footer > .but:not(:disabled):hover { border-color: var(--sheet-tone); }
}
@media (max-width: 360px) {
    .mivo-play-design #script-dialog .play-dialog-footer > .but { padding-inline: 12px; }
}

/* The game mounts these panels in several places, including the native theme's modal host. */
.mivo-play-design.has-play-palette :is(#script-dialog, .ot-avatar-sheet, .mivo-phone-new-menu, .ot-menu-sheet,
    .sp-editor, .sw-graph-sheet, .script-event-end-popover, .modal-content) {
    --theme-color: var(--sheet-tone);
    --focus-color: var(--sheet-tone);
    --main-color: var(--sheet-ink);
    --main-bg-color: var(--sheet-paper);
    --muted-color: var(--sheet-secondary);
    --main-border-color: var(--sheet-rule);
    --minor-bg-color: var(--sheet-soft);
    --script-surface: var(--sheet-paper);
    --script-line: var(--sheet-rule);
    --beauty-on-accent: var(--sheet-on-tone);
}
.mivo-play-design.has-play-palette :is(.ot-avatar-sheet[open], .mivo-phone-new-menu[open], .ot-menu-sheet,
    .sp-editor, .sw-graph-sheet, .sw-graph-inspector, .sw-graph-menu, .sw-hits, .script-event-end-popover, .modal .modal-content) {
    color: var(--sheet-ink);
    background: var(--sheet-lines), var(--sheet-paper);
    border: 2px solid var(--sheet-lip);
    border-radius: 12px;
    box-shadow: var(--sheet-frame);
}
.mivo-play-design.has-play-palette #script-dialog.script-dialog[open] {
    border-color: var(--sheet-lip);
    box-shadow: var(--sheet-frame);
}
.mivo-play-design.has-play-palette #script-dialog:is(.is-ot-portrait, .is-phone-profile, .is-phone-entry, .is-script-event, [aria-describedby~="ot-cast-met-count"]) {
    background-image: var(--sheet-lines);
}
.mivo-play-design.has-play-palette .sw-graph-page .sw-graph {
    --graph-accent: var(--sheet-tone);
    --graph-warm: var(--sheet-tone);
    --graph-paper: var(--sheet-paper);
    --graph-board: var(--sheet-canvas);
    --graph-rule: var(--sheet-rule);
    --graph-ink: var(--sheet-ink);
    --graph-muted: var(--sheet-secondary);
}
.mivo-play-design.has-play-palette .modal-content {
    --muted-bg-color: var(--sheet-soft);
    --main-shadow: none;
}
.mivo-play-design #script-dialog .ot-avatar-sheet > header,
.mivo-play-design .sw-graph-sheet > header,
.mivo-play-design .sp-editor > header {
    color: var(--sheet-ink);
    background-color: var(--sheet-soft);
    border-bottom: 3px double var(--sheet-lip);
}
.mivo-play-design .sp-editor .script-field > span { color: var(--sheet-ink); }
.mivo-play-design .sp-editor :is(.script-input, select) {
    color: var(--sheet-ink); background: var(--sheet-well); border: 1px solid var(--sheet-rule); box-shadow: var(--sheet-inset);
}
.mivo-play-design .sp-editor button.but { color: var(--sheet-ink); background: var(--sheet-soft); }
.mivo-play-design .sp-editor button.c-theme { color: var(--sheet-on-tone); background: var(--sheet-tone); }
/* Put the hard edge on the card or image frame, outside its caption. */
.mivo-play-design #script-dialog :is(.ot-personal-card, .ot-contact-looks, .script-discovery-upload,
    .sw-edit-avatar, .sw-import-list label, .play-ledger-balance),
.mivo-play-design #script-dialog .ot-look-tile > :is(img,svg,i),
.mivo-play-design #script-dialog .ot-cast-card {
    box-shadow: var(--sheet-raised);
}
.mivo-play-design #script-dialog[aria-describedby="ot-contact-name"] .ot-contact-looks {
    box-sizing: border-box; padding: 10px; border: 1px solid var(--sheet-rule);
    border-radius: 9px; background: var(--sheet-paper);
}
.mivo-play-design #script-dialog .ot-cast-card {
    margin: 0 0 8px; padding: 9px; border: 1px solid var(--sheet-rule); border-radius: 9px; background: var(--sheet-paper);
}
.mivo-play-design #script-dialog .ot-look-tiles .ot-look-tile { row-gap: 6px; }
.mivo-play-design #script-dialog :is(.ot-personal-name, .ot-look-tile, .ot-look-tile > span,
    .ot-personal-info > summary, .ot-personal-row, .ot-carry-toggle, .ot-look-selected) {
    box-shadow: none; text-shadow: none;
}
.mivo-play-design.has-play-palette #script-dialog.script-dialog[open] .script-dialog-head > [data-dialog-close],
.mivo-play-design.has-play-palette :is(.ot-avatar-sheet > header > .ot-avatar-close, .sp-editor > header > .sw-icon,
    .sw-graph-sheet > header > .sw-icon, .sw-inspector-heading > .sw-icon, .sw-graph-hint > .sw-icon,
    .meo-engine-sheet .meo-engine-close, .mivo-save-detail-dialog .mivo-save-close, .modal-content .close[data-dismiss=modal]) {
    display: inline-grid; place-items: center; box-sizing: border-box; flex: none;
    width: 34px; height: 34px; min-width: 34px; min-height: 34px; padding: 0;
    border: 1px solid var(--sheet-lip); border-radius: 6px; background: var(--sheet-face),var(--sheet-paper);
    color: var(--sheet-ink); box-shadow: var(--sheet-raised);
}
.mivo-play-design #script-dialog .script-dialog-head > [data-dialog-close] > svg,
.mivo-play-design .ot-avatar-sheet > header > .ot-avatar-close > svg {
    display: block; width: 16px; height: 16px; margin: 0; padding: 0; transform: none;
}
.mivo-play-design.has-play-palette :is(#script-dialog,.sw-graph-sheet,.sp-editor)
    :is(button.but,a.but):where(:not(.ot-personal-name,.ot-look-tile,.ot-personal-row,.ot-cast-card)):not(:disabled) {
    box-shadow: var(--sheet-raised);
}
.mivo-play-design.has-play-palette :is(#script-dialog,.sw-graph-sheet,.sp-editor)
    :is(button.but,a.but):where(:not(.ot-personal-name,.ot-look-tile,.ot-personal-row,.ot-cast-card)):not(:disabled):active {
    box-shadow: var(--sheet-pressed);
}
.mivo-play-design.has-play-palette :is(.play-dialog-footer > .but, [data-dialog-close], .sp-editor > .sw-row > .but,
    .sw-sheet-footer > .but, .script-event-composer > button[type=submit]):not(:disabled) {
    box-shadow: var(--sheet-raised);
}
.mivo-play-design.has-play-palette :is(.play-dialog-footer > .but, [data-dialog-close], .sp-editor > .sw-row > .but,
    .sw-sheet-footer > .but, .script-event-composer > button[type=submit]):not(:disabled):active {
    box-shadow: var(--sheet-pressed);
}
.mivo-play-design.has-play-palette :is(#script-dialog, .sp-editor, .mivo-phone-new-menu, .ot-menu-sheet, .modal-content)
    :is(button:disabled, [aria-disabled=true], [role=button][aria-disabled=true]) { box-shadow: none; }
.mivo-play-design #script-dialog .play-dialog-footer > .but:not(:disabled):active,
.mivo-play-design .sp-editor > .sw-row > .but:not(:disabled):active { transform: translateY(2px); }
.mivo-play-design.has-play-palette #script-dialog .play-dialog-footer > .but:not(:disabled),
.mivo-play-design .sp-editor > .sw-row > .but {
    background-image: var(--sheet-face);
    border-color: var(--sheet-lip);
}
.mivo-play-design #script-dialog .play-dialog-footer > .but.c-theme:not(:disabled) {
    background-color: var(--sheet-tone);
    color: var(--sheet-on-tone);
}
.mivo-play-design.has-play-palette :is(.ot-menu-sheet, .mivo-phone-new-menu) :is(.ot-menu-item, .mivo-phone-menu-action, .mivo-thread-option) {
    background-color: var(--sheet-paper);
    border-radius: 7px;
}
.mivo-play-design.has-play-palette :is(.ot-menu-sheet, .mivo-phone-new-menu) { padding: 7px; }
.mivo-play-design.has-play-palette .ot-menu-grid { gap: 5px; }
.mivo-play-design.has-play-palette .ot-menu-sheet button { min-height: 34px; padding: 5px 7px; }
.mivo-play-design.has-play-palette .mivo-phone-new-menu :is(.mivo-phone-menu-action,.mivo-thread-option) {
    min-height: 36px; padding: 6px 8px; gap: 7px;
}
.mivo-play-design.has-play-palette .mivo-phone-new-menu .is-group .mivo-phone-menu-icon { width: 26px; height: 26px; }
.mivo-play-design.has-play-palette .mivo-phone-new-menu .mivo-phone-choice-setting { padding: 7px 8px; }
.mivo-play-design .play-person-form .play-person-names { min-width: 0; }
.mivo-play-design #script-dialog .play-person-form :is(textarea, input:not([type=radio]):not([type=file]), select),
.mivo-play-design.has-play-palette :is(.ot-avatar-sheet, .sw-graph-sheet, .modal-content) :is(textarea, input[type=text], input[type=number], select) {
    border: 1px solid var(--sheet-rule); border-top-color: var(--sheet-lip);
    border-radius: 8px; background-color: var(--sheet-well); color: var(--sheet-ink); box-shadow: var(--sheet-inset);
}
.mivo-play-design #script-dialog .play-person-form .script-input:focus,
.mivo-play-design .sp-editor .script-input:focus {
    outline: 2px solid var(--sheet-tone); outline-offset: 1px; background: var(--sheet-paper);
}

.mivo-play-design .sp-frame > .sp-editor { box-sizing: border-box; width: calc(100% - 28px); max-width: 414px; max-height: min(572px, 75%, calc(100% - var(--sp-top) - var(--sp-bottom))); padding: 11px 13px; gap: 8px; }
.npc-note-fields { display: grid; gap: 8px; padding-top: 8px; }
.npc-person-notes > summary, .npc-place-picker > summary { display: flex; align-items: center; gap: 6px; list-style: none; cursor: pointer; }
.npc-person-notes > summary::-webkit-details-marker, .npc-place-picker > summary::-webkit-details-marker { display: none; }
.mivo-play-design :is(#script-dialog,.sp-editor) .npc-person-notes > summary {
    min-height: 34px; justify-content: space-between; padding: 4px 9px;
    color: var(--sheet-ink); background: var(--sheet-soft); font-weight: 600; font-size: 13px; border: 1px solid var(--sheet-rule); border-radius: 7px;
}
.npc-person-notes > summary svg, .npc-place-picker > summary svg, .npc-place-static svg, .npc-visit-head svg, .npc-place-options button svg { flex: none; width: 15px; height: 15px; }
.npc-person-notes[open] > summary svg, .npc-place-picker[open] > summary svg:last-child { transform: rotate(180deg); }
.play-field-group > .npc-place-field, .play-person-form .npc-age-row > .script-field {
    display: grid; grid-template-columns: var(--npc-label) minmax(0,1fr); align-items: baseline; gap: 6px;
}
.npc-place-field, .npc-place-picker, .npc-age-row > .script-field { min-width: 0; }
.npc-place-picker > summary, .npc-place-static {
    display: flex; align-items: center; gap: 6px; min-width: 0; min-height: var(--npc-control); padding: 4px 8px;
    border: 1px solid var(--sheet-rule); border-radius: 7px; background: var(--sheet-well); color: var(--sheet-ink); font-size: 14px;
}
.npc-place-static { color: var(--sheet-secondary); }
.npc-place-value { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npc-place-picker > summary svg:first-child, .npc-place-static svg { color: var(--sheet-secondary); }
.npc-place-options {
    display: grid; max-height: 154px; margin-top: 4px; padding: 3px; overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: none; border: 1px solid var(--sheet-lip); border-radius: 7px; background: var(--sheet-paper); box-shadow: var(--sheet-inset);
}
.npc-place-options::-webkit-scrollbar { display: none; }
.npc-place-group { padding: 4px 6px; font-size: 11px; font-weight: 600; color: var(--sheet-secondary); }
.mivo-play-design.has-play-palette :is(#script-dialog,.sp-editor) .npc-place-options button {
    display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 32px; padding: 4px 6px;
    border: 0; border-radius: 4px; background: transparent; color: var(--sheet-ink); text-align: start; overflow-wrap: anywhere; font-size: 13px; box-shadow: none;
}
.mivo-play-design.has-play-palette :is(#script-dialog,.sp-editor) .npc-place-options button:is([aria-pressed=true],:hover,:focus-visible) { background: var(--sheet-soft); }
.npc-visit-head, .npc-age-row { display: grid; align-items: center; grid-template-columns: minmax(0,1fr) auto; gap: 6px; }
.mivo-play-design :is(#script-dialog,.sp-editor) :is(.npc-age-row,.npc-visit-head) > .but {
    display: inline-flex; justify-content: center; align-items: center; gap: 3px; box-sizing: border-box;
    height: var(--npc-control); min-height: var(--npc-control); margin: 0; padding: 3px 10px; font-size: 13px; line-height: 1.2;
    color: var(--sheet-ink); background: var(--sheet-face), var(--sheet-soft); border: 1px solid var(--sheet-lip); border-radius: 7px;
}
.npc-visits .sp-visit-list .sw-row { grid-template-columns: minmax(0,1fr) 54px 32px; align-items: start; margin: 6px 0 0; }
.sp-visit-list .npc-place-field { display: grid; gap: 5px; }
.mivo-play-design :is(#script-dialog,.sp-editor) .sp-visit-list .sw-icon { width: 32px; height: var(--npc-control); min-height: 0; margin-top: 22px; }
.npc-age-row > .script-field { align-items: center; }

/* Keep the controls of short forms aligned while long stories and lists scroll independently. */
.mivo-play-design #script-dialog:not(.is-npc-editor) #script-dialog-content > .script-field {
    gap: 4px; margin: 0 0 9px;
}
.mivo-play-design #script-dialog:not(.is-npc-editor) #script-dialog-content > .script-field:last-child { margin-bottom: 0; }
.mivo-play-design #script-dialog:not(.is-npc-editor) .script-field > span { font-size: 12px; font-weight: 550; }
.mivo-play-design #script-dialog:not(.is-npc-editor) .script-field > .script-input {
    box-sizing: border-box; width: 100%; min-width: 0; min-height: 36px; margin: 0;
    padding: 5px 9px; border-radius: 7px; font-size: 16px; line-height: 1.4;
}
.mivo-play-design #script-dialog:not(.is-npc-editor) .script-field > textarea.script-input {
    height: 70px; min-height: 48px; resize: vertical;
}
.mivo-play-design #script-dialog:not(.is-npc-editor) .script-field > select.script-input {
    -webkit-appearance: none; appearance: none; padding-inline-end: 28px;
    background-image: linear-gradient(45deg,transparent 50%,currentColor 50%), linear-gradient(135deg,currentColor 50%,transparent 50%);
    background-position: calc(100% - 13px) center, calc(100% - 9px) center;
    background-size: 4px 4px; background-repeat: no-repeat;
}
.mivo-play-design #script-dialog:not(.is-npc-editor) .script-inline-actions {
    align-items: end; gap: 7px; margin-block: 7px;
}
.mivo-play-design #script-dialog .script-check {
    display: flex; align-items: center; min-height: 34px; gap: 8px; margin: 0; font-size: 14px;
}
.mivo-play-design #script-dialog .script-check input { flex: none; margin: 0; accent-color: var(--sheet-tone); }
.mivo-play-design #script-dialog .play-event-options { display: grid; gap: 10px; }
.mivo-play-design #script-dialog .play-event-options .script-field {
    display: grid; grid-template-columns: minmax(0,1fr) minmax(7em,auto); gap: 8px; align-items: center; margin: 0;
}
.mivo-play-design #script-dialog .play-event-options .script-check {
    justify-content: space-between; padding-bottom: 5px; border-bottom: 1px solid var(--sheet-rule);
}
.mivo-play-design #script-dialog .play-event-options .script-check input { width: 18px; height: 18px; }
.mivo-play-design #script-dialog .play-event-options .script-field > span { font-size: 14px; font-weight: 400; }
.mivo-play-design #script-dialog .play-event-options .script-check small { display: block; margin: 3px 0 2px; color: var(--sheet-secondary); font-size: 12px; }
.mivo-play-design #script-dialog:is(.is-phone-profile,.is-phone-entry,.is-ot-portrait) #script-dialog-content {
    min-height: 0; padding: 10px var(--sheet-pad); overflow: auto; overscroll-behavior: contain;
}
.mivo-play-design #script-dialog.is-script-event > #script-dialog-content {
    display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden;
}
.mivo-play-design #script-dialog.is-script-event .script-event-dialog-scroll { min-height: 0; overflow-y: auto; padding: 10px var(--sheet-pad); }
.mivo-play-design #script-dialog.is-script-event .script-event-composer { padding: 7px var(--sheet-pad) 9px; }
.mivo-play-design #script-dialog.is-script-event .script-event-composer .script-field > textarea.script-input {
    height: 40px; min-height: 40px; max-height: 80px;
}
.mivo-play-design #script-dialog.is-script-event .script-event-composer > button[type=submit] { min-height: 40px; }
.mivo-play-design #script-dialog.is-script-event .script-choice-list .but { min-height: 36px; padding: 6px 9px; }
body.mivo-play-design #script-dialog.script-dialog.is-script-event.has-event-end-menu[open] { height: var(--sheet-limit); }
.mivo-play-design #script-dialog.is-script-event.has-event-end-menu > #script-dialog-content,
.mivo-play-design #script-dialog.is-script-event.has-event-end-menu .script-event-dialog-scroll { flex: 1; }
.mivo-play-design .script-event-end-popover { width: min(300px,calc(100vw - 64px)); }
.mivo-play-design #script-dialog.is-script-event .script-event-end-popover { max-height: max(72px,calc(var(--sheet-limit) - 124px)); }
.mivo-play-design .script-event-end-heading { padding: 7px 10px; gap: 8px; }
.mivo-play-design .script-event-end-symbol { width: 32px; height: 32px; border-radius: 8px; }
.mivo-play-design .script-event-end-symbol .creation-icon { width: 17px; height: 17px; }
.mivo-play-design .script-event-end-heading h3 { font-size: 15px; }
.mivo-play-design .script-event-end-body { padding: 8px 10px; }
.mivo-play-design .script-event-end-section + .script-event-end-section { margin-top: 9px; padding-top: 8px; }
.mivo-play-design .script-event-end-section > p { margin-bottom: 6px; }
.mivo-play-design .script-event-end-popover .but { min-height: 34px; padding: 5px 9px; border-radius: 7px; font-size: 13px; }
.mivo-play-design #script-dialog.is-script-map #script-dialog-content { min-height: 0; overflow-y: auto; }
.mivo-play-design #script-dialog .script-map-viewport { max-height: calc(var(--sheet-limit) - 4px); }
.mivo-play-design .sw-graph-page .sw-graph-sheet > header, .mivo-play-design .sw-graph-page .sw-sheet-footer { padding: 7px 10px; }
.mivo-play-design #script-dialog .sw-sheet-body { padding: 9px 11px; gap: 7px; }
.mivo-play-design .sw-graph-page .sw-graph :is(.sw-inspector-footer,.sw-sheet-footer) > .c-theme { color: var(--sheet-on-tone); }
.mivo-play-design #script-dialog .ot-avatar-sheet[open] {
    inset: var(--sheet-top) 0 max(var(--sheet-keyboard,0px),var(--sheet-bottom));
    width: var(--sheet-width); max-height: var(--sheet-limit); overflow: hidden;
}
.mivo-play-design #script-dialog .ot-avatar-editor { gap: 8px; padding: 9px var(--sheet-pad); }
.mivo-play-design .ot-menu-sheet, .mivo-play-design .mivo-phone-new-menu[open] { max-height: min(360px,60vh); overflow-y: auto; }
.mivo-play-design.has-play-palette .modal.in .modal-dialog {
    box-sizing: border-box; width: min(414px,calc(100vw - 28px)); max-width: none;
    margin: auto; padding: 0;
}
.mivo-play-design.has-play-palette .modal.in.flex { align-items: center; }
.mivo-play-design.has-play-palette .modal.meo-engine-modal.in .meo-engine-native.modal-dialog { margin: auto !important; }
.mivo-play-design.has-play-palette .modal.in .modal-content {
    max-height: min(572px,75vh,calc(var(--sheet-screen) - var(--sheet-top) - var(--sheet-bottom) - 24px));
    overflow: auto; overscroll-behavior: contain;
}
.mivo-play-design.has-play-palette .modal-content .meo-engine-sheet {
    --engine-edge: var(--sheet-pad); --meo-bg: var(--sheet-paper); --meo-text: var(--sheet-ink);
    --meo-accent: var(--sheet-tone); --meo-muted: var(--sheet-secondary); --meo-line: var(--sheet-rule);
    max-height: min(568px,calc(75vh - 4px),calc(var(--meo-engine-vh,var(--sheet-screen)) - var(--sheet-top) - var(--sheet-bottom) - 28px));
}
.mivo-play-design.has-play-palette .modal-content .meo-engine-save { color: var(--sheet-on-tone); }

@media (prefers-reduced-motion: reduce) {
    .mivo-play-design.has-play-palette :is(#script-dialog, .sp-editor, .mivo-phone-new-menu, .ot-menu-sheet, .modal-content) :is(button, a.but, summary) { transition: none; }
    .mivo-play-design #script-dialog .play-dialog-footer > .but:not(:disabled):active { transform: none; }
}

/* Keep related actions together on the narrow play sheets. */
.mivo-play-design #script-dialog :is(.play-world-appearance,.play-world-links) {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); gap: 6px; margin: 8px 0 0;
}
.mivo-play-design #script-dialog :is(.play-world-appearance,.play-world-links) > :is(.but,label) {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 0;
    height: 36px; min-height: 36px; margin: 0; padding: 3px; box-sizing: border-box; font-size: 13px; line-height: 1.2;
}
.mivo-play-design #script-dialog .sw-world-color {
    position: relative; color: var(--sheet-ink); background: var(--sheet-face),var(--sheet-soft);
    border: 1px solid var(--sheet-rule); border-radius: 8px; box-shadow: var(--sheet-raised); cursor: pointer;
}
.mivo-play-design #script-dialog .sw-world-color input[type=color] {
    box-sizing: border-box; width: 18px; height: 18px; min-width: 0; margin: 0; padding: 0; cursor: pointer;
}
.mivo-play-design #script-dialog:not(.is-npc-editor) .play-search-tools {
    display: flex; flex-wrap: nowrap; gap: 5px; align-items: flex-end;
}
.mivo-play-design #script-dialog .play-search-tools .script-field { flex: 1 1 0; min-width: 0; margin: 0; }
.mivo-play-design #script-dialog .play-search-tools :is(.but,input) {
    box-sizing: border-box; min-width: 0; min-height: 36px; height: 36px; margin: 0;
}
.mivo-play-design #script-dialog .play-search-tools .but { flex: none; padding: 3px 7px; line-height: 1.2; }

.mivo-play-design.has-play-palette .sw-person-scene :is(.sw-icon,.sp-pill,.sp-place) {
    color: var(--sheet-ink); background: var(--sheet-face),var(--sheet-soft);
    border-color: var(--sheet-rule); box-shadow: var(--sheet-raised);
}
.mivo-play-design.has-play-palette .sw-person-scene .sw-icon {
    display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.mivo-play-design.has-play-palette .sw-person-scene .sp-act {
    color: var(--sheet-on-tone); background: var(--sheet-face),var(--sheet-tone);
    border-color: var(--sheet-rule); box-shadow: var(--sheet-raised); text-shadow: none;
}
.mivo-play-design.has-play-palette .sw-person-scene :is(.sp-place select,.sp-place svg) { color: var(--sheet-ink); }
.mivo-play-design.has-play-palette .sw-person-scene .sp-place option { background: var(--sheet-paper); color: var(--sheet-ink); }
.mivo-play-design.has-play-palette .sw-person-scene button[aria-pressed=true] { border-color: var(--sheet-tone); box-shadow: inset 0 0 0 1px var(--sheet-tone); }
.mivo-play-design.has-play-palette .sw-person-scene :is(.sp-act,.sw-icon,.sp-pill):active { box-shadow: var(--sheet-pressed); }
.mivo-play-design #script-dialog .ot-contact-looks .ot-look-detail {
    display: grid; grid-template-columns: minmax(0,1fr) max-content max-content;
    grid-template-areas: "name replace metadata" "preview cutout remove";
    grid-template-rows: auto auto; align-items: center; gap: 7px 5px;
}
.mivo-play-design #script-dialog .ot-look-selected { grid-area: name; min-width: 0; overflow-wrap: anywhere; }
.mivo-play-design #script-dialog .ot-look-preview { grid-area: preview; align-self: start; max-width: 100%; }
.mivo-play-design #script-dialog .ot-look-preview img { min-width: 0; object-fit: contain; }
.mivo-play-design #script-dialog .ot-look-replace { grid-area: replace; }
.mivo-play-design #script-dialog .ot-look-cutout { grid-area: cutout; align-self: start; }
.mivo-play-design #script-dialog .ot-look-metadata { grid-area: metadata; }
.mivo-play-design #script-dialog .ot-look-detail > .but { justify-self: stretch; }
.mivo-play-design #script-dialog .ot-look-remove-actions {
    grid-area: remove; display: grid; align-self: start; justify-self: stretch; gap: 7px;
}
.mivo-play-design #script-dialog .ot-look-detail :is(.but:not(.c-theme),.but,.ot-look-preview) {
    display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 36px; margin: 0; padding: 3px 6px;
    border: 1px solid var(--sheet-rule); border-radius: 7px; background: var(--sheet-face),var(--sheet-soft); box-shadow: var(--sheet-raised);
}
.mivo-play-design #script-dialog .ot-look-detail .ot-look-preview img { width: 28px; height: 28px; }
.mivo-play-design #script-dialog .ot-look-detail .but.c-theme { background: var(--sheet-face),var(--sheet-tone); color: var(--sheet-on-tone); }
.mivo-play-design #script-dialog .ot-avatar-sheet[open] > header {
    display: grid; grid-template-columns: 34px minmax(0,1fr) 34px; align-items: center; gap: 5px;
    padding: 6px var(--sheet-pad); border-bottom: 1px solid var(--sheet-rule);
}
.mivo-play-design #script-dialog .ot-avatar-sheet > header h2 { grid-column: 2; text-align: center; margin: 0; font-size: 16px; }
.mivo-play-design #script-dialog .ot-avatar-close {
    grid-column: 3; width: 34px; height: 34px; border: 1px solid var(--sheet-rule); border-radius: 8px;
    background: var(--sheet-face),var(--sheet-soft); color: var(--sheet-ink); box-shadow: var(--sheet-raised);
}
.mivo-play-design #script-dialog #script-dialog-content > :is(a,button).but {
    display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; box-sizing: border-box;
    min-height: 36px; margin-block: 3px; padding: 5px 9px; line-height: 1.3;
}
.mivo-play-design #script-dialog #script-dialog-content > .but + .but { margin-inline-start: 5px; }
.mivo-play-design #script-dialog .mivo-save-item { display: grid; grid-template-columns: minmax(0,1fr) auto; }
.mivo-play-design #script-dialog .mivo-save-item .mivo-save-item-actions { flex-wrap: nowrap; max-width: none; }
.mivo-play-design #script-dialog .mivo-save-file-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.mivo-play-design #script-dialog .mivo-save-file-actions > :is(label,button) {
    box-sizing: border-box; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 36px;
    margin: 0; padding: 4px; border: 1px solid var(--sheet-rule); border-radius: 7px; line-height: 1.2;
    color: var(--sheet-ink); background: var(--sheet-face),var(--sheet-soft); box-shadow: var(--sheet-raised);
}
.mivo-play-design #script-dialog .play-file-picker { position: relative; cursor: pointer; text-align: center; }
.mivo-play-design #script-dialog .play-file-picker input {
    position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer;
}
.mivo-play-design #script-dialog :is(.play-file-picker,.sw-world-color):focus-within { outline: 2px solid var(--sheet-tone); outline-offset: 2px; }
.mivo-play-design #script-dialog .play-file-picker:has(input:disabled) { opacity: .5; }

.mivo-play-design.has-play-palette #script-dialog :is(.play-world-links,.play-world-appearance,.play-search-tools,.mivo-save-item-actions,.mivo-save-confirm) > .but:not(.c-theme,.c-red,.c-red-2):not(:disabled),
.mivo-play-design.has-play-palette #script-dialog #script-dialog-content > .but:not(.c-theme,.c-red,.c-red-2):not(:disabled) {
    color: var(--sheet-ink); background: var(--sheet-face),var(--sheet-soft);
}
