:root {
  /* Kryptex cabinet, dark theme (kryptex-front: _theme-switch.scss, cabinet/_sidebar.scss) */
  --bg: #0a0a0a;            /* --dark-bg-public: the frame around the page and the sidebar */
  --panel: #0f0f0f;         /* --dark: page-main */
  --raise: #161719;         /* --dark-light: cards */
  --raise-2: #1d1f22;
  --line: #1d2225;          /* --border-light */
  --line-2: #2a2f34;
  --sep: #ffffff1a;         /* .snav__sep */
  --text: #ffffff;
  --muted: rgba(194, 205, 211, 0.7);   /* .snav__item */
  --faint: rgba(150, 164, 171, 0.55);  /* .snav__label */
  --brand: #036ee9;         /* --primary */
  --brand-hover: #1a7df0;
  --brand-hi: #67adff;      /* --link */
  --brand-soft: #3992ff1c;  /* --primary-middle */
  --icon: rgba(147, 197, 253, 0.7);    /* .snav__icon svg */
  --danger: #ff6b5c;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --dock-bg: rgba(22, 23, 25, 0.92);
  --radius: 8px;            /* $border-radius */
  --btn-radius: 5px;        /* $btn-border-radius */
  --ui: "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}
.logo-dark { display: none; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 16px; height: 16px; fill: none; flex: none; }
/* Nucleo icons carry their own stroke attributes; filled shapes are marked data-stroke="none" */
svg [data-stroke="none"] { stroke: none; }
:focus-visible { outline: 2px solid var(--brand-hi); outline-offset: 2px; }
h2 { margin: 0; font-size: 14px; font-weight: 500; }
a { color: var(--brand-hi); }

/* ---------- buttons (cabinet .btn-primary) ---------- */
.btn-primary { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border: 0; border-radius: var(--btn-radius); background: var(--brand); color: #fff; font-weight: 500; font-size: 14px; letter-spacing: .005em; transition: background .15s; }
.btn-primary:hover:not(:disabled):not(.busy) { background: var(--brand-hover); }
.btn-primary:disabled { background: var(--raise-2); color: rgba(255,255,255,.35); cursor: default; }
.btn-primary svg { stroke: #fff; }

/* ---------- cabinet shell: sidebar + page-main ---------- */
.cab { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: 100vh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
/* logo centre lines up with the header buttons (16px frame + 1px border + 13.5px + 23px) */
.sidebar__logo { display: flex; align-items: center; height: 107px; padding: 0 0 0 30px; flex: none; }
.sidebar__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 12px 20px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.sidebar__foot { flex: none; padding: 12px 18px 18px 20px; border-top: 1px solid var(--sep); }
.sidebar__foot .gen { width: 100%; }
.snav__label { margin: 8px 0 12px; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.snav__sep { height: 1px; background: var(--sep); margin: 14px 0; }
.variants-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 13px; color: var(--muted); }

.page-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; margin: 16px 16px 16px 0; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.05); background: var(--panel); overflow: hidden; }
/* the panel's top edge is soft and the separator below is crisp, so the content sits 4px above centre to look centred */
.page-header { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 78px; padding: 0 22px 4px 30px; border-bottom: 1px solid var(--line); }
.page-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; padding: 20px 30px 24px; }
.card { background: var(--raise); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; }

/* breadcrumb pill = format picker (cabinet page title pill) */
.format-picker { position: relative; }
.crumb { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 0; border-radius: var(--radius); background: var(--brand-soft); color: var(--brand-hi); white-space: nowrap; font-weight: 500; transition: background .15s; }
.crumb:hover, .crumb[aria-expanded="true"] { background: rgba(57, 146, 255, 0.18); }
.format-name { display: flex; gap: 6px; }
.format-name b { font-weight: 500; }
.crumb small { font-size: 12px; color: rgba(103, 173, 255, .6); font-variant-numeric: tabular-nums; }
.crumb .chev { transition: transform .15s; }
.crumb[aria-expanded="true"] .chev { transform: rotate(180deg); }
.ratio { display: grid; place-items: center; width: 18px; height: 18px; flex: none; }
.ratio i { display: block; border: 1.5px solid currentColor; border-radius: 2px; }
.format-menu { position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; width: 340px; max-width: calc(100vw - 32px); max-height: calc(100vh - 110px); overflow: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); box-shadow: var(--shadow); }
.format-menu[hidden] { display: none; }
.format-menu button { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: var(--radius); background: none; color: var(--muted); text-align: left; }
.format-menu button:hover { background: rgba(255,255,255,.04); color: rgba(194, 205, 211, .95); }
.format-menu button.on { background: rgba(255,255,255,.06); color: #fff; }
.format-menu button .ratio { color: var(--icon); }
.format-menu button.on .ratio { color: #93c5fd; }
.format-menu .fm-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.format-menu .fm-text b { font-weight: 500; color: inherit; }
.format-menu .fm-text small { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.safe { position: absolute; pointer-events: none; border: 1.5px dashed rgba(255, 255, 255, .55); border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); z-index: 1; }
.safe[hidden] { display: none; }
.safe span { position: absolute; top: calc(100% + 6px); left: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }

/* header buttons (cabinet: 46px squares on #1a1b1d) */
.who { display: flex; align-items: center; gap: 10px; }
.m-logo { display: none; }
.head-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; min-width: 46px; padding: 0 14px; border: 0; border-radius: var(--radius); background: var(--raise); color: #fff; font-weight: 500; font-size: 13px; white-space: nowrap; transition: background .15s; }
.head-btn:hover { background: var(--raise-2); }
.head-btn.icon { padding: 0; width: 46px; }
.head-btn svg { width: 19px; height: 19px; }
.head-btn[hidden] { display: none; }
.badge.warn { color: #f2b035; box-shadow: inset 0 0 0 1px rgba(242, 176, 53, .35); }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 17px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #60a5fa, #036ee9); box-shadow: 0 0 0 2px #fff inset; text-transform: uppercase; }
.icon-btn { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 0; border-radius: var(--radius); background: none; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- sidebar form ---------- */
.obj-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.obj-tab, .obj-add { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 6px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--raise); color: var(--muted); font-size: 13px; font-weight: 500; transition: all .15s; }
.obj-tab img, .obj-tab i { width: 24px; height: 24px; border-radius: 5px; object-fit: contain; background: var(--panel); flex: none; }
.obj-tab:hover, .obj-add:hover { color: rgba(194, 205, 211, .95); background: var(--raise-2); }
.obj-tab.on { color: var(--brand-hi); background: var(--brand-soft); border-color: rgba(57, 146, 255, .45); }
.obj-x { margin-left: 2px; padding: 0 4px; border-radius: 4px; color: var(--faint); font-size: 15px; line-height: 1; }
.obj-x:hover { color: var(--danger); background: rgba(255,255,255,.06); }
.obj-add { padding: 0 12px; border-style: dashed; background: none; }
.upload-line { margin: -8px 0 14px; font-size: 12px; color: var(--faint); }
.upload-line .link { border: 0; background: none; padding: 0; color: var(--brand-hi); font-size: 12px; font-weight: 500; cursor: pointer; }
.upload-line .link:hover { text-decoration: underline; }
.upload-line .link:disabled { color: var(--faint); cursor: progress; text-decoration: none; }
.quota { margin-left: 6px; font-style: normal; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.quota.low { color: #f2b035; }
body.dropping .canvas-wrap::after { content: 'Drop the image to use it as the object'; position: absolute; inset: 12px; display: grid; place-items: center; border: 2px dashed var(--brand-hi); border-radius: 12px; background: rgba(3, 110, 233, .12); color: #fff; font-weight: 500; pointer-events: none; z-index: 5; }
.prompt { display: block; border: 1px solid var(--line); border-radius: var(--radius); background: var(--raise); transition: border-color .15s, box-shadow .15s; margin-bottom: 16px; }
.prompt:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.prompt textarea { display: block; width: 100%; border: 0; outline: none; background: none; resize: none; padding: 12px 14px 4px; font-size: 14px; line-height: 1.45; }
.prompt-hint { display: block; padding: 0 14px 10px; font-size: 11px; color: var(--faint); }
textarea::placeholder, input::placeholder { color: var(--faint); }

.group { margin-bottom: 14px; }
.group-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.group-label em { font-style: normal; font-weight: 500; color: var(--faint); margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button { height: 30px; padding: 0 11px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--raise); color: var(--muted); font-size: 13px; font-weight: 500; transition: all .15s; }
.chips button:hover { color: rgba(194, 205, 211, .95); background: var(--raise-2); }
.chips button.on { color: var(--brand-hi); background: var(--brand-soft); border-color: rgba(57, 146, 255, .45); }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatches button { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 0; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(128,128,128,.3); transition: box-shadow .15s, transform .15s; }
.swatches button:hover { transform: scale(1.08); }
.swatches button.on { box-shadow: inset 0 0 0 1px rgba(128,128,128,.3), 0 0 0 2px var(--panel), 0 0 0 4px var(--brand); }

.gen-row { display: flex; gap: 8px; margin-top: 18px; }
.mini-seg { display: flex; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--raise); border: 1px solid var(--line); }
.mini-seg button { width: 30px; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-weight: 500; font-size: 13px; }
.mini-seg button.on { background: var(--brand-soft); color: var(--brand-hi); }
.gen { overflow: hidden; }
.gen-label { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; font-variant-numeric: tabular-nums; }
.gen kbd { font: 500 11px var(--ui); opacity: .7; padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.16); }
.gen-fill { position: absolute; inset: 0 auto 0 0; width: 0; overflow: hidden; transition: width .3s linear; }
.gen.busy { background: #0b2c57; cursor: progress; }
.gen.busy .gen-fill { background: var(--brand); }
.gen.busy .gen-fill::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent); animation: sweep 1.4s ease-in-out infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.err { color: var(--danger); font-size: 12px; margin: 0 0 10px; }
.err:empty { display: none; }

.input { display: block; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--raise); outline: none; resize: vertical; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input + .input { margin-top: 8px; }
.title-input { font-size: 15px; font-weight: 500; }
.tag-input { margin-top: 8px; text-transform: uppercase; letter-spacing: .08em; font-size: 12.5px; }
.tag-input::placeholder { text-transform: none; letter-spacing: 0; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.field-hint { margin: 6px 2px 0; font-size: 11.5px; color: #F2B035; }
.field-hint:empty { display: none; }
.field-hint + .input { margin-top: 8px; }

/* ---------- stage ---------- */
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.canvas-wrap { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 28px 32px 18px; }
#canvas { display: block; border-radius: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.45); }
#canvas { touch-action: none; }
#canvas.grab { cursor: grab; }
#canvas.dragging { cursor: grabbing; }
.empty { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 24px; border-radius: 12px; border: 1px solid var(--line); background: var(--dock-bg); backdrop-filter: blur(12px); box-shadow: var(--shadow); text-align: center; pointer-events: none; }
.empty svg { width: 22px; height: 22px; color: #93c5fd; margin-bottom: 2px; }
.empty b { font-weight: 500; }
.empty span { color: var(--muted); font-size: 12px; }
.empty[hidden] { display: none; }

.dock { align-self: center; display: flex; align-items: center; gap: 4px; margin: 0 16px 16px; padding: 5px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); max-width: calc(100% - 32px); overflow-x: auto; scrollbar-width: none; }
.dock .sep { width: 1px; height: 22px; background: var(--sep); flex: none; margin: 0 3px; }
.dock-group { display: flex; gap: 2px; }
.layouts button { width: 40px; height: 32px; flex: none; padding: 5px; border: 0; border-radius: 8px; background: none; color: var(--faint); transition: background .15s, color .15s; }
.layouts button:hover { background: rgba(255,255,255,.04); color: var(--muted); }
.layouts button.on { background: rgba(255,255,255,.06); color: #93c5fd; }
.layouts svg { width: 100%; height: 100%; stroke: none; }
.layouts .frame { fill: none; stroke: currentColor; stroke-width: 5; opacity: .45; }
.layouts .t, .layouts .o { fill: currentColor; }
.layouts .b { fill: currentColor; opacity: .5; }
.bgs { gap: 4px; padding: 0 4px; }
.bg-btn { display: flex; align-items: center; gap: 3px; height: 34px; padding: 0 5px; border: 0; border-radius: 9px; background: none; color: var(--faint); transition: background .15s; }
.bg-btn:hover { background: rgba(255,255,255,.04); }
.bg-btn i { display: block; width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(128,128,128,.35); }
.bg-btn svg { width: 12px; height: 12px; }
.bg-btn.on i { box-shadow: inset 0 0 0 1px rgba(128,128,128,.35), 0 0 0 2px var(--panel), 0 0 0 4px var(--brand-hi); }
.bg-btn.on { color: var(--muted); }

.bg-pop { position: absolute; z-index: 15; width: 300px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); box-shadow: var(--shadow); }
.bg-pop[hidden], .bg-pop [hidden] { display: none; }
.bg-pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 500; }
.bg-pop-head span { display: flex; align-items: center; gap: 10px; }
.bg-pop .link { border: 0; background: none; padding: 0; color: var(--brand-hi); font-size: 12px; font-weight: 600; }
.hex-row { display: flex; gap: 8px; margin-bottom: 10px; }
.picker { position: relative; width: 42px; height: 42px; flex: none; border-radius: var(--radius); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line-2); cursor: pointer; }
.picker input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); border: 0; padding: 0; cursor: pointer; }
.hex { font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; }
.hex.bad { border-color: var(--danger); }
.bg-presets { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; justify-items: center; }
.bg-presets button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(128,128,128,.35); }
.bg-presets button.on { box-shadow: inset 0 0 0 1px rgba(128,128,128,.35), 0 0 0 2px var(--raise), 0 0 0 4px var(--brand-hi); }
.bg-meshes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bg-meshes button { display: flex; flex-direction: column; gap: 5px; padding: 4px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 11.5px; }
.bg-meshes button:hover { background: rgba(255,255,255,.04); color: var(--text); }
.bg-meshes i { display: block; aspect-ratio: 16 / 10; border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(128,128,128,.2); }
.bg-meshes button.on { color: var(--text); }
.bg-meshes button.on i { box-shadow: 0 0 0 2px var(--raise), 0 0 0 4px var(--brand-hi); }
.dice.small { height: 28px; padding: 0 10px; font-size: 12px; }
.dock-scale { display: flex; align-items: center; gap: 8px; padding: 0 6px; color: var(--muted); }
.dock-scale input { width: 76px; accent-color: var(--brand); }
.dock-scale output { width: 34px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.icon-btn.toggle.on { background: rgba(255,255,255,.06); color: #93c5fd; }
.dice { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; margin-left: 2px; border: 0; border-radius: 6px; background: var(--brand-soft); color: var(--brand-hi); font-weight: 500; white-space: nowrap; transition: background .15s; }
.dice:hover { background: rgba(57, 146, 255, 0.18); }
.dice.roll svg { animation: roll .45s cubic-bezier(.3,1.4,.5,1); }
@keyframes roll { from { transform: rotate(-180deg) scale(.7); } }

.bottom { display: flex; align-items: center; gap: 16px; padding: 12px 14px; border-top: 1px solid var(--line); }
.variants { flex: 1; display: flex; gap: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.thumb { position: relative; width: 64px; height: 64px; flex: none; padding: 5px; border-radius: var(--radius); border: 0; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .15s, transform .15s; }
.thumb:hover:not(:disabled) { transform: translateY(-2px); }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb.on { box-shadow: inset 0 0 0 2px var(--brand-hi); background: var(--brand-soft); }
.thumb:disabled { cursor: default; }
.thumb.pending, .thumb.partial { overflow: hidden; }
.thumb.pending::after, .thumb.partial::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.09) 50%, transparent 70%); background-size: 250% 100%; animation: shimmer 1.3s linear infinite; }
.thumb.partial img { filter: blur(2px) saturate(.8); opacity: .75; }
.thumb.failed { box-shadow: inset 0 0 0 1px var(--danger); }
.thumb.failed::before { content: '×'; display: grid; place-items: center; height: 100%; color: var(--danger); font-size: 22px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.hint { color: var(--faint); font-size: 12px; margin: 0; align-self: center; }

.downloads { display: flex; align-items: center; gap: 8px; flex: none; }
.download-one { background: var(--panel); }
.download-one:disabled { opacity: .45; cursor: default; }
.download { height: 46px; flex: none; gap: 10px; padding: 0 18px 0 14px; text-align: left; }
.download svg { width: 20px; height: 20px; }
.download span { display: flex; flex-direction: column; line-height: 1.2; }
.download b { font-weight: 500; }
.download small { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }

/* ---------- history ---------- */
.history { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 14px 12px; position: sticky; top: 0; background: var(--raise); z-index: 1; }
.history-head span { font-size: 11px; color: var(--faint); font-weight: 600; }
.history ol { list-style: none; margin: 0; padding: 0 10px 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.history li.hint { grid-column: 1 / -1; padding: 24px 4px; text-align: center; }
.history button { width: 100%; padding: 0; border: 0; border-radius: var(--radius); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); text-align: left; overflow: hidden; transition: box-shadow .15s; }
.history button:hover { box-shadow: inset 0 0 0 1px var(--line-2); }
.history button.on { box-shadow: inset 0 0 0 2px var(--brand-hi); }
.history .pic { position: relative; display: block; aspect-ratio: 1; padding: 8px; background: radial-gradient(circle at 50% 45%, var(--raise), var(--panel) 70%); }
.history .pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.history .count { position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--dock-bg); color: var(--muted); }
.history .meta { display: block; padding: 6px 8px 8px; }
.history b { display: block; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history small { display: block; font-size: 10.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- team dialog ---------- */
.modal { width: min(520px, calc(100vw - 32px)); max-height: min(680px, calc(100vh - 48px)); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); overflow: auto; }
.modal::backdrop { background: rgba(5, 8, 14, .6); backdrop-filter: blur(4px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 20px; }
.modal-head h2 { font-size: 18px; font-weight: 500; }
.invite { display: flex; gap: 8px; padding: 12px 20px 0; flex-wrap: wrap; }
.invite .input { flex: 1 1 200px; width: auto; }
.role-seg button { width: auto; padding: 0 10px; }
.invite-btn { flex: none; height: 44px; padding: 0 18px; }
.invite-note { margin: 8px 20px 0; font-size: 12px; color: var(--muted); }
.invite-note:empty { display: none; }
.invite-note.err-text { color: var(--danger); }
.invite-link { margin: 10px 20px 0; padding: 12px; border-radius: 10px; background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); font-size: 12px; color: var(--muted); }
.invite-link[hidden] { display: none; }
.invite-link div { display: flex; gap: 8px; margin-top: 8px; }
.invite-link .input { flex: 1; font-size: 12px; padding: 8px 10px; }
.spend { margin: 16px 20px 0; padding: 14px; border-radius: var(--radius); background: var(--raise); border: 1px solid var(--line); }
.spend[hidden] { display: none; }
.spend-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.spend-head b { font-weight: 500; }
.spend-head span { font-size: 11.5px; color: var(--faint); }
.spend-cells { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.spend-cells div { display: flex; flex-direction: column; gap: 2px; }
.spend-cells small { font-size: 11px; color: var(--faint); }
.spend-cells b { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.spend-cells span { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.members { list-style: none; margin: 16px 0 0; padding: 4px 8px 12px; border-top: 1px solid var(--line); }
.members li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; }
.members li:hover { background: var(--raise); }
.members .avatar { flex: none; }
.members .who-text { flex: 1; min-width: 0; }
.members b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.members small { display: block; font-size: 11.5px; color: var(--faint); }
.members .pending { color: #F2B035; }
.members .role { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--raise-2); color: var(--muted); border: 0; }
button.role:hover { color: var(--text); }
.members .role.admin { color: var(--brand-hi); background: var(--brand-soft); }
.members .avatar { width: 32px; height: 32px; font-size: 13px; box-shadow: none; }
.members .act { display: flex; gap: 2px; }
.members .act button { height: 28px; padding: 0 8px; border: 0; border-radius: 7px; background: none; color: var(--faint); font-size: 12px; }
.members .act button:hover { background: var(--raise-2); color: var(--text); }
.members .act button.danger:hover { color: var(--danger); }

/* ---------- key dialog ---------- */
.key-intro, .key-warn { margin: 6px 20px 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.key-intro b { color: var(--text); font-weight: 600; }
.key-warn { color: #F2B035; }
.key-warn[hidden] { display: none; }
.key-warn code { font-size: 12px; }
.key-slot { margin: 14px 20px 0; padding: 14px; border-radius: var(--radius); background: var(--raise); box-shadow: inset 0 0 0 1px var(--line); }
.key-slot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.key-slot-head b { font-weight: 600; }
.key-state { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.key-state.set { color: #3FCB8B; }
.key-form { display: flex; align-items: center; gap: 8px; }
.key-form[hidden] { display: none; }
.key-form .input { flex: 1; width: auto; background: var(--panel); font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.key-form .gen { flex: none; width: auto; height: 42px; padding: 0 16px; font-size: 13px; }
.danger-link { flex: none; border: 0; background: none; padding: 0 4px; color: var(--faint); font-size: 12px; font-weight: 600; cursor: pointer; }
.danger-link:hover { color: var(--danger); }
.danger-link[hidden] { display: none; }
.key-note { margin: 0; font-size: 12px; color: var(--faint); }
.key-note[hidden] { display: none; }
.key-err { margin: 10px 20px 0; }
.key-security { display: flex; gap: 10px; margin: 16px 0 0; padding: 14px 20px 18px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.5; color: var(--faint); }
.key-security svg { margin-top: 1px; color: var(--muted); }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px 26px; border-radius: 12px; border: 1px solid var(--line); background: var(--raise); }
.login-card .brand { margin-bottom: 24px; }
.login-card .input { margin-bottom: 10px; }
.login-card .gen { width: 100%; margin-top: 6px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 500; }
.login-card .brand { display: flex; align-items: center; gap: 12px; }
.tag { font-size: 12px; font-weight: 500; color: var(--brand-hi); padding: 4px 10px; border-radius: var(--radius); background: var(--brand-soft); white-space: nowrap; }
.login-text { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.login-text b { color: var(--text); font-weight: 600; }
.login-card [hidden] { display: none; }
.dev-link { display: block; margin-bottom: 12px; color: #F2B035; font-weight: 600; }
.login-card .link { border: 0; background: none; padding: 0; color: var(--brand-hi); font-weight: 600; cursor: pointer; }

/* ---------- responsive ---------- */
@media (max-width: 1800px) {
  #randomize span { display: none; }
  #randomize { padding: 0 10px; }
  .dock-scale input { width: 72px; }
}
@media (max-width: 1400px) {
  .crumb small { display: none; }
  .badge span { display: none; }
  #randomize span { display: none; }
  #randomize { padding: 0 10px; }
  .dock-scale input { width: 60px; }
  .dock { flex-wrap: wrap; justify-content: center; row-gap: 4px; max-width: calc(100% - 24px); }
  .page-body { grid-template-columns: minmax(0, 1fr) 220px; padding: 16px 20px 20px; }
}
@media (max-width: 1100px) {
  .cab { grid-template-columns: 280px minmax(0, 1fr); }
  .page-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .history { max-height: 220px; }
  .history ol { display: flex; overflow-x: auto; }
  .history li { flex: 0 0 120px; }
}
@media (max-width: 860px) {
  .cab { display: flex; flex-direction: column; height: auto; }
  .sidebar { order: 2; }
  .sidebar__logo { display: none; }
  .sidebar__scroll { overflow: visible; padding: 8px 16px; }
  .sidebar__foot { position: sticky; bottom: 0; background: var(--bg); padding: 12px 16px 16px; }
  .page-main { margin: 0; border-radius: 0; }
  .page-header { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .m-logo { display: block; }
  .format-picker { order: 2; width: 100%; }
  .crumb { width: 100%; }
  .crumb .chev { margin-left: auto; }
  .format-menu { width: 100%; }
  .head-btn { height: 40px; min-width: 40px; }
  .head-btn.icon { width: 40px; }
  .avatar { width: 40px; height: 40px; }
  .page-body { padding: 12px; }
  .canvas-wrap { padding: 16px 12px 12px; min-height: 62vw; }
  .dock { margin: 0 12px 12px; align-self: stretch; flex-wrap: wrap; justify-content: center; row-gap: 8px; }
  .dock .sep { display: none; }
  .empty { padding: 12px 16px; }
  .empty span { display: none; }
  .bottom { flex-wrap: wrap; }
  .downloads { width: 100%; }
  .download { flex: 1; justify-content: center; }
  .gen kbd { display: none; }
}
