:root {
    --pink: #ff4db8;
    --pink-hot: #ff2d9b;
    --pink-soft: #ff9ad4;
    --violet: #c44dff;
    --glass-strong: rgba(10, 4, 16, 0.30);
    --line: rgba(255, 77, 184, 0.5);
    --text: #fff6fb;
    --muted: rgba(255, 230, 245, 0.72);
    --danger: #ff6b8a;
    --font-ui: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-display: "ZCOOL XiaoWei", "Noto Sans SC", serif;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
}
body {
    font-family: var(--font-ui);
    color: var(--text);
    background: #0a050c;
}

.page-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    /* 始终花火横版主图；取景偏左以露出床榻/夜景主视觉（与线上一致） */
    background: url("/craftspark/img/hero-bg.jpg") 28% top / cover no-repeat fixed;
    background-color: #0a050c;
}
.page-veil {
    position: fixed;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(8, 2, 12, 0.28) 0%, rgba(8, 2, 12, 0.45) 35%, rgba(8, 2, 12, 0.86) 100%);
    z-index: 1;
    pointer-events: none;
}

.shell {
    position: relative;
    z-index: 3;
    width: min(100% - 24px, 920px);
    height: 100dvh;
    margin: 0 auto;
    padding: 10px 0 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}
.brand-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.45rem, 4.5vw, 1.85rem);
    letter-spacing: 0.04em;
    background: linear-gradient(120deg, #fff, var(--pink-soft), var(--violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 10px rgba(255, 45, 155, 0.45));
}
.brand-sub {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.75rem;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.email-banner {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 45, 155, 0.16);
    font-size: 0.8rem;
    flex-shrink: 0;
}
.email-banner[hidden] {
    display: none !important;
}

.module-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    flex-shrink: 0;
}
.module-tab {
    border: 1.5px solid rgba(255, 90, 200, 0.5);
    background: rgba(16, 6, 20, 0.30);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: inherit;
    border-radius: 14px;
    padding: 8px 6px;
    cursor: pointer;
    text-align: center;
}
.module-tab strong { display: block; font-size: 0.92rem; }
.module-tab small { color: var(--muted); font-size: 0.7rem; }
.character-tabs {
    grid-template-columns: repeat(4, 1fr);
}
.character-tabs .module-tab {
    padding: 8px 4px;
}
@media (max-width: 720px) {
    .character-tabs {
        grid-template-columns: repeat(2, 1fr);
    }
    .character-tabs .module-tab small {
        display: none;
    }
}
.character-tabs .module-tab .tab-emoji {
    display: block;
    font-size: 1.05rem;
    line-height: 1.2;
}
.module-tab.active,
.module-tab:hover {
    border-color: #ff7acc;
    box-shadow: 0 0 0 1px rgba(255, 77, 184, 0.25), 0 8px 22px rgba(255, 45, 155, 0.22);
}

.workspace {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    border: 1px solid rgba(255, 100, 200, 0.4);
    background: var(--glass-strong);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.workspace-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 120, 200, 0.18);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.10);
}
.workspace-head h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: #ffd7ef;
}
.workspace-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}
.workspace-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.coin-pill.time-pill.is-timing-active {
    border-color: rgba(93, 255, 177, 0.45);
    background: rgba(30, 100, 70, 0.22);
}
.coin-pill.time-pill.is-paused strong {
    color: var(--muted);
}
.coin-pill.time-pill.is-low {
    border-color: rgba(255, 160, 100, 0.55);
}
.coin-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(255, 90, 200, 0.55);
    background: rgba(255, 45, 155, 0.14);
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
}
.coin-pill strong { color: var(--pink-soft); font-size: 0.95rem; }
.coin-pill span { font-size: 0.72rem; color: var(--muted); }

.workspace-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.panel {
    display: none;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
.panel.active { display: flex; }

/* Only chat scrolls — page itself never scrolls */
.chat-log {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}
.msg {
    max-width: min(92%, 520px);
    padding: 9px 11px;
    border-radius: 14px;
    line-height: 1.45;
    font-size: 0.88rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(255, 45, 155, 0.55), rgba(160, 40, 180, 0.45));
}
.msg.ai {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 150, 220, 0.2);
}
.msg.ai:has(.gen-result) {
    max-width: min(96%, 420px);
    white-space: normal;
}
.gen-result { display: grid; gap: 8px; }
.gen-caption { font-size: 0.82rem; opacity: 0.85; }
.chat-inline-image {
    display: block;
    width: 100%;
    max-width: min(100%, 380px);
    max-height: 48vh;
    object-fit: contain;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.25);
    cursor: zoom-in;
}
.chat-video-wrap {
    position: relative;
    width: 100%;
    max-width: min(100%, 380px);
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}
.chat-inline-video {
    display: block;
    width: 100%;
    max-height: 48vh;
    object-fit: contain;
    background: #000;
}
.media-fs-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    z-index: 2;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 150, 220, 0.45);
    background: rgba(10, 4, 16, 0.72);
    color: #ffe6f5;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.media-fs-btn:hover {
    background: rgba(255, 45, 155, 0.35);
}

.composer {
    flex-shrink: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 120, 200, 0.18);
    display: grid;
    gap: 6px;
    background: rgba(0, 0, 0, 0.16);
}
.composer textarea {
    width: 100%;
    resize: none;
    min-height: 52px;
    max-height: 72px;
    border-radius: 12px;
    border: 1px solid rgba(255, 120, 200, 0.35);
    background: rgba(20, 6, 24, 0.75);
    color: var(--text);
    padding: 9px 11px;
    font: inherit;
    outline: none;
}
.composer textarea:focus {
    border-color: var(--pink);
    box-shadow: 0 0 0 3px rgba(255, 45, 155, 0.18);
}
.composer-tools { display: flex; }
.composer-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.composer-row textarea { flex: 1; min-width: 0; }

/* upload left | prompt center | generate right */
.media-row {
    align-items: center;
}
.upload-group {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}
.note {
    margin: 0;
    color: var(--muted);
    font-size: 0.74rem;
}

.seg {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}
.seg-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 6px 11px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
}
.seg-btn.active {
    background: linear-gradient(135deg, var(--pink-hot), var(--violet));
    color: white;
}

.thumb {
    width: 56px;
    cursor: pointer;
    text-align: center;
    flex-shrink: 0;
}
.thumb img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px dashed rgba(255, 140, 210, 0.55);
    background: rgba(255, 255, 255, 0.04);
    display: block;
}
.thumb span {
    display: block;
    margin-top: 2px;
    font-size: 0.65rem;
    color: var(--muted);
    line-height: 1.1;
}

.btn-primary, .btn-ghost, .btn-danger, .btn-text {
    font: inherit;
    cursor: pointer;
    border-radius: 12px;
}
.btn-primary {
    border: 0;
    color: white;
    background: linear-gradient(135deg, #ff2d9b, #c44dff);
    padding: 10px 14px;
    box-shadow: 0 8px 20px rgba(255, 45, 155, 0.3);
}
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary.wide { width: 100%; }
.generate-btn {
    flex-shrink: 0;
    min-width: 68px;
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    align-self: stretch;
}
.btn-ghost {
    border: 1px solid rgba(255, 120, 200, 0.45);
    background: rgba(20, 6, 24, 0.45);
    color: var(--text);
    padding: 7px 11px;
    font-size: 0.84rem;
}
.btn-danger {
    border: 1px solid rgba(255, 100, 130, 0.5);
    background: rgba(80, 10, 30, 0.45);
    color: #ffd0da;
    padding: 7px 11px;
}
.btn-text {
    border: 0;
    background: transparent;
    color: var(--pink-soft);
    text-decoration: underline;
    padding: 0;
}

.loading {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(8, 2, 12, 0.62);
    backdrop-filter: blur(2px);
    z-index: 5;
}
.loading.active { display: flex; }
.loading p { margin: 0; color: var(--pink-soft); }
.loading.active p::after {
    content: '...';
    display: inline-block;
    overflow: hidden;
    width: 0;
    animation: ellipsis 1.25s steps(4, end) infinite;
}
@keyframes ellipsis { to { width: 1.2em; } }

.site-footer {
    flex-shrink: 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.7rem;
    line-height: 1.35;
    padding: 2px 0 4px;
}
.site-footer p { margin: 0; }
.site-footer .legal {
    margin-top: 2px;
    font-size: 0.62rem;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal[hidden] { display: none !important; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 14px;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(4px);
    overflow: auto;
}
.modal-card {
    position: relative;
    width: min(100%, 420px);
    max-height: min(90dvh, 720px);
    overflow: auto;
    padding: 20px 16px 16px;
    border-radius: 18px;
    border: 1px solid rgba(255, 100, 200, 0.4);
    background: linear-gradient(180deg, rgba(36, 10, 30, 0.96), rgba(12, 4, 18, 0.98));
}
.modal-wide { width: min(100%, 720px); }
.modal-card h3 {
    margin: 0 0 12px;
    font-family: var(--font-display);
    font-size: 1.3rem;
}
.modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
}
.modal-card label {
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 0.86rem;
    color: var(--muted);
}
.modal-card input {
    border-radius: 12px;
    border: 1px solid rgba(255, 120, 200, 0.35);
    background: rgba(0, 0, 0, 0.35);
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}
.hint, .muted { color: var(--muted); font-size: 0.84rem; }
.form-link, .form-switch { font-size: 0.86rem; color: var(--muted); }
.form-link a, .form-switch a { color: var(--pink-soft); }
.form-feedback {
    min-height: 1.2em;
    margin: 0 0 8px;
    font-size: 0.84rem;
    color: var(--danger);
}
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 14px;
}
.coin-lg { font-size: 1.3rem; color: var(--pink-soft); margin: 0; }
.profile-actions { display: grid; gap: 8px; }
.invite-box {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 120, 200, 0.2);
}
.invite-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.invite-row p {
    margin: 0;
    flex: 1;
    min-width: 0;
    word-break: break-all;
    font-size: 0.84rem;
}
.btn-copy {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(255, 120, 200, 0.45);
    background: rgba(20, 6, 24, 0.45);
    color: var(--pink-soft);
    cursor: pointer;
    padding: 0;
}
.btn-copy:hover {
    border-color: var(--pink);
    background: rgba(255, 45, 155, 0.16);
}
.btn-ghost:disabled,
.btn-ghost.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    color: rgba(255, 230, 245, 0.45);
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(40, 40, 48, 0.45);
    pointer-events: none;
}
.list-scroll {
    max-height: 50dvh;
    overflow: auto;
    display: grid;
    gap: 8px;
}
.tx-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.86rem;
}
.tx-row .amt-pos { color: #8dffb4; }
.tx-row .amt-neg { color: #ff9db8; }
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    max-height: min(60dvh, 560px);
    overflow: auto;
}
.work-card {
    border-radius: 14px;
    border: 1px solid rgba(255, 120, 200, 0.22);
    background: rgba(20, 6, 24, 0.45);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.work-card-media {
    position: relative;
    background: rgba(0, 0, 0, 0.35);
    min-height: 140px;
}
.work-thumb {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}
.work-thumb-video {
    height: auto;
    min-height: 150px;
    max-height: 220px;
    object-fit: contain;
    background: #000;
    cursor: default;
}
.work-video-shell {
    position: relative;
    background: #000;
}
.work-card-info {
    padding: 10px;
    display: grid;
    gap: 4px;
}
.work-prompt {
    margin: 0;
    font-size: 0.8rem;
    color: rgba(255, 230, 245, 0.88);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.work-meta { margin: 0; }
.work-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    color: var(--pink-soft);
    border: 1px solid rgba(255, 120, 200, 0.35);
    background: rgba(255, 45, 155, 0.12);
}
.work-time {
    margin: 0;
    font-size: 0.72rem;
    color: rgba(255, 230, 245, 0.55);
}
.work-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.work-download-btn,
.work-delete-btn {
    flex: 1;
    padding: 7px 8px;
    border-radius: 10px;
    border: 1px solid rgba(255, 120, 200, 0.28);
    cursor: pointer;
    font-size: 0.78rem;
}
.work-download-btn {
    background: rgba(255, 45, 155, 0.16);
    color: #ffe6f5;
}
.work-download-btn:hover {
    background: rgba(255, 45, 155, 0.28);
}
.work-delete-btn {
    background: rgba(255, 80, 120, 0.12);
    color: rgba(255, 210, 220, 0.92);
}
.work-delete-btn:hover {
    background: rgba(255, 80, 120, 0.24);
}

.mobile-save-sheet {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20000;
    background: rgba(8, 4, 16, 0.72);
    align-items: flex-end;
    justify-content: center;
}
.mobile-save-sheet.active { display: flex; }
.mobile-save-panel {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    overflow-y: auto;
    background: rgba(28, 10, 36, 0.98);
    border: 1px solid rgba(255, 120, 200, 0.35);
    border-radius: 16px 16px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    color: #ffe6f5;
}
.mobile-save-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #ffe6f5;
    font-size: 16px;
    cursor: pointer;
}
.mobile-save-title {
    margin: 0 28px 8px 0;
    font-size: 1.05rem;
}
.mobile-save-hint,
.mobile-save-tip {
    margin: 0 0 10px;
    font-size: 0.82rem;
    color: rgba(255, 230, 245, 0.65);
}
.mobile-save-preview {
    margin: 10px 0 14px;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    text-align: center;
}
.mobile-save-preview img,
.mobile-save-preview video {
    display: block;
    width: 100%;
    max-height: 42vh;
    object-fit: contain;
    margin: 0 auto;
}
.mobile-save-actions {
    display: grid;
    gap: 8px;
}
.mobile-save-btn {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 120, 200, 0.35);
    background: rgba(255, 255, 255, 0.08);
    color: #ffe6f5;
    cursor: pointer;
    font-size: 0.92rem;
}
.mobile-save-btn-primary {
    background: rgba(255, 45, 155, 0.35);
    border-color: rgba(255, 45, 155, 0.55);
}

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(4, 0, 10, 0.94);
    justify-content: center;
    align-items: center;
    cursor: pointer;
}
.lightbox.active { display: flex; }
.lightbox img,
.lightbox video {
    max-width: 95vw;
    max-height: 95vh;
    border-radius: 12px;
    border: 1px solid rgba(255, 120, 200, 0.35);
    background: #000;
}
#lightboxContent {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 95vw;
    max-height: 95vh;
    cursor: default;
}
.lightbox-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 120, 200, 0.4);
    background: rgba(255, 45, 155, 0.18);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 120, 200, 0.4);
    background: rgba(20, 6, 24, 0.55);
    cursor: pointer;
    font-size: 0.84rem;
}
.user-chip .chip-label {
    color: var(--text);
    font-weight: 600;
}
.user-chip .coins,
.user-chip .time-mini {
    color: var(--pink-soft);
    font-weight: 700;
}

@media (max-width: 720px) {
    .shell {
        width: min(100% - 12px, 920px);
        padding-top: 6px;
        gap: 6px;
    }
    .brand-sub { display: none; }
    .site-footer .legal { display: none; }
    .module-tab { padding: 7px 4px; }
    .module-tab strong { font-size: 0.84rem; }
    .thumb { width: 48px; }
    .thumb img { width: 48px; height: 48px; }
    .generate-btn { min-width: 58px; padding: 8px 10px; }
    .composer textarea { min-height: 48px; }
    .media-row {
        align-items: center;
    }
    .profile-grid { grid-template-columns: 1fr; }
}

/* --- 花火 · 纯聊天布局（底图不变） --- */
.shell-chat {
    width: min(100% - 20px, 1260px);
    gap: 6px;
}

.topbar-chat {
    flex-wrap: wrap;
}
.topbar-glass {
    padding: 10px 14px;
    border-radius: 18px;
    border: 1px solid rgba(255, 120, 200, 0.28);
    background: rgba(12, 4, 18, 0.52);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--pink-hot), var(--violet));
    box-shadow: 0 0 18px rgba(255, 77, 184, 0.35);
    flex-shrink: 0;
}
.char-search {
    display: block;
    position: relative;
    margin-top: 8px;
}
.char-search input {
    width: 100%;
    padding: 7px 10px 7px 30px;
    border-radius: 999px;
    border: 1px solid rgba(255, 120, 200, 0.25);
    background: rgba(0, 0, 0, 0.28);
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    outline: none;
}
.char-search input:focus {
    border-color: var(--pink);
    box-shadow: 0 0 0 2px rgba(255, 77, 184, 0.12);
}
.char-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.timing-hint-bar {
    flex-shrink: 0;
    padding: 7px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 140, 210, 0.35);
    background: rgba(255, 45, 155, 0.12);
    font-size: 0.78rem;
    line-height: 1.45;
    color: #ffe8f7;
}
.timing-hint-bar[hidden] {
    display: none !important;
}
.timing-hint-bar.is-warn {
    border-color: rgba(255, 180, 100, 0.45);
    background: rgba(255, 120, 60, 0.14);
}

.header-timing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.time-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid rgba(255, 100, 200, 0.55);
    background: rgba(16, 6, 22, 0.55);
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.time-pill span.icon {
    opacity: 0.85;
    font-size: 0.9rem;
}
.time-pill strong {
    color: var(--pink-soft);
    font-weight: 700;
    letter-spacing: 0.02em;
}
.time-pill.is-timing-active {
    border-color: rgba(255, 90, 180, 0.85);
    box-shadow: 0 0 0 1px rgba(255, 77, 184, 0.35), 0 0 18px rgba(255, 45, 155, 0.2);
}
.time-pill.is-paused strong {
    color: rgba(255, 200, 230, 0.85);
}
.time-pill.is-low {
    border-color: rgba(255, 120, 90, 0.65);
}
.time-pill:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-timing {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 120, 200, 0.45);
    background: rgba(255, 45, 155, 0.18);
    color: #fff6fb;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
}
.btn-timing:hover:not(:disabled) {
    background: rgba(255, 45, 155, 0.32);
}
.btn-timing:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.btn-timing.is-pause-blocked {
    border-color: rgba(255, 160, 120, 0.4);
    background: rgba(80, 40, 20, 0.35);
}

.user-chip .time-mini {
    color: var(--pink-soft);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.chat-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(148px, 220px) minmax(0, 1fr);
    gap: 10px;
    overflow: hidden;
}
.chat-layout-v2 {
    grid-template-columns: minmax(200px, 260px) minmax(0, 1fr) minmax(160px, 200px);
}

.character-rail,
.context-rail {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-radius: 16px;
    border: 1px solid rgba(255, 100, 200, 0.38);
    background: rgba(12, 4, 18, 0.52);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}
.character-featured {
    margin: 0 8px 4px;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(255, 130, 210, 0.4);
    background: linear-gradient(145deg, rgba(255, 45, 155, 0.16), rgba(100, 40, 140, 0.18));
    flex-shrink: 0;
}
.character-featured .face-lg {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    margin-bottom: 6px;
}
.character-featured strong {
    font-size: 0.88rem;
}
.character-featured span {
    display: block;
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 2px;
}
.rail-head {
    padding: 10px 10px 6px;
    border-bottom: 1px solid rgba(255, 120, 200, 0.15);
    flex-shrink: 0;
}
.rail-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    color: #ffd7ef;
}
.rail-hint {
    margin: 4px 0 0;
    font-size: 0.68rem;
    color: var(--muted);
    line-height: 1.35;
}

.character-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
}

.character-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 8px;
    align-items: center;
    width: 100%;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid rgba(255, 110, 200, 0.28);
    background: rgba(12, 4, 16, 0.45);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.character-card:hover {
    border-color: rgba(255, 130, 210, 0.55);
    background: rgba(255, 45, 155, 0.1);
}
.character-card.active {
    border-color: #ff7acc;
    box-shadow: 0 0 0 1px rgba(255, 77, 184, 0.3), 0 6px 18px rgba(255, 45, 155, 0.22);
    background: rgba(255, 45, 155, 0.16);
}
.character-card .avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.character-card .meta strong {
    display: block;
    font-size: 0.84rem;
    font-weight: 700;
}
.character-card .meta span {
    display: block;
    margin-top: 2px;
    font-size: 0.68rem;
    color: var(--muted);
    line-height: 1.3;
}

.chat-stage {
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    border: 1px solid rgba(255, 100, 200, 0.4);
    background: var(--glass-strong);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}
.chat-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 120, 200, 0.18);
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}
.chat-partner {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.chat-partner h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: #ffd7ef;
}
.chat-partner p {
    margin: 2px 0 0;
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.partner-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 800;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.chat-status-pill {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.68rem;
    border: 1px solid rgba(255, 120, 200, 0.35);
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
}
.chat-status-pill[data-state="ready"] {
    color: #b8ffd8;
    border-color: rgba(120, 255, 180, 0.35);
    background: rgba(40, 120, 80, 0.2);
}
.chat-status-pill[data-state="timing"] {
    color: #ffd0ec;
    border-color: rgba(255, 120, 200, 0.45);
}
.chat-status-pill[data-state="blocked"] {
    color: #ffc9a8;
    border-color: rgba(255, 160, 100, 0.4);
}

.composer-chat .composer-note {
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
    padding: 0 2px;
}
.composer-chat .send-btn {
    min-width: 64px;
    align-self: stretch;
}

.time-lg {
    margin: 4px 0 0;
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
    color: var(--pink-soft);
    font-weight: 700;
}
.timing-inline {
    margin-top: 6px !important;
    font-size: 0.75rem !important;
}

.site-footer-compact {
    flex-shrink: 0;
    padding: 4px 0 2px;
}
.site-footer-compact p {
    margin: 0;
    font-size: 0.72rem;
}

.bubble-row {
    display: flex;
    gap: 8px;
    max-width: min(90%, 520px);
}
.bubble-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.bubble-row .bubble-mini-face {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-size: 0.78rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.bubble-col .msg {
    max-width: 100%;
}
.bubble-row:not(.user) .msg {
    border-top-left-radius: 4px;
}
.bubble-row.user .msg {
    border-top-right-radius: 4px;
}
.bubble-time {
    font-size: 0.62rem;
    color: var(--muted);
    margin-top: 3px;
    padding: 0 2px;
}
.partner-tagline.live {
    color: #9dffc8;
}
.composer-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.quick-chip {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 130, 210, 0.28);
    background: rgba(255, 45, 155, 0.08);
    font-size: 0.7rem;
    color: #ffd0ec;
    cursor: pointer;
    font-family: inherit;
}
.quick-chip:hover {
    background: rgba(255, 45, 155, 0.22);
}
.context-cards {
    padding: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.context-card {
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 120, 200, 0.15);
    background: rgba(18, 6, 24, 0.55);
}
.context-card h4 {
    margin: 0 0 6px;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--pink-soft);
}
.context-card p {
    margin: 0;
    font-size: 0.7rem;
    color: var(--muted);
    line-height: 1.45;
}
.context-meter {
    margin-top: 8px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.context-meter span {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--pink), var(--violet));
    transition: width 0.4s ease;
}
.context-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.context-tag {
    font-size: 0.62rem;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 150, 220, 0.3);
    background: rgba(0, 0, 0, 0.2);
    color: #ffc8e8;
}
.character-card .presence-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5dffb1;
    box-shadow: 0 0 6px #5dffb1;
    justify-self: end;
}

@media (max-width: 960px) {
    .chat-layout-v2 {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }
    .context-rail,
    .character-featured,
    .char-search {
        display: none;
    }
}
@media (max-width: 720px) {
    .chat-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }
    .character-rail {
        max-height: 132px;
    }
    .character-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .character-card {
        min-width: 148px;
        grid-template-columns: 40px 1fr;
    }
    .rail-hint { display: none; }
    .header-timing {
        width: 100%;
        justify-content: space-between;
    }
}
