:root {
    color-scheme: light;
    --primary: #9b6a9c;
    --primary-hover: #855886;
    --bg: #f6f8fa;
    --card: rgba(255, 255, 255, .86);
    --sidebar-bg: rgba(255, 255, 255, .82);
    --text: #24292e;
    --text-main: #24292e;
    --text-sub: #666;
    --border: rgba(225, 228, 232, .9);
    --input-bg: rgba(255, 255, 255, .92);
    --chip-bg: rgba(255, 255, 255, .9);
    --chip-hover: #f0f0f0;
    --member: #fb7299;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

button, input, select { font: inherit; }

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border);
}

.group-title {
    margin-bottom: 1px;
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 700;
}

.field-row { display: flex; align-items: center; gap: 8px; }
.field-row > span { width: 60px; flex-shrink: 0; color: var(--text-main); font-size: 12px; }
.field-stack { display: grid; gap: 5px; }
.field-stack > span { color: var(--text-sub); font-size: 11px; }

input, select {
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(155, 106, 156, .11); }

.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.date-grid input { padding: 0 7px; font-size: 12px; }

.btn {
    height: 38px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    cursor: pointer;
    font-weight: 600;
    transition: background .2s, border-color .2s, transform .2s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-full { width: 100%; }
.btn-primary { color: #fff; background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--input-bg); border-color: var(--border); }
.btn-secondary:hover { background: var(--chip-hover); border-color: #aaa; }
.search-button { margin-top: -2px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.stats > div {
    min-width: 0;
    padding: 9px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(0, 0, 0, .025);
    border: 1px solid var(--border);
    border-radius: 7px;
}
.stats span { color: var(--text-sub); font-size: 10px; }
.stats strong { overflow: hidden; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-footer { margin-top: auto; display: grid; gap: 8px; }
.status-bar { padding: 9px; color: var(--text-sub); background: rgba(0, 0, 0, .03); border-radius: 6px; font-size: 11px; line-height: 1.5; text-align: center; }
.sidebar-footer p { margin: 0; color: #999; font-size: 10px; text-align: center; }

.main-content { min-width: 0; padding: 20px 40px 36px; }
.page-header {
    max-width: 1080px;
    margin: 0 auto 18px;
    padding-bottom: 12px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--border);
}
.page-header h1 { margin: 0; font-size: 22px; font-weight: 650; }
.page-header p { margin: 0; color: var(--text-sub); font-size: 12px; text-align: right; }

.results-section { max-width: 1080px; margin: 0 auto; }
.result-list { display: block; }

.message-card {
    position: relative;
    margin-bottom: 10px;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    word-wrap: break-word;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .05);
    transition: border-color .2s, box-shadow .2s;
}

.message-card:hover { border-color: var(--primary); box-shadow: 0 8px 25px rgba(0, 0, 0, .12); }

.user-header-row {
    min-width: 0;
    margin-bottom: 10px;
    padding-right: 96px;
    display: flex;
    align-items: center;
}

.message-avatar {
    position: relative;
    width: 38px;
    height: 38px;
    margin-right: 12px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--primary);
    background: #f2ebf3;
    border: 1px solid var(--border);
    border-radius: 50%;
    font-weight: 700;
}

.message-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.user-info-col { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.sender-name { overflow: hidden; color: var(--text); font-size: 15px; font-weight: 700; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.sender-name.is-member { color: var(--member); }
.message-time { margin-top: 4px; color: var(--text-sub); font-size: 12px; line-height: 1.2; }

.user-id {
    position: absolute;
    top: 14px;
    right: 15px;
    max-width: 120px;
    padding: 2px 8px;
    overflow: hidden;
    color: var(--text-sub);
    background: var(--chip-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .02);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-content { margin: 0; color: var(--text); font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.message-content p { margin-top: 0; }
.message-content a { color: var(--primary); text-decoration: none; }
.message-content a:hover { text-decoration: underline; }
.mb-2 { margin-bottom: 8px !important; }
.template-pre { white-space: pre-wrap; overflow-wrap: anywhere; }

.template-image-express-image {
    max-width: 120px !important;
    max-height: 120px !important;
    object-fit: contain;
    border-radius: 8px;
    margin: 5px 0 !important;
    box-shadow: none !important;
}

.template-media {
    display: block;
    max-width: 100%;
    max-height: 420px;
    border-radius: 6px;
    margin-top: 5px;
}

.message-image-button { display: block; padding: 0; border: 0; background: transparent; cursor: zoom-in; }

.audio-wrapper {
    position: relative;
    width: fit-content;
    min-width: 160px;
    max-width: 280px;
    margin-top: 8px;
    padding: 8px 16px;
    display: inline-flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 25px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .02);
    cursor: pointer;
    user-select: none;
    transition: all .2s ease;
}
.audio-wrapper:hover { border-color: var(--primary); background: var(--chip-hover); transform: translateY(-1px); }
.audio-wrapper.playing { border-color: var(--primary); background: rgba(155, 106, 156, .05); }
.audio-wrapper audio { display: none; }
.audio-control-icon { position: relative; width: 28px; height: 28px; margin-right: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--primary); border-radius: 50%; }
.audio-control-icon .audio-icon-play, .audio-control-icon .audio-icon-pause { display: none; }
.audio-control-icon.is-play .audio-icon-play, .audio-control-icon.is-pause .audio-icon-pause { display: inline-flex; }
.audio-icon-play { width: 0; height: 0; margin-left: 2px; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid currentColor; }
.audio-icon-pause { align-items: center; justify-content: center; gap: 3px; }
.audio-icon-pause span { width: 3px; height: 10px; display: block; background: currentColor; border-radius: 999px; }
.audio-wave-box { height: 20px; margin-right: 12px; flex: 1; display: flex; align-items: center; gap: 3px; }
.wave-bar { width: 3px; height: 4px; background: var(--text-sub); border-radius: 2px; opacity: .6; }
.playing .wave-bar { background: var(--primary); animation: wave 1s infinite ease-in-out; opacity: 1; }
.playing .wave-bar:nth-child(1) { height: 10px; animation-delay: 0s; }
.playing .wave-bar:nth-child(2) { height: 16px; animation-delay: .2s; }
.playing .wave-bar:nth-child(3) { height: 8px; animation-delay: .4s; }
.playing .wave-bar:nth-child(4) { height: 14px; animation-delay: .1s; }
.playing .wave-bar:nth-child(5) { height: 6px; animation-delay: .3s; }
.audio-duration { color: var(--text-sub); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
@keyframes wave { 50% { transform: scaleY(2); } }

.video-wrapper { position: relative; max-width: 100%; margin: 8px 0; display: inline-block; overflow: hidden; vertical-align: top; background: transparent; border-radius: 12px; line-height: 0; }
.video-placeholder { position: relative; width: 280px; min-width: 200px; min-height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: transparent; border-radius: 12px; box-shadow: 0 4px 10px rgba(0, 0, 0, .2); cursor: pointer; }
.video-placeholder video { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; background: transparent; border-radius: 0; }
.video-placeholder.is-playing { background: #000; cursor: default; }
.play-icon-overlay { position: relative; z-index: 1; opacity: .9; }
.play-icon-circle { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .3); border-radius: 50%; box-shadow: 0 4px 8px rgba(0, 0, 0, .3); backdrop-filter: blur(2px); }
.play-icon-circle span { width: 0; height: 0; margin-left: 3px; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 13px solid currentColor; }

body.modal-open { overflow: hidden; }
.image-modal { position: fixed; inset: 0; z-index: 2001; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .9); backdrop-filter: blur(7px); }
.image-modal[hidden] { display: none; }
.image-modal-stage { width: 100%; height: 100%; padding: 20px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.image-modal img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 0 20px rgba(0, 0, 0, .5); cursor: grab; transition: transform .2s ease-out; }
.image-modal-close { position: fixed; top: 14px; right: 18px; z-index: 1; width: 42px; height: 42px; padding: 0; color: #fff; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .25); border-radius: 50%; cursor: pointer; font-size: 30px; line-height: 1; }

.message-quote {
    margin: 0 0 8px 8px;
    padding: 8px;
    color: #57606a;
    background: rgba(155, 106, 156, .05);
    border-left: 4px solid #d0d7de;
    border-radius: 0 6px 6px 0;
}

.gift-card {
    max-width: 300px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    background: #fff0f6;
    border: 1px solid #ffadd2;
    border-radius: 6px;
}

.gift-card img { width: 25px; height: 25px; max-width: 32px; max-height: 32px; margin-right: 8px; object-fit: contain; border-radius: 4px; box-shadow: none; }
.gift-placeholder { margin-right: 8px; font-size: 24px; }
.gift-copy { min-width: 0; flex: 1; overflow: hidden; }
.gift-name { overflow: hidden; color: #eb2f96; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.gift-count { color: #888; font-size: 11px; }
.gift-cost { margin-left: 5px; color: #fa8c16; font-weight: 700; }

.red-packet-card {
    width: 220px;
    max-width: 220px;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(255, 120, 117, .12), rgba(255, 120, 117, .04)), rgba(0, 0, 0, .02);
    border: 1px solid rgba(255, 110, 110, .22);
    border-radius: 10px;
}

.red-packet-card img, .red-packet-placeholder { width: 34px; height: 34px; flex-shrink: 0; border-radius: 6px; object-fit: cover; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }
.red-packet-placeholder { display: grid; place-items: center; background: #fff; font-size: 22px; }
.red-packet-copy { min-width: 0; flex: 1; }
.red-packet-label { margin-bottom: 2px; color: #ff7875; font-size: 10px; font-weight: 700; }
.red-packet-message { color: var(--text-main); font-size: 12px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.red-packet-meta { margin-top: 4px; color: var(--text-sub); font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }

.flip-label {
    height: 20px;
    margin-right: 6px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    transform: translateY(-1px);
}

.flip-label.question-tag { background: linear-gradient(135deg, #b583b6, #9b6a9c); }
.flip-label.answer-tag { margin-top: 12px; margin-bottom: 6px; background: #24292e; }

.vod-card-row {
    position: relative;
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: transform .2s, border-color .2s, box-shadow .2s;
}

.vod-card-row:hover { border-color: var(--primary); box-shadow: 0 3px 10px rgba(0, 0, 0, .05); transform: translateX(3px); }
.vod-row-cover-container { position: relative; width: 120px; height: 68px; margin-right: 15px; flex-shrink: 0; overflow: hidden; border-radius: 6px; }
.vod-row-cover { width: 100%; height: 100%; object-fit: cover; }
.vod-row-cover-empty { display: grid; place-items: center; color: #fff; background: var(--primary); font-weight: 700; }
.vod-row-info { min-width: 0; height: 68px; padding: 2px 0; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.vod-row-name { color: var(--text); font-size: 15px; font-weight: 700; }
.vod-row-title { margin-top: 4px; overflow: hidden; color: var(--text-sub); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.vod-row-time { margin-top: auto; color: #999; font-size: 12px; }
.vod-badge { position: absolute; right: 4px; bottom: 4px; z-index: 2; padding: 2px 6px; color: #fff; background: #722ed1; border-radius: 4px; font-size: 10px; opacity: .9; }
.message-tags { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 2px 8px; color: var(--text-sub); background: var(--chip-bg); border: 1px solid var(--border); border-radius: 20px; font-size: 10px; line-height: 1.5; }
.tag.room { color: var(--primary); }

.empty-state { padding: 70px 20px; color: var(--text-sub); text-align: center; background: var(--card); border: 1px dashed var(--border); border-radius: 12px; }
.empty-state h2 { margin: 0 0 5px; color: var(--text); font-size: 18px; }
.empty-state p { margin: 0; }
.load-more { min-width: 180px; margin: 20px auto 0; display: flex; }

@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--border); }
    .search-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .sidebar-group { height: 100%; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
    .search-button { grid-column: 1 / -1; }
    .sidebar-footer { margin-top: 0; }
    .main-content { padding: 20px; }
}

@media (max-width: 600px) {
    .sidebar { padding: 12px; }
    .search-form { grid-template-columns: 1fr; gap: 10px; }
    .search-button { grid-column: auto; }
    .main-content { padding: 16px 12px 28px; }
    .page-header { align-items: flex-start; flex-direction: column; gap: 5px; }
    .page-header p { text-align: left; }
    .user-header-row { padding-right: 0; }
    .user-id { position: static; width: fit-content; max-width: 100%; margin: 0 0 8px 50px; order: 2; }
    .vod-row-cover-container { width: 92px; height: 54px; margin-right: 10px; }
    .vod-row-info { height: 54px; }
}
