/* Characters: the marketplace, your own, and the builder (a live model on the left, the dials on the right). */
.ch-body { overflow-x: clip; }
.ch { max-width: 1160px; margin: 0 auto; padding: 14px 16px 80px; }
.ch-view[hidden] { display: none; }
.ch-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.ch-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.ch-tab { height: 34px; padding: 0 16px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.ch-tab.is-on { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }

.ch-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.ch-btn:active { transform: scale(.97); }
.ch-btn[disabled] { opacity: .55; pointer-events: none; }
.ch-btn-p { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.ch-btn-ghost { background: transparent; }
.ch-btn-danger { color: #ff6b6b; }

.ch-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.ch-search { flex: 1 1 220px; margin: 0; }
.ch-search input { width: 100%; height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); font: inherit; font-size: 15px; }
.ch-search input:focus { outline: none; border-color: var(--yellow); }
.ch-sorts { display: flex; gap: 6px; }
.ch-chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.ch-chip.is-on { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.ch-count { margin: 0 0 10px; color: var(--muted); font-size: 13px; }

/* cards */
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 440px) { .ch-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.ch-card { position: relative; display: block; padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: var(--panel); color: var(--ink); text-align: left; cursor: pointer; font: inherit; box-shadow: 0 0 0 1px var(--line); transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.ch-card:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--line-2), 0 12px 30px rgba(0, 0, 0, .35); }
.ch-card-pic { aspect-ratio: 3 / 4; background: var(--panel-2); position: relative; overflow: hidden; }
.ch-card-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-card-pic svg { width: 100%; height: 100%; display: block; }
.ch-card-body { padding: 9px 10px 11px; }
.ch-card-body strong { display: block; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-card-body span { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.ch-card-body em { font-style: normal; display: flex; gap: 8px; margin-top: 5px; color: var(--muted-2); font-size: 11.5px; }
.ch-flag { position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; backdrop-filter: blur(6px); }
.ch-empty { grid-column: 1 / -1; padding: 50px 16px; text-align: center; color: var(--muted); }
.ch-empty strong { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.ch-end { text-align: center; padding: 18px 0 0; }

/* the builder */
.ch-build { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ch-build { max-width: 760px; margin: 0 auto; }
.ch-stage { display: grid; gap: 10px; padding: 14px; border-radius: 18px; background: radial-gradient(120% 80% at 50% 0%, rgba(121, 0, 7, .22), transparent 60%), var(--panel); border: 1px solid var(--line); }
.ch-figure { aspect-ratio: 1 / 2; max-height: 60vh; margin: 0 auto; width: 100%; max-width: 280px; }
.ch-figure svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .45)); }
.ch-figure svg * { transition: all .18s ease-out; }
.ch-photo { width: 100%; max-width: 300px; margin: 0 auto; border-radius: 14px; display: block; aspect-ratio: 4 / 5; object-fit: cover; }
.ch-photo[hidden] { display: none; }
.ch-stage-foot { display: grid; gap: 8px; justify-items: center; }
.ch-stage-foot .ch-btn { min-width: 180px; }
.ch-fine { margin: 0; color: var(--muted-2); font-size: 12px; text-align: center; }
.ch-fine:empty { display: none; }
.ch-stage.is-making .ch-figure { animation: ch-pulse 1.2s ease-in-out infinite; }
@keyframes ch-pulse { 50% { opacity: .45; } }

.ch-panel { display: grid; gap: 14px; padding: 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.ch-steps { position: sticky; top: calc(var(--hdr, 0px) + 8px); z-index: 5; box-shadow: 0 10px 24px rgba(0, 0, 0, .45); display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.ch-step { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.ch-step.is-on { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.ch-dice { width: 40px; height: 36px; border: 0; border-radius: 9px; background: transparent; font-size: 20px; cursor: pointer; line-height: 1; }
.ch-dice:hover { background: var(--panel-2); }
.ch-dice:active { transform: rotate(25deg) scale(.9); }
.ch-form { display: grid; gap: 14px; }
.ch-form[hidden] { display: none; }
.ch-form + .ch-form { padding-top: 18px; border-top: 1px solid var(--line); }
.ch-sec { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); scroll-margin-top: calc(var(--hdr, 0px) + 70px); }
.ch-field { display: grid; gap: 5px; }
.ch-field > span, .ch-pick > span, .ch-slider > span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.ch-field input, .ch-field textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); font: inherit; font-size: 15px; resize: vertical; }
.ch-field input:focus, .ch-field textarea:focus { outline: none; border-color: var(--yellow); }

.ch-sliders { display: grid; gap: 10px; }
@media (min-width: 560px) { .ch-sliders { grid-template-columns: 1fr 1fr; column-gap: 18px; } }
.ch-slider { display: grid; gap: 2px; }
.ch-slider > span b { color: var(--ink); font-weight: 800; letter-spacing: 0; text-transform: none; font-size: 12px; margin-left: 6px; }
.ch-slider em { display: flex; justify-content: space-between; font-style: normal; font-size: 11px; color: var(--muted-2); margin-top: -2px; }
.ch-slider input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; margin: 0; background: transparent; cursor: pointer; }
.ch-slider input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(90deg, rgba(121, 0, 7, .9), rgba(255, 255, 255, .12)); }
.ch-slider input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: linear-gradient(90deg, rgba(121, 0, 7, .9), rgba(255, 255, 255, .12)); }
.ch-slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; border: 3px solid var(--yellow); box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.ch-slider input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--yellow); box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }

.ch-pick { display: grid; gap: 7px; }
.ch-pick > div { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-opt { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.ch-opt:hover { border-color: rgba(121, 0, 7, .6); color: var(--ink); }
.ch-opt.is-on { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.ch-swatch { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .15); cursor: pointer; }
.ch-swatch.is-on { border-color: #fff; box-shadow: 0 0 0 2px var(--yellow); }
.ch-preview { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.ch-preview summary { cursor: pointer; font-weight: 700; color: var(--ink-2); }
.ch-preview p { margin: 8px 0 0; white-space: pre-wrap; line-height: 1.45; }
.ch-actions { display: grid; gap: 10px; padding-top: 6px; border-top: 1px solid var(--line); }
.ch-actions > div { display: flex; gap: 8px; justify-content: flex-end; }
.ch-share { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.ch-share input { width: 18px; height: 18px; accent-color: var(--yellow); }
.ch-err { margin: 0; color: #ff6b6b; font-size: 13px; min-height: 0; }
.ch-err:empty { display: none; }

/* the sheet */
.ch-sheet { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); margin: auto; padding: 0; border: 1px solid var(--line-2); border-radius: 18px; background: var(--panel); color: var(--ink); overflow: hidden; }
.ch-sheet::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); }
.ch-sheet-in { max-height: calc(100dvh - 26px); overflow-y: auto; padding: 18px; display: grid; gap: 14px; position: relative; }
.ch-x { position: absolute; top: 12px; right: 12px; z-index: 2; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid rgba(255, 255, 255, .14); border-radius: 50%; background: rgba(10, 10, 12, .72); color: #fff; cursor: pointer; backdrop-filter: blur(8px); -webkit-tap-highlight-color: transparent; transition: background .15s, transform .15s; }
.ch-x:hover { background: rgba(40, 40, 46, .9); }
.ch-x:active { transform: scale(.92); }
.ch-x svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.ch-sheet-top { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.ch-sheet-pic { aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--panel-2); }
.ch-sheet-pic img, .ch-sheet-pic svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-sheet-id h2 { margin: 0; font-size: 22px; padding-right: 36px; overflow-wrap: anywhere; }
.ch-sheet-id p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.ch-by { color: var(--muted) !important; font-size: 12.5px !important; }
.ch-by a { color: inherit; text-decoration: none; font-weight: 700; }
.ch-stats { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ch-stats span { padding: 3px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11.5px; color: var(--ink-2); font-weight: 700; }
.ch-traits { display: grid; gap: 6px; }
.ch-trait { display: grid; grid-template-columns: 74px 1fr 74px; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.ch-trait > span:last-child { text-align: right; }
.ch-trait i { position: relative; display: block; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.ch-trait i::after { content: ""; position: absolute; top: -4px; width: 14px; height: 14px; border-radius: 50%; background: var(--yellow); left: calc(var(--v) * 1% - 7px); box-shadow: 0 0 0 2px var(--panel); }
.ch-persona { margin: 0; white-space: pre-wrap; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.ch-persona:empty { display: none; }
.ch-feat h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ch-feat-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ch-feat-v { display: grid; gap: 5px; color: var(--ink); text-decoration: none; min-width: 0; }
.ch-feat-v img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: #111; display: block; }
.ch-feat-v span { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-mem h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ch-mem ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.ch-mem li { font-size: 13px; color: var(--ink-2); padding: 7px 10px; border-radius: 9px; background: var(--panel-2); }
.ch-mem li small { display: block; color: var(--muted-2); font-size: 11px; margin-top: 2px; }
.ch-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-sheet-actions .ch-btn { flex: 1 1 auto; }
.ch-blank { width: 100%; height: 100%; display: grid; place-items: center; font-size: 46px; font-weight: 800; color: var(--muted-2); background: radial-gradient(120% 80% at 50% 0%, rgba(121, 0, 7, .25), transparent 65%), var(--panel-2); }
.ch-stage { align-content: start; }

.ch-card-pic img.is-broken { display: none; }
.ch-x:focus { outline: none; }
.ch-x:focus-visible { outline: 2px solid rgba(255, 255, 255, .6); outline-offset: 2px; }
.ch-sheet-in:focus { outline: none; }
.ch-sheet-pic img { cursor: zoom-in; }
/* his photo, full screen */
.ch-zoom { position: fixed; inset: 0; z-index: 4000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .94); cursor: zoom-out; animation: ch-zoom-in .18s ease-out; }
.ch-zoom img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.ch-zoom .ch-x { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; }
@keyframes ch-zoom-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.ch-build-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ch-build-head h2 { margin: 0; font-size: 22px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-rand { height: 36px; padding: 0 12px; font-size: 13.5px; }
