:root {
  --bg: #0d0f0f;
  --bg-soft: #111313;
  --panel: #151717;
  --panel-hover: #191b1b;
  --line: #2b2e2d;
  --line-strong: #3a3d3c;
  --text: #f2f1ee;
  --muted: #999c99;
  --muted-2: #696d6a;
  --accent: #ff684a;
  --accent-bright: #ff785e;
  --success: #57c984;
  --bone: #ede8df;
  --radius: 12px;
  --radius-lg: 16px;
  --font: "DM Sans", system-ui, sans-serif;
  --font-ui: "Manrope", system-ui, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; font: 14px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
body::after { content: ""; position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: .025; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitchTiles'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E"); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite { position: fixed; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; clip: rect(0,0,0,0); white-space: nowrap; border: 0; overflow: hidden; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 126px minmax(0, 1fr); }
.brand-rail { position: relative; min-height: 100vh; overflow: hidden; border-right: 1px solid var(--line); padding: 26px 0 24px; background: linear-gradient(180deg, #111313 0%, #0d0f0f 100%); }
.wordmark { position: relative; z-index: 2; display: block; padding: 0 28px; color: var(--text); text-decoration: none; font: 600 21px/1 var(--font-ui); letter-spacing: .17em; }
.brand-glyph { position: absolute; z-index: 0; left: -31px; top: 76px; color: transparent; font: 400 235px/.8 Georgia, serif; -webkit-text-stroke: 1px #5b5e5b; transform: scaleX(.84); opacity: .85; }
.brand-glyph::after { content: ""; position: absolute; right: 15px; top: 13px; width: 1px; height: 265px; background: linear-gradient(180deg, transparent, var(--accent) 22%, var(--accent) 48%, transparent 80%); transform: rotate(-14deg); transform-origin: top; }
.brand-mantra { position: absolute; left: 28px; top: 260px; z-index: 2; color: #747875; text-transform: uppercase; letter-spacing: .26em; font-size: 8px; line-height: 2.1; }
.brand-version { position: absolute; left: 28px; bottom: 24px; z-index: 2; color: #858986; text-transform: uppercase; letter-spacing: .22em; font-size: 8px; line-height: 1.8; }
.brand-version span { display: block; width: 17px; height: 1px; margin-bottom: 14px; background: #9a9d9a; }

.app-main { min-width: 0; min-height: 100vh; display: grid; grid-template-rows: 62px minmax(0, 1fr); }
.topbar { border-bottom: 1px solid var(--line); display: flex; align-items: stretch; justify-content: space-between; padding: 0 28px 0 44px; background: rgba(13,15,15,.92); }
.main-nav { display: flex; gap: 42px; height: 100%; }
.nav-link { position: relative; padding: 1px 0 0; border: 0; background: none; color: var(--muted); font: 500 13px/1 var(--font-ui); }
.nav-link::after { content: ""; position: absolute; left: 0; right: 100%; bottom: -1px; height: 2px; background: var(--accent); transition: right .3s var(--ease); }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); }
.nav-link.active::after { right: 0; }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.service-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.service-state span, .ready-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(87,201,132,.11); }
.profile { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--panel); color: var(--text); font-size: 10px; }
.mobile-menu { display: none; }

.workspace { min-width: 0; min-height: 0; height: calc(100vh - 62px); }
.view { display: none; min-width: 0; min-height: 0; height: 100%; opacity: 0; transform: translateY(7px); }
.view.active { display: flex; opacity: 1; transform: none; animation: view-in .38s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(7px); } }
.view-studio { display: none; grid-template-columns: 118px minmax(390px, 460px) minmax(460px, 1fr); }
.view-studio.active { display: grid; }

.avatar-rail { min-width: 0; border-right: 1px solid var(--line); padding: 34px 18px; overflow-y: auto; }
.avatar-list { display: grid; gap: 22px; }
.avatar-card, .avatar-add { width: 100%; display: grid; justify-items: center; gap: 8px; border: 0; background: none; color: var(--muted); font-size: 11px; }
.avatar-card img, .avatar-fallback { width: 64px; height: 78px; border-radius: 6px; object-fit: cover; border: 1px solid transparent; background: #252827; transition: border .2s, transform .3s var(--ease); }
.avatar-card:hover img, .avatar-card:hover .avatar-fallback { transform: translateY(-2px); border-color: var(--line-strong); }
.avatar-card.active { color: var(--text); }
.avatar-card.active img, .avatar-card.active .avatar-fallback { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(255,104,74,.14); }
.avatar-fallback { display: grid; place-items: center; font-size: 16px; color: #a8aaa8; }
.avatar-add { margin-top: 28px; color: var(--muted); line-height: 1.35; }
.avatar-add svg { width: 22px; height: 22px; }
.avatar-add::before { content: ""; grid-row: 1; grid-column: 1; width: 64px; height: 58px; border: 1px solid var(--line-strong); border-radius: 6px; }
.avatar-add svg { grid-row: 1; grid-column: 1; align-self: center; }

.controls-panel { min-width: 0; padding: 24px 22px 20px; overflow: auto; border-right: 1px solid var(--line); }
.create-switch { display: grid; grid-template-columns: 1fr 1fr; height: 44px; border: 1px solid var(--line); border-radius: 9px; padding: 3px; background: #101212; }
.create-switch button { border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; }
.create-switch button.active { background: var(--accent); color: #130e0b; font-weight: 600; }
.selected-avatar-label { margin: 20px 0 8px; color: var(--muted); font-size: 11px; }
.avatar-select, .mini-avatar-select { width: 100%; height: 50px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 6px; }
.avatar-select img, .mini-avatar-select img { width: 36px; height: 36px; object-fit: cover; border-radius: 5px; }
.avatar-select span, .mini-avatar-select span { flex: 1; text-align: left; }
.avatar-select svg, .mini-avatar-select svg { width: 16px; margin-right: 6px; color: var(--muted); }
.generation-tabs { display: grid; grid-template-columns: 1.1fr 1.1fr .95fr .72fr; margin-top: 18px; border-bottom: 1px solid var(--line); }
.generation-tabs button { min-width: 0; height: 45px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 0 7px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 10px; white-space: nowrap; }
.generation-tabs button svg { width: 15px; height: 15px; }
.generation-tabs button:hover { color: var(--text); }
.generation-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.control-stack { margin-top: 14px; display: grid; gap: 9px; }
.control-section { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #111313; }
.section-heading { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 7px 11px; border: 0; background: transparent; text-align: left; }
.section-heading strong { font-size: 12px; font-weight: 500; }
.section-heading small { margin-left: auto; color: var(--muted); font-size: 10px; text-decoration: underline; }
.section-heading svg { margin-left: auto; width: 15px; height: 15px; color: var(--muted); transform: rotate(-90deg); transition: transform .25s var(--ease); }
.control-section.open .section-heading svg { transform: rotate(0); }
.step-number { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: #c6c8c5; font-size: 11px; }
.section-body { display: none; padding: 0 11px 11px; }
.control-section.open .section-body { display: block; animation: reveal .28s var(--ease); }
@keyframes reveal { from { opacity: 0; transform: translateY(-5px); } }
.prompt-section textarea { width: 100%; min-height: 105px; resize: vertical; border: 1px solid var(--accent); border-radius: 8px; background: #151818; color: var(--text); padding: 13px 14px 26px; font-size: 12px; line-height: 1.55; }
.prompt-section textarea:focus { outline: 0; box-shadow: 0 0 0 3px rgba(255,104,74,.08); }
.prompt-section .section-body { position: relative; }
.char-count { position: absolute; right: 22px; bottom: 19px; color: var(--muted-2); font-size: 9px; }
.char-count b { font-weight: 400; }
.character-settings { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(125px, .9fr); gap: 14px; align-items: end; }
.mini-avatar-select { height: 43px; }
.mini-avatar-select img { width: 30px; height: 30px; }
.range-field { color: var(--muted); font-size: 9px; }
.range-field span { display: flex; justify-content: space-between; margin-bottom: 7px; }
.range-field output { color: var(--text); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.compact-fields { grid-template-columns: 1fr 1fr; gap: 12px; }
.control-section.open .compact-fields { display: grid; }
.compact-fields label { display: grid; gap: 6px; color: var(--muted); font-size: 9px; }
select, input { width: 100%; height: 39px; border: 1px solid var(--line-strong); border-radius: 7px; background: #141616; color: var(--text); padding: 0 10px; font-size: 11px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m2 2 4 4 4-4' fill='none' stroke='%23999c99' stroke-width='1.3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.generate-row { display: grid; grid-template-columns: 1fr 46px; gap: 10px; margin-top: 18px; }
.primary-action { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 11px; border: 0; border-radius: 8px; background: var(--accent); color: #140d0b; font-weight: 600; transition: background .2s, transform .2s var(--ease); }
.primary-action:hover { background: var(--accent-bright); transform: translateY(-1px); }
.primary-action:disabled { cursor: wait; opacity: .72; transform: none; }
.square-action, .secondary-action { border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); color: var(--muted); }
.square-action:hover, .secondary-action:hover { background: var(--panel-hover); color: var(--text); }

.canvas-panel { position: relative; min-width: 0; min-height: 0; display: grid; grid-template-rows: 42px minmax(0, 1fr) 60px; padding: 0 20px; overflow: hidden; }
.canvas-meta { display: flex; align-items: center; justify-content: flex-end; gap: 9px; color: var(--muted); font-size: 10px; }
.canvas-meta strong { color: #d2d4d1; font-weight: 500; }
.canvas-meta i { height: 15px; width: 1px; background: var(--line-strong); }
.canvas-layout { min-height: 0; display: grid; grid-template-columns: minmax(300px, 1fr) 102px; gap: 10px; }
.output-frame { position: relative; min-width: 0; min-height: 0; margin: 0; overflow: hidden; background: var(--bone); }
.output-frame img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 38%; transition: opacity .35s; }
.output-frame figcaption { position: absolute; right: 16px; bottom: 13px; display: grid; color: #36342f; text-align: right; }
.output-frame figcaption em { font: italic 16px/1.1 Georgia, serif; }
.output-frame figcaption span { margin-top: 4px; text-transform: uppercase; letter-spacing: .17em; font-size: 5px; }
.generation-progress { display: none; position: absolute; inset: 0; align-items: end; background: rgba(13,15,15,.24); backdrop-filter: blur(4px); }
.generation-progress.active { display: flex; }
.generation-progress span { width: 0; height: 2px; background: var(--accent); animation: progress 1.8s var(--ease) forwards; }
@keyframes progress { 0% { width: 0; } 40% { width: 42%; } 78% { width: 76%; } 100% { width: 100%; } }
.recent-rail { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 11px 9px; overflow: auto; }
.recent-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.recent-heading strong { font-size: 10px; font-weight: 500; }
.recent-heading button { padding: 0; border: 0; background: none; color: var(--muted); font-size: 8px; text-decoration: underline; }
.recent-thumb { width: 100%; aspect-ratio: 3/4; padding: 0; overflow: hidden; border: 1px solid transparent; border-radius: 5px; background: #1a1c1c; margin-bottom: 8px; }
.recent-thumb.active { border-color: var(--accent); }
.recent-thumb img { width: 100%; height: 100%; object-fit: cover; }
.recent-thumb:nth-child(3) img { filter: grayscale(.55) contrast(.95); object-position: 48% 25%; }
.canvas-actions { display: flex; align-items: center; gap: 24px; color: var(--muted); }
.canvas-actions button, .canvas-actions a { height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: none; color: inherit; text-decoration: none; font-size: 10px; }
.canvas-actions button:hover, .canvas-actions a:hover { color: var(--text); }
.canvas-actions > button:first-child { width: 38px; }
.canvas-actions > span { flex: 1; }
.canvas-actions svg { width: 17px; height: 17px; }

.view-training { position: relative; flex-direction: column; padding: 28px 36px 54px; overflow: auto; }
.training-heading h1, .collection-header h1 { margin: 0; font: 500 clamp(30px, 3vw, 42px)/1.05 var(--font-ui); letter-spacing: -.04em; }
.training-heading p, .collection-header p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.training-grid { width: 100%; flex: 1; min-height: 560px; display: grid; grid-template-columns: 190px minmax(340px, .95fr) minmax(370px, 1fr); gap: 38px; align-items: center; max-width: 1260px; margin: 4px auto 0; }
.training-steps { align-self: center; display: grid; }
.training-steps button { position: relative; min-height: 91px; display: grid; grid-template-columns: 38px 1fr; grid-template-rows: auto auto; column-gap: 11px; align-content: start; padding: 0; border: 0; background: none; text-align: left; color: var(--muted); }
.training-steps button:not(:last-child)::after { content: ""; position: absolute; left: 18px; top: 38px; bottom: 0; width: 1px; background: var(--line-strong); }
.training-steps button.active:not(:last-child)::after { background: linear-gradient(var(--accent), var(--line-strong)); }
.training-steps span { grid-row: 1/3; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 11px; }
.training-steps strong { align-self: end; color: inherit; font-size: 13px; font-weight: 500; }
.training-steps small { align-self: start; margin-top: 4px; font-size: 10px; }
.training-steps button.active span { color: var(--text); border-color: var(--accent); }
.training-steps button.active strong { color: var(--text); }
.reference-panel { position: relative; align-self: center; height: min(62vh, 620px); min-height: 470px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); overflow: hidden; }
.reference-panel > img { width: 100%; height: calc(100% - 70px); object-fit: cover; object-position: center 36%; display: block; }
.replace-reference { height: 70px; display: flex; align-items: center; gap: 14px; padding: 0 19px; color: var(--text); cursor: pointer; background: rgba(18,20,20,.96); }
.replace-reference span { display: grid; }
.replace-reference strong { font-size: 11px; font-weight: 500; }
.replace-reference small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.identity-form { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 18px; align-self: center; }
.identity-form > label, .identity-columns label { display: grid; gap: 7px; color: #c7c9c6; font-size: 11px; }
.identity-form > label:first-child, .identity-form > label:nth-child(2), .identity-form fieldset, .identity-form .toggle-row, .training-advanced, .training-actions, .training-estimate, .pipeline-link { grid-column: 1/-1; }
.identity-form input, .identity-form select { height: 42px; font-size: 12px; }
.identity-form fieldset { padding: 8px 0 0; margin: 0; border: 0; }
.identity-form legend { margin-bottom: 10px; font-size: 13px; }
.identity-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.info { display: inline-grid; place-items: center; width: 14px; height: 14px; margin-left: 4px; border: 1px solid var(--muted); border-radius: 50%; color: var(--muted); font-size: 8px; }
.toggle-row { position: relative; display: flex !important; grid-template-columns: unset !important; align-items: center; gap: 12px !important; color: #d2d4d1 !important; cursor: pointer; }
.toggle-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-row span { width: 36px; height: 20px; padding: 2px; border-radius: 20px; background: #363938; transition: background .2s; }
.toggle-row span::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: #c4c6c3; transition: transform .25s var(--ease), background .2s; }
.toggle-row input:checked + span { background: var(--accent); }
.toggle-row input:checked + span::after { transform: translateX(16px); background: white; }
.training-advanced { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0 2px; }
.training-advanced summary { min-height: 45px; display: flex; align-items: center; list-style: none; color: var(--muted); cursor: pointer; }
.training-advanced summary::-webkit-details-marker { display: none; }
.training-advanced summary svg { margin-left: auto; width: 15px; }
.training-advanced[open] .identity-columns { margin: 0 0 15px; }
.training-actions { display: grid; grid-template-columns: 1.4fr .9fr; gap: 10px; }
.training-actions b { font-size: 18px; font-weight: 400; }
.training-estimate { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 9px; }
.training-estimate span { display: flex; align-items: center; gap: 6px; }
.training-estimate span:not(:last-child) { padding-right: 18px; border-right: 1px solid var(--line-strong); }
.training-estimate svg { width: 14px; height: 14px; }
.pipeline-link { width: max-content; color: var(--muted); font-size: 9px; text-decoration: none; border-bottom: 1px solid var(--line-strong); padding-bottom: 3px; }
.pipeline-link:hover { color: var(--text); border-color: var(--accent); }
.pipeline-link b { color: var(--accent); font-size: 12px; font-weight: 400; }
.draft-footer { position: fixed; left: 126px; right: 0; bottom: 0; height: 42px; border-top: 1px solid var(--line); background: rgba(13,15,15,.96); display: flex; align-items: center; justify-content: space-between; padding: 0 34px; color: var(--muted); font-size: 9px; }
.draft-footer span { display: flex; align-items: center; gap: 9px; }
.draft-footer svg { width: 15px; height: 15px; }
.draft-footer b { font-weight: 400; }

.collection-view { flex-direction: column; overflow: auto; padding: 38px 42px; }
.collection-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.primary-action.compact { min-height: 42px; padding: 0 18px; }
.avatar-collection { margin-top: 34px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 15px; }
.collection-avatar { min-width: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); text-align: left; padding: 0; }
.collection-avatar-media { height: 245px; background: #222; overflow: hidden; }
.collection-avatar img { width: 100%; height: 100%; object-fit: cover; }
.collection-avatar .avatar-fallback { width: 100%; height: 100%; border: 0; border-radius: 0; font-size: 28px; }
.collection-avatar-copy { display: flex; justify-content: space-between; align-items: center; padding: 14px; }
.collection-avatar-copy span { display: grid; }
.collection-avatar-copy strong { font-size: 12px; font-weight: 500; }
.collection-avatar-copy small { margin-top: 4px; color: var(--muted); font-size: 9px; text-transform: capitalize; }
.collection-avatar-copy i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.library-filter { display: flex; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.library-filter button { min-width: 62px; height: 32px; border: 0; border-radius: 5px; background: none; color: var(--muted); font-size: 10px; }
.library-filter button.active { background: var(--panel-hover); color: var(--text); }
.library-grid { margin-top: 34px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; align-items: start; }
.library-grid figure { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.library-grid img { display: block; width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.library-grid figcaption { display: flex; justify-content: space-between; padding: 13px 14px; }
.library-grid figcaption span { font-size: 11px; }
.library-grid figcaption small { color: var(--muted); font-size: 9px; }

.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 240px; max-width: 360px; padding: 13px 15px; border: 1px solid var(--line-strong); border-radius: 8px; background: #1a1c1c; box-shadow: 0 14px 35px rgba(0,0,0,.35); color: var(--text); font-size: 11px; animation: toast-in .3s var(--ease); }
.toast.error { border-color: rgba(255,104,74,.65); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 92px minmax(0, 1fr); }
  .brand-rail { padding-top: 27px; }
  .wordmark { padding: 0 15px; font-size: 16px; }
  .brand-mantra, .brand-version { left: 15px; }
  .view-studio { grid-template-columns: 92px minmax(350px, 430px) minmax(390px, 1fr); }
  .avatar-rail { padding-inline: 13px; }
  .avatar-card img, .avatar-fallback { width: 54px; height: 68px; }
  .avatar-add::before { width: 54px; }
  .draft-footer { left: 92px; }
  .training-grid { grid-template-columns: 155px minmax(300px, .8fr) minmax(330px, 1fr); gap: 24px; }
}

@media (max-width: 940px) {
  body { overflow: auto; }
  .app-shell { display: block; }
  .brand-rail { display: none; }
  .app-main { min-height: 100vh; grid-template-rows: 58px minmax(0, 1fr); }
  .topbar { position: sticky; top: 0; z-index: 10; padding: 0 18px; }
  .mobile-menu { display: grid; align-content: center; gap: 5px; width: 32px; border: 0; background: none; }
  .mobile-menu span { width: 19px; height: 1px; background: var(--text); }
  .main-nav { position: fixed; inset: 58px 0 auto 0; height: auto; padding: 12px 18px 18px; display: none; gap: 18px; background: #111313; border-bottom: 1px solid var(--line); }
  body.nav-open .main-nav { display: flex; }
  .nav-link { min-height: 34px; }
  .service-state { display: none; }
  .workspace { height: auto; min-height: calc(100vh - 58px); }
  .view { min-height: calc(100vh - 58px); height: auto; }
  .view-studio.active { display: grid; grid-template-columns: 80px minmax(330px, 420px) minmax(0, 1fr); }
  .canvas-panel { min-height: 660px; }
  .training-grid { grid-template-columns: 120px minmax(280px, .75fr) minmax(300px, 1fr); }
  .draft-footer { left: 0; }
}

@media (max-width: 760px) {
  .main-nav { justify-content: space-between; gap: 10px; }
  .nav-link { font-size: 11px; }
  .view-studio.active { display: flex; flex-direction: column; }
  .avatar-rail { order: 0; width: 100%; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; overflow-x: auto; }
  .avatar-list { display: flex; gap: 14px; }
  .avatar-card { min-width: 62px; }
  .avatar-card img, .avatar-fallback { width: 48px; height: 58px; }
  .avatar-add { margin: 0 0 0 8px; min-width: 60px; }
  .avatar-add::before { width: 48px; height: 48px; }
  .avatar-add span { display: none; }
  .controls-panel { order: 2; border-right: 0; padding: 18px 16px 28px; }
  .canvas-panel { order: 1; min-height: 68vh; padding: 0 12px; grid-template-rows: 38px minmax(0, 1fr) 52px; border-bottom: 1px solid var(--line); }
  .canvas-layout { grid-template-columns: minmax(0, 1fr) 78px; }
  .canvas-actions { gap: 16px; }
  .canvas-action { font-size: 0 !important; gap: 0 !important; }
  .canvas-action svg { width: 19px; height: 19px; }
  .training-heading { padding-bottom: 26px; }
  .view-training { padding: 26px 16px 62px; }
  .training-grid { display: flex; flex-direction: column; align-items: stretch; min-height: 0; gap: 24px; margin: 0; }
  .training-steps { display: grid; grid-template-columns: repeat(4, 1fr); order: 0; overflow-x: auto; }
  .training-steps button { min-width: 84px; min-height: 68px; display: grid; justify-items: center; grid-template-columns: 1fr; grid-template-rows: 33px auto; text-align: center; }
  .training-steps span { grid-row: 1; width: 31px; height: 31px; }
  .training-steps strong { font-size: 10px; }
  .training-steps small, .training-steps button::after { display: none; }
  .reference-panel { height: 62vh; min-height: 420px; }
  .identity-form { grid-template-columns: 1fr; }
  .identity-form > * { grid-column: 1 !important; }
  .collection-view { padding: 28px 16px; }
  .collection-header { align-items: flex-start; }
  .collection-header h1 { font-size: 32px; }
  .avatar-collection { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collection-avatar-media { height: 210px; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* APEX Atelier — selected editorial direction */
:root {
  --bg: #f7f4ee;
  --bg-soft: #f1eee7;
  --panel: #fbf9f5;
  --panel-hover: #f0ece5;
  --line: #d8d3ca;
  --line-strong: #bbb5ab;
  --text: #151514;
  --muted: #74716c;
  --muted-2: #aaa59d;
  --accent: #ff593f;
  --accent-bright: #ff6d53;
  --success: #37b86d;
  --bone: #f0ebe2;
  --font-title: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --font-display: Baskerville, "Iowan Old Style", Georgia, serif;
  --ease-editorial: cubic-bezier(.22, .61, .36, 1);
  --ease-soft: cubic-bezier(.16, 1, .3, 1);
}

html, body { background: var(--bg); color: var(--text); }
html.figma-capture, html.figma-capture body { width: 1536px; min-width: 1536px; height: 1024px; }
body::after { display: none; }
.app-shell { display: block; min-height: 100vh; }
.brand-rail { display: none; }
.app-main { min-height: 100vh; grid-template-rows: 74px minmax(0, 1fr); }
.topbar { z-index: 20; height: 74px; align-items: stretch; justify-content: flex-start; padding: 0 40px; background: rgba(249,247,242,.93); border-color: rgba(21,21,20,.13); backdrop-filter: blur(18px); }
.topbar-wordmark { display: flex; align-items: center; color: var(--text); text-decoration: none; font: 500 20px/1 var(--font-title); letter-spacing: .245em; }
.topbar-rule { align-self: center; width: 1px; height: 30px; margin: 0 46px 0 58px; background: rgba(21,21,20,.2); }
.main-nav { gap: 48px; margin-left: 0; }
.nav-link { color: #5f5d59; font: 500 15px/1 var(--font-display); transition: color .28s var(--ease-editorial), opacity .28s var(--ease-editorial); }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); font: 700 14px/1 var(--font-ui); }
.nav-link::after { left: 50%; right: auto; bottom: 9px; width: 0; height: 2px; transform: translateX(-50%); transition: width .42s var(--ease-soft); }
.nav-link.active::after { width: 100%; }
.topbar-actions { gap: 26px; margin-left: auto; }
.service-state { color: #282826; font-size: 12px; }
.service-state span, .ready-dot { background: var(--success); box-shadow: none; }
.profile { position: relative; width: 42px; height: 42px; margin-left: 70px; border: 0; background: #eeeae3; color: #1a1a19; }
.profile::before { content: ""; position: absolute; left: -46px; top: 13px; width: 1px; height: 16px; background: rgba(21,21,20,.16); }
.workspace { height: calc(100vh - 74px); background: var(--bg); }
.view { color: var(--text); }
.view.active { animation: none; }

.view-studio { position: relative; grid-template-columns: minmax(540px, 52.1%) minmax(520px, 47.9%); grid-template-rows: minmax(0, 1fr); overflow: hidden; background: #f8f5ef; }
.view-studio.active { display: grid; }
.atelier-hero { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #e5ded3; }
.atelier-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset -105px 0 125px rgba(247,244,238,.7); }
.atelier-hero .output-frame { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: #e7e0d5; }
.atelier-hero .output-frame img { position: absolute; left: -5%; top: -14.3%; width: 102.5%; height: auto; display: block; object-fit: contain; filter: saturate(.83) contrast(.96) brightness(1.04); transform: none; will-change: opacity, transform; }
.atelier-hero .output-frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #171716; }
.inpaint-mask { position: absolute; z-index: 4; inset: 0; width: 100%; height: 100%; display: none; cursor: crosshair; touch-action: none; opacity: .48; }
.output-frame.is-inpainting .inpaint-mask { display: block; }
.edit-toolbar, .input-chip { position: absolute; z-index: 6; display: flex; align-items: center; border: 1px solid rgba(42,38,33,.12); background: rgba(249,247,242,.9); color: #2b2926; box-shadow: 0 8px 26px rgba(35,30,25,.1); backdrop-filter: blur(14px); }
.edit-toolbar { left: 28px; bottom: 30px; gap: 14px; min-height: 42px; padding: 7px 10px 7px 14px; border-radius: 22px; font: 500 9px/1 var(--font-title); }
.edit-toolbar label { display: flex; align-items: center; gap: 7px; color: #827c74; }
.edit-toolbar input { width: 72px; height: auto; padding: 0; border: 0; background: none; }
.edit-toolbar button { padding: 5px 7px; border: 0; border-left: 1px solid #d6d0c7; background: none; color: #6c6760; font-size: 8px; }
.input-chip { left: 28px; top: 28px; min-width: 168px; justify-content: space-between; gap: 12px; padding: 9px 10px 9px 13px; border-radius: 5px; }
.input-chip > span { display: grid; grid-template-columns: 8px auto; column-gap: 8px; }
.input-chip i { grid-row: 1/3; align-self: center; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.input-chip strong { font: 600 9px/1.2 var(--font-title); }
.input-chip small { margin-top: 2px; color: #8a847c; font: 500 8px/1 var(--font-display); }
.input-chip button { width: 23px; height: 23px; padding: 0; border: 0; border-radius: 50%; background: #ebe6de; color: #4f4a44; }
.atelier-mantra { position: absolute; z-index: 3; left: 42px; top: 26%; color: rgba(72,65,57,.68); font: 500 10px/2.45 var(--font-display); letter-spacing: .34em; }
.atelier-mantra span { display: block; width: 37px; height: 1px; margin: 28px 0 250px; background: rgba(72,65,57,.45); }
.generation-progress { z-index: 4; background: rgba(248,245,239,.34); backdrop-filter: blur(9px); }
.generation-progress span { height: 4px; background: var(--accent); }

.atelier-side { position: relative; min-width: 0; min-height: 0; overflow: hidden; padding: 56px 40px 146px; background: linear-gradient(115deg, rgba(255,255,255,.26), transparent 36%), #f8f5ef; }
.avatar-strip { display: flex; gap: 18px; align-items: start; min-height: 132px; margin-left: 89px; }
.avatar-list { display: flex; gap: 18px; min-width: 0; }
.avatar-card, .avatar-add { width: 96px; display: grid; justify-items: center; gap: 8px; padding: 0; border: 0; background: none; color: #57544f; font: 400 11px/1.2 var(--font-display); transition: color .32s var(--ease-editorial); }
.avatar-card img, .avatar-card .avatar-fallback, .avatar-add-mark { width: 90px; height: 96px; border: 1px solid transparent; border-radius: 5px; object-fit: cover; background: #eeeae3; transition: transform .42s var(--ease-soft), border-color .32s var(--ease-editorial), box-shadow .32s var(--ease-editorial), filter .42s var(--ease-editorial); }
.avatar-card:hover img, .avatar-card:hover .avatar-fallback { transform: translateY(-2px); border-color: #aaa49a; filter: saturate(1.04); }
.avatar-card.active { color: var(--accent); }
.avatar-card.active img, .avatar-card.active .avatar-fallback { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.avatar-add { margin: 0; }
.avatar-add::before { display: none; }
.avatar-add-mark { width: 75px; height: 75px; margin: 10px 0 0 -8px; display: grid; place-items: center; }
.avatar-add > span:not(.avatar-add-mark) { display: none; }
.avatar-add svg { width: 27px; height: 27px; grid-row: auto; grid-column: auto; color: #272624; }
.avatar-fallback { display: grid; place-items: center; color: #6d6962; font-size: 18px; }

.atelier-title { position: relative; margin-top: 44px; padding-left: 0; }
.title-kicker { display: flex; align-items: center; gap: 20px; color: #34322e; text-transform: uppercase; letter-spacing: .3em; font: 500 10px/1 var(--font-ui); }
.title-kicker::before { content: ""; width: 17px; height: 2px; background: var(--accent); }
.atelier-title h1 { margin: 20px 0 5px; font: 300 clamp(68px, 7vw, 108px)/.82 var(--font-title); letter-spacing: -.04em; will-change: opacity, transform; }
.atelier-title p { margin: 22px 0 0; max-width: 500px; color: #65615b; font: 500 clamp(16px, 1.3vw, 20px)/1.35 var(--font-display); letter-spacing: -.012em; }
.title-mantra { position: absolute; right: 41px; top: 18px; padding: 27px 0 27px 40px; border-left: 1px solid rgba(21,21,20,.22); color: #9f978c; font: 500 9px/1.75 var(--font-display); letter-spacing: .27em; }

.atelier-recents { margin-top: 62px; }
.recent-heading { display: flex; align-items: center; margin-bottom: 23px; }
.recent-heading strong { display: flex; align-items: center; gap: 19px; color: #262521; text-transform: uppercase; letter-spacing: .27em; font: 500 10px/1 var(--font-ui); }
.recent-heading strong::after { content: ""; width: 38px; height: 1px; background: #bbb5aa; }
.recent-heading button { margin-left: auto; border: 0; background: none; color: #6f6b65; text-transform: uppercase; letter-spacing: .13em; font-size: 9px; text-decoration: none; }
.recent-heading b { margin-left: 10px; color: #2c2b28; font-size: 13px; font-weight: 400; }
.recent-stack { position: relative; min-height: 0; padding: 0; overflow: visible; }
.recent-collage { width: 100%; max-width: 667px; height: auto; display: block; transform-origin: 50% 65%; transition: transform .7s var(--ease-soft), filter .45s var(--ease-editorial); }
.recent-stack:hover .recent-collage { transform: translateY(-2px) scale(1.004); filter: drop-shadow(0 10px 12px rgba(47,39,31,.08)); }
.recent-thumb { position: absolute; z-index: 2; top: 0; bottom: 0; width: 25%; min-width: 0; aspect-ratio: auto; margin: 0; padding: 0; overflow: hidden; border: 0; border-radius: 0; background: transparent; box-shadow: none; opacity: 0; }
.recent-thumb:nth-of-type(1) { left: 0; }
.recent-thumb:nth-of-type(2) { left: 25%; }
.recent-thumb:nth-of-type(3) { left: 50%; }
.recent-thumb:nth-of-type(4) { left: 75%; }
.recent-thumb img { display: none; }
.recent-thumb:focus-visible { opacity: 1; outline: 2px solid var(--accent); outline-offset: -4px; }
.result-actions { margin-top: 22px; display: flex; align-items: center; justify-content: flex-end; gap: 16px; min-height: 32px; color: #5e5a54; }
.result-actions > span { margin-right: auto; display: flex; align-items: center; gap: 7px; }
.result-actions strong { font-size: 10px; font-weight: 500; }
.result-actions small { padding-left: 8px; border-left: 1px solid #cfc9c0; color: #918b82; font-size: 9px; }
.result-actions a, .result-actions button { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: #56524c; text-decoration: none; font-size: 9px; }
.result-actions svg { width: 14px; height: 14px; }

.atelier-composer { position: absolute; z-index: 10; left: 9.4%; right: 2.5%; bottom: clamp(22px, 6.2vh, 64px); min-height: 100px; display: grid; grid-template-columns: minmax(340px, 1fr) 170px 160px 134px 230px 209px; align-items: stretch; padding: 12px 13px 12px 32px; border: 1px solid rgba(53,47,40,.08); border-radius: 35px; background: rgba(250,248,244,.95); box-shadow: 0 18px 46px rgba(51,44,36,.16); backdrop-filter: blur(24px); transition: box-shadow .55s var(--ease-editorial), border-color .4s var(--ease-editorial), transform .55s var(--ease-soft); will-change: transform; }
.atelier-composer:focus-within { border-color: rgba(53,47,40,.16); box-shadow: 0 24px 62px rgba(51,44,36,.19); transform: translateY(-2px); }
.composer-prompt, .avatar-select, .generation-tabs, .composer-select, .composer-controls { min-width: 0; border: 0; border-right: 1px solid #d1cbc2; background: transparent; }
.composer-prompt { position: relative; display: grid; align-content: center; padding-right: 24px; }
.composer-prompt > span, .composer-prompt small, .composer-label { display: none; }
.composer-prompt > span, .composer-label { color: #4f4b45; text-transform: uppercase; letter-spacing: .16em; font: 500 8px/1 var(--font-ui); }
.composer-prompt textarea { width: 100%; height: 34px; min-height: 0; resize: none; overflow: hidden; padding: 5px 0 0; border: 0; background: none; color: var(--text); font: 400 clamp(16px, 1.4vw, 21px)/1.15 var(--font-display); white-space: nowrap; }
.composer-prompt textarea:focus { outline: 0; }
.composer-prompt small { position: absolute; right: 18px; bottom: 15px; color: #b1aaa1; font-size: 8px; }
.composer-prompt small b { font-weight: 400; }
.avatar-select { height: auto; display: grid; align-content: center; gap: 0; padding: 0 18px 0 28px; border-radius: 0; }
.composer-value { min-width: 0; display: flex; align-items: center; gap: 9px; color: #1d1c1a; font: 500 11px/1.2 var(--font-display); }
.composer-value img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.composer-value b { overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.composer-value svg { width: 15px; height: 15px; margin-left: auto; }
.generation-tabs { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-auto-flow: row; align-content: center; gap: 0; margin: 0; padding: 0 16px; }
.generation-tabs .composer-value { margin-top: 0; }
.generation-tabs svg { width: 18px; height: 18px; }
.generation-tabs select { width: 100%; min-width: 0; height: auto; padding: 0 16px 0 0; border: 0; background-color: transparent; background-position: right center; color: var(--text); font: 500 11px/1.2 var(--font-display); }
.composer-select { display: grid; align-content: center; gap: 0; padding: 0 14px; }
.composer-select select { width: 70px; height: auto; padding: 0 18px 0 0; border: 0; background-color: transparent; background-position: right center; color: var(--text); font: 500 11px/1.2 var(--font-display); }
.composer-controls { display: none; }
.composer-controls summary { display: flex; align-items: center; gap: 7px; list-style: none; color: #37342f; font-size: 10px; cursor: pointer; }
.composer-controls summary::-webkit-details-marker { display: none; }
.composer-controls summary svg { width: 16px; height: 16px; }
.composer-controls-panel { position: absolute; right: -8px; bottom: calc(100% + 22px); width: 290px; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; padding: 18px; border: 1px solid #d4cec4; border-radius: 15px; background: #faf8f3; box-shadow: 0 16px 42px rgba(40,34,27,.16); }
.composer-controls:not([open]) .composer-controls-panel { display: none; }
.composer-controls-panel label { display: grid; gap: 7px; color: #706b64; font-size: 9px; }
.composer-controls-panel input, .composer-controls-panel select { height: 38px; border-color: #d2ccc2; background-color: #f5f1ea; color: #20201e; }
.composer-output-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding-top: 12px; border-top: 1px solid #d4cec4; color: #5e5a54; }
.composer-output-actions > span { margin-right: auto; display: flex; align-items: center; gap: 7px; }
.composer-output-actions strong { font-size: 10px; font-weight: 500; }
.composer-output-actions small { padding-left: 8px; border-left: 1px solid #cfc9c0; color: #918b82; font-size: 9px; }
.composer-output-actions a, .composer-output-actions button { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: #56524c; text-decoration: none; font-size: 9px; }
.composer-output-actions svg { width: 14px; height: 14px; }
.composer-generate, .composer-publish { align-self: center; height: 66px; border: 0; border-radius: 14px; font: 400 16px/1 var(--font-display); transition: transform .45s var(--ease-soft), background .3s var(--ease-editorial), box-shadow .45s var(--ease-editorial); }
.composer-generate { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 0 0 0 22px; background: #171716; color: #fff; }
.composer-generate b { font: 300 19px/1 var(--font-title); transition: transform .45s var(--ease-soft); }
.composer-generate:hover { background: #282725; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(20,20,18,.18); }
.composer-generate:hover b { transform: translateX(5px); }
.composer-generate.is-loading b { animation: arrow-breathe 1.15s var(--ease-editorial) infinite alternate; }
.composer-generate:disabled { opacity: .65; cursor: wait; transform: none; }
.composer-publish { margin: 0 10px 0 23px; background: var(--accent); color: #fff; }
.composer-publish:hover { background: var(--accent-bright); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(255,89,63,.2); }

body.just-loaded .view-studio.active .atelier-hero { animation: hero-reveal .95s var(--ease-soft) both; }
body.just-loaded .view-studio.active .avatar-strip { animation: editorial-rise .72s .16s var(--ease-soft) both; }
body.just-loaded .view-studio.active .atelier-title { animation: editorial-rise .78s .24s var(--ease-soft) both; }
body.just-loaded .view-studio.active .atelier-recents { animation: editorial-rise .8s .34s var(--ease-soft) both; }
body.just-loaded .view-studio.active .atelier-composer { animation: composer-rise .88s .38s var(--ease-soft) both; }

@keyframes hero-reveal {
  from { opacity: 0; transform: scale(1.018); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes editorial-rise {
  from { opacity: 0; transform: translateY(13px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes composer-rise {
  from { opacity: 0; transform: translateY(18px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes arrow-breathe {
  from { transform: translateX(0); opacity: .62; }
  to { transform: translateX(7px); opacity: 1; }
}

.view-training, .collection-view { background: #f7f4ee; }
.training-heading p, .collection-header p, .identity-form > label, .identity-columns label { color: var(--muted); }
select, input { border-color: #cdc7bd; background-color: #f1ede6; color: #20201e; }
.reference-panel, .collection-avatar, .library-grid figure { background: #f3efe8; }
.replace-reference, .draft-footer { background: rgba(247,244,238,.96); color: var(--text); }
.draft-footer { left: 0; }
.toast { background: #1d1d1b; color: #f8f5ef; }

@media (max-width: 1400px) {
  .atelier-hero .output-frame img { left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; object-position: 51% 40%; }
  .atelier-side { padding-inline: 34px; }
  .avatar-strip { margin-left: 25px; gap: 10px; }
  .avatar-list { gap: 10px; }
  .avatar-card, .avatar-add { flex: 0 0 78px; width: 78px; }
  .avatar-card img, .avatar-card .avatar-fallback, .avatar-add-mark { width: 70px; height: 84px; }
  .atelier-composer { left: 3%; right: 3%; grid-template-columns: minmax(260px,1fr) 145px 126px 100px 160px 172px; padding-left: 24px; }
}

@media (max-width: 1240px) {
  .atelier-side { padding-inline: 34px; }
  .avatar-strip { margin-left: 0; }
  .avatar-card, .avatar-add { width: 78px; }
  .avatar-card img, .avatar-card .avatar-fallback, .avatar-add-mark { width: 70px; height: 84px; }
  .atelier-composer { left: 3%; right: 3%; grid-template-columns: minmax(260px,1fr) 145px 112px 92px 148px 154px; padding-left: 24px; }
}

@media (max-width: 980px) {
  .topbar { padding-inline: 22px; }
  .topbar-rule { margin-inline: 24px; }
  .profile { margin-left: 0; }
  .profile::before { display: none; }
  .main-nav { gap: 25px; }
  .view-studio { grid-template-columns: 50% 50%; }
  .atelier-side { padding: 28px 24px 142px; }
  .avatar-strip, .avatar-list { gap: 10px; }
  .avatar-card, .avatar-add { width: 65px; }
  .avatar-card img, .avatar-card .avatar-fallback, .avatar-add-mark { width: 58px; height: 70px; }
  .atelier-title { margin-top: 35px; }
  .title-mantra { display: none; }
  .atelier-recents { margin-top: 45px; }
  .atelier-composer { grid-template-columns: minmax(220px,1fr) 130px 104px 92px 138px; }
  .composer-publish { display: none; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-main { grid-template-rows: 62px auto; }
  .topbar { position: sticky; top: 0; height: 62px; padding: 0 16px; }
  .topbar-wordmark { font-size: 16px; }
  .topbar-rule { margin: 0 14px; }
  .mobile-menu { order: 4; display: grid; margin-left: 10px; }
  .main-nav { display: none; }
  body.nav-open .main-nav { display: flex; inset: 62px 0 auto; height: auto; padding: 14px 18px 18px; background: #f8f5ef; border-color: #d8d3ca; }
  .topbar-actions { margin-left: auto; }
  .service-state { display: none; }
  .profile { width: 34px; height: 34px; }
  .workspace { height: auto; min-height: calc(100vh - 62px); }
  .view-studio.active { display: flex; flex-direction: column; overflow: visible; }
  .atelier-hero { order: 0; height: 58vh; min-height: 450px; }
  .atelier-hero .output-frame img { object-position: 50% 28%; }
  .atelier-mantra { display: none; }
  .atelier-side { order: 1; min-height: 656px; padding: 72px 18px 36px; overflow: hidden; }
  .avatar-strip { min-height: 101px; overflow-x: auto; }
  .avatar-list { flex: none; }
  .avatar-card, .avatar-add { width: 64px; }
  .avatar-card img, .avatar-card .avatar-fallback, .avatar-add-mark { width: 57px; height: 66px; }
  .atelier-title { margin: 30px 0 0; padding: 0; }
  .atelier-title h1 { font-size: 66px; }
  .atelier-title p { font-size: 17px; }
  .atelier-recents { margin-top: 54px; }
  .recent-stack { min-height: 145px; overflow-x: auto; padding: 8px 4px 14px; }
  .recent-thumb { flex: 0 0 122px; margin-right: -17px; }
  .result-actions { flex-wrap: wrap; }
  .result-actions > span { width: 100%; }
  .atelier-composer { order: 2; position: relative; left: auto; right: auto; bottom: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 0; min-height: 0; padding: 13px; border-radius: 22px 22px 0 0; }
  .composer-prompt { grid-column: 1/-1; min-height: 82px; padding: 10px 12px 12px; border-right: 0; border-bottom: 1px solid #d1cbc2; }
  .composer-prompt textarea { white-space: normal; }
  .avatar-select, .generation-tabs, .composer-select { min-height: 74px; }
  .composer-select { border-right: 0; }
  .composer-controls { min-height: 56px; border-right: 1px solid #d1cbc2; border-top: 1px solid #d1cbc2; }
  .composer-generate { height: 52px; margin: 8px; }
  .composer-publish { display: block; grid-column: 1/-1; height: 48px; margin: 5px 8px; }
  .composer-controls-panel { right: 0; width: calc(200vw - 52px); max-width: 340px; }
}

/* Training pipeline — the atelier language carried through the full workflow. */
.view-training { padding: 38px 42px 92px; scroll-padding-bottom: 76px; background: linear-gradient(135deg, rgba(255,255,255,.28), transparent 36%), var(--bg); }
.training-heading { max-width: 1260px; width: 100%; margin: 0 auto; }
.training-heading h1, .collection-header h1 { font: 300 clamp(38px, 4vw, 58px)/1 var(--font-title); letter-spacing: -.045em; }
.training-heading p, .collection-header p { color: #77726b; font: 500 14px/1.45 var(--font-display); }
.training-grid { grid-template-columns: 174px minmax(320px, .82fr) minmax(430px, 1fr); gap: 34px; align-items: center; margin-top: 18px; }
.training-steps button { min-height: 88px; }
.training-steps button:not(:last-child)::after { background: #cbc5bb; }
.training-steps button.complete:not(:last-child)::after { background: var(--accent); }
.training-steps button.complete span { border-color: var(--accent); background: var(--accent); color: #fff; }
.training-steps button.complete span::after { content: "✓"; font: 600 12px/1 var(--font-ui); }
.training-steps button.complete span { font-size: 0; }
.training-steps button.active span { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255,89,63,.08); }
.training-steps strong { color: #827d76; font: 500 13px/1.2 var(--font-title); }
.training-steps small { color: #9c968e; font: 500 10px/1.2 var(--font-display); }
.reference-panel { height: min(63vh, 640px); border-color: #d4cec4; border-radius: 4px; box-shadow: 0 16px 44px rgba(50,43,35,.08); }
.reference-panel::after { content: "REFERENCE / 01"; position: absolute; top: 17px; left: 17px; padding: 7px 9px; background: rgba(248,245,239,.86); color: #554f47; letter-spacing: .18em; font: 600 8px/1 var(--font-title); backdrop-filter: blur(8px); }
.replace-reference { background: rgba(248,245,239,.96); }

.training-stage-stack { position: relative; align-self: center; min-width: 0; }
.training-stage { display: none; min-width: 0; }
.training-stage.active { display: grid; animation: editorial-rise .6s var(--ease-soft) both; }
.identity-form.training-stage.active { display: grid; }
.identity-form > label, .identity-columns label, .preset-picker, .test-prompt, .slug-field { color: #76716a; font: 600 9px/1.3 var(--font-title); letter-spacing: .08em; text-transform: uppercase; }
.identity-form input, .identity-form select, .training-stage input, .training-stage select, .training-stage textarea { border-color: #d2ccc2; border-radius: 3px; background-color: rgba(244,240,233,.8); color: #24221f; text-transform: none; letter-spacing: 0; }
.identity-form input:focus, .identity-form select:focus, .training-stage input:focus, .training-stage select:focus, .training-stage textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.identity-form legend { font: 500 15px/1 var(--font-display); }
.toggle-row { color: #5d5953 !important; font: 500 11px/1.2 var(--font-title) !important; text-transform: none !important; letter-spacing: 0 !important; }
.toggle-row span { background: #d8d2c9; }
.training-advanced { border-color: #d5cfc5; }
.training-advanced summary { color: #716c65; font: 500 11px/1 var(--font-title); }
.training-actions .primary-action, .stage-actions .primary-action { background: #171716; color: #fff; }
.training-actions .primary-action:hover, .stage-actions .primary-action:hover { background: #292825; }
.training-actions .secondary-action, .stage-actions .secondary-action, .publish-test-actions .secondary-action { min-height: 48px; border-color: #cbc5bb; border-radius: 6px; background: transparent; color: #4d4944; }
.training-actions .secondary-action:hover, .stage-actions .secondary-action:hover, .publish-test-actions .secondary-action:hover { background: #ece7df; }
.training-estimate { color: #8f8981; }

.dataset-stage, .train-stage, .publish-stage { gap: 18px; align-content: center; }
.stage-eyebrow { display: flex; align-items: center; gap: 13px; color: #6e6962; text-transform: uppercase; letter-spacing: .24em; font: 600 9px/1 var(--font-title); }
.stage-eyebrow::before { content: ""; width: 18px; height: 2px; background: var(--accent); }
.stage-eyebrow span { color: #aaa39a; }
.stage-title-row { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.stage-title-row h2 { margin: 0; max-width: 410px; font: 300 31px/1.05 var(--font-title); letter-spacing: -.04em; }
.stage-title-row p { margin: 9px 0 0; max-width: 430px; color: #77716a; font: 500 12px/1.45 var(--font-display); }
.text-action { display: inline-flex; align-items: center; gap: 6px; padding: 5px 0; border: 0; border-bottom: 1px solid #c9c3b9; background: none; color: #736e67; font-size: 9px; }
.text-action svg { width: 13px; height: 13px; }
.pipeline-status, .training-run-card { padding: 16px; border: 1px solid #d2ccc2; border-radius: 7px; background: rgba(250,248,244,.68); }
.pipeline-status { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 13px; }
.pipeline-status > div, .run-card-head { min-width: 0; display: flex; align-items: center; gap: 11px; }
.pipeline-status strong, .run-card-head strong { display: block; font: 600 11px/1.2 var(--font-title); }
.pipeline-status small, .run-card-head small { display: block; margin-top: 3px; overflow: hidden; color: #8b857d; font: 500 9px/1.25 var(--font-display); text-overflow: ellipsis; white-space: nowrap; }
.pipeline-status > b, .run-card-head > b { color: #5f5b55; font: 500 12px/1 var(--font-title); }
.status-orbit { flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #cdc7be; border-radius: 50%; }
.status-orbit i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.is-running .status-orbit i { background: var(--accent); animation: status-pulse 1.3s var(--ease-editorial) infinite alternate; }
.is-ready .status-orbit i { background: var(--success); }
.is-error .status-orbit i { background: #d44335; }
.pipeline-progress { grid-column: 1/-1; height: 2px; overflow: hidden; background: #ded8cf; }
.pipeline-progress i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .65s var(--ease-soft); }
@keyframes status-pulse { to { transform: scale(1.5); box-shadow: 0 0 0 4px rgba(255,89,63,.12); } }
.dataset-toolbar { min-height: 40px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid #d6d0c7; color: #77716a; font-size: 9px; }
.dataset-toolbar strong { color: #2b2926; font-size: 11px; }
.dataset-toolbar label { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.dataset-toolbar select { width: 132px; height: 31px; font-size: 9px; }
.dataset-utilities { display: flex; align-items: center; gap: 12px; }
.dataset-utilities .text-action { font-size: 8px; white-space: nowrap; text-decoration: none; }
.danger-action { color: #a64539 !important; }
.danger-action:hover { border-color: #cf8e84 !important; background: rgba(166,69,57,.06) !important; }
.dataset-preview-grid { min-height: 194px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.dataset-cell { position: relative; min-width: 0; aspect-ratio: 1; padding: 0; overflow: hidden; border: 1px solid transparent; border-radius: 4px; background: #e7e1d8; }
.dataset-cell img { width: 100%; height: 100%; display: block; object-fit: cover; }
.dataset-cell.is-removed img { opacity: .25; filter: grayscale(1); }
.dataset-cell b { position: absolute; right: 5px; bottom: 5px; padding: 3px 5px; border-radius: 10px; background: rgba(22,21,19,.68); color: #fff; font: 600 7px/1 var(--font-title); }
.dataset-cell::after { content: "×"; position: absolute; top: 5px; right: 5px; width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; background: rgba(248,245,239,.88); color: #262420; opacity: 0; transition: opacity .2s; }
.dataset-cell:hover::after, .dataset-cell.is-removed::after { opacity: 1; }
.dataset-cell.is-removed::after { content: "+"; }
.stage-empty { grid-column: 1/-1; align-self: center; margin: 0; color: #99938a; text-align: center; font: 500 11px/1.4 var(--font-display); }
.stage-actions { display: grid; grid-template-columns: .7fr 1.5fr; gap: 9px; scroll-margin-bottom: 66px; }
.stage-actions.has-tertiary { grid-template-columns: .65fr .85fr 1.35fr; }
.stage-actions > button:only-child { grid-column: 1/-1; }
.stage-actions .primary-action:disabled { background: #cfc9bf; color: #827d76; cursor: not-allowed; }

.preset-picker, .test-prompt, .slug-field { display: grid; gap: 7px; }
.preset-picker select { height: 46px; font-size: 11px; }
.preset-picker small { color: #979188; font: 500 9px/1.4 var(--font-display); text-transform: none; letter-spacing: 0; }
.training-run-card { display: grid; gap: 15px; }
.run-card-head > div { min-width: 0; flex: 1; }
.run-card-head > b { margin-left: auto; }
.run-metrics { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #ded8cf; padding-top: 13px; }
.run-metrics span { display: grid; gap: 3px; padding-left: 13px; }
.run-metrics span:not(:first-child) { border-left: 1px solid #ded8cf; }
.run-metrics small { color: #948e86; font-size: 8px; text-transform: uppercase; letter-spacing: .12em; }
.run-metrics strong { font: 500 12px/1 var(--font-title); }
.sample-strip { min-height: 94px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.sample-strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; background: #e8e2d9; }
.train-stage .identity-columns { padding-bottom: 15px; }
.publish-artifact { display: grid; gap: 4px; padding: 14px 16px; border-left: 2px solid var(--accent); background: rgba(250,248,244,.68); }
.publish-artifact span { color: #928c84; text-transform: uppercase; letter-spacing: .13em; font-size: 8px; }
.publish-artifact strong { overflow: hidden; font: 500 11px/1.3 var(--font-title); text-overflow: ellipsis; white-space: nowrap; }
.publish-artifact small { color: #8a847c; font: 500 9px/1.3 var(--font-display); }
.test-prompt textarea { resize: vertical; min-height: 74px; padding: 10px 11px; font: 500 11px/1.45 var(--font-display); }
.publish-preview { min-height: 155px; overflow: hidden; border: 1px solid #d5cfc6; border-radius: 5px; background: #ede8df; }
.publish-preview img { width: 100%; height: 155px; display: block; object-fit: cover; object-position: center 28%; }
.publish-preview-empty { height: 155px; display: grid; place-items: center; align-content: center; gap: 9px; color: #9a948b; font: 500 10px/1 var(--font-display); }
.publish-preview-empty svg { width: 21px; height: 21px; }
.publish-lifecycle { min-height: 18px; color: #807a72; font: 500 9px/1.4 var(--font-display); }
.publish-lifecycle.is-ready { color: #347457; }
.publish-lifecycle.is-error { color: #a64539; }
.publish-test-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.publish-test-actions .secondary-action { min-height: 40px; font-size: 10px; }
.slug-field input { height: 42px; }
.accent-action { background: var(--accent) !important; }
.accent-action:hover { background: var(--accent-bright) !important; }

/* Avatars and library use the same quiet editorial utility layer. */
.collection-view { padding: 52px 42px; background: linear-gradient(145deg, rgba(255,255,255,.24), transparent 35%), var(--bg); }
.collection-header { width: 100%; max-width: 1380px; margin: 0 auto; }
.avatar-collection { width: 100%; max-width: 1380px; margin: 42px auto 0; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px; }
.collection-avatar { border-color: #d6d0c7; border-radius: 5px; background: #f5f1ea; transition: transform .45s var(--ease-soft), box-shadow .45s var(--ease-editorial); }
.collection-avatar:hover { transform: translateY(-3px); box-shadow: 0 18px 38px rgba(49,42,34,.1); }
.collection-avatar-media { width: 100%; height: 270px; display: block; padding: 0; border: 0; border-radius: 0; background: #e9e3da; overflow: hidden; }
.collection-avatar-media img, .collection-avatar-media .avatar-fallback { transition: transform .7s var(--ease-soft), filter .45s var(--ease-editorial); }
.collection-avatar:hover .collection-avatar-media img { transform: scale(1.018); filter: saturate(1.04); }
.collection-avatar-copy { padding: 15px 14px 11px; }
.collection-avatar-copy strong { font: 500 15px/1 var(--font-display); }
.collection-avatar-copy small { color: #88827a; font: 500 8px/1.2 var(--font-title); letter-spacing: .08em; text-transform: uppercase; }
.collection-avatar-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #dad4cb; }
.collection-avatar-actions button { height: 38px; border: 0; background: transparent; color: #6d6861; font-size: 9px; }
.collection-avatar-actions button + button { border-left: 1px solid #dad4cb; }
.collection-avatar-actions button:hover { background: #ebe6de; color: #1f1e1b; }
.primary-action.compact { border-radius: 6px; background: #171716; color: #fff; font-size: 10px; }
.primary-action.compact:hover { background: #292825; }

.library-controls { display: flex; align-items: end; gap: 14px; }
.library-controls > label { display: grid; gap: 6px; color: #827c74; text-transform: uppercase; letter-spacing: .12em; font-size: 8px; }
.library-controls select { width: 150px; height: 39px; border-radius: 6px; }
.library-filter { border-color: #d0cac0; border-radius: 6px; }
.library-filter button { color: #77716a; }
.library-filter button.active { background: #e9e4dc; color: #22211f; }
.library-grid { width: 100%; max-width: 1380px; margin: 42px auto 0; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.library-grid figure { border-color: #d6d0c7; border-radius: 5px; background: #f5f1ea; }
.library-media { position: relative; width: 100%; display: block; padding: 0; border: 0; background: #e7e1d8; overflow: hidden; }
.library-grid .library-media img { aspect-ratio: 3/4; transition: transform .7s var(--ease-soft), filter .45s var(--ease-editorial); }
.library-item:hover .library-media img { transform: scale(1.018); filter: saturate(1.04); }
.video-badge { position: absolute; left: 10px; top: 10px; display: flex; align-items: center; gap: 5px; padding: 6px 8px; border-radius: 13px; background: rgba(248,245,239,.9); color: #282622; font: 500 8px/1 var(--font-title); font-style: normal; }
.video-badge svg { width: 11px; height: 11px; }
.library-placeholder { width: 100%; aspect-ratio: 3/4; display: grid; place-items: center; color: #9f988f; letter-spacing: .3em; font-size: 12px; }
.library-item figcaption { gap: 14px; padding: 14px; }
.library-item figcaption > span { min-width: 0; display: grid; gap: 4px; }
.library-item figcaption > span:last-child { text-align: right; }
.library-item figcaption strong { font: 500 14px/1 var(--font-display); }
.library-item figcaption small { max-width: 170px; overflow: hidden; color: #8b857d; font: 500 8px/1.2 var(--font-title); text-overflow: ellipsis; white-space: nowrap; }
.library-item figcaption b { color: #6e6962; font: 500 8px/1 var(--font-title); }
.library-item-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #dad4cb; }
.library-item-actions button, .library-item-actions a { height: 38px; display: grid; place-items: center; border: 0; background: transparent; color: #6d6861; text-decoration: none; font-size: 9px; }
.library-item-actions > * + * { border-left: 1px solid #dad4cb; }
.library-item-actions button:hover, .library-item-actions a:hover { background: #ebe6de; color: #1f1e1b; }
.library-empty { grid-column: 1/-1; min-height: 350px; display: grid; place-items: center; align-content: center; gap: 9px; color: #8e887f; text-align: center; }
.library-empty h2 { margin: 5px 0 0; color: #25231f; font: 300 28px/1 var(--font-title); }
.library-empty p { margin: 0 0 9px; font: 500 11px/1.4 var(--font-display); }
.library-empty .primary-action { min-height: 42px; padding: 0 18px; background: #171716; color: #fff; font-size: 10px; }

@media (max-width: 980px) {
  .training-grid { grid-template-columns: 120px minmax(250px, .72fr) minmax(380px, 1fr); gap: 22px; }
  .dataset-preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .view-training { padding: 26px 16px 62px; }
  .training-stage-stack { width: 100%; }
  .reference-panel { height: 52vh; min-height: 390px; }
  .dataset-preview-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .training-stage { min-height: 520px; }
  .stage-title-row h2 { font-size: 28px; }
  .collection-view { padding: 30px 16px; }
  .collection-header { display: grid; }
  .library-controls { width: 100%; align-items: end; justify-content: space-between; }
  .library-controls > label { flex: 1; }
  .library-controls select { width: 100%; }
  .library-filter button { min-width: 55px; }
  .avatar-collection, .library-grid { margin-top: 28px; gap: 10px; }
  .collection-avatar-media { height: 215px; }
}

/* APEX layout and typography normalization.
   One readable sans-serif system and one shared content grid across the product. */
:root {
  --font: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --font-ui: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --font-title: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --page-max: 1380px;
  --page-gutter: clamp(24px, 5.08vw, 78px);
}

body,
button,
input,
textarea,
select {
  font-family: var(--font-ui);
}

.nav-link {
  font: 500 14px/1 var(--font-ui);
  letter-spacing: -.01em;
}

.nav-link.active {
  font: 700 14px/1 var(--font-ui);
}

.service-state,
.avatar-card,
.composer-value,
.generation-tabs select,
.composer-select select,
.composer-generate,
.composer-publish {
  font-family: var(--font-ui);
}

.service-state b { font-size: inherit; font-weight: 500; }
.service-state.is-checking span { background: #aaa49b; }
.service-state.is-preview span { background: #d89c3d; }
.service-state.is-unavailable span { background: #d85b4a; }

.atelier-title p {
  max-width: 520px;
  font: 400 clamp(16px, 1.25vw, 19px)/1.5 var(--font-ui);
  letter-spacing: -.015em;
}

.composer-prompt textarea {
  font: 400 clamp(16px, 1.32vw, 20px)/1.3 var(--font-ui);
  letter-spacing: -.018em;
}

.composer-generate,
.composer-publish {
  font-size: 15px;
  font-weight: 600;
}

.view-training,
.collection-view {
  padding-right: var(--page-gutter);
  padding-left: var(--page-gutter);
}

.training-heading,
.training-grid,
.collection-header,
.avatar-collection,
.library-grid {
  width: min(100%, var(--page-max));
  max-width: var(--page-max);
  margin-right: auto;
  margin-left: auto;
}

.training-heading,
.collection-header {
  min-height: 76px;
  align-items: flex-start;
}

.training-heading h1,
.collection-header h1 {
  font: 400 clamp(40px, 3.65vw, 56px)/1.02 var(--font-title);
  letter-spacing: -.045em;
}

.training-heading p,
.collection-header p {
  max-width: 620px;
  margin-top: 10px;
  font: 400 14px/1.55 var(--font-ui);
  letter-spacing: -.008em;
}

.training-grid {
  grid-template-columns: 176px minmax(340px, .82fr) minmax(430px, 1fr);
  gap: clamp(28px, 2.7vw, 42px);
  margin-top: 24px;
}

.training-steps strong {
  font: 600 13px/1.25 var(--font-ui);
}

.training-steps small {
  margin-top: 5px;
  font: 400 11px/1.35 var(--font-ui);
}

.identity-form > label,
.identity-columns label,
.preset-picker,
.test-prompt,
.slug-field,
.stage-eyebrow {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 650;
}

.identity-form input,
.identity-form select,
.training-stage input,
.training-stage select,
.training-stage textarea {
  min-height: 44px;
  font-size: 12px;
}

.identity-form legend {
  font: 500 15px/1.25 var(--font-ui);
}

.toggle-row,
.training-advanced summary {
  font-family: var(--font-ui) !important;
  font-size: 12px !important;
}

.stage-title-row h2 {
  max-width: 460px;
  font: 400 32px/1.12 var(--font-title);
  letter-spacing: -.035em;
}

.stage-title-row p {
  max-width: 470px;
  font: 400 13px/1.55 var(--font-ui);
}

.pipeline-status strong,
.run-card-head strong,
.publish-artifact strong {
  font-family: var(--font-ui);
  font-size: 12px;
}

.pipeline-status small,
.run-card-head small,
.preset-picker small,
.publish-artifact small {
  font-family: var(--font-ui);
  font-size: 10px;
  line-height: 1.4;
}

.dataset-toolbar,
.text-action,
.training-estimate,
.pipeline-link {
  font-size: 10px;
}

.run-metrics small,
.publish-artifact span,
.collection-avatar-copy small,
.library-controls > label,
.video-badge,
.library-item figcaption small,
.library-item figcaption b {
  font-family: var(--font-ui);
  font-size: 9px;
}

.collection-header .primary-action.compact {
  min-height: 44px;
  padding-inline: 20px;
  font-size: 11px;
}

.avatar-collection,
.library-grid {
  margin-top: 36px;
}

.collection-avatar-copy strong,
.library-item figcaption strong {
  font: 600 14px/1.25 var(--font-ui);
}

.collection-avatar-actions button,
.library-item-actions button,
.library-item-actions a {
  min-height: 40px;
  font-size: 10px;
  font-weight: 550;
}

.library-controls > label {
  gap: 7px;
  font-weight: 650;
}

.library-controls select,
.library-filter button {
  font-size: 11px;
}

.draft-footer {
  position: relative;
  inset: auto;
  flex: 0 0 42px;
  width: 100%;
  margin-top: 22px;
  padding: 0;
  background: transparent;
  font-size: 10px;
}

.avatar-picker {
  position: absolute;
  z-index: 30;
  bottom: calc(100% + 14px);
  width: 316px;
  max-height: min(470px, calc(100vh - 210px));
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(53,47,40,.12);
  border-radius: 18px;
  background: rgba(250,248,244,.98);
  box-shadow: 0 24px 64px rgba(51,44,36,.2);
  backdrop-filter: blur(24px);
}

.avatar-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 8px 6px 10px;
}

.avatar-picker-head strong {
  font-size: 13px;
  font-weight: 650;
}

.avatar-picker-head button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #eee9e1;
  color: #5f5a53;
  font-size: 18px;
}

.avatar-picker-list {
  display: grid;
  gap: 4px;
}

.avatar-picker-item {
  min-height: 66px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 8px;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #272521;
  text-align: left;
}

.avatar-picker-item:hover,
.avatar-picker-item.active {
  background: #efeae2;
}

.avatar-picker-item img,
.avatar-picker-item .avatar-fallback {
  width: 48px;
  height: 52px;
  border: 0;
  border-radius: 7px;
  object-fit: cover;
}

.avatar-picker-item > span {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.avatar-picker-item strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-picker-item small {
  color: #8a847c;
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.avatar-picker-item i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c7c1b8;
}

.avatar-picker-item.active i {
  background: var(--success);
}

.avatar-picker-create {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 7px;
  border: 1px solid #d3cdc3;
  border-radius: 10px;
  background: transparent;
  color: #4e4943;
  font-size: 11px;
  font-weight: 600;
}

.avatar-picker-create:hover { background: #eee9e1; color: #1d1c1a; }
.avatar-picker-create svg { width: 15px; height: 15px; }
.library-media.is-preview-fallback img { filter: saturate(.72) contrast(.92) brightness(1.04); }

@media (max-width: 1180px) {
  :root { --page-gutter: 32px; }
  .training-grid { grid-template-columns: 132px minmax(290px, .75fr) minmax(370px, 1fr); gap: 24px; }
}

@media (max-width: 760px) {
  :root { --page-gutter: 16px; }
  .view-training,
  .collection-view { padding-right: var(--page-gutter); padding-left: var(--page-gutter); }
  .training-heading,
  .collection-header { min-height: 0; }
  .training-heading h1,
  .collection-header h1 { font-size: 36px; }
  .training-heading p,
  .collection-header p { font-size: 13px; }
  .training-grid { display: flex; gap: 22px; margin-top: 0; }
  .training-steps strong { font-size: 11px; }
  .stage-title-row h2 { font-size: 28px; }
  .collection-header .primary-action.compact { margin-top: 18px; }
  .library-controls { margin-top: 20px; }
  .avatar-collection,
  .library-grid { margin-top: 26px; }
  .avatar-picker {
    position: fixed;
    right: 13px;
    bottom: 238px;
    left: 13px !important;
    width: auto;
    max-height: min(56vh, 430px);
  }
}
