/* di-fi's interface system (docs/ui-guidelines.md): tokens for type, space, shape, depth and motion, and the controls
   built from them (buttons, fields, pop-ups, switches, tables, badges, dialogs, toasts, menus). Loaded after a page's
   own styles. Colours keep their roles from app.css; this adds what controls need to be readable and to answer: a 3:1
   field edge, a focus ring, and hover and press layers. */
:root {
  --field-line: #8f897f; --focus: color-mix(in srgb, var(--accent) 55%, transparent);
  --hover: color-mix(in srgb, var(--ink) 5%, transparent); --press: color-mix(in srgb, var(--ink) 9%, transparent);
  --t-caption: 12px; --t-footnote: 13px; --t-body: 15px; --t-title3: 18px; --t-title2: 22px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --e1: 0 0 0 1px var(--line), 0 1px 2px rgba(24, 21, 15, .05);
  --e2: 0 0 0 1px var(--line), 0 8px 24px rgba(24, 21, 15, .12);
  --e3: 0 0 0 1px var(--line), 0 24px 64px rgba(24, 21, 15, .22);
  --d-fast: 120ms; --d-base: 200ms; --d-slow: 320ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-in: cubic-bezier(.4, 0, 1, 1); --ease-spring: cubic-bezier(.34, 1.36, .64, 1);
  --control-h: 36px; --control-h-sm: 30px;
  --glass: color-mix(in srgb, var(--bg) 78%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --field-line: #77726a; --focus: color-mix(in srgb, var(--accent) 70%, transparent);
    --hover: color-mix(in srgb, var(--ink) 7%, transparent); --press: color-mix(in srgb, var(--ink) 12%, transparent);
    --e1: 0 0 0 1px var(--line); --e2: 0 0 0 1px var(--line), 0 10px 30px rgba(0, 0, 0, .45); --e3: 0 0 0 1px var(--line), 0 24px 70px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --field-line: #77726a; --focus: color-mix(in srgb, var(--accent) 70%, transparent);
  --hover: color-mix(in srgb, var(--ink) 7%, transparent); --press: color-mix(in srgb, var(--ink) 12%, transparent);
  --e1: 0 0 0 1px var(--line); --e2: 0 0 0 1px var(--line), 0 10px 30px rgba(0, 0, 0, .45); --e3: 0 0 0 1px var(--line), 0 24px 70px rgba(0, 0, 0, .6);
}

/* ---- base ---- */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.num, .stat b, td.num { font-variant-numeric: tabular-nums; }

/* ---- buttons: primary, secondary, plain, destructive; every one with hover, press, focus, disabled and busy ---- */
.btn { min-height: var(--control-h); padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--field-line); background: var(--surface);
       font-size: 14px; font-weight: 550; position: relative; isolation: isolate; overflow: hidden;
       transition: background-color var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out),
                   box-shadow var(--d-fast) var(--ease-out), opacity var(--d-fast); }
.btn::after { content: ""; position: absolute; inset: 0; background: transparent; transition: background-color var(--d-fast) var(--ease-out); z-index: -1; pointer-events: none; }
.btn:hover:not(:disabled)::after { background: var(--hover); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:active:not(:disabled)::after { background: var(--press); }
.btn.small { min-height: var(--control-h-sm); padding: 0 11px; border-radius: 9px; font-size: 13px; }
.btn.primary { background: var(--accent-fill, var(--accent)); border-color: transparent; color: var(--accent-ink); font-weight: 650;
               box-shadow: 0 1px 2px color-mix(in srgb, var(--accent-fill, var(--accent)) 35%, transparent); }
.btn.primary:hover:not(:disabled)::after { background: color-mix(in srgb, var(--accent-ink) 12%, transparent); }
.btn.primary:active:not(:disabled)::after { background: color-mix(in srgb, #000 12%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--ink); background: transparent; }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: transparent; color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::before { content: ""; position: absolute; width: 16px; height: 16px; left: calc(50% - 8px); top: calc(50% - 8px); border-radius: 50%;
                                  border: 2px solid var(--muted); border-right-color: transparent; animation: ui-spin .7s linear infinite; }
.btn.primary[aria-busy="true"]::before { border-color: var(--accent-ink); border-right-color: transparent; }
.icon-btn { transition: background-color var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out); }
.icon-btn:active { transform: scale(.94); }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ---- fields and pop-up menus ---- */
select, input[type=text], input[type=password], input[type=number], input[type=search], input[type=email], input:not([type]), textarea {
  min-height: var(--control-h); border: 1px solid var(--field-line); border-radius: var(--r-md); background: var(--raised); padding: 7px 12px;
  transition: border-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast) var(--ease-out), background-color var(--d-fast); }
textarea { min-height: 84px; line-height: 1.5; }
select:hover, input:hover:not(:disabled):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), textarea:hover { border-color: color-mix(in srgb, var(--field-line) 60%, var(--ink)); }
select:focus, input:focus, textarea:focus { outline: none; }
select:focus-visible, input:focus-visible:not([type=checkbox]):not([type=radio]):not([type=range]), textarea:focus-visible,
select:focus, input[type=text]:focus, input[type=password]:focus, input[type=number]:focus, input[type=search]:focus, input:not([type]):focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input::placeholder, textarea::placeholder { color: var(--subtle); opacity: 1; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; text-overflow: ellipsis;
         background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 1.8l3 2.7M3 7.5l3 2.7 3-2.7'/%3E%3C/svg%3E");
         background-repeat: no-repeat; background-position: right 12px center; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); }
/* a switch: a checkbox marked .toggle, for settings that take effect at once */
input[type=checkbox].toggle { appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 999px; flex: none; cursor: pointer; margin: 0;
  background: color-mix(in srgb, var(--ink) 18%, var(--raised)); position: relative; transition: background-color var(--d-base) var(--ease-out); }
input[type=checkbox].toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform var(--d-base) var(--ease-spring); }
input[type=checkbox].toggle:checked { background: var(--accent-fill, var(--accent)); }
input[type=checkbox].toggle:checked::after { transform: translateX(16px); }

/* ---- segmented control ---- */
.seg { padding: 3px; gap: 2px; border-radius: 11px; background: var(--chip); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border-radius: 8px; transition: background-color var(--d-fast) var(--ease-out), color var(--d-fast), box-shadow var(--d-fast); }
.seg button:hover:not([aria-pressed="true"]) { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--e1); }

/* ---- pills (filters) ---- */
.pill { min-height: 30px; padding: 4px 13px; transition: background-color var(--d-fast) var(--ease-out), border-color var(--d-fast), color var(--d-fast); }
.pill:hover:not(.active) { border-color: var(--field-line); }

/* ---- badges: status reads without colour (a dot) ---- */
.badge { font-size: var(--t-caption); font-weight: 600; padding: 2px 9px; gap: 5px; line-height: 18px; }
.badge.ok::before, .badge.bad::before, .badge.warn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.bad::before { border-radius: 1px; transform: rotate(45deg); }  /* (a diamond for problems, a dot for good news) */

/* ---- tables ---- */
.ui-table, .admin table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-footnote); }
.ui-table th, .admin table th { position: sticky; top: 0; z-index: 1; background: var(--surface); font-size: var(--t-caption); font-weight: 600; color: var(--muted);
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ui-table td, .admin table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ui-table tbody tr, .admin table tbody tr { transition: background-color var(--d-fast); }
.ui-table tbody tr:hover, .admin table tbody tr:hover { background: var(--hover); }
.ui-table td.num, .ui-table th.num { text-align: right; }

/* ---- cards and panels ---- */
.panel { border: 0; box-shadow: var(--e1); }
.card, .acct, .cos-card { transition: box-shadow var(--d-base) var(--ease-out), transform var(--d-base) var(--ease-out); }
.acct, .cos-card { border: 0; box-shadow: var(--e1); border-radius: var(--r-lg); }
.cos-card:hover, .acct:hover { box-shadow: var(--e2); }

/* ---- dialogs (ui.js: confirm, prompt, alert): one short task over a softened page ---- */
.ui-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: var(--s4);
  background: color-mix(in srgb, var(--bg) 40%, rgba(0, 0, 0, .45)); backdrop-filter: blur(6px) saturate(1.1); -webkit-backdrop-filter: blur(6px) saturate(1.1);
  animation: ui-fade var(--d-base) var(--ease-out); }
.ui-dialog { width: min(440px, 100%); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--e3); padding: var(--s5);
  display: flex; flex-direction: column; gap: var(--s3); animation: ui-pop var(--d-slow) var(--ease-spring); }
.ui-dialog h2 { margin: 0; font: 650 var(--t-title3)/1.3 var(--display-font); letter-spacing: -.01em; }
.ui-dialog p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; white-space: pre-line; }
.ui-dialog label { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-footnote); color: var(--muted); }
.ui-dialog .ui-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s2); }
.ui-backdrop.leaving { animation: ui-fade-out 140ms var(--ease-in) forwards; }
.ui-backdrop.leaving .ui-dialog { animation: ui-pop-out 140ms var(--ease-in) forwards; }
@keyframes ui-fade { from { opacity: 0; } }
@keyframes ui-fade-out { to { opacity: 0; } }
@keyframes ui-pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }
@keyframes ui-pop-out { to { opacity: 0; transform: scale(.98); } }

/* ---- toasts: confirmations and errors, in the page ---- */
.ui-toasts { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 95;
  display: flex; flex-direction: column; align-items: center; gap: var(--s2); pointer-events: none; width: min(520px, calc(100% - 32px)); }
.ui-toast { pointer-events: auto; display: flex; align-items: center; gap: var(--s3); padding: 10px 12px 10px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--ink) 92%, transparent); color: var(--bg); font-size: 14px; box-shadow: var(--e2);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: ui-rise var(--d-base) var(--ease-out); max-width: 100%; }
.ui-toast.bad { background: var(--bad); color: #fff; }
.ui-toast span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ui-toast button { border: 0; background: none; color: inherit; font: inherit; font-weight: 650; cursor: pointer; padding: 4px 8px; border-radius: 8px; opacity: .9; }
.ui-toast button:hover { background: color-mix(in srgb, currentColor 14%, transparent); opacity: 1; }
.ui-toast.leaving { animation: ui-sink 160ms var(--ease-in) forwards; }
@keyframes ui-rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes ui-sink { to { opacity: 0; transform: translateY(8px); } }

/* ---- menus (More ⋯): a list of actions grown from their button ---- */
.ui-menu { position: fixed; z-index: 92; min-width: 200px; max-width: 300px; padding: 6px; border-radius: 14px; background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); box-shadow: var(--e2);
  display: flex; flex-direction: column; gap: 1px; animation: ui-menu var(--d-base) var(--ease-out); transform-origin: top right; }
.ui-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; color: var(--ink);
  font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.ui-menu button:hover, .ui-menu button:focus-visible { background: var(--accent); color: var(--accent-ink); outline: none; }
.ui-menu button.danger { color: var(--bad); } .ui-menu button.danger:hover, .ui-menu button.danger:focus-visible { background: var(--bad); color: #fff; }
.ui-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
@keyframes ui-menu { from { opacity: 0; transform: scale(.96) translateY(-4px); } }

/* ---- a section arriving ---- */
.ui-enter { animation: ui-enter var(--d-base) var(--ease-out); }
@keyframes ui-enter { from { opacity: 0; transform: translateY(6px); } }

/* ---- phones: 44 px hit areas ---- */
@media (max-width: 700px) {
  .btn, .btn.small { min-height: 44px; }
  select, input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]) { min-height: 44px; font-size: 16px; }
}

/* ---- people who asked for less motion or less transparency ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .btn[aria-busy="true"]::before { animation: ui-spin 1.4s linear infinite !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .ui-backdrop, .ui-toast, .ui-menu { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .ui-menu { background: var(--surface); }
}
@media (prefers-contrast: more) {
  :root { --field-line: var(--ink); --line: color-mix(in srgb, var(--ink) 45%, var(--bg)); }
}

/* ---- the admin page (docs/ui-guidelines.md section 7) ---- */
.admin .side-group { margin: 16px 10px 4px; font-size: var(--t-caption); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--subtle); }
.admin .side-group:first-child { margin-top: 0; }
.admin .side-link { transition: background-color var(--d-fast) var(--ease-out), color var(--d-fast); position: relative; }
.admin .side-link:active { transform: scale(.985); }
.admin .side-link.active { background: var(--surface); box-shadow: var(--e1); color: var(--ink); }
.admin .side-link.active svg { color: var(--accent); }
.admin .side-link:hover:not(.active) { background: var(--hover); }
.admin .section-pick { display: none; }
.admin .admin-head { position: sticky; top: 0; z-index: 6; background: var(--glass); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  max-width: none; transition: padding var(--d-base) var(--ease-out), box-shadow var(--d-base); }
.admin .admin-head > * { max-width: 1248px; }
.admin .admin-head h1 { transition: font-size var(--d-base) var(--ease-out); }
.admin .admin-head.scrolled { padding-top: 12px; padding-bottom: 10px; box-shadow: 0 1px 0 var(--line); }
.admin .admin-head.scrolled h1 { font-size: 22px; } .admin .admin-head.scrolled p, .admin .admin-head.scrolled .summary { display: none; }
.admin .summary .stat { background: var(--surface); box-shadow: var(--e1); border: 0; }
.admin .summary .stat b { font-variant-numeric: tabular-nums; }
.admin .empty-state { border-color: var(--field-line); background: color-mix(in srgb, var(--surface) 50%, transparent); }
@media (max-width: 860px) {
  .admin .admin-nav { display: none; }
  .admin .section-pick { display: block; flex: 1; min-width: 0; max-width: 360px; font-weight: 600; }
  .admin .admin-head { top: 0; }
}
@media (prefers-reduced-transparency: reduce) { .admin .admin-head { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; } }
.admin #storyPanel.no-story > :not(h2):not(.story-none) { display: none; }
.admin #storyPanel:not(.no-story) .story-none { display: none; }
@media (max-width: 860px) { .admin .admin-head { top: var(--side-h, 0px); } }
/* (the studio's name reads as a title until it's pointed at or edited) */
.fx-top .fx-name { border-color: transparent; background: transparent; }
.fx-top .fx-name:hover:not(:disabled) { border-color: var(--field-line); }
.fx-top .fx-name:focus { border-color: var(--accent); background: var(--raised); }

/* ---- filter bars over lists (admin.html filterBar) ---- */
.fbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.fbar .fbar-search { flex: 1 1 220px; max-width: 360px; }
.fbar .fbar-pick { width: auto; flex: 0 1 auto; min-width: 0; max-width: 220px; }
.fbar .fbar-count { margin-left: auto; font-size: var(--t-footnote); color: var(--subtle); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* (in a narrow side panel the filters stack: search across, the pop-ups two by two) */
.fbar-stack .fbar, #pSessions .fbar { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fbar-stack .fbar .fbar-search, #pSessions .fbar .fbar-search { grid-column: 1 / -1; max-width: none; }
.fbar-stack .fbar .fbar-pick, #pSessions .fbar .fbar-pick { max-width: none; width: 100%; }
.fbar-stack .fbar .btn, .fbar-stack .fbar .fbar-count, #pSessions .fbar .btn, #pSessions .fbar .fbar-count { grid-column: 1 / -1; justify-self: start; margin: 0; }
.admin .filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.admin .filters .fbar { flex: 1; margin: 0; }
.admin #tab-accounts .filters { margin-bottom: 16px; }

/* ---- the audit log, by day ---- */
.admin .log-day { margin: 18px 0 6px; padding: 0 10px; font: 650 var(--t-footnote)/1.3 var(--ui-font); color: var(--muted); }
.admin .log-day:first-child { margin-top: 0; }
.admin .log .entry { grid-template-columns: 64px 150px 1fr; }
.admin .log .entry time { font-variant-numeric: tabular-nums; }

/* ---- the model picker (Settings) ---- */
.model-field { display: block; }
.model-pick { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; width: 100%; min-height: 52px; padding: 7px 34px 7px 12px;
  border: 1px solid var(--field-line); border-radius: var(--r-md); background: var(--raised); color: var(--ink); cursor: pointer; text-align: left; font: inherit; position: relative;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 1.8l3 2.7M3 7.5l3 2.7 3-2.7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; transition: border-color var(--d-fast), box-shadow var(--d-fast); }
.model-pick:hover { border-color: color-mix(in srgb, var(--field-line) 60%, var(--ink)); }
.model-pick:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.model-pick b { font-weight: 600; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-pick small { font-size: var(--t-caption); color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-pick .badge { position: absolute; top: 6px; right: 30px; }
.model-pop { position: fixed; z-index: 92; display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 14px; background: var(--surface);
  box-shadow: var(--e2); animation: ui-menu var(--d-base) var(--ease-out); transform-origin: top left; }
.model-pop-list { overflow: auto; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.model-opt { display: flex; flex-direction: column; gap: 3px; text-align: left; border: 0; background: none; color: var(--ink); font: inherit; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.model-opt > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--t-footnote); }
.model-opt b { font-size: 14px; } .model-opt code { font-size: var(--t-caption); color: var(--muted); }
.model-opt:hover, .model-opt:focus-visible { background: var(--hover); outline: none; }
.model-opt.on { background: var(--accent-soft); }
.warn-text { color: var(--warn); }

/* ---- room for the work: a wider page, the header lined up with it, columns that breathe ---- */
.admin main { max-width: 1480px; }
.admin .admin-head { padding-left: max(16px, calc((100% - 1480px) / 2 + 16px)); padding-right: max(16px, calc((100% - 1480px) / 2 + 16px)); }
.admin .admin-head > * { max-width: none; }
@media (min-width: 1000px) { .admin .cols.three { grid-template-columns: minmax(300px, 340px) minmax(340px, 420px) minmax(0, 1fr); gap: 16px; } }
/* (three columns need room: on a small laptop the trace takes the whole row under the other two) */
@media (min-width: 1000px) and (max-width: 1279px) { .admin .cols.three { grid-template-columns: minmax(280px, 320px) minmax(0, 1fr); } .admin .cols.three > :nth-child(3) { grid-column: 1 / -1; } }
.admin .studio { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; }
.admin .session-row { padding: 8px 10px; gap: 12px; }
.admin .row-art { width: 56px; height: 40px; border-radius: 8px; }
.admin .row-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.admin .row-text span { font-size: var(--t-caption); color: var(--muted); }
.admin #sessions, .admin #turns { display: flex; flex-direction: column; gap: 2px; }
.admin .acct-stats { grid-template-columns: repeat(4, 1fr); }
.admin .acct-stats b { font-variant-numeric: tabular-nums; }
.admin .acct .actions { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 860px) { .admin .studio { grid-template-columns: 1fr; } }
.admin .trace-stats { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
.admin .trace-stats b { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- the player page (index.html) ---- */
/* (the story's composer keeps its own soft field: its row is the field) */
.compose-row textarea, .compose-row textarea:hover, .compose-row textarea:focus, .compose-row textarea:focus-visible {
  border: 0; background: transparent; box-shadow: none; min-height: 44px; }
.compose-row:focus-within { box-shadow: 0 0 0 3px var(--focus), 0 8px 28px -12px rgba(0, 0, 0, .35); }
body:not(.admin) .ui-toasts { bottom: calc(90px + env(safe-area-inset-bottom)); }  /* (clear of the story's composer) */
/* every custom control on the player page answers a press (buttons.md: "Always include a press state") */
body:not(.admin) :is(.tile, .clickable, .studio-card, .studio-new, .side-link, .side-story, .side-credits, .pill-btn, .builder-step, .builder-pick,
  .choice-opt, .style-card, .cosmetic, .idea, .gift, .set-icon, .set-link, .news-brief, .draft-open, .world-card, .store-item, .exit, .linkish, .byline) {
  transition: transform var(--d-fast) var(--ease-out), box-shadow var(--d-base) var(--ease-out), background-color var(--d-fast), border-color var(--d-fast); }
body:not(.admin) :is(.tile, .clickable, .studio-card, .studio-new, .world-card, .store-item, .style-card, .cosmetic, .choice-opt, .idea, .gift):active { transform: scale(.985); }
body:not(.admin) :is(.side-link, .side-story, .side-credits, .pill-btn, .builder-step, .builder-pick, .set-icon, .set-link, .news-brief, .draft-open, .exit):active { transform: scale(.97); }
/* the player page's dialogs (profile, character, a module's settings): the shared shape and arrival */
.module-dialog { border: 0; border-radius: var(--r-xl); box-shadow: var(--e3); }
.module-dialog[open] { animation: ui-pop var(--d-slow) var(--ease-spring); }
.module-dialog[open]::backdrop { animation: ui-fade var(--d-base) var(--ease-out); }
/* the sheets (settings, credits, notifications, your story): the standard easing, and their edge in dark mode */
.sheet { transition: transform var(--d-slow) var(--ease-out); }
.scrim { transition: opacity var(--d-base) var(--ease-out); }
/* pictures stay put: they can't be dragged out of the page (ui.js stops the drag where CSS can't) */
img { -webkit-user-drag: none; user-drag: none; }

/* ---- a cosmetic's 16:9 thumbnail (fx.js DiFx.thumb): the store and the admin's Cosmetics tab and studio ---- */
/* a cosmetic's 16:9 thumbnail: a small profile wearing it, moving on hover */
.cthumb { --fx-accent: #873bc4; --fx-tint: #dea44e; position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden;
          background: var(--bg); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6%; padding: 5%; box-sizing: border-box; }
.cthumb-banner { position: relative; flex: 0 0 34%; min-height: 0; border-radius: 6px; overflow: hidden; background: linear-gradient(135deg, var(--fx-tint), var(--fx-accent)); }
.cthumb-banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 2.4s ease-out; }
.cthumb-who { display: flex; align-items: center; gap: 4%; margin-top: -9%; padding-left: 4%; }
.cthumb-who i { width: 15%; aspect-ratio: 1; border-radius: 50%; background: var(--fx-accent); border: 2px solid var(--bg); position: relative; z-index: 1; }
.cthumb-who span { width: 35%; height: 7px; border-radius: 4px; background: color-mix(in srgb, var(--fx-accent) 55%, var(--ink)); margin-top: 6%; }
.cthumb-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4%; flex: 1; }
.cthumb-cards i { border-radius: 5px; background: color-mix(in srgb, var(--fx-accent) 16%, var(--raised)); border: 1px solid var(--line); }
/* a banner's thumbnail is its picture: the whole of it, with the profile's avatar and name over its corner */
.cthumb.kind-banner { padding: 0; } .cthumb.kind-banner .cthumb-banner { flex: 1; border-radius: 0; }
.cthumb.kind-banner .cthumb-cards { display: none; }
.cthumb.kind-banner .cthumb-who { position: absolute; left: 4%; bottom: 6%; width: 50%; margin: 0; padding: 0; z-index: 1; }
.cthumb.kind-banner .cthumb-who span { background: rgba(255,255,255,.85); margin: 0; box-shadow: 0 1px 6px rgba(0,0,0,.4); }
.cthumb .banner-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.fx-sweep { position: absolute; inset: 0; pointer-events: none; z-index: 1;
            background: linear-gradient(105deg, transparent 30%, color-mix(in srgb, var(--fx-tint) 60%, #fff) 50%, transparent 70%);
            mix-blend-mode: screen; animation: fx-sweep 1.6s ease-out forwards; }
@keyframes fx-sweep { from { transform: translateX(-100%); opacity: .9; } to { transform: translateX(100%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fx-sweep { display: none; } .cthumb-banner img { transition: none; } }
