/* dialogs.css: the legacy dialogs on the Deep Ink kit.
   The account, confirm, cost and testers dialogs (sv-modal markup in index.html),
   the Models panel chrome, the AI terminal, the toasts, and the stacking of the
   full-screen layers. Open and close go through SVModal (ui-v2/js/modal.js), which
   owns Escape, the backdrop click, focus and the stack depth (--sv-layer).
   Screen classes are svl-*. Loads after kit.css, so an equal selector here wins. */

/* ---------- layers ---------- */
/* Full-screen panels and admin tools share --sv-z-screen. SVModal raises each open
   layer by its stack depth, and dialogs sit on --sv-z-modal above all of them. */
#set-panel, #model-panel, #db-screen, #ailogic-screen, #board-screen, #costs-screen { z-index: calc(var(--sv-z-screen) + var(--sv-layer, 0) * 2); }

/* ---------- dialog shell ---------- */
.sv-modal > .sv-modal__panel { animation: svl-rise var(--sv-t3) var(--sv-ease) both; }
.sv-modal__panel[tabindex="-1"]:focus { outline: none; }   /* a programmatic landing spot, not a control */
.modal-actions.sv-modal__foot { margin-top: 0; }   /* the legacy .modal-actions spacing (styles.css) */
.svl-lead { margin: 0 0 var(--sv-space-4); }
.svl-start { align-self: flex-start; }
.svl-msg { margin: var(--sv-space-3) 0 0; font-family: var(--sv-font-body); font-size: var(--sv-fs-17); color: var(--sv-success); }
.svl-msg.err { color: var(--sv-danger); }
@keyframes svl-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- confirm (askConfirm) ---------- */
.svl-confirm { width: min(440px, 100%); }
.svl-confirm__msg { margin: 0; }

/* ---------- testers (admin) ---------- */
.svl-testers { width: min(520px, 100%); }
.svl-grant { display: flex; gap: var(--sv-space-2); }
.svl-grant .sv-input { flex: 1; }
.svl-list-label { margin: var(--sv-space-5) 0 0; }
.svl-list { max-height: 260px; overflow-y: auto; }
.svl-list .sv-row:last-child { border-bottom: 0; }
.svl-tester__who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svl-list .sv-hint { margin: 0; padding: var(--sv-space-2) 0; }

/* ---------- account ---------- */
.svl-account { width: min(440px, 100%); }
.svl-id { display: flex; align-items: center; gap: var(--sv-space-3); margin: 0 0 var(--sv-space-4); }
.svl-avatar { width: var(--sv-h-lg); height: var(--sv-h-lg); flex: none; display: grid; place-items: center; border: 1px solid var(--sv-line-strong); border-radius: var(--sv-r);
  background: var(--sv-surface-field); font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-19); line-height: 1; color: var(--sv-violet-bright); }
.svl-id__name { overflow-wrap: anywhere; }
.svl-id__email { overflow-wrap: anywhere; }
.svl-ink { display: flex; align-items: center; gap: var(--sv-space-2); margin: 0 0 var(--sv-space-5); padding: var(--sv-space-3) var(--sv-space-4);
  border: 1px solid var(--sv-line-2); border-radius: var(--sv-r); background: var(--sv-surface-field); color: var(--sv-violet); }
.svl-ink__n { font-size: var(--sv-fs-17); color: var(--sv-text); }
.svl-ink__label { margin-left: auto; text-align: right; }
.svl-section { margin: 0 0 var(--sv-space-4); }
.svl-section .sv-hint { margin: 0; }
.account-msg { font-family: var(--sv-font-body); font-size: var(--sv-fs-17); line-height: 1.35; color: var(--sv-text-muted); }
.account-msg:empty { display: none; }
.account-msg.ok { color: var(--sv-success); }
.account-msg.err { color: var(--sv-danger); }
.svl-danger { padding-top: var(--sv-space-3); border-top: 1px solid var(--sv-line); }
.svl-danger__toggle.sv-btn--quiet { margin-left: calc(var(--sv-space-3) * -1); color: var(--sv-danger); }
.svl-danger__toggle.sv-btn--quiet:hover { color: var(--sv-danger); border-color: color-mix(in srgb, var(--sv-danger) 45%, transparent); }
.svl-danger__confirm { margin-top: var(--sv-space-2); }
.svl-danger__note { margin: 0; color: var(--sv-danger); }
.svl-danger .sv-input:focus { border-color: var(--sv-danger); }

/* ---------- adventure cost (admin) ---------- */
.svl-cost { width: min(640px, 100%); }
.svl-cost__empty { margin: 0; padding: var(--sv-space-3) 0; text-align: center; }
.svl-cost__total { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sv-space-3); margin: 0 0 var(--sv-space-4); padding: var(--sv-space-3) var(--sv-space-4);
  border: 1px solid var(--sv-line-2); border-radius: var(--sv-r); background: var(--sv-surface-field); }
.svl-cost__usd { font-size: var(--sv-fs-24); color: var(--sv-violet-bright); }
.svl-cost__wrap { overflow-x: auto; }
.svl-cost__table { width: 100%; border-collapse: collapse; }
.svl-cost__table th { padding: var(--sv-space-2); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--sv-line-strong);
  font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-12); letter-spacing: var(--sv-ls-label); color: var(--sv-text-dim); }
.svl-cost__table td { padding: var(--sv-space-2); border-bottom: 1px solid var(--sv-line); color: var(--sv-text-soft); }
.svl-cost__table .svl-num { text-align: right; white-space: nowrap; }
.svl-cost__model { font-size: var(--sv-fs-17); color: var(--sv-text); }
.svl-cost__table .svl-usd { color: var(--sv-violet-bright); }
.svl-cost__table tfoot td { border-top: 1px solid var(--sv-line-strong); border-bottom: 0; color: var(--sv-text); }
.svl-cost__table tfoot td:first-child { font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-14); letter-spacing: var(--sv-ls-control); }

/* ---------- Models panel (#model-panel): kit chrome on the slide-in sheet ---------- */
#model-panel { position: fixed; inset: 0; pointer-events: none; color: var(--sv-text); font-family: var(--sv-font-body); }
#model-panel .sp-scrim { position: absolute; inset: 0; background: rgba(var(--sv-ground-rgb),.72); opacity: 0; pointer-events: none; transition: opacity var(--sv-t3) var(--sv-ease); }
#model-panel.full.open .sp-scrim { opacity: 1; pointer-events: auto; }
#model-panel .sp-clip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#model-panel .sp { position: absolute; inset: 0; display: flex; flex-direction: column; pointer-events: auto; background: var(--sv-surface-overlay); background-color: var(--sv-bg);
  transform: translateX(-100%); transition: transform var(--sv-t3) var(--sv-ease); }
#model-panel.open .sp { transform: none; box-shadow: var(--sv-e-overlay); }
#model-panel .sp-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--sv-space-3); min-height: var(--sv-topbar-h);
  padding: 0 var(--sv-space-5); border-bottom: 1px solid var(--sv-line); }
#model-panel .sp-body { flex: 1; overflow-y: auto; padding: var(--sv-space-5) var(--sv-space-4) var(--sv-space-7); }
#model-panel .sp-in { max-width: 620px; margin: 0 auto; }
#model-panel .mp-intro { margin: 0 0 var(--sv-space-5); font-style: italic; font-size: var(--sv-fs-17); color: var(--sv-text-muted); }
#model-panel .mp-g { margin: 0 0 var(--sv-space-5); padding: var(--sv-space-4); border: 1px solid var(--sv-line); border-radius: var(--sv-r); background: var(--sv-surface-card); box-shadow: var(--sv-e-raised); }
#model-panel .mp-eh { margin: 0; font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-17); letter-spacing: var(--sv-ls-title); color: var(--sv-text); }
#model-panel .mp-esub { margin: var(--sv-space-1) 0 var(--sv-space-2); font-style: italic; font-size: var(--sv-fs-14); color: var(--sv-text-dim); }
#model-panel .mp-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sv-space-4); padding: var(--sv-space-3) 0; border-bottom: 1px solid var(--sv-line); }
#model-panel .mp-row:last-child { border-bottom: 0; }
#model-panel .mp-t { font-size: var(--sv-fs-17); color: var(--sv-text); }
#model-panel .mp-t .mp-d { display: block; margin-top: 2px; font-style: italic; font-size: var(--sv-fs-14); color: var(--sv-text-dim); }
#model-panel .mp-subh { margin: var(--sv-space-4) 0 0; padding-top: var(--sv-space-3); border-top: 1px solid var(--sv-line);
  font-family: var(--sv-font-display); font-weight: 600; font-size: var(--sv-fs-12); letter-spacing: var(--sv-ls-label); color: var(--sv-text-dim); }
#model-panel .mp-slider-wrap { padding: var(--sv-space-3) 0 var(--sv-space-2); border-bottom: 1px solid var(--sv-line); }
#model-panel .mp-slider-wrap:last-child { border-bottom: 0; }
#model-panel .mp-slider-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sv-space-3); margin-bottom: var(--sv-space-2); }
#model-panel .mp-ctxval { font-family: var(--sv-font-mono); font-size: var(--sv-fs-12); font-variant-numeric: tabular-nums; color: var(--sv-violet-bright); }
#model-panel .mp-slider { display: block; width: 100%; height: 2px; margin: var(--sv-space-2) 0; appearance: none; -webkit-appearance: none; background: var(--sv-line-strong); border-radius: 0; outline: none; cursor: pointer; }
#model-panel .mp-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 16px; border: 1px solid var(--sv-rim); border-radius: var(--sv-r-badge); background: var(--sv-violet-bright); cursor: pointer; }
#model-panel .mp-slider::-moz-range-thumb { width: 12px; height: 16px; border: 1px solid var(--sv-rim); border-radius: var(--sv-r-badge); background: var(--sv-violet-bright); cursor: pointer; }
#model-panel .mp-slider:focus-visible { outline: var(--sv-focus); outline-offset: 6px; }
#model-panel .svl-mp-static { cursor: default; opacity: .75; }   /* read-only engine value for non-admins */

/* ---------- AI terminal (admin, backtick): a floating, draggable log window ---------- */
.ai-term { position: fixed; top: var(--sv-topbar-h); right: var(--sv-space-5); z-index: var(--sv-z-term); box-sizing: border-box;
  width: 470px; height: 300px; min-width: 300px; min-height: 140px; max-width: calc(100vw - 32px); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden; resize: both;   /* overflow other than visible is required for resize */
  background: var(--sv-surface-overlay); background-color: var(--sv-bg); box-shadow: var(--sv-e-overlay); color: var(--sv-text-muted); }   /* opaque: it floats over live text */
.ait-head { flex: none; display: flex; align-items: center; gap: var(--sv-space-2); height: var(--sv-h-md); padding: 0 var(--sv-space-1) 0 var(--sv-space-3);
  border-bottom: 1px solid var(--sv-line); cursor: move; user-select: none; }
.ait-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--sv-tint-slate); }
.ait-dot.live { background: var(--sv-success); }
.ait-title { flex: none; color: var(--sv-text-soft); }
.ait-model { flex: 1; min-width: 0; text-align: right; color: var(--sv-text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ait-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sv-space-2) var(--sv-space-3); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.ait-ev { margin-bottom: var(--sv-space-2); }
.ait-ts, .ait-dim, .ait-empty { color: var(--sv-text-dim); }
.ait-task { color: var(--sv-text); font-weight: 500; }
.ait-run { color: var(--sv-warning); }
.ait-ok { color: var(--sv-success); }
.ait-err { color: var(--sv-danger); }

/* ---------- toasts (kit sv-toast; showToast / advToast toggle [hidden]) ---------- */
/* left:50% halves the width a toast may shrink-wrap to; size it to its text instead */
#toast, #adv-toast { width: max-content; text-align: center; }
#adv-toast { bottom: 112px; }   /* clear of the adventure composer */
@media (max-width: 720px) {
  #toast { bottom: calc(var(--sv-bottombar-h) + var(--sv-space-4)); }   /* above the home's bottom bar */
  #adv-toast { top: calc(var(--sv-topbar-h) + var(--sv-space-2)); bottom: auto; }   /* the phone composer is tall, and the keyboard covers the bottom */
}
