@layer components {
/* Modals, popovers, toasts, command palette, lightbox */
.scrim { position: absolute; inset: 0; background: var(--scrim); backdrop-filter: blur(4px); }

.modal-wrap { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; justify-content: center; align-items: flex-start; padding: 8vh 16px 16px; }
.dialog {
  position: relative; width: min(720px, 100%); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-16);
  box-shadow: var(--shadow-dialog); overflow: hidden; animation: pop 180ms ease-out; max-height: calc(92vh - 16px); display: flex; flex-direction: column;
}
.dialog.sm { width: min(520px, 100%); }
.dialog.lg { width: min(900px, 100%); }
.d-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px 18px; border-bottom: 1px solid var(--line); }
.d-h h2 { font-family: var(--f-display); font-size: var(--fs-17); font-weight: 700; }
.d-h .sub { font-size: var(--fs-12); color: var(--fg-3); }
.d-b { padding: 18px; overflow: auto; }
.d-f { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.d-f .note { font-size: var(--fs-11-5); color: var(--fg-3); display: flex; gap: 6px; align-items: center; }

@keyframes pop { from { transform: translateY(10px) scale(0.985); opacity: 0.5; } }

.pop {
  position: fixed; z-index: var(--z-pop); background: var(--bg-4); border: 1px solid var(--line-2); border-radius: var(--r-12);
  box-shadow: var(--shadow-pop); padding: 5px; min-width: 230px; animation: pop 120ms ease-out; max-height: 70vh; overflow: auto;
}
.pop-g { font-size: var(--fs-10); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-4); font-weight: 600; padding: 8px 9px 3px; }
.pop-g.plain { text-transform: none; letter-spacing: 0; font-weight: 400; }
.pop-i { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border-radius: var(--r-7); color: var(--fg-2); font-size: var(--fs-12-5); text-align: left; }
.pop-i:hover, .pop-i.focus { background: var(--bg-5); color: var(--fg); }
.pop-i.on { color: var(--fg); }
.pop-i.on::after { content: "✓"; margin-left: auto; color: var(--accent); font-weight: 700; }
.pop-i kbd { margin-left: auto; }
.pop-i.on kbd { display: none; }
.pop-sep { height: 1px; background: var(--line-2); margin: 4px 6px; }
.pop-search { width: 100%; height: 30px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-7); padding: 0 9px; outline: none; margin-bottom: 4px; }

.toasts { position: fixed; right: 30px; bottom: 30px; display: flex; flex-direction: column; gap: 8px; z-index: var(--z-toast); pointer-events: none; width: min(360px, calc(100vw - 60px)); }
.toast { background: var(--bg-4); border: 1px solid var(--line-2); border-radius: var(--r-11); padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; box-shadow: var(--shadow-pop); animation: tin 250ms ease-out; pointer-events: auto; font-size: var(--fs-12-5); }
.toast .tx { flex: 1; min-width: 0; color: var(--fg-2); }
.toast .tx b { color: var(--fg); font-weight: 600; }
.toast .via { display: flex; align-items: center; gap: 5px; font-size: var(--fs-11); color: var(--fg-3); margin-top: 3px; }
.toast.error { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
@keyframes tin { from { transform: translateY(8px); opacity: 0.4; } }

.palette { position: relative; width: min(640px, 100%); background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--r-14); box-shadow: var(--shadow-dialog); overflow: hidden; animation: pop 180ms ease-out; }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 52px; border-bottom: 1px solid var(--line-2); color: var(--fg-3); }
.pal-in input { flex: 1; background: none; border: 0; outline: none; font-size: var(--fs-15); color: var(--fg); }
.pal-in .scope { font-size: var(--fs-11); color: var(--fg-3); border: 1px solid var(--line-2); border-radius: var(--r-6); padding: 2px 7px; white-space: nowrap; }
.pal-list { max-height: min(440px, 58vh); overflow: auto; padding: 6px; }
.pal-g { font-size: var(--fs-10-5); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-4); font-weight: 600; padding: 10px 10px 4px; }
.pal-i { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--r-8); color: var(--fg-2); }
.pal-i:hover, .pal-i.on { background: var(--bg-5); color: var(--fg); }
.pal-i .mono { font-size: var(--fs-11); color: var(--fg-3); width: 70px; flex: none; }
.pal-i .grow { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-i .hint { font-size: var(--fs-11); color: var(--fg-3); }
.pal-f { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line-2); font-size: var(--fs-11); color: var(--fg-3); flex-wrap: wrap; }
.pal-f span { display: flex; gap: 5px; align-items: center; }

.lightbox { position: fixed; inset: 0; z-index: var(--z-lightbox); background: rgb(var(--void-rgb) / 0.92); display: flex; flex-direction: column; }
.lb-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--fg-2); font-size: var(--fs-12-5); }
.lb-stage { flex: 1; overflow: hidden; display: grid; place-items: center; padding: 0 16px 16px; cursor: grab; }
.lb-stage.dragging { cursor: grabbing; }
.lb-inner { position: relative; width: min(1200px, 100%); transition: transform var(--t-base); transform-origin: center; }
.lb-inner img { display: block; width: 100%; height: auto; border-radius: var(--r-8); user-select: none; -webkit-user-drag: none; }
.lb-inner svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.zoomv { font-family: var(--f-mono); font-size: var(--fs-11-5); width: 46px; text-align: center; }

.reconnect { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: var(--z-toast); background: var(--bg-4); border: 1px solid var(--line-2); border-radius: var(--r-pill); padding: 6px 14px; font-size: var(--fs-12); color: var(--fg-2); box-shadow: var(--shadow-pop); }
.pal-i .dia { width: 10px; height: 10px; transform: rotate(45deg); border-radius: var(--r-2); background: var(--c); margin: 0 3px; flex: none; }
.pal-f .end { margin-left: auto; }
.pal-empty { margin: 10px; }
.kb-g { font-size: var(--fs-10-5); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-4); font-weight: 600; margin: 14px 0 6px; }
.kb-g:first-child { margin-top: 0; }
.kb-list { display: flex; flex-direction: column; gap: 2px; }
.kb-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: center; padding: 5px 0; font-size: var(--fs-12-5); color: var(--fg-2); }
.kb-keys { display: flex; gap: 4px; align-items: center; }
.kb-keys .or { color: var(--fg-4); }

/* Blazor's last-resort bar when the page stops updating */
#blazor-error-ui { display: none; position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: var(--z-toast); background: var(--bg-3); color: var(--fg); border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); border-radius: var(--r-12); padding: 10px 40px 10px 14px; box-shadow: var(--shadow-dialog); font-size: var(--fs-12-5); }
#blazor-error-ui .reload { color: var(--accent); margin-left: 6px; }
#blazor-error-ui .dismiss { position: absolute; right: 10px; top: 8px; color: var(--fg-3); }

/* Right-aligned detail in a menu row (a role description, an epic key). */
.pop-hint { margin-left: auto; color: var(--fg-3); font-size: var(--fs-11); }
.pop-hint.key { font-family: var(--f-mono); font-size: var(--fs-10-5); }
/* A form control sitting alone in a menu. */
.pop-field { padding: 4px 6px 6px; }
}
