* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0d0f18;
    --bg2: #151a2a;
    --bg3: #20283d;
    --text: #f1f3f8;
    --text2: #98a1b8;
    --accent: #f04f72;
    --accent2: #8b7cf6;
    --success: #53d6a2;
    --warning: #f0be5a;
    --border: #2d354d;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

select {
    color-scheme: dark;
}

select option,
select optgroup {
    background: #171b29;
    color: #f1f3f8;
}

select option:checked,
select option:hover {
    background: #2a3147;
    color: #ffffff;
}

#app {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--border);
}

#sidebar-header h1 {
    font-size: 20px;
    background: linear-gradient(135deg, #e94560, #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#points-display {
    font-size: 12px;
    color: var(--text2);
    margin-top: 4px;
}

.section-title {
    padding: 16px 16px 8px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text2);
    letter-spacing: 1px;
}

#char-list, #model-list {
    padding: 0 8px;
}

.char-item, .model-item {
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.char-item:hover, .model-item:hover {
    background: var(--bg3);
}

.char-item.active, .model-item.active {
    background: var(--accent);
}

.char-avatar {
    font-size: 24px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg3);
    border-radius: 50%;
    flex-shrink: 0;
}

.char-info {
    min-width: 0;
}

.char-name {
    font-size: 14px;
    font-weight: 600;
}

.char-desc {
    font-size: 11px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-item {
    display: block;
}

.model-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-name {
    font-size: 13px;
    font-weight: 600;
}

.model-price {
    font-size: 11px;
    color: #55efc4;
}

.model-desc {
    font-size: 11px;
    color: var(--text2);
    margin-top: 2px;
}

.model-speed {
    font-size: 10px;
    color: #fdcb6e;
    margin-top: 2px;
}

#sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

#clear-btn, #settings-btn {
    padding: 8px 16px;
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    flex: 1;
}

#clear-btn:hover, #settings-btn:hover {
    background: var(--accent);
}

#api-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
}

#api-status.online { background: #55efc4; }
#api-status.offline { background: #ff6b6b; }

#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-y: auto;
}

#chat-header {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#current-char {
    font-size: 16px;
    font-weight: 600;
}

#current-model {
    font-size: 12px;
    color: var(--text2);
}

.chat-model-control {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    justify-content: flex-end;
}

.chat-model-control select {
    width: 188px;
    height: 34px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: #111625;
    color: var(--text);
    padding: 0 34px 0 10px;
    font-size: 12px;
    outline: none;
}

.chat-model-control select:focus {
    border-color: rgba(233,69,96,0.7);
    box-shadow: 0 0 0 3px rgba(233,69,96,0.12);
}

#chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    opacity: 0.5;
}

.welcome-icon { font-size: 64px; }
#welcome h2 { font-size: 22px; }
#welcome p { font-size: 14px; color: var(--text2); }

.msg-row {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-row.user {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}

.msg-row.assistant .msg-avatar {
    background: var(--bg3);
    border: 1px solid rgba(255,255,255,0.10);
}
.msg-row.user .msg-avatar { background: var(--accent); }

.msg-avatar-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-avatar-img + .msg-avatar-text {
    display: none;
}

.msg-avatar-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.msg-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-row.assistant .msg-bubble {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
}

.msg-row.user .msg-bubble {
    background: var(--bg3);
    border-top-right-radius: 4px;
}

.msg-cost {
    font-size: 10px;
    color: var(--text2);
    margin-top: 4px;
}

.msg-row.assistant .msg-cost { margin-left: 48px; }
.msg-row.user .msg-cost { margin-right: 48px; text-align: right; }

#input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#msg-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 120px;
}

#msg-input:focus {
    border-color: var(--accent);
}

#msg-input::placeholder {
    color: var(--text2);
}

#send-btn {
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

#send-btn:hover { opacity: 0.9; }
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text2);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--bg2);
    padding: 24px;
    border-radius: 12px;
    width: 400px;
    border: 1px solid var(--border);
}

.modal-content h3 {
    margin-bottom: 16px;
}

.modal-content label {
    display: block;
    font-size: 12px;
    color: var(--text2);
    margin: 8px 0 4px;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.modal-content input:focus {
    border-color: var(--accent);
}

.modal-btns {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-btns button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

#settings-save {
    background: var(--accent);
    color: white;
}

#settings-close {
    background: var(--bg3);
    color: var(--text);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ─── Admin Styles ─── */

.admin-sidebar { width: 200px; min-width: 200px; }

#admin-nav { padding: 8px; }

.nav-item {
    display: block;
    padding: 10px 16px;
    color: var(--text2);
    text-decoration: none;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent); color: white; }

.admin-page { padding: 24px; }

.admin-page h2 { font-size: 20px; margin-bottom: 20px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

.stat-num { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--text2); margin-top: 4px; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.toolbar input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

.toolbar input:focus { border-color: var(--accent); }

.btn {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.btn:hover { opacity: 0.9; }

.btn-sm {
    padding: 4px 10px;
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin: 1px;
}

.btn-sm:hover { background: var(--accent); }
.btn-sm.active { background: var(--accent); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg2);
    border-bottom: 2px solid var(--border);
    color: var(--text2);
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.badge-admin { background: #6c5ce7; color: white; }
.badge-user { background: var(--bg3); color: var(--text2); }
.badge-on { background: #55efc4; color: #1a1a2e; }
.badge-off { background: #ff6b6b; color: white; }

.pager {
    margin-top: 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.form-group {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    max-width: 500px;
}

.form-group h3 { font-size: 16px; margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin: 8px 0 4px; }
.form-group input {
    width: 100%;
    padding: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.form-group input:focus { border-color: var(--accent); }

code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
}

/* ─── User Login/Register ─── */

#user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-points { font-size: 13px; color: #55efc4; }

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.login-overlay.hidden { display: none; }

.login-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 380px;
}

.login-card h2 {
    text-align: center;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #e94560, #a29bfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 24px;
}

.login-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.login-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
}

.login-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 4px;
}

.form-field input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.form-field input:focus { border-color: var(--accent); }

.login-submit {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    margin-top: 8px;
}

.login-submit:hover { opacity: 0.9; }

.login-error {
    color: #ff6b6b;
    font-size: 12px;
    margin-top: 8px;
    text-align: center;
}

#recharge-btn {
    padding: 4px 12px;
    background: #55efc4;
    color: #1a1a2e;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

/* ─── Character Tags & Filter ─── */

.char-tags { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; }

.mini-tag {
    font-size: 9px;
    padding: 1px 6px;
    background: var(--bg3);
    border-radius: 8px;
    color: var(--text2);
}

.char-tag {
    font-size: 11px;
    padding: 3px 10px;
    background: var(--bg3);
    border-radius: 10px;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.15s;
}

.char-tag:hover { background: var(--accent); color: white; }
.char-tag.active { background: var(--accent); color: white; }

/* ─── Conversation List ─── */

#conv-list { padding: 0 8px; }

.conv-item {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
}

.conv-item:hover { background: var(--bg3); }
.conv-item.active { background: var(--accent); }

.conv-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 20px;
}

.conv-time {
    font-size: 10px;
    color: var(--text2);
}

.conv-del {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
}

.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: #ff6b6b; }

/* ─── Model Tags ─── */

.model-tags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.mtag {
    font-size: 9px;
    padding: 1px 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    color: var(--text2);
}

/* ─── Character Greeting ─── */

.greeting-msg {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    font-style: italic;
    color: var(--text2);
    font-size: 13px;
}

/* ─── Regenerate Button ─── */

#regenerate-btn:hover {
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}

/* ─── Voice Button ─── */

#voice-toggle {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text2);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}

#voice-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Model Cards ─── */

#model-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 16px;
}

.model-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.model-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.model-card-name {
    font-size: 16px;
    font-weight: 700;
}

.model-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.model-clear-key {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    color: var(--text2);
    font-size: 11px;
}

/* ─── Login Close Button ─── */

.login-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}
.login-close:hover { color: var(--accent); }

/* ─── NSFW Model Description ─── */

.model-nsfw {
    font-size: 11px;
    color: #e94560;
    margin-top: 2px;
    line-height: 1.4;
}

/* ─── Community Feed ─── */

.post-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.post-user { font-weight: 600; font-size: 14px; }
.post-time { font-size: 11px; color: var(--text2); }

.post-content {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.post-char-card {
    background: var(--bg);
    border: 1px solid rgba(233,69,96,0.3);
    border-radius: 10px;
    padding: 14px;
    margin: 10px 0;
}

.char-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.post-actions {
    display: flex;
    gap: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 10px;
}

.action-btn {
    cursor: pointer;
    font-size: 13px;
    color: var(--text2);
    transition: color 0.15s;
}
.action-btn:hover { color: var(--accent); }

.comments-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ─── Kink Tag ─── */

.kink-tag {
    background: rgba(233,69,96,0.15) !important;
    color: #e94560 !important;
    border: 1px solid rgba(233,69,96,0.3) !important;
}
.kink-tag.active {
    background: #e94560 !important;
    color: white !important;
}

/* Modernized app shell and modal polish */

#sidebar {
    width: 304px;
    min-width: 304px;
}

#sidebar-header h1 {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#user-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 10px;
    align-items: center;
}

#user-header > a {
    grid-column: 1 / -1;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.char-item,
.model-item {
    margin: 3px 0;
}

.char-item:hover,
.model-item:hover {
    background: rgba(255,255,255,0.06);
}

.char-item.active,
.model-item.active {
    background: linear-gradient(135deg, rgba(240,79,114,0.95), rgba(139,124,246,0.9));
    color: white;
}

.char-avatar {
    background: linear-gradient(135deg, rgba(240,79,114,0.18), rgba(139,124,246,0.18));
}

.model-price,
#user-points,
#api-status.online {
    color: var(--success);
}

.model-speed {
    color: var(--warning);
}

.model-pref-line {
    margin-top: 5px;
    overflow: hidden;
    color: #ffd4dc;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#sidebar-footer {
    background: rgba(13, 15, 24, 0.82);
    position: sticky;
    bottom: 0;
}

#main {
    overflow: hidden;
}

#chat-header {
    padding: 16px 24px;
}

.chat-session-panel {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr) minmax(180px, 260px);
    gap: 12px;
    padding: 12px 24px;
    border-top: 1px solid rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(10, 12, 20, 0.72);
}

.chat-session-panel.hidden,
.quick-reply-bar.hidden {
    display: none;
}

.chat-role-mini {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-width: 0;
}

.chat-role-mini img {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    object-fit: cover;
    background: #090b12;
    border: 1px solid rgba(255,255,255,0.08);
}

.chat-role-mini b,
.chat-session-memory b,
.chat-session-progress b {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 13px;
}

.chat-role-mini span,
.chat-session-progress small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text2);
    font-size: 11px;
}

.chat-session-memory {
    min-width: 0;
    display: grid;
    gap: 7px;
    padding: 0 12px;
    border-left: 1px solid rgba(255,255,255,0.08);
    border-right: 1px solid rgba(255,255,255,0.08);
}

.chat-session-memory p {
    margin: 3px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text2);
    font-size: 12px;
}

.chat-session-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.chat-session-pref-head {
    color: #ff9ab0;
    font-size: 10px;
    font-weight: 900;
}

.chat-session-tags span {
    padding: 3px 7px;
    border-radius: 999px;
    color: #ffd4dc;
    background: rgba(240,79,114,0.13);
    font-size: 10px;
}

.chat-session-progress {
    min-width: 0;
    display: grid;
    gap: 6px;
}

.chat-session-progress > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.node-count-btn {
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    color: #ff9ab0;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
}

.node-count-btn:hover {
    color: #ffd4dc;
}

.relation-meter {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
}

.relation-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #61e4ae, #f04f72);
}

#chat-area {
    padding: 24px;
}

#welcome {
    opacity: 1;
    text-align: center;
    max-width: 680px;
    margin: 0 auto;
}

#welcome h2 {
    font-size: 30px;
}

.welcome-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.welcome-actions button,
.login-banner button {
    border: none;
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 999px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 700;
}

.welcome-actions button + button {
    background: rgba(255,255,255,0.08);
    color: var(--text);
    border: 1px solid var(--border);
}

.login-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    border: 1px solid rgba(240,79,114,0.28);
    background: rgba(240,79,114,0.12);
    color: var(--text);
    border-radius: 10px;
    font-size: 13px;
}

.msg-stack {
    max-width: min(720px, 76vw);
}

.msg-stack .msg-bubble {
    max-width: 100%;
}

.msg-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    opacity: 0.46;
    transition: opacity .16s ease;
}

.msg-row:hover .msg-actions {
    opacity: 1;
}

.msg-row.user .msg-actions {
    justify-content: flex-end;
}

.msg-actions button {
    min-height: 24px;
    padding: 0 8px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
    color: var(--text2);
    background: rgba(255,255,255,0.045);
    cursor: pointer;
    font-size: 11px;
}

.msg-actions button:hover,
.msg-actions button.active {
    border-color: rgba(240,79,114,0.38);
    color: #ffd4dc;
    background: rgba(240,79,114,0.13);
}

#input-area {
    background: rgba(13, 15, 24, 0.92);
}

.quick-reply-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px 0;
    background: rgba(13, 15, 24, 0.92);
    border-top: 1px solid rgba(255,255,255,0.06);
    overflow-x: auto;
}

.quick-reply-bar > span {
    flex: 0 0 auto;
    color: var(--text2);
    font-size: 11px;
    font-weight: 800;
}

.quick-reply-bar button {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 0 11px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 999px;
    color: var(--text);
    background: rgba(255,255,255,0.055);
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.quick-reply-bar button:hover {
    border-color: rgba(240,79,114,0.42);
    color: #ffd4dc;
    background: rgba(240,79,114,0.13);
}

.story-node-drawer.hidden {
    display: none;
}

.story-node-drawer {
    position: fixed;
    inset: 0;
    z-index: 190;
}

.story-node-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(0,0,0,0.54);
    backdrop-filter: blur(8px);
    cursor: pointer;
}

.story-node-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(420px, 100vw);
    height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-left: 1px solid rgba(255,255,255,0.10);
    background: #10131b;
    box-shadow: -28px 0 90px rgba(0,0,0,0.42);
}

.story-node-panel header,
.story-node-panel footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.story-node-panel footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    border-bottom: 0;
    justify-content: flex-end;
}

.story-node-panel h3 {
    margin: 0;
    font-size: 18px;
}

.story-node-panel p {
    margin: 4px 0 0;
    color: var(--text2);
    font-size: 12px;
    line-height: 1.55;
}

.story-node-list {
    overflow: auto;
    padding: 14px;
    display: grid;
    align-content: start;
    gap: 10px;
}

.story-node-item,
.story-node-empty {
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
}

.story-node-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--text2);
    font-size: 11px;
}

.story-node-meta span {
    color: #ffd4dc;
    font-weight: 800;
}

.story-node-item p {
    margin: 9px 0 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.story-node-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}

.story-node-actions button {
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,0.055);
    cursor: pointer;
    font-size: 12px;
}

.story-node-actions button:hover {
    border-color: rgba(240,79,114,0.40);
    color: #ffd4dc;
    background: rgba(240,79,114,0.13);
}

.story-node-empty b {
    display: block;
    font-size: 14px;
}

#send-btn {
    background: linear-gradient(135deg, var(--accent), #e63f6e);
}

#regenerate-btn,
#voice-toggle {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text2);
    min-width: 48px;
    height: 44px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}

#regenerate-btn:hover,
#voice-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.modal {
    background: rgba(4, 5, 9, 0.72);
    z-index: 160;
    backdrop-filter: blur(12px);
}

.modal-content {
    box-shadow: var(--shadow);
    max-height: calc(100vh - 56px);
    overflow: auto;
}

.modal-wide {
    width: min(1040px, calc(100vw - 32px));
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.modal-content h3 {
    margin-bottom: 5px;
    font-size: 20px;
}

.modal-content p {
    color: var(--text2);
    font-size: 13px;
    line-height: 1.5;
}

.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    resize: vertical;
    font-family: inherit;
}

.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
    border-color: var(--accent);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: white;
}

.btn-secondary {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border) !important;
}

.modal-close {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    flex: 0 0 auto;
}

.modal-close:hover {
    color: var(--text);
    border-color: var(--accent);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 12px;
}

.tag-divider {
    width: 100%;
    color: var(--text2);
    font-size: 10px;
    padding: 4px 2px 1px;
}

.tag-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 156px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(13,15,24,0.62);
}

.creator-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.creator-editor {
    min-width: 0;
}

.creator-block {
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.035);
}

.creator-block-head,
.creator-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.creator-block-head b {
    display: block;
    font-size: 13px;
}

.creator-block-head span {
    display: block;
    margin-top: 2px;
    color: var(--text2);
    font-size: 11px;
}

.creator-link-btn {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(240,79,114,0.28);
    border-radius: 8px;
    color: #ff9aad;
    background: rgba(240,79,114,0.10);
    cursor: pointer;
    font-size: 12px;
}

.creator-link-btn:hover {
    border-color: rgba(240,79,114,0.58);
    background: rgba(240,79,114,0.18);
}

.creator-template-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.creator-template {
    display: grid;
    gap: 4px;
    min-height: 88px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text);
    background: rgba(8,10,17,0.62);
    text-align: left;
    cursor: pointer;
}

.creator-template:hover,
.creator-template.active {
    border-color: rgba(240,79,114,0.54);
    background: rgba(240,79,114,0.13);
}

.creator-template span {
    font-size: 22px;
}

.creator-template b {
    font-size: 13px;
}

.creator-template small {
    color: var(--text2);
    font-size: 11px;
    line-height: 1.35;
}

.creator-appearance-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.creator-appearance-field {
    min-width: 0;
}

.creator-appearance-field label {
    display: block;
    margin: 0 0 5px;
    color: var(--text2);
    font-size: 11px;
}

.creator-appearance-field select {
    width: 100%;
    min-height: 38px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    color: var(--text);
    background: rgba(8,10,17,0.72);
    font-size: 12px;
}

.creator-field-head {
    margin-top: 10px;
}

.creator-field-head label {
    margin: 0;
}

.creator-preview {
    position: sticky;
    top: 0;
    display: grid;
    gap: 12px;
    min-width: 0;
}

.creator-preview-card,
.creator-preview-section {
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    background: rgba(10,12,20,0.78);
}

.creator-preview-card {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
}

.creator-preview-avatar {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(145deg, rgba(240,79,114,0.22), rgba(83,214,162,0.16));
    font-size: 30px;
}

.creator-preview-body {
    min-width: 0;
}

.creator-preview-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 17px;
    font-weight: 900;
}

.creator-preview-desc {
    margin-top: 6px;
    color: var(--text2);
    font-size: 12px;
    line-height: 1.5;
}

.creator-preview-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.creator-preview-tags span {
    max-width: 100%;
    padding: 4px 7px;
    border-radius: 999px;
    color: #ffd4dc;
    background: rgba(240,79,114,0.14);
    font-size: 11px;
}

.creator-preview-section {
    padding: 12px;
}

.creator-preview-section b {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
}

.creator-preview-section p {
    margin: 0;
    color: var(--text2);
    font-size: 12px;
    line-height: 1.6;
}

.creator-quality-list {
    display: grid;
    gap: 7px;
}

.creator-quality {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text2);
    font-size: 12px;
}

.creator-quality span {
    width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255,255,255,0.07);
    color: var(--text2);
    font-size: 11px;
}

.creator-quality.done {
    color: #dffbed;
}

.creator-quality.done span {
    background: rgba(83,214,162,0.18);
    color: #61e4ae;
}

.creator-quality b {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
}

.creator-preview-foot {
    padding: 10px 12px;
    border-left: 2px solid rgba(83,214,162,0.56);
    border-radius: 6px;
    color: var(--text2);
    background: rgba(83,214,162,0.08);
    font-size: 12px;
    line-height: 1.5;
}

.story-role-brief {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
}

.story-role-brief:empty {
    display: none;
}

.story-role-brief img {
    width: 64px;
    height: 78px;
    border-radius: 8px;
    object-fit: cover;
    background: #090b12;
}

.story-role-brief b {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
}

.story-role-brief p {
    margin: 0 0 8px;
}

.story-role-brief div div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.story-role-brief span {
    padding: 4px 7px;
    border-radius: 999px;
    color: #ffd4dc;
    background: rgba(240,79,114,0.14);
    font-size: 11px;
}

.story-preset-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 10px 0 14px;
}

.story-preset-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-height: 132px;
    padding: 13px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    color: var(--text);
    background: linear-gradient(180deg, rgba(255,255,255,0.065), rgba(255,255,255,0.032));
    cursor: pointer;
    text-align: left;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.story-preset-card:hover,
.story-preset-card.active {
    border-color: rgba(240,79,114,0.52);
    background: linear-gradient(180deg, rgba(240,79,114,0.15), rgba(119,92,255,0.08));
    transform: translateY(-1px);
}

.story-preset-card:disabled {
    cursor: wait;
    opacity: .72;
    transform: none;
}

.story-preset-card.loading {
    border-color: rgba(255,255,255,0.34);
}

.story-preset-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.story-preset-card b {
    min-width: 0;
    font-size: 15px;
    line-height: 1.25;
}

.story-preset-card-action {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 50%;
    color: #ffd8e0;
    background: rgba(255,255,255,0.06);
    font-size: 22px;
    line-height: 1;
}

.story-preset-card-body {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    color: var(--text2);
    font-size: 12px;
    line-height: 1.55;
}

.story-preset-card small {
    margin-top: auto;
    color: #ff9aad;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
}

.empty-state,
.inline-error {
    color: var(--text2);
    font-size: 13px;
    padding: 14px 12px;
}

.inline-error {
    color: #ff8aa1;
    border: 1px solid rgba(240,79,114,0.32);
    background: rgba(240,79,114,0.12);
    border-radius: 8px;
}

.kink-mini {
    background: rgba(240,79,114,0.18);
    color: #ff8aa1;
}

.custom-badge {
    font-size: 9px;
    color: white;
    background: rgba(83,214,162,0.24);
    border: 1px solid rgba(83,214,162,0.28);
    border-radius: 999px;
    padding: 1px 6px;
    margin-left: 4px;
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    #app {
        height: auto;
        min-height: 100vh;
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        min-width: 0;
        max-height: 44vh;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    #main {
        min-height: 56vh;
    }

    #chat-area {
        min-height: 46vh;
        padding: 18px;
    }

    .chat-session-panel {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 10px;
    }

    .chat-session-memory {
        padding: 10px 0;
        border-left: 0;
        border-right: 0;
        border-top: 1px solid rgba(255,255,255,0.08);
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .quick-reply-bar {
        padding: 9px 12px 0;
    }

    .story-node-panel {
        width: 100vw;
    }

    .story-node-panel header,
    .story-node-panel footer {
        padding: 14px;
    }

    #input-area {
        padding: 12px;
        gap: 8px;
    }

    #send-btn {
        padding: 12px 16px;
    }

    .msg-bubble,
    .msg-stack {
        max-width: 86vw;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Platform navigation, discover feed, and character inspector */

.app-nav {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
}

.app-nav button,
.app-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text2);
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}

.app-nav button.active,
.app-nav button:hover,
.app-nav a:hover {
    color: white;
    border-color: rgba(240,79,114,0.48);
    background: linear-gradient(135deg, rgba(240,79,114,0.22), rgba(139,124,246,0.18));
}

body[data-view="discover"] #input-area {
    display: none;
}

body[data-view="discover"] #chat-area {
    padding: 28px;
}

#detail-panel {
    width: 292px;
    min-width: 292px;
    border-left: 1px solid var(--border);
    background: rgba(14, 17, 28, 0.96);
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.detail-empty,
#detail-card {
    padding: 22px;
}

.detail-empty {
    min-height: 100%;
    place-items: center;
    text-align: center;
    color: var(--text2);
}

.detail-empty span {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 14px;
    border-radius: 18px;
    color: white;
    background: linear-gradient(135deg, rgba(240,79,114,0.35), rgba(139,124,246,0.28));
    font-size: 26px;
}

.detail-empty h3,
#detail-card h2 {
    color: var(--text);
}

.detail-empty p,
#detail-card p {
    color: var(--text2);
    font-size: 13px;
    line-height: 1.6;
}

.detail-cover {
    width: 100%;
    aspect-ratio: 0.78;
    border-radius: 14px;
    margin-bottom: 18px;
    background: #121827;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0,0,0,0.22);
}

.detail-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.detail-kicker {
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}

#detail-card h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.detail-tags,
.discover-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.detail-tags {
    margin: 16px 0;
}

.detail-tags span,
.discover-card-tags span {
    color: var(--text2);
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 3px 8px;
    font-size: 11px;
}

.detail-actions {
    display: grid;
    gap: 10px;
    margin: 18px 0;
}

.detail-actions button {
    min-height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    font-weight: 700;
}

.detail-actions button + button {
    background: rgba(255,255,255,0.06);
    color: var(--text);
}

.detail-meta {
    display: grid;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    color: var(--text2);
    font-size: 12px;
}

.detail-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-top: 14px;
}

.detail-stat-grid span {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
}

.detail-stat-grid b {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font-size: 13px;
}

.detail-stat-grid small {
    color: var(--text2);
    font-size: 10px;
}

.detail-story-preview {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.detail-story-preview b {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
}

.detail-story-preview p {
    margin: 0;
}

.detail-scene-list {
    display: grid;
    gap: 7px;
}

.detail-scene-list button {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,0.045);
    cursor: pointer;
    text-align: left;
}

.detail-scene-list button:hover {
    border-color: rgba(240,79,114,0.42);
    background: rgba(240,79,114,0.12);
}

.detail-scene-list span {
    display: grid;
    place-items: center;
}

.detail-scene-list b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.discover-shell {
    display: grid;
    gap: 22px;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
}

.discover-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 24px;
    align-items: stretch;
    min-height: 260px;
    padding: 30px;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.08);
    background:
        linear-gradient(135deg, rgba(240,79,114,0.17), rgba(139,124,246,0.10)),
        radial-gradient(circle at 78% 22%, rgba(139,124,246,0.35), transparent 36%),
        #111624;
}

.discover-kicker {
    display: inline-block;
    margin-bottom: 14px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.discover-hero h1 {
    max-width: 620px;
    font-size: clamp(32px, 5vw, 56px);
    line-height: 1.02;
    margin-bottom: 14px;
}

.discover-hero p {
    max-width: 540px;
    color: var(--text2);
    line-height: 1.7;
    font-size: 15px;
}

.discover-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.discover-actions button,
.discover-section-head button {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 10px 18px;
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    cursor: pointer;
    font-weight: 700;
}

.discover-actions button + button,
.discover-section-head button {
    background: rgba(255,255,255,0.06);
    border-color: var(--border);
    color: var(--text);
}

.discover-spotlight {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    border-radius: 16px;
    background: rgba(4,5,9,0.26);
    border: 1px solid rgba(255,255,255,0.08);
    text-align: center;
    overflow: hidden;
    position: relative;
}

.discover-spotlight img {
    width: 100%;
    height: 100%;
    min-height: 190px;
    object-fit: cover;
    grid-area: 1 / 1;
    filter: saturate(1.05);
}

.discover-spotlight::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 35%, rgba(4,5,9,0.78));
}

.discover-spotlight strong {
    font-size: 20px;
    grid-area: 1 / 1;
    align-self: end;
    margin-bottom: 42px;
    z-index: 1;
}

.discover-spotlight small {
    color: var(--text2);
    grid-area: 1 / 1;
    align-self: end;
    margin-bottom: 20px;
    z-index: 1;
}

.discover-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.discover-metrics span {
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text2);
}

.discover-metrics strong {
    margin-right: 6px;
    color: var(--text);
    font-size: 20px;
}

.discover-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.discover-section-head h2 {
    font-size: 20px;
}

.discover-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}

.discover-card {
    overflow: hidden;
    border-radius: 14px;
    background: rgba(255,255,255,0.045);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
    position: relative;
}

.discover-card:hover,
.discover-card.active {
    transform: translateY(-2px);
    border-color: rgba(240,79,114,0.62);
    background: rgba(240,79,114,0.08);
}

.discover-card-cover {
    height: 238px;
    background: #121827;
    position: relative;
    overflow: hidden;
}

.discover-card-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform .22s ease, filter .22s ease;
}

.discover-card:hover .discover-card-cover img {
    transform: scale(1.035);
    filter: saturate(1.1);
}

.discover-card-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.02) 35%, rgba(4,5,9,0.58));
}

.discover-card-badge {
    position: absolute;
    left: 10px;
    bottom: 10px;
    color: white;
    background: rgba(4,5,9,0.58);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    backdrop-filter: blur(8px);
}

.discover-card-body {
    padding: 14px;
}

.discover-card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.discover-card-title h3 {
    font-size: 16px;
}

.discover-card-title span {
    color: var(--text2);
    font-size: 15px;
}

.discover-card p {
    min-height: 38px;
    color: var(--text2);
    font-size: 12px;
    line-height: 1.55;
}

.discover-card-tags {
    margin-top: 10px;
}

.discover-card-stats {
    display: flex;
    gap: 10px;
    color: var(--text2);
    font-size: 11px;
    margin-top: 12px;
}

.discover-card-cta {
    width: 100%;
    min-height: 36px;
    margin-top: 12px;
    border: 1px solid rgba(240,79,114,0.42);
    border-radius: 9px;
    color: white;
    background: linear-gradient(135deg, rgba(240,79,114,0.95), rgba(139,124,246,0.86));
    cursor: pointer;
    font-weight: 700;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .16s ease, transform .16s ease;
}

.discover-card:hover .discover-card-cta,
.discover-card.active .discover-card-cta {
    opacity: 1;
    transform: translateY(0);
}

.world-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.world-tile {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.world-tile.active,
.world-tile:hover {
    border-color: rgba(240,79,114,0.52);
    background: rgba(240,79,114,0.09);
}

.world-tile span {
    font-size: 22px;
}

@media (max-width: 1180px) {
    #detail-panel {
        display: none;
    }
}

@media (max-width: 900px) {
    .app-nav {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    body[data-view="discover"] #chat-area {
        padding: 16px;
    }

    .discover-hero {
        grid-template-columns: 1fr;
        padding: 22px;
    }

    .discover-spotlight {
        min-height: 170px;
    }

    .discover-card-cover {
        height: 220px;
    }

    .discover-card-cta {
        opacity: 1;
        transform: none;
    }

    .discover-metrics {
        grid-template-columns: 1fr;
    }
}

/* v4 character marketplace refresh */

body[data-view="discover"] #chat-area {
    padding: 20px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
        #0b0d12;
}

.discover-shell {
    max-width: 1320px;
    gap: 18px;
}

.discover-toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(11, 13, 18, 0.9);
    backdrop-filter: blur(16px);
}

.discover-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
}

.discover-tabs button,
.discover-search {
    min-height: 38px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
    color: var(--text2);
}

.discover-tabs button {
    padding: 0 14px;
    white-space: nowrap;
    cursor: pointer;
}

.discover-tabs button.active,
.discover-tabs button:hover {
    color: white;
    border-color: rgba(240,79,114,0.55);
    background: rgba(240,79,114,0.18);
}

.discover-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
}

.discover-search span {
    color: var(--text2);
    font-size: 18px;
}

.discover-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 13px;
}

.discover-hero {
    grid-template-columns: minmax(0, 1.1fr) minmax(230px, 320px);
    min-height: 230px;
    border-radius: 8px;
    padding: 22px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(19,22,31,0.96), rgba(9,11,17,0.96));
}

.discover-hero h1 {
    max-width: 760px;
    font-size: clamp(28px, 3.2vw, 42px);
    letter-spacing: 0;
}

.discover-hero p {
    max-width: 660px;
    line-height: 1.62;
}

.discover-spotlight {
    min-height: 218px;
    border-radius: 8px;
}

.discover-spotlight img {
    min-height: 218px;
}

.discover-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.discover-metrics span,
.world-tile {
    border-radius: 8px;
    background: rgba(255,255,255,0.035);
}

.discover-section-head {
    padding-top: 2px;
}

.discover-section-head h2 {
    font-size: 18px;
}

.discover-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}

.discover-card {
    border-radius: 8px;
    background: rgba(255,255,255,0.055);
    box-shadow: none;
}

.discover-card-cover {
    height: 310px;
}

.discover-card-rank,
.discover-fav,
.discover-card-hot {
    position: absolute;
    z-index: 1;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(5,6,10,0.56);
    color: white;
    backdrop-filter: blur(10px);
}

.discover-card-rank {
    left: 10px;
    top: 10px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.discover-fav {
    right: 10px;
    top: 10px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 16px;
}

.discover-fav.active {
    color: #ff6e8a;
    border-color: rgba(255,110,138,0.55);
}

.discover-card-badge {
    bottom: 42px;
}

.discover-card-hot {
    left: 10px;
    bottom: 10px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
}

.discover-card-title h3 {
    font-size: 15px;
    line-height: 1.25;
}

.discover-card p {
    min-height: 40px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.discover-card-actions {
    display: grid;
    grid-template-columns: 0.82fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.discover-card-detail,
.discover-card-cta {
    width: 100%;
    min-height: 36px;
    margin-top: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    opacity: 1;
    transform: none;
}

.discover-card-detail {
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text);
    background: rgba(255,255,255,0.06);
}

.discover-card-cta {
    border: 1px solid rgba(240,79,114,0.42);
    color: white;
    background: #f23b6b;
}

.discover-hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 16px 20px;
}

.discover-hero h1 {
    max-width: 760px;
    font-size: clamp(24px, 2.4vw, 32px);
    margin-bottom: 8px;
}

.discover-hero p {
    max-width: 780px;
    font-size: 13px;
    line-height: 1.55;
}

.discover-actions {
    margin-top: 12px;
}

.discover-actions button {
    padding: 8px 14px;
}

.discover-spotlight,
.discover-metrics {
    display: none;
}

.world-tile {
    grid-template-columns: auto 1fr;
    min-height: 72px;
}

.world-tile small {
    grid-column: 2;
    color: var(--text2);
    font-size: 11px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-modal.hidden {
    display: none;
}

.role-modal {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: grid;
    place-items: center;
    padding: 24px;
}

.role-modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.role-modal-dialog {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(280px, 420px) minmax(360px, 560px);
    width: min(100%, 1040px);
    max-height: min(860px, calc(100vh - 48px));
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 12px;
    background: #10131b;
    box-shadow: 0 28px 110px rgba(0,0,0,0.52);
}

.role-modal-close {
    position: absolute;
    right: 14px;
    top: 14px;
    z-index: 3;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(5,6,10,0.58);
    color: white;
    cursor: pointer;
    font-size: 20px;
}

.role-modal-visual {
    position: relative;
    min-height: 620px;
    background: #06070b;
}

.role-modal-visual img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.role-modal-visual::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 48%, rgba(6,7,11,0.82));
}

.role-modal-visual-meta {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.role-modal-visual-meta span {
    padding: 6px 10px;
    border-radius: 999px;
    color: white;
    background: rgba(5,6,10,0.58);
    border: 1px solid rgba(255,255,255,0.12);
    font-size: 12px;
    backdrop-filter: blur(10px);
}

.role-modal-main {
    overflow: auto;
    padding: 34px;
}

.role-modal-kicker {
    color: #ff7f9a;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 10px;
}

.role-modal-main h2 {
    font-size: clamp(30px, 4vw, 46px);
    line-height: 1.05;
    margin-bottom: 12px;
}

.role-modal-desc {
    color: var(--text2);
    font-size: 15px;
    line-height: 1.7;
}

.role-modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 18px 0;
}

.role-modal-tags span {
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.055);
    color: var(--text2);
    font-size: 12px;
}

.role-modal-actions {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 10px;
    margin: 18px 0 24px;
}

.role-modal-actions button {
    min-height: 46px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.role-primary {
    border: 1px solid rgba(240,79,114,0.50);
    color: white;
    background: #f23b6b;
}

.role-secondary {
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text);
    background: rgba(255,255,255,0.06);
}

.role-secondary.active {
    color: #ff8aa1;
    border-color: rgba(255,110,138,0.46);
}

.role-detail-block {
    padding-top: 18px;
    margin-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.role-detail-block h3 {
    font-size: 14px;
    margin-bottom: 10px;
}

.role-detail-block p,
.role-detail-block small,
.muted {
    color: var(--text2);
    line-height: 1.7;
}

.role-model-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.role-model-strip button {
    display: grid;
    gap: 3px;
    min-height: 48px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text);
    background: rgba(255,255,255,0.045);
    cursor: pointer;
    text-align: left;
}

.role-model-strip button.active {
    border-color: rgba(240,79,114,0.55);
    background: rgba(240,79,114,0.16);
}

.role-model-strip small {
    font-size: 11px;
}

.similar-role-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.similar-role {
    display: grid;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.similar-role img {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.08);
}

.similar-role span {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1180px) {
    .discover-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .discover-card-cover {
        height: 276px;
    }
}

@media (max-width: 900px) {
    #sidebar {
        max-height: 36vh;
    }

    .discover-toolbar {
        grid-template-columns: 1fr;
    }

    .discover-hero {
        display: none;
    }

    .discover-card-cover {
        height: 260px;
    }

    .role-modal {
        padding: 0;
    }

    .role-modal-dialog {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        grid-template-columns: 1fr;
        overflow: auto;
    }

    .role-modal-visual {
        min-height: 58vh;
    }

    .role-modal-main {
        padding: 24px 18px 32px;
    }

    .role-modal-actions,
    .role-model-strip {
        grid-template-columns: 1fr;
    }

    .similar-role-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* v5 competitor feature supplements */

.discover-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
}

.discover-option-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
}

.discover-categories {
    display: flex;
    gap: 6px;
    overflow-x: auto;
}

.discover-categories button,
.discover-sort,
.discover-privacy-toggle {
    min-height: 34px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
    color: var(--text2);
}

.discover-categories button,
.discover-privacy-toggle {
    padding: 0 12px;
    white-space: nowrap;
    cursor: pointer;
}

.discover-categories button.active,
.discover-categories button:hover,
.discover-privacy-toggle.active,
.discover-privacy-toggle:hover {
    color: white;
    border-color: rgba(240,79,114,0.55);
    background: rgba(240,79,114,0.18);
}

.discover-sort {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    font-size: 12px;
}

.discover-sort select {
    border: 0;
    outline: 0;
    color: var(--text);
    background: #171b29;
    color-scheme: dark;
    font-size: 12px;
    border-radius: 6px;
    padding: 3px 4px;
}

.discover-sort select option {
    background: #171b29;
    color: #f1f3f8;
}

.discover-recent {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.035);
    overflow-x: auto;
}

.discover-recent > span {
    color: var(--text2);
    font-size: 12px;
    white-space: nowrap;
}

.discover-recent button {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 92px;
    border: 0;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}

.discover-recent img {
    width: 30px;
    height: 38px;
    border-radius: 6px;
    object-fit: cover;
}

.discover-recent b {
    max-width: 68px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.discover-creator-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: var(--text2);
    font-size: 11px;
}

.discover-creator-line span,
.role-creator-card > span {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    color: white;
    background: linear-gradient(135deg, rgba(240,79,114,0.9), rgba(139,124,246,0.8));
    font-size: 11px;
    font-weight: 800;
}

.discover-creator-line b {
    color: var(--text);
    font-weight: 700;
}

.blur-sensitive .discover-card-cover.sensitive img,
.blur-sensitive .role-modal-visual.sensitive img,
.blur-sensitive .detail-cover img {
    filter: blur(16px) saturate(0.75);
    transform: scale(1.03);
}

.sensitive-mask {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-items: center;
    color: white;
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    background: rgba(6,7,11,0.24);
}

.role-mask {
    z-index: 2;
    font-size: 14px;
}

.role-creator-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
}

.role-creator-card b {
    display: block;
    font-size: 13px;
}

.role-creator-card small {
    color: var(--text2);
    font-size: 11px;
}

.role-creator-card button {
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(240,79,114,0.42);
    border-radius: 8px;
    color: white;
    background: rgba(240,79,114,0.22);
    cursor: pointer;
}

.role-creator-card button.active {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.10);
    color: var(--text2);
}

.role-modal-actions-extended {
    grid-template-columns: minmax(140px, 1fr) repeat(4, minmax(74px, 96px));
}

.role-model-pref {
    margin-top: 7px;
    color: #ffd4dc;
    font-size: 11px;
    line-height: 1.45;
}

.role-gallery {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.role-gallery-thumb {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.role-gallery-thumb img {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.10);
    object-fit: cover;
}

.role-comment-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
}

.role-comment-box textarea {
    resize: vertical;
    min-height: 44px;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.10);
    outline: 0;
    color: var(--text);
    background: rgba(255,255,255,0.045);
    font-family: inherit;
}

.role-comment-box button {
    min-width: 70px;
    border: 1px solid rgba(240,79,114,0.42);
    border-radius: 8px;
    color: white;
    background: #f23b6b;
    cursor: pointer;
}

.role-comments {
    display: grid;
    gap: 8px;
}

.role-comment {
    padding: 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.035);
}

.role-comment b {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
}

.role-comment p {
    margin: 0;
    color: var(--text2);
    font-size: 12px;
    line-height: 1.55;
}

.role-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 260;
    transform: translate(-50%, 12px);
    opacity: 0;
    pointer-events: none;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    color: white;
    background: rgba(11,13,18,0.92);
    box-shadow: 0 18px 48px rgba(0,0,0,0.34);
    transition: opacity .16s ease, transform .16s ease;
}

.role-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 900px) {
    .discover-option-row {
        grid-template-columns: 1fr;
    }

    .discover-sort,
    .discover-privacy-toggle {
        width: 100%;
    }

    .role-modal-actions-extended,
    .role-comment-box,
    .role-story-options,
    .story-preset-grid {
        grid-template-columns: 1fr;
    }

    .role-gallery {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* v8 detail density and visual choice panels */

.role-modal-dialog {
    grid-template-columns: minmax(240px, 350px) minmax(540px, 1fr);
    width: min(1120px, calc(100vw - 48px));
    height: min(780px, calc(100vh - 40px));
    max-height: min(780px, calc(100vh - 40px));
}

.role-modal-visual {
    min-height: 0;
    height: 100%;
}

.role-modal-main {
    padding: 24px 28px 28px;
}

.role-modal-main h2 {
    font-size: clamp(28px, 3vw, 40px);
    margin-bottom: 8px;
}

.role-modal-desc {
    line-height: 1.55;
}

.role-quick-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0 10px;
}

.role-quick-stats span {
    display: grid;
    gap: 2px;
    padding: 9px 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
}

.role-quick-stats b {
    color: white;
    font-size: 14px;
}

.role-quick-stats small {
    color: var(--text2);
    font-size: 11px;
}

.role-preference-panel {
    display: grid;
    gap: 10px;
    margin: 10px 0 12px;
    padding: 12px;
    border: 1px solid rgba(240,79,114,0.22);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(240,79,114,0.12), rgba(139,124,246,0.08));
}

.role-active-pref-banner {
    display: grid;
    gap: 8px;
    margin: 12px 0;
    padding: 12px;
    border: 1px solid rgba(240,79,114,0.36);
    border-radius: 8px;
    background: rgba(240,79,114,0.12);
}

.role-active-pref-banner b {
    color: #ffd4dc;
    font-size: 13px;
}

.role-active-pref-banner span,
.role-preference-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.role-active-pref-banner span span,
.role-active-pref-banner i,
.role-preference-chips span {
    padding: 4px 8px;
    border-radius: 999px;
    color: #fff;
    background: rgba(240,79,114,0.24);
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
}

.role-preference-panel b {
    display: block;
    font-size: 13px;
}

.role-preference-panel small {
    color: var(--text2);
    font-size: 11px;
}

.role-preference-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.role-preference-chips span,
.discover-pref-line .pref {
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(240,79,114,0.30);
    color: #ff9ab0;
    background: rgba(240,79,114,0.12);
    font-size: 12px;
    font-weight: 700;
}

.role-preference-chips span.fallback {
    border-color: rgba(255,255,255,0.12);
    color: var(--text2);
    background: rgba(255,255,255,0.055);
}

.role-story-launch {
    display: grid;
    gap: 10px;
    margin: 12px 0;
    padding: 12px;
    border: 1px solid rgba(83,214,162,0.20);
    border-radius: 8px;
    background: rgba(83,214,162,0.07);
}

.role-story-launch b {
    display: block;
    font-size: 13px;
}

.role-story-launch small {
    display: block;
    margin-top: 3px;
    color: var(--text2);
    line-height: 1.55;
}

.role-story-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.role-story-options button {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 2px 8px;
    min-height: 58px;
    padding: 9px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,0.05);
    cursor: pointer;
    text-align: left;
}

.role-story-options button:hover {
    border-color: rgba(83,214,162,0.44);
    background: rgba(83,214,162,0.12);
}

.role-story-options span {
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    font-size: 17px;
}

.role-story-options b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.role-story-options small {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 11px;
    line-height: 1.35;
}

.role-modal-tags {
    margin: 10px 0 12px;
}

.role-creator-card {
    padding: 10px 12px;
}

.role-modal-actions {
    margin: 12px 0 14px;
}

.role-modal-actions button {
    min-height: 42px;
}

.role-section-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 10px;
    margin-top: 12px;
}

.role-section-grid .role-detail-block {
    margin-top: 0;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.035);
}

.role-section-grid .role-detail-block h3 {
    margin-bottom: 8px;
}

.role-section-grid .role-detail-block p {
    max-height: 104px;
    overflow: auto;
    font-size: 12px;
}

.role-detail-block {
    padding-top: 14px;
    margin-top: 14px;
}

.role-gallery {
    gap: 7px;
}

.role-gallery-thumb img {
    aspect-ratio: 4 / 5;
}

.role-model-strip button {
    min-height: 42px;
    padding: 7px 9px;
}

.discover-pref-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    min-height: 24px;
}

.discover-card-tags:empty {
    display: none;
}

.choice-native {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0 12px;
}

.choice-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-tile {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 9px;
    min-height: 74px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,0.045);
    cursor: pointer;
    text-align: left;
}

.choice-tile:hover,
.choice-tile.active {
    border-color: rgba(240,79,114,0.48);
    background: rgba(240,79,114,0.14);
}

.choice-tile span {
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
}

.choice-tile b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.choice-tile small {
    color: var(--text2);
    font-size: 11px;
    line-height: 1.35;
}

.tag-picker {
    display: grid;
    grid-template-columns: 1fr;
    max-height: 220px;
    gap: 10px;
}

.kink-group {
    display: grid;
    gap: 7px;
}

.kink-group-title {
    color: var(--text2);
    font-size: 11px;
    font-weight: 800;
}

.kink-group-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

@media (max-width: 900px) {
    .role-modal-dialog {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        grid-template-columns: 1fr;
    }

    .role-modal-visual {
        height: 42vh;
        min-height: 320px;
    }

    .role-quick-stats,
    .role-section-grid,
    .choice-grid,
    .choice-grid.compact {
        grid-template-columns: 1fr 1fr;
    }

    .creator-layout {
        grid-template-columns: 1fr;
    }

    .creator-preview {
        position: static;
    }

    .creator-template-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .creator-appearance-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .role-quick-stats,
    .role-section-grid,
    .choice-grid,
    .choice-grid.compact {
        grid-template-columns: 1fr;
    }

    .modal-wide {
        width: calc(100vw - 18px);
    }

    .creator-template-grid,
    .creator-appearance-grid,
    .creator-preview-card,
    .form-grid,
    .story-role-brief {
        grid-template-columns: 1fr;
    }

    .creator-preview-avatar {
        width: 58px;
        height: 58px;
        font-size: 26px;
    }
}

/* My workspace and wallet */

.mine-shell {
    display: grid;
    gap: 16px;
    width: 100%;
}

.mine-hero {
    display: grid;
    gap: 8px;
    padding: 20px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(240,79,114,0.14), rgba(139,124,246,0.08)), #131824;
}

.mine-hero span {
    color: #ff7891;
    font-size: 12px;
    font-weight: 900;
}

.mine-hero h1 {
    margin: 0;
    font-size: clamp(26px, 3vw, 40px);
    letter-spacing: 0;
}

.mine-hero p {
    max-width: 620px;
    margin: 0;
    color: var(--text2);
    line-height: 1.6;
}

.mine-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.mine-hero button,
.mine-section-head button,
.wallet-package,
.wallet-redeem-grid button {
    min-height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
}

.mine-hero button,
.wallet-redeem-grid button {
    border: 1px solid rgba(240,79,114,0.48);
    color: white;
    background: #f04f72;
    padding: 0 14px;
}

.mine-hero-actions button + button,
.mine-section-head button {
    border: 1px solid rgba(255,255,255,0.10);
    color: var(--text);
    background: rgba(255,255,255,0.06);
    padding: 0 12px;
}

.mine-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.mine-metrics div,
.mine-panel {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
}

.mine-metrics div {
    display: grid;
    gap: 4px;
    padding: 14px;
}

.mine-metrics b {
    font-size: 24px;
}

.mine-metrics span {
    color: var(--text2);
    font-size: 12px;
}

.mine-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 16px;
}

.mine-layout.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mine-panel {
    min-width: 0;
    padding: 16px;
}

.mine-section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.mine-section-head h2 {
    margin: 0;
    font-size: 17px;
}

.wallet-packages {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.wallet-package {
    display: grid;
    gap: 4px;
    min-height: 112px;
    padding: 12px;
    text-align: left;
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
    background: rgba(255,255,255,0.045);
}

.wallet-package:hover {
    border-color: rgba(240,79,114,0.45);
    background: rgba(240,79,114,0.12);
}

.wallet-package strong {
    font-size: 26px;
}

.wallet-package span {
    color: var(--text2);
    font-size: 12px;
    line-height: 1.45;
}

.mine-transactions {
    margin-top: 16px;
}

.mine-transactions h3 {
    margin: 0 0 8px;
    font-size: 14px;
}

.mine-tx-row {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 12px;
}

.mine-tx-row .plus {
    color: var(--success);
}

.mine-tx-row .minus {
    color: #ff7891;
}

.mine-tx-row small {
    color: var(--text2);
}

.mine-role-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 10px;
}

.mine-role-strip button {
    display: grid;
    gap: 7px;
    padding: 0;
    border: 0;
    color: var(--text);
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.mine-role-strip img {
    width: 100%;
    aspect-ratio: 3 / 4;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    object-fit: cover;
    background: #090c13;
}

.mine-role-strip b,
.mine-role-strip span,
.mine-role-strip em {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mine-role-strip span,
.mine-empty {
    color: var(--text2);
    font-size: 12px;
}

.mine-role-strip em {
    width: fit-content;
    max-width: 100%;
    padding: 3px 7px;
    border-radius: 999px;
    color: #ffd4dc;
    background: rgba(240,79,114,0.13);
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
}

.mine-empty {
    padding: 18px;
    border: 1px dashed rgba(255,255,255,0.12);
    border-radius: 8px;
}

.wallet-modal-content {
    max-width: 760px;
}

.wallet-redeem-grid {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.wallet-balance {
    display: grid;
    gap: 3px;
    min-height: 74px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
}

.wallet-balance span,
.wallet-redeem-grid label,
.wallet-note span {
    color: var(--text2);
    font-size: 12px;
}

.wallet-balance b {
    font-size: 26px;
}

.wallet-redeem-grid label {
    display: grid;
    gap: 7px;
}

.wallet-redeem-grid input {
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: 0;
    color: var(--text);
    background: var(--bg);
}

.wallet-message {
    min-height: 20px;
    margin-top: 10px;
    color: #ff9caf;
    font-size: 12px;
}

.wallet-note {
    display: grid;
    gap: 4px;
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
}

@media (max-width: 900px) {
    .mine-metrics,
    .mine-layout,
    .mine-layout.two,
    .wallet-packages,
    .wallet-redeem-grid {
        grid-template-columns: 1fr;
    }

    .mine-tx-row {
        grid-template-columns: 68px minmax(0, 1fr);
    }

    .mine-tx-row small {
        grid-column: 2;
    }
}

/* Role marketplace */

body.market-body {
    height: 100vh;
    overflow: hidden;
    background: #0b0d13;
    color: var(--text);
}

.market-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
}

.market-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.08);
    background: #10141e;
}

.market-brand {
    display: grid;
    gap: 4px;
    padding: 22px 18px;
}

.market-brand span {
    color: #ff6686;
    font-size: 20px;
    font-weight: 900;
}

.market-brand strong {
    color: var(--text2);
    font-size: 12px;
}

.market-nav {
    display: grid;
    gap: 5px;
    padding: 0 10px;
}

.market-nav a {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--text2);
    text-decoration: none;
}

.market-nav a.active,
.market-nav a:hover {
    color: white;
    background: rgba(255,255,255,0.07);
}

.market-user {
    margin-top: auto;
    display: grid;
    gap: 8px;
    padding: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.market-user div {
    color: var(--text2);
    font-size: 12px;
}

.market-user button,
.market-tabs button,
.market-categories button,
.market-actions button,
.market-rank-item,
.market-fav {
    cursor: pointer;
}

.market-user button,
.market-tabs button,
.market-categories button,
.market-actions button {
    min-height: 34px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,0.055);
    font-weight: 800;
}

.market-main {
    min-width: 0;
    height: 100vh;
    overflow: auto;
    padding: 22px 28px 40px;
}

.market-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
    gap: 18px;
    align-items: end;
    margin-bottom: 16px;
}

.market-top span {
    color: #ff7891;
    font-size: 12px;
    font-weight: 900;
}

.market-top h1 {
    max-width: 760px;
    margin: 4px 0 0;
    font-size: clamp(28px, 3.4vw, 48px);
    line-height: 1.05;
    letter-spacing: 0;
}

.market-search input {
    width: 100%;
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    outline: 0;
    color: var(--text);
    background: #090c13;
}

.market-toolbar {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.market-tabs,
.market-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.market-tabs button,
.market-categories button {
    padding: 0 13px;
    color: var(--text2);
}

.market-tabs button.active,
.market-categories button.active,
.market-tabs button:hover,
.market-categories button:hover {
    color: white;
    border-color: rgba(240,79,114,0.48);
    background: rgba(240,79,114,0.16);
}

.market-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 18px;
    align-items: start;
}

.market-section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.market-section-head h2 {
    margin: 0;
    font-size: 18px;
}

.market-section-head span {
    color: var(--text2);
    font-size: 12px;
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.market-card,
.market-rank {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
    overflow: hidden;
}

.market-card-cover {
    position: relative;
    height: 310px;
    background: #090c13;
}

.market-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.market-card-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 52%, rgba(5,6,10,0.76));
    pointer-events: none;
}

.market-fav,
.market-hot {
    position: absolute;
    z-index: 2;
    border: 1px solid rgba(255,255,255,0.13);
    color: white;
    background: rgba(5,6,10,0.58);
    backdrop-filter: blur(10px);
}

.market-fav {
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    font-size: 18px;
}

.market-fav.active {
    color: #ff7891;
}

.market-hot {
    left: 10px;
    bottom: 10px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
}

.market-card-body {
    display: grid;
    gap: 9px;
    padding: 13px;
}

.market-card-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.market-card-title h3 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}

.market-card-body p {
    min-height: 38px;
    margin: 0;
    color: var(--text2);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.market-tags,
.market-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.market-tags span,
.market-meta span {
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    color: var(--text2);
    font-size: 11px;
}

.market-author {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--text2);
    font-size: 12px;
}

.market-author b {
    color: var(--text);
}

.market-actions {
    display: grid;
    grid-template-columns: 1fr 86px;
    gap: 8px;
}

.market-actions button:first-child {
    border-color: rgba(240,79,114,0.48);
    color: white;
    background: #f04f72;
}

.market-rank {
    position: sticky;
    top: 18px;
    padding: 14px;
}

#market-rank-list {
    display: grid;
    gap: 8px;
}

.market-rank-item {
    display: grid;
    grid-template-columns: 34px 44px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    width: 100%;
    padding: 7px;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,0.04);
    text-align: left;
}

.market-rank-item:hover {
    background: rgba(255,255,255,0.075);
}

.market-rank-item img {
    width: 44px;
    height: 56px;
    border-radius: 7px;
    object-fit: cover;
}

.market-rank-item b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-rank-item small,
.market-rank-item span {
    color: var(--text2);
}

.market-empty {
    padding: 28px;
    border: 1px dashed rgba(255,255,255,0.14);
    border-radius: 8px;
    color: var(--text2);
}

.market-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 260;
    transform: translate(-50%, 10px);
    opacity: 0;
    pointer-events: none;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    color: white;
    background: rgba(11,13,18,0.94);
    box-shadow: 0 16px 48px rgba(0,0,0,0.34);
    transition: opacity .16s ease, transform .16s ease;
}

.market-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 1080px) {
    .market-content {
        grid-template-columns: 1fr;
    }

    .market-rank {
        position: static;
    }
}

@media (max-width: 760px) {
    body.market-body {
        height: auto;
        overflow: auto;
    }

    .market-shell,
    .market-top {
        grid-template-columns: 1fr;
        height: auto;
    }

    .market-sidebar {
        position: sticky;
        top: 0;
        z-index: 20;
    }

    .market-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 10px;
    }

    .market-main {
        height: auto;
        overflow: visible;
        padding: 18px 14px 32px;
    }

    .market-card-cover {
        height: 280px;
    }
}

/* Admin v2 workspace */

body.admin-v2-body {
    height: 100vh;
    overflow: hidden;
    background: #0b0d13;
    color: #eef2fb;
}

.admin-v2-body button,
.admin-v2-body input,
.admin-v2-body select,
.admin-v2-body textarea {
    font: inherit;
}

.hidden {
    display: none !important;
}

.admin-login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 20%, rgba(240, 79, 114, 0.14), transparent 32%),
        linear-gradient(135deg, #0b0d13, #141824);
}

.admin-login-card {
    width: min(100%, 380px);
    display: grid;
    gap: 10px;
    padding: 28px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 10px;
    background: rgba(18, 22, 32, 0.96);
    box-shadow: 0 28px 90px rgba(0,0,0,0.44);
}

.admin-login-brand {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
}

.admin-login-brand span {
    color: #ff6686;
    font-size: 13px;
    font-weight: 800;
}

.admin-login-brand strong {
    font-size: 24px;
}

.admin-login-card label,
.admin-form-grid label,
.admin-inline-form label,
.admin-model-card label,
.admin-search {
    display: grid;
    gap: 7px;
    color: #9ba6bc;
    font-size: 12px;
}

.admin-login-card input,
.admin-form-grid input,
.admin-form-grid select,
.admin-form-grid textarea,
.admin-inline-form input,
.admin-model-card input,
.admin-model-card select,
.admin-search input,
.admin-section-head select {
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid #2a344a;
    border-radius: 7px;
    outline: 0;
    color: #eef2fb;
    background: #090c13;
}

.admin-form-grid textarea {
    resize: vertical;
    line-height: 1.55;
}

.admin-login-card input:focus,
.admin-form-grid input:focus,
.admin-form-grid select:focus,
.admin-form-grid textarea:focus,
.admin-model-card input:focus,
.admin-model-card select:focus,
.admin-search input:focus {
    border-color: rgba(240,79,114,0.72);
}

.admin-form-error {
    min-height: 18px;
    color: #ff7891;
    font-size: 12px;
}

.admin-shell-v2 {
    height: 100vh;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    background: #0b0d13;
}

.admin-nav-v2 {
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.08);
    background: #10141e;
}

.admin-brand-v2 {
    display: grid;
    gap: 3px;
    padding: 22px 18px 16px;
}

.admin-brand-v2 span {
    color: #ff6686;
    font-weight: 900;
    font-size: 18px;
}

.admin-brand-v2 strong {
    color: #9ba6bc;
    font-size: 12px;
    letter-spacing: 0;
}

#admin-nav {
    display: grid;
    gap: 4px;
    padding: 0 10px 14px;
    overflow-y: auto;
}

.admin-nav-item {
    min-height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 7px;
    color: #9ba6bc;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.admin-nav-item:hover,
.admin-nav-item.active {
    color: #ffffff;
    background: rgba(255,255,255,0.07);
}

.admin-nav-item.active {
    box-shadow: inset 3px 0 0 #f04f72;
}

.admin-nav-footer {
    margin-top: auto;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 14px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.admin-nav-footer span {
    min-width: 0;
    color: #c8d0e1;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-nav-footer a,
.admin-nav-footer button {
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 7px;
    color: #c8d0e1;
    background: rgba(255,255,255,0.045);
    padding: 7px 9px;
    text-decoration: none;
    cursor: pointer;
    font-size: 12px;
}

.admin-main-v2 {
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-topbar-v2 {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 20px 28px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(11,13,19,0.96);
}

.admin-topbar-v2 h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0;
}

.admin-topbar-v2 p {
    margin: 5px 0 0;
    color: #9ba6bc;
    font-size: 13px;
}

.admin-topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.admin-content-v2 {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 22px 28px 40px;
}

.admin-primary,
.admin-secondary,
.admin-row-actions button,
.admin-pager button,
.admin-segments button,
.admin-action-list button {
    min-height: 34px;
    padding: 0 13px;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
}

.admin-primary {
    border: 1px solid rgba(240,79,114,0.55);
    color: white;
    background: #f04f72;
}

.admin-primary.full {
    width: 100%;
    min-height: 42px;
    margin-top: 4px;
}

.admin-secondary,
.admin-row-actions button,
.admin-pager button,
.admin-segments button,
.admin-action-list button {
    border: 1px solid rgba(255,255,255,0.10);
    color: #d7deed;
    background: rgba(255,255,255,0.055);
}

.admin-row-actions button.danger {
    color: #ff7891;
}

.admin-link-btn {
    border: 0;
    padding: 0;
    color: #61e4ae;
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.admin-link-btn:hover {
    color: #9cf2c8;
    text-decoration: underline;
}

.admin-link-btn .admin-thumb {
    display: block;
}

.admin-segments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-segments button.active,
.admin-pager button.active {
    color: white;
    border-color: rgba(240,79,114,0.50);
    background: rgba(240,79,114,0.18);
}

.admin-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.admin-toolbar.sticky {
    position: sticky;
    top: -22px;
    z-index: 4;
    padding: 12px 0;
    background: #0b0d13;
}

.admin-search {
    min-width: min(100%, 300px);
}

.admin-inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.admin-inline-form label {
    width: 120px;
}

.admin-metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.admin-metric-grid.compact {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.admin-metric,
.admin-panel,
.admin-model-card,
.admin-alert,
.admin-empty,
.admin-code-box {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: #131824;
}

.admin-metric {
    display: grid;
    gap: 4px;
    padding: 15px;
}

.admin-metric b {
    font-size: 24px;
    line-height: 1;
}

.admin-metric span {
    color: #eef2fb;
    font-size: 13px;
    font-weight: 800;
}

.admin-metric small,
.admin-muted,
.admin-panel p,
.admin-section-head p,
.admin-model-card p,
.admin-model-meta,
.admin-name-cell small {
    color: #9ba6bc;
}

.admin-two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.admin-ops-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.admin-panel {
    padding: 18px;
    margin-bottom: 16px;
}

.admin-panel.narrow {
    max-width: 760px;
}

.admin-section-head {
    margin-bottom: 14px;
}

.admin-section-head.inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.admin-section-head h2 {
    margin: 0 0 4px;
    font-size: 16px;
}

.admin-section-head p {
    margin: 0;
    font-size: 12px;
}

.admin-action-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.admin-timeline,
.admin-rank-list {
    display: grid;
    gap: 9px;
}

.admin-timeline article,
.admin-rank-list article {
    padding: 10px;
    border-radius: 7px;
    background: rgba(255,255,255,0.035);
}

.admin-timeline article > div,
.admin-rank-list article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
}

.admin-timeline b,
.admin-rank-list b {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #eef2fb;
    font-size: 13px;
}

.admin-timeline small,
.admin-rank-list small {
    color: #9ba6bc;
    font-size: 11px;
}

.admin-timeline p {
    margin: 7px 0 0;
    color: #c8d0e1;
    font-size: 12px;
    line-height: 1.55;
}

.admin-rank-list article {
    grid-template-columns: 38px minmax(0, 1fr);
}

.admin-rank-list article > span {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: #ff9ab0;
    background: rgba(240,79,114,0.12);
    font-size: 12px;
    font-weight: 900;
}

.admin-check-list {
    display: grid;
    gap: 8px;
}

.admin-check-list > div {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 2px 10px;
    padding: 10px;
    border-radius: 7px;
    background: rgba(255,255,255,0.035);
}

.admin-check-list b {
    grid-row: 1 / 3;
    color: #53d6a2;
}

.admin-check-list .bad b {
    color: #ff7891;
}

.admin-check-list small {
    color: #9ba6bc;
}

.admin-table-wrap {
    overflow: auto;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: #111620;
}

.admin-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.admin-data-table.fixed {
    table-layout: fixed;
}

.admin-data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: #9ba6bc;
    background: #151b28;
    font-size: 11px;
    text-align: left;
}

.admin-data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    vertical-align: middle;
    white-space: normal;
}

.admin-data-table tr:hover td {
    background: rgba(255,255,255,0.025);
}

.admin-name-cell {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 8px;
    align-items: center;
}

.admin-name-cell span {
    grid-row: 1 / 3;
    display: grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255,255,255,0.06);
}

.admin-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    background: rgba(255,255,255,0.07);
    color: #c8d0e1;
}

.admin-badge.green {
    color: #61e4ae;
    background: rgba(83,214,162,0.12);
}

.admin-badge.red {
    color: #ff7891;
    background: rgba(255,120,145,0.12);
}

.admin-badge.purple {
    color: #b6a9ff;
    background: rgba(139,124,246,0.15);
}

.admin-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.admin-chips span {
    padding: 3px 7px;
    border-radius: 999px;
    color: #c8d0e1;
    background: rgba(255,255,255,0.055);
    font-size: 11px;
}

.admin-chips span.pink {
    color: #ff9caf;
    background: rgba(240,79,114,0.13);
}

.admin-pager {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 12px;
}

.admin-alert {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.admin-alert b {
    color: #ffffff;
}

.admin-alert.success {
    border-color: rgba(83,214,162,0.28);
}

.admin-alert.error {
    border-color: rgba(255,120,145,0.32);
}

.admin-empty,
.admin-loading {
    padding: 28px;
    color: #9ba6bc;
    text-align: center;
}

.admin-model-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding-bottom: 16px;
}

.admin-model-card {
    display: grid;
    gap: 11px;
    padding: 16px;
}

.admin-model-card header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.admin-model-card h2 {
    margin: 0 0 4px;
    font-size: 17px;
}

.admin-model-card code,
.admin-code-box code {
    color: #aab5ca;
    background: #090c13;
    border: 1px solid rgba(255,255,255,0.06);
}

.admin-model-card p {
    min-height: 34px;
    margin: 0;
    line-height: 1.45;
}

.admin-model-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
}

.admin-model-meta span {
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(255,255,255,0.055);
}

.admin-model-meta a,
.admin-doc-link {
    color: #61e4ae;
    text-decoration: none;
    font-size: 11px;
}

.admin-model-meta a {
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(83,214,162,0.10);
}

.admin-provider-note {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(83,214,162,0.16);
    border-radius: 8px;
    color: #c8d0e1;
    background: rgba(83,214,162,0.06);
    font-size: 12px;
}

.admin-provider-note b {
    color: #dffbed;
}

.admin-provider-note a {
    color: #61e4ae;
    text-decoration: none;
}

.model-provider-note {
    margin-top: 0;
    gap: 6px 10px;
    align-items: flex-start;
}

.model-provider-note span {
    color: #aeb8ca;
}

.admin-model-provider-grid {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px;
}

.admin-model-row {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: 10px;
    align-items: end;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.admin-form-grid.single {
    grid-template-columns: 1fr;
}

.admin-form-grid .span-2 {
    grid-column: 1 / -1;
}

.admin-form-grid label.inline,
.admin-model-card label.inline {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #c8d0e1;
}

.admin-form-grid label.inline input,
.admin-model-card label.inline input {
    width: auto;
    min-height: 0;
}

.admin-form-actions {
    margin-top: 16px;
}

.admin-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    padding: 20px;
}

.admin-modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(0,0,0,0.68);
    cursor: pointer;
}

.admin-modal-panel {
    position: relative;
    z-index: 1;
    width: min(760px, 100%);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    background: #131824;
    box-shadow: 0 24px 90px rgba(0,0,0,0.46);
}

.admin-modal-panel:has(.admin-media-preview) {
    width: min(1120px, 100%);
}

.admin-modal-panel header,
.admin-modal-footer {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-modal-panel header h2 {
    margin: 0;
    font-size: 18px;
}

.admin-modal-panel header p {
    margin: 4px 0 0;
    color: #9ba6bc;
    font-size: 12px;
}

.admin-modal-body {
    overflow: auto;
    padding: 18px;
}

.admin-modal-footer {
    justify-content: flex-end;
    border-top: 1px solid rgba(255,255,255,0.08);
    border-bottom: 0;
}

.admin-media-preview {
    display: grid;
    place-items: center;
    min-height: 280px;
    max-height: calc(100vh - 210px);
    overflow: auto;
    border-radius: 8px;
    background: #090c13;
}

.admin-media-preview img,
.admin-media-preview video {
    max-width: 100%;
    max-height: calc(100vh - 230px);
    object-fit: contain;
}

.admin-media-url {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.admin-media-url input {
    min-width: 0;
}

.admin-media-url a {
    color: #61e4ae;
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
}

.admin-icon-btn {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 999px;
    color: #eef2fb;
    background: rgba(255,255,255,0.055);
    cursor: pointer;
    font-size: 20px;
}

.admin-toast {
    min-width: 0;
    opacity: 0;
    transform: translateY(4px);
    color: #61e4ae;
    font-size: 12px;
    transition: opacity .16s ease, transform .16s ease;
}

.admin-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.admin-code-box {
    padding: 12px;
    margin-bottom: 14px;
}

.admin-code-box pre {
    margin: 8px 0 0;
    white-space: pre-wrap;
}

.admin-node-snippet {
    display: block;
    max-width: 440px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1180px) {
    .admin-metric-grid,
    .admin-metric-grid.compact {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .admin-model-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    body.admin-v2-body {
        overflow: auto;
    }

    .admin-shell-v2 {
        min-height: 100vh;
        height: auto;
        grid-template-columns: 1fr;
    }

    .admin-nav-v2 {
        position: sticky;
        top: 0;
        z-index: 20;
    }

    #admin-nav {
        display: flex;
        overflow-x: auto;
        padding-bottom: 10px;
    }

    .admin-nav-item {
        white-space: nowrap;
    }

    .admin-nav-footer {
        display: none;
    }

    .admin-main-v2 {
        height: auto;
        overflow: visible;
    }

    .admin-content-v2 {
        overflow: visible;
        padding: 16px;
    }

    .admin-topbar-v2,
    .admin-toolbar,
    .admin-section-head.inline,
    .admin-two-col,
    .admin-ops-grid {
        display: grid;
        grid-template-columns: 1fr;
    }

    .admin-metric-grid,
    .admin-metric-grid.compact,
    .admin-form-grid,
    .admin-model-row {
        grid-template-columns: 1fr;
    }

    .admin-form-grid .span-2 {
        grid-column: auto;
    }
}

/* v26 gallery, membership, invite and mobile operation polish */

.chat-memory-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.chat-memory-actions button {
    min-height: 26px;
    padding: 0 9px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,0.055);
    cursor: pointer;
    font-size: 11px;
}

.chat-memory-actions button:hover {
    border-color: rgba(240,79,114,0.42);
    background: rgba(240,79,114,0.14);
}

.role-gallery-thumb {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.role-gallery-thumb.private img {
    filter: saturate(0.84) brightness(0.82);
}

.role-gallery-thumb small {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 6px;
    overflow: hidden;
    padding: 4px 6px;
    border-radius: 7px;
    color: white;
    background: rgba(8,10,16,0.78);
    font-size: 10px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.membership-plan-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.membership-plan {
    display: grid;
    gap: 6px;
    min-height: 128px;
    padding: 13px;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,0.045);
    cursor: pointer;
    text-align: left;
}

.membership-plan:hover {
    border-color: rgba(83,214,162,0.42);
    background: rgba(83,214,162,0.11);
}

.membership-plan b,
.invite-card b {
    font-size: 15px;
}

.membership-plan strong {
    color: #61e4ae;
    font-size: 22px;
}

.membership-plan em {
    color: #ffd4dc;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
}

.membership-plan span,
.invite-card span,
.invite-card small {
    color: var(--text2);
    font-size: 12px;
    line-height: 1.45;
}

.invite-card {
    display: grid;
    gap: 7px;
    padding: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
}

.invite-bind {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-top: 10px;
}

.invite-bind input {
    min-height: 38px;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 8px;
    outline: 0;
    color: var(--text);
    background: rgba(255,255,255,0.045);
}

.invite-bind button,
.mine-role-strip small {
    min-height: 30px;
    border: 1px solid rgba(240,79,114,0.42);
    border-radius: 8px;
    color: white;
    background: rgba(240,79,114,0.88);
    cursor: pointer;
    font-weight: 800;
}

.invite-bind button {
    padding: 0 12px;
}

.mine-role-strip small {
    display: grid;
    place-items: center;
    margin-top: 2px;
    font-size: 11px;
}

.admin-thumb {
    width: 54px;
    height: 72px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
    object-fit: cover;
    background: #090c13;
}

.admin-funnel {
    display: grid;
    gap: 10px;
}

.admin-funnel article {
    display: grid;
    gap: 8px;
}

.admin-funnel article > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #eef2fb;
    font-size: 13px;
}

.admin-funnel span {
    color: var(--text2);
    font-size: 12px;
}

.admin-funnel i {
    display: block;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, #61e4ae, #f04f72);
}

.mobile-bottom-nav {
    display: none;
}

/* Compact sidebar filters */

.sidebar-filter-panel {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    padding: 0;
}

.sidebar-world-panel {
    margin-top: 0;
    padding: 0 12px 10px;
}

.sidebar-filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text2);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.sidebar-filter-subhead {
    padding-top: 0;
}

.sidebar-more-btn {
    border: 1px solid rgba(240,79,114,0.28);
    border-radius: 999px;
    padding: 2px 8px;
    color: #ff8aa0;
    background: rgba(240,79,114,0.08);
    cursor: pointer;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.5;
    white-space: nowrap;
}

.sidebar-more-btn:hover {
    color: #ffffff;
    border-color: rgba(240,79,114,0.58);
    background: rgba(240,79,114,0.22);
}

.sidebar-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
}

#tag-filter .char-tag,
#world-filter .char-tag {
    max-width: 100%;
    min-height: 24px;
    padding: 4px 9px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.35;
    white-space: nowrap;
}

#tag-filter .kink-tag {
    background: rgba(240,79,114,0.10) !important;
}

#tag-filter .kink-tag.active {
    background: #e94560 !important;
}

@media (max-width: 760px) {
    .sidebar-world-panel {
        padding-bottom: 8px;
    }

    #tag-filter .char-tag,
    #world-filter .char-tag {
        min-height: 28px;
    }
}

@media (max-width: 900px) {
    .chat-session-panel {
        grid-template-columns: 1fr;
        padding: 10px 14px;
    }

    .chat-session-memory {
        padding: 10px 0;
        border-left: 0;
        border-right: 0;
        border-top: 1px solid rgba(255,255,255,0.08);
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .membership-plan-grid,
    .invite-bind {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    #main {
        padding-bottom: 70px;
    }

    #chat-area {
        padding: 16px 14px;
    }

    #input-area {
        bottom: 58px;
        z-index: 80;
    }

    .quick-reply-bar {
        bottom: 124px;
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 8px;
        z-index: 90;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
        padding: 7px;
        border: 1px solid rgba(255,255,255,0.10);
        border-radius: 12px;
        background: rgba(11,13,19,0.94);
        box-shadow: 0 18px 48px rgba(0,0,0,0.36);
        backdrop-filter: blur(14px);
    }

    .mobile-bottom-nav button {
        min-width: 0;
        min-height: 40px;
        border: 0;
        border-radius: 8px;
        color: var(--text2);
        background: transparent;
        cursor: pointer;
        font-weight: 800;
    }

    .mobile-bottom-nav button.active {
        color: white;
        background: rgba(240,79,114,0.88);
    }

    .role-modal-dialog {
        width: 100vw;
        height: 100svh;
        max-height: 100svh;
        grid-template-columns: 1fr;
        border-radius: 0;
    }

    .role-modal-visual {
        min-height: 260px;
        max-height: 42svh;
    }

    .role-modal-main {
        padding: 18px 16px 92px;
    }

    .discover-controls,
    .discover-option-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .discover-controls::-webkit-scrollbar,
    .discover-option-row::-webkit-scrollbar {
        display: none;
    }
}

/* v37 mobile app shell polish */
@media (max-width: 760px) {
    body {
        background: #090b11;
    }

    #app {
        min-height: 100svh;
        background: #090b11;
    }

    #sidebar {
        position: sticky;
        top: 0;
        z-index: 70;
        width: 100%;
        min-width: 0;
        max-height: none;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid rgba(255,255,255,0.08);
        background: rgba(13,15,24,0.96);
        backdrop-filter: blur(14px);
    }

    #sidebar-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 4px 10px;
        align-items: center;
        padding: 10px 12px 9px;
        border-bottom: 0;
    }

    #user-header {
        min-width: 0;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 4px 8px;
        align-items: center;
    }

    #sidebar-header h1 {
        min-width: 0;
        font-size: 18px;
        line-height: 1.15;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #user-header > a {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 28px;
        margin-top: 0 !important;
        padding: 0 !important;
        border-radius: 999px !important;
        font-size: 0 !important;
        box-shadow: none;
    }

    #user-header > a::before {
        content: "广场";
        font-size: 11px;
        font-weight: 800;
    }

    #user-info {
        grid-column: 1 / -1;
        min-width: 0;
    }

    #guest-login-btn,
    #recharge-btn,
    #user-logout-btn {
        min-height: 28px !important;
        border-radius: 999px !important;
        padding: 0 10px !important;
        font-size: 11px !important;
    }

    #points-display {
        justify-self: end;
        margin-top: 0;
        padding: 4px 8px;
        border-radius: 999px;
        color: #c8cedd;
        background: rgba(255,255,255,0.05);
        white-space: nowrap;
    }

    #sidebar .app-nav,
    #sidebar > div[style*="padding:8px 12px"],
    #sidebar > .section-title,
    #world-filter,
    #char-list,
    #conv-section,
    #model-list,
    #sidebar-footer {
        display: none !important;
    }

    #main {
        min-height: calc(100svh - 58px);
        padding-bottom: 76px;
        background: #090b11;
    }

    #chat-header {
        min-height: 40px;
        padding: 8px 14px;
        gap: 8px;
        border-bottom-color: rgba(255,255,255,0.07);
        background: #090b11;
    }

    #current-char {
        display: block;
        max-width: 62vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 14px;
        font-weight: 800;
    }

    #current-world,
    #current-scene {
        display: none;
    }

    body[data-view="discover"] #current-model {
        display: none;
    }

    .chat-model-control {
        min-width: 0;
        gap: 6px;
        flex: 0 0 auto;
    }

    .chat-model-control #current-model {
        display: none;
    }

    .chat-model-control select {
        width: 138px;
        height: 32px;
        font-size: 12px;
        border-radius: 8px;
        background: #121827;
    }

    body[data-view="discover"] #chat-area {
        min-height: calc(100svh - 110px);
        padding: 10px 12px 96px;
        background: #090b11;
    }

    .discover-shell {
        width: 100%;
        gap: 12px;
    }

    .discover-toolbar {
        position: sticky;
        top: 0;
        z-index: 8;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin: 0 -2px;
        padding: 0 0 10px;
        border: 0;
        border-radius: 0;
        background: linear-gradient(180deg, #090b11 72%, rgba(9,11,17,0));
        box-shadow: none;
        backdrop-filter: none;
    }

    .discover-search {
        order: -1;
        min-height: 44px;
        padding: 0 12px;
        border-radius: 10px;
        background: #171a22;
        border-color: rgba(255,255,255,0.08);
    }

    .discover-search input {
        font-size: 13px;
    }

    .discover-tabs,
    .discover-categories {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 1px;
        scrollbar-width: none;
    }

    .discover-tabs::-webkit-scrollbar,
    .discover-categories::-webkit-scrollbar {
        display: none;
    }

    .discover-tabs button,
    .discover-categories button {
        flex: 0 0 auto;
        min-height: 34px;
        padding: 0 12px;
        border-radius: 9px;
        font-size: 12px;
    }

    .discover-option-row {
        grid-column: auto;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        align-items: center;
        overflow: visible;
    }

    .discover-categories {
        min-width: 0;
    }

    .discover-sort {
        min-height: 34px;
        padding: 0 8px;
        border-radius: 9px;
        white-space: nowrap;
    }

    .discover-sort span {
        display: none;
    }

    .discover-sort select {
        max-width: 72px;
        font-size: 12px;
    }

    .discover-privacy-toggle {
        display: none;
    }

    .discover-recent {
        min-height: 48px;
        padding: 7px 8px;
        border-radius: 10px;
        background: #11151d;
    }

    .discover-recent > span {
        font-size: 11px;
    }

    .discover-recent button {
        min-width: 74px;
        gap: 5px;
    }

    .discover-recent img {
        width: 26px;
        height: 34px;
    }

    .discover-recent b {
        max-width: 44px;
        font-size: 11px;
    }

    .discover-hero {
        display: none;
    }

    .discover-section-head {
        padding: 8px 2px 0;
        align-items: center;
    }

    .discover-section-head h2 {
        font-size: 17px;
        line-height: 1.25;
    }

    .discover-section-head button {
        min-height: 34px;
        padding: 0 12px;
        border-radius: 999px;
        font-size: 12px;
    }

    .discover-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .discover-card {
        border-radius: 12px;
        overflow: hidden;
        border-color: rgba(255,255,255,0.08);
        background: #11151d;
    }

    .discover-card-cover {
        height: clamp(218px, 72vw, 315px);
    }

    .discover-card-body {
        padding: 12px;
    }

    .discover-card-title h3 {
        font-size: 16px;
    }

    .discover-card p {
        min-height: 0;
        margin-top: 7px;
        font-size: 12px;
        line-height: 1.55;
    }

    .discover-card-tags,
    .discover-pref-line {
        gap: 5px;
        margin-top: 8px;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .discover-card-tags::-webkit-scrollbar,
    .discover-pref-line::-webkit-scrollbar {
        display: none;
    }

    .discover-card-tags span,
    .discover-pref-line .pref {
        flex: 0 0 auto;
        font-size: 10px;
    }

    .discover-card-stats {
        margin-top: 10px;
        gap: 8px;
        font-size: 11px;
    }

    .discover-card-actions {
        grid-template-columns: 0.8fr 1fr;
        gap: 8px;
        margin-top: 12px;
    }

    .discover-card-detail,
    .discover-card-cta {
        min-height: 40px;
        border-radius: 10px;
        font-size: 13px;
    }

    .mobile-bottom-nav {
        left: 12px;
        right: 12px;
        bottom: 8px;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
        border-radius: 14px;
        background: rgba(10,12,18,0.96);
    }

    .mobile-bottom-nav button {
        min-height: 38px;
        border-radius: 10px;
        font-size: 12px;
    }

    #input-area {
        left: 0;
        right: 0;
        bottom: 56px;
        padding: 8px 10px;
        background: rgba(9,11,17,0.96);
        backdrop-filter: blur(12px);
    }
}

/* v38 mobile first-screen tightening */
@media (max-width: 760px) {
    #sidebar-header {
        display: block;
        padding: 9px 12px;
    }

    #user-header {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    #sidebar-header h1 {
        flex: 1 1 auto;
    }

    #user-header > a {
        flex: 0 0 auto;
    }

    #user-info {
        flex: 0 0 auto;
        min-width: auto;
    }

    #guest-display,
    #user-display {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        max-width: 48vw;
    }

    #user-name,
    #user-points {
        max-width: 72px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 11px;
    }

    #points-display {
        display: none;
    }

    body[data-view="discover"] #chat-area {
        padding-top: 8px;
    }

    .discover-toolbar {
        padding-bottom: 9px;
    }

    .discover-section-head {
        padding-top: 6px;
    }

    .discover-card-cover {
        height: clamp(188px, 58vw, 236px);
    }

    .discover-card-body {
        padding: 11px 12px 12px;
    }

    .discover-card-actions {
        margin-top: 10px;
    }

    .discover-grid {
        padding-bottom: 86px;
    }

    #mobile-bottom-nav.mobile-bottom-nav {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        top: auto !important;
        bottom: 8px !important;
        z-index: 999 !important;
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

/* v41 interaction fixes */
.inline-code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.inline-code-row button {
    min-width: 72px;
    border: 1px solid rgba(240,79,114,0.35);
    border-radius: 8px;
    color: #ffd4dc;
    background: rgba(240,79,114,0.12);
    cursor: pointer;
    font-weight: 800;
}

.email-verify-panel p {
    color: var(--text2);
    font-size: 13px;
    margin-bottom: 10px;
}

.modal,
.login-overlay,
.role-modal,
.story-node-drawer {
    z-index: 1200;
}

body.modal-open #mobile-bottom-nav.mobile-bottom-nav {
    display: none !important;
}

@supports (height: 100dvh) {
    body,
    #app {
        height: 100dvh;
    }
}

@media (max-width: 760px) {
    #chat-header {
        position: sticky;
        top: env(safe-area-inset-top, 0px);
        z-index: 95;
        min-height: 44px;
        background: rgba(9, 11, 17, 0.96);
        backdrop-filter: blur(14px);
    }

    .chat-model-control select {
        max-width: 42vw;
    }

    #main {
        min-height: calc(100dvh - 58px);
    }

    #chat-area {
        min-height: 0;
    }
}

/* v45 character image chat surface */
body[data-view="chat"] #chat-area.chat-has-role-bg {
    background-color: #070910;
    background-image:
        linear-gradient(180deg, rgba(5,6,10,0.90) 0%, rgba(5,6,10,0.72) 42%, rgba(5,6,10,0.94) 100%),
        radial-gradient(circle at 50% 4%, rgba(240,79,114,0.20), transparent 38%),
        var(--chat-role-bg);
    background-size: cover, cover, cover;
    background-position: center, center, center 18%;
    background-repeat: no-repeat;
}

body[data-view="chat"] #chat-area.chat-has-role-bg .msg-row.assistant .msg-bubble {
    background: rgba(18, 23, 38, 0.86);
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 12px 36px rgba(0,0,0,0.22);
    backdrop-filter: blur(10px);
}

body[data-view="chat"] #chat-area.chat-has-role-bg #welcome {
    padding: 24px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    background: rgba(8, 10, 16, 0.54);
    backdrop-filter: blur(12px);
}

body[data-view="chat"] #chat-area.chat-has-role-bg .greeting-msg {
    background: rgba(8, 10, 16, 0.62);
    backdrop-filter: blur(10px);
}

@media (max-width: 760px) {
    body[data-view="chat"] #chat-area.chat-has-role-bg {
        background-position: center, center, center top;
        background-size: cover, cover, auto 100%;
    }
}
