:root {
    color-scheme: light;
    --bg: #eef3f8;
    --panel: rgba(255, 255, 255, 0.78);
    --panel-solid: #ffffff;
    --panel-soft: rgba(236, 243, 250, 0.82);
    --glass: rgba(255, 255, 255, 0.64);
    --glass-strong: rgba(255, 255, 255, 0.86);
    --text: #172033;
    --muted: #64748b;
    --line: rgba(130, 151, 179, 0.34);
    --line-strong: rgba(80, 102, 134, 0.2);
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.12);
    --green: #0f766e;
    --amber: #b45309;
    --danger: #b91c1c;
    --violet: #7c3aed;
    --cyan: #0891b2;
    --shadow: 0 18px 50px rgba(30, 41, 59, 0.1);
    --shadow-lift: 0 24px 70px rgba(30, 41, 59, 0.16);
    --radius: 8px;
    --blur: blur(18px) saturate(1.15);
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f131b;
    --panel: rgba(22, 29, 41, 0.72);
    --panel-solid: #171d29;
    --panel-soft: rgba(34, 43, 59, 0.84);
    --glass: rgba(17, 24, 39, 0.62);
    --glass-strong: rgba(22, 29, 41, 0.88);
    --text: #eef4ff;
    --muted: #9aa8bd;
    --line: rgba(137, 156, 184, 0.22);
    --line-strong: rgba(182, 197, 220, 0.14);
    --primary: #60a5fa;
    --primary-strong: #3b82f6;
    --primary-soft: rgba(96, 165, 250, 0.15);
    --green: #34d399;
    --amber: #f59e0b;
    --danger: #f87171;
    --violet: #a78bfa;
    --cyan: #22d3ee;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    --shadow-lift: 0 26px 80px rgba(0, 0, 0, 0.36);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(145deg, rgba(37, 99, 235, 0.1) 0%, rgba(8, 145, 178, 0.04) 34%, rgba(124, 58, 237, 0.08) 100%),
        linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 86%, #ffffff) 48%, var(--bg) 100%);
    color: var(--text);
    font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(100, 116, 139, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 116, 139, 0.08) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), transparent 70%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), transparent 70%);
}

[data-theme="dark"] body {
    background:
        linear-gradient(145deg, rgba(96, 165, 250, 0.1) 0%, rgba(34, 211, 238, 0.04) 36%, rgba(167, 139, 250, 0.09) 100%),
        linear-gradient(180deg, var(--bg) 0%, #111827 48%, var(--bg) 100%);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

a,
button,
.button,
input,
select,
textarea {
    transition:
        background-color 180ms var(--ease),
        border-color 180ms var(--ease),
        color 180ms var(--ease),
        box-shadow 180ms var(--ease),
        transform 180ms var(--ease),
        opacity 180ms var(--ease);
}

img {
    max-width: 100%;
    display: block;
}

code {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.08rem 0.35rem;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 72px;
    padding: 0 5vw;
    background: var(--glass-strong);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--text);
    font-weight: 800;
    font-size: 1.08rem;
    white-space: nowrap;
}

.brand:hover {
    text-decoration: none;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.28);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.28rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.site-nav a,
.theme-button,
.nav-toggle {
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    padding: 0.52rem 0.74rem;
    font: inherit;
    cursor: pointer;
    font-weight: 650;
}

.site-nav a:hover,
.site-nav a.active,
.theme-button:hover {
    background: var(--primary-soft);
    color: var(--primary);
    text-decoration: none;
}

.theme-button {
    gap: 0.48rem;
    border: 1px solid var(--line);
    background: var(--glass);
}

.theme-track {
    width: 34px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    padding: 2px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 20%, transparent);
    box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.16);
}

.theme-thumb {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.24);
    transform: translateX(0);
}

[data-theme="dark"] .theme-thumb {
    transform: translateX(16px);
}

.theme-label {
    min-width: 2.1rem;
    text-align: left;
}

.nav-toggle {
    display: none;
    border: 1px solid var(--line);
}

.page-shell {
    width: min(1180px, 90vw);
    margin: 0 auto;
    padding: 2.35rem 0 3.4rem;
    animation: page-in 520ms var(--ease) both;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    width: min(1180px, 90vw);
    margin: 0 auto;
    padding: 1.45rem 0 2rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.site-footer span:first-child {
    color: var(--text);
    font-weight: 800;
}

.site-footer span:last-child {
    text-align: right;
}

.page-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.35rem;
    padding: 0.2rem 0 0.35rem;
}

.page-title h1 {
    margin: 0;
    font-size: 2.35rem;
    line-height: 1.16;
    letter-spacing: 0;
}

.page-title p {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.panel,
.toolbar-panel,
.notice-strip,
.thread-item,
.resource-card,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.panel {
    padding: 1.35rem;
}

.panel h1,
.panel h2 {
    margin-top: 0;
    letter-spacing: 0;
}

.narrow {
    max-width: 680px;
    margin: 0 auto;
}

.toolbar-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.library-toolbar {
    align-items: stretch;
    flex-direction: column;
    overflow: hidden;
}

.library-toolbar::before,
.forum-toolbar::before {
    content: "";
    display: block;
    height: 3px;
    margin: -1rem -1rem 0;
    background: linear-gradient(90deg, var(--primary), var(--cyan), var(--violet));
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 180px 180px auto;
    gap: 0.75rem;
    width: 100%;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--glass);
    color: var(--text);
    font: inherit;
    padding: 0.72rem 0.82rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 2.45rem;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%),
        linear-gradient(to right, var(--line), var(--line));
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 12px) 50%,
        calc(100% - 2.15rem) 50%;
    background-size:
        6px 6px,
        6px 6px,
        1px 1.55rem;
    background-repeat: no-repeat;
}

select:hover {
    border-color: color-mix(in srgb, var(--primary) 52%, var(--line));
    background-color: var(--glass-strong);
}

select option {
    background: var(--panel-solid);
    color: var(--text);
}

[data-theme="dark"] select option {
    background: #171d29;
    color: #eef4ff;
}

input:focus,
select:focus,
textarea:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

textarea {
    resize: vertical;
}

small {
    display: block;
    margin-top: 0.32rem;
    color: var(--muted);
}

label span,
legend {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
    margin-bottom: 0.32rem;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 0;
}

.button,
button {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--glass);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0.55rem 0.9rem;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.button:hover,
button:hover {
    text-decoration: none;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.button.primary {
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary-strong), var(--cyan));
    border-color: var(--primary-strong);
    box-shadow: 0 14px 36px color-mix(in srgb, var(--primary) 34%, transparent);
}

.button.ghost {
    background: transparent;
}

.link-button {
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
}

.button-row,
.form-actions,
.inline-form,
.sort-links,
.request-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.stack-form,
.form-grid,
.comment-form {
    display: grid;
    gap: 1rem;
}

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

.wide {
    grid-column: 1 / -1;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-row a,
.sort-links a,
.tabs a {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    background: var(--glass);
    padding: 0.35rem 0.7rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.tag-row a:hover,
.sort-links a:hover,
.tabs a:hover {
    transform: translateY(-1px);
    border-color: var(--primary);
    text-decoration: none;
}

.tag-row a:hover,
.tag-row a.active,
.sort-links a.active,
.tabs a.active {
    background: linear-gradient(135deg, var(--primary), var(--violet));
    border-color: var(--primary);
    color: #ffffff;
    text-decoration: none;
}

.tag-row.compact a {
    font-size: 0.9rem;
    padding: 0.22rem 0.55rem;
}

.tag-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.tag-picker legend {
    width: 100%;
}

.tag-picker label,
.check-line {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.tag-picker input,
.check-line input {
    width: auto;
}

.notice-strip {
    display: grid;
    gap: 0;
    margin-bottom: 1.2rem;
    overflow: hidden;
}

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

.announcement-strip a {
    border-bottom: 0;
}

.notice-strip a {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1rem;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
    color: var(--text);
}

.notice-strip a:hover {
    background: var(--primary-soft);
    text-decoration: none;
}

.notice-strip a:last-child {
    border-bottom: 0;
    border-right: 0;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.05rem;
}

.resource-card {
    overflow: hidden;
    position: relative;
    transform: translateZ(0);
    animation: card-in 520ms var(--ease) both;
}

.resource-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.34), transparent 34%, rgba(96, 165, 250, 0.1));
    opacity: 0;
    transition: opacity 200ms var(--ease);
}

.resource-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lift);
    border-color: color-mix(in srgb, var(--primary) 38%, var(--line));
}

.resource-card:hover::before {
    opacity: 1;
}

.resource-card .cover {
    aspect-ratio: 16 / 7.4;
    background: var(--panel-soft);
    overflow: hidden;
}

.resource-card .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 320ms var(--ease), filter 320ms var(--ease);
}

.resource-card:hover .cover img {
    transform: scale(1.045);
    filter: saturate(1.08) contrast(1.03);
}

.resource-body {
    padding: 0.9rem 1rem 1rem;
    position: relative;
    display: grid;
    gap: 0.48rem;
}

.resource-body h2 {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.35;
    letter-spacing: 0;
}

.resource-body h2 a {
    color: var(--text);
}

.resource-body h2 a:hover {
    color: var(--primary);
    text-decoration: none;
}

.resource-body p {
    color: var(--muted);
    min-height: 3.2rem;
    margin: 0;
}

.meta-line,
.card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.resource-card .meta-line span,
.type-badge {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--glass);
    padding: 0.16rem 0.48rem;
}

.meta-line span,
.meta-line a {
    display: inline-flex;
    align-items: center;
}

.card-stats {
    justify-content: space-between;
    margin-top: 0.55rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--line);
}

.auth-panel {
    position: relative;
    overflow: hidden;
    padding: 1.5rem;
}

.auth-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--cyan), var(--violet));
}

.auth-heading {
    margin-bottom: 1.2rem;
}

.auth-heading h2 {
    margin: 0 0 0.35rem;
    font-size: 1.45rem;
}

.auth-heading p,
.auth-switch span {
    color: var(--muted);
}

.auth-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.profile-settings .profile-head {
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.detail-layout,
.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 1.2rem;
    align-items: start;
}

.split-layout {
    grid-template-columns: 330px minmax(0, 1fr);
}

.detail-main,
.detail-side,
.profile-page {
    display: grid;
    gap: 1.2rem;
}

.resource-hero {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 1.2rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.35rem;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.resource-hero > img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--panel-soft);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
}

.resource-hero h1 {
    margin: 0.3rem 0 0.6rem;
    font-size: 2.15rem;
    line-height: 1.18;
    letter-spacing: 0;
}

.score-line {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.score-line strong {
    font-size: 2rem;
}

.comment {
    border-top: 1px solid var(--line);
    padding: 1rem;
    margin-top: 1rem;
    background: color-mix(in srgb, var(--panel-soft) 58%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.shared-resource {
    background: var(--panel-soft);
    border-radius: var(--radius);
    padding: 0.65rem 0.8rem;
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.info-list dt {
    color: var(--muted);
}

.info-list dd {
    margin: 0;
}

.thread-list,
.mini-list,
.message-thread {
    display: grid;
    gap: 0.75rem;
}

.thread-list {
    gap: 0.9rem;
}

.thread-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.05rem;
    position: relative;
    overflow: hidden;
    transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
}

.thread-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
}

.thread-help::before {
    background: var(--amber);
}

.thread-discussion::before {
    background: var(--cyan);
}

.thread-item:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--primary) 34%, var(--line));
    box-shadow: var(--shadow-lift);
}

.thread-item h2 {
    margin: 0.42rem 0;
    font-size: 1.18rem;
    letter-spacing: 0;
}

.thread-item p {
    margin: 0;
    color: var(--muted);
}

.count-pill {
    min-width: 78px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    align-self: center;
}

.type-badge {
    color: var(--primary);
    font-weight: 750;
}

.thread-help .type-badge {
    color: var(--amber);
}

.profile-head {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.profile-head img {
    width: 88px;
    height: 88px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.mini-list a {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--text);
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 0.85rem;
    transition: transform 180ms var(--ease), border-color 180ms var(--ease), background-color 180ms var(--ease);
}

.announcement-layout {
    grid-template-columns: 360px minmax(0, 1fr);
}

.announcement-list-panel {
    position: sticky;
    top: 92px;
}

.announcement-panel {
    min-height: 420px;
    padding: 1.55rem;
}

.announcement-panel h1 {
    margin: 0.55rem 0 1rem;
    font-size: 2rem;
    line-height: 1.22;
}

.announcement-panel p {
    font-size: 1.02rem;
    line-height: 1.85;
}

.mini-list a:hover,
.mini-list a.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    transform: translateX(2px);
    text-decoration: none;
}

.mini-list span {
    color: var(--muted);
    white-space: nowrap;
}

.message {
    width: min(78%, 560px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--glass);
    padding: 0.75rem 0.9rem;
}

.message.mine {
    justify-self: end;
    background: color-mix(in srgb, var(--primary) 20%, var(--panel));
    border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
}

.message p {
    margin: 0 0 0.35rem;
}

.message span {
    color: var(--muted);
    font-size: 0.86rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

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

.stat-card {
    padding: 1.2rem;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    left: 1.2rem;
    right: 1.2rem;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--cyan), var(--violet));
    border-radius: 999px 999px 0 0;
}

.stat-card strong {
    display: block;
    font-size: 2rem;
    line-height: 1;
}

.stat-card span {
    color: var(--muted);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 0.8rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 600;
    background: color-mix(in srgb, var(--panel-soft) 70%, transparent);
}

tbody tr:hover {
    background: color-mix(in srgb, var(--primary-soft) 62%, transparent);
}

.flash {
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    background: var(--glass-strong);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.flash.success {
    border-color: color-mix(in srgb, var(--green) 45%, var(--line));
}

.flash.warning {
    border-color: color-mix(in srgb, var(--amber) 45%, var(--line));
}

.flash.error {
    border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}

.empty-state {
    padding: 1.2rem;
    color: var(--muted);
    background: var(--glass);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

details.resource-details {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.85rem;
}

details.resource-details[open] {
    display: grid;
    gap: 0.85rem;
}

summary {
    cursor: pointer;
    font-weight: 700;
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.resource-card:nth-child(2n) {
    animation-delay: 60ms;
}

.resource-card:nth-child(3n) {
    animation-delay: 120ms;
}

@media (max-width: 980px) {
    .resource-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-layout,
    .split-layout,
    .resource-hero {
        grid-template-columns: 1fr;
    }

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

    .announcement-list-panel {
        position: static;
    }

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

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

    .page-title h1 {
        font-size: 2rem;
    }

    .resource-hero h1 {
        font-size: 1.85rem;
    }
}

@media (max-width: 720px) {
    .site-header {
        align-items: center;
        padding: 0.7rem 4vw;
        min-height: 64px;
    }

    .brand span {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-toggle {
        display: inline-flex;
        min-height: 38px;
        padding: 0.42rem 0.68rem;
    }

    .site-nav {
        display: none;
        position: absolute;
        left: 4vw;
        right: 4vw;
        top: calc(100% + 0.5rem);
        background: var(--glass-strong);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 0.7rem;
        justify-content: flex-start;
        max-height: 74vh;
        overflow-y: auto;
        backdrop-filter: var(--blur);
        -webkit-backdrop-filter: var(--blur);
    }

    .site-nav.open {
        display: flex;
    }

    .site-nav a,
    .theme-button {
        width: 100%;
        justify-content: flex-start;
    }

    .theme-button {
        justify-content: space-between;
    }

    .page-shell,
    .site-footer {
        width: min(94vw, 1180px);
    }

    .page-shell {
        padding-top: 1.35rem;
    }

    .page-title h1 {
        font-size: 1.72rem;
    }

    .page-title p {
        font-size: 0.94rem;
    }

    .site-footer,
    .toolbar-panel,
    .notice-strip a,
    .thread-item,
    .profile-head {
        flex-direction: column;
        align-items: stretch;
    }

    .filters,
    .form-grid,
    .resource-grid,
    .stat-grid,
    .announcement-strip {
        grid-template-columns: 1fr;
    }

    .filters {
        gap: 0.6rem;
    }

    .library-toolbar,
    .forum-toolbar {
        padding: 0.85rem;
    }

    .library-toolbar::before,
    .forum-toolbar::before {
        margin: -0.85rem -0.85rem 0;
    }

    .resource-body p {
        min-height: auto;
    }

    .resource-card {
        display: grid;
        grid-template-columns: 108px minmax(0, 1fr);
    }

    .resource-card .cover {
        height: 100%;
        min-height: 132px;
        aspect-ratio: auto;
    }

    .resource-body {
        padding: 0.86rem;
        gap: 0.45rem;
    }

    .resource-body h2 {
        font-size: 1.02rem;
    }

    .resource-card .tag-row.compact,
    .card-stats {
        gap: 0.36rem;
    }

    .card-stats {
        margin-top: 0.4rem;
        padding-top: 0.55rem;
        font-size: 0.84rem;
    }

    .panel {
        padding: 1rem;
    }

    .message {
        width: 100%;
    }

    .auth-panel {
        padding: 1.15rem;
    }

    .auth-switch {
        align-items: stretch;
        flex-direction: column;
        gap: 0.75rem;
    }

    .announcement-panel {
        min-height: 0;
        padding: 1.1rem;
    }

    .announcement-panel h1 {
        font-size: 1.45rem;
    }

    .notice-strip a {
        border-right: 0;
    }

    .announcement-strip a {
        border-bottom: 1px solid var(--line);
    }

    .announcement-strip a:last-child {
        border-bottom: 0;
    }

    .thread-item {
        padding: 0.95rem 0.95rem 0.95rem 1.05rem;
    }

    .thread-item h2 {
        font-size: 1.05rem;
    }

    .count-pill {
        align-self: flex-start;
        min-width: 0;
        height: auto;
        padding: 0.28rem 0.62rem;
    }

    .button,
    button {
        width: 100%;
    }

    .nav-toggle {
        width: auto;
    }

    .inline-form .button,
    .inline-form button,
    .button-row .button,
    .button-row button,
    .request-row .button {
        width: auto;
    }
}

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

/* UI refresh v4 */
:root {
    --bg: #f3f5f2;
    --panel: #fbfcf8;
    --panel-solid: #ffffff;
    --panel-soft: #edf2ea;
    --glass: #f9fbf6;
    --glass-strong: #ffffff;
    --text: #17201b;
    --muted: #65736b;
    --line: #d8e0d7;
    --line-strong: #c5d0c5;
    --primary: #0f766e;
    --primary-strong: #0d9488;
    --primary-soft: #d9f2ed;
    --green: #15803d;
    --amber: #b7791f;
    --danger: #b42318;
    --violet: #5b5bd6;
    --cyan: #0e7490;
    --shadow: 0 12px 34px rgba(28, 44, 37, 0.08);
    --shadow-lift: 0 18px 54px rgba(28, 44, 37, 0.14);
    --blur: blur(0);
}

[data-theme="dark"] {
    --bg: #111411;
    --panel: #181d19;
    --panel-solid: #1c221e;
    --panel-soft: #202820;
    --glass: #161b17;
    --glass-strong: #1b211d;
    --text: #f2f6ef;
    --muted: #a6b2a8;
    --line: #303a32;
    --line-strong: #435046;
    --primary: #2dd4bf;
    --primary-strong: #14b8a6;
    --primary-soft: rgba(45, 212, 191, 0.13);
    --green: #86efac;
    --amber: #facc15;
    --danger: #fb7185;
    --violet: #a5b4fc;
    --cyan: #67e8f9;
    --shadow: 0 14px 42px rgba(0, 0, 0, 0.22);
    --shadow-lift: 0 24px 70px rgba(0, 0, 0, 0.32);
}

body {
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 280px),
        linear-gradient(90deg, rgba(91, 91, 214, 0.04), transparent 38%),
        var(--bg);
}

[data-theme="dark"] body {
    background:
        linear-gradient(180deg, rgba(45, 212, 191, 0.08), transparent 320px),
        linear-gradient(90deg, rgba(165, 180, 252, 0.05), transparent 42%),
        var(--bg);
}

body::before {
    opacity: 0.45;
    background-size: 34px 34px;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
}

textarea {
    resize: none;
    min-height: 116px;
}

.site-header {
    min-height: 66px;
    background: color-mix(in srgb, var(--glass-strong) 94%, transparent);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

.brand {
    font-size: 1rem;
    letter-spacing: 0;
}

.brand-icon {
    width: 34px;
    height: 34px;
    box-shadow: none;
}

.site-nav {
    gap: 0.18rem;
}

.site-nav a,
.theme-button,
.nav-toggle {
    min-height: 38px;
    padding: 0.42rem 0.68rem;
    font-size: 0.94rem;
    font-weight: 700;
}

.site-nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.page-shell {
    padding-top: 1.5rem;
}

.page-title {
    display: block;
    margin-bottom: 1rem;
    padding: 1.05rem 1.15rem;
    background: linear-gradient(135deg, var(--panel-solid), var(--panel-soft));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

[data-theme="dark"] .page-title {
    background: linear-gradient(135deg, #1b211d, #151915);
}

.page-title h1 {
    font-size: 1.8rem;
}

.page-title p {
    max-width: 760px;
    font-size: 0.96rem;
}

.panel,
.toolbar-panel,
.notice-strip,
.thread-item,
.resource-card,
.stat-card {
    background: var(--panel-solid);
    border-color: var(--line);
    box-shadow: var(--shadow);
}

[data-theme="dark"] .panel,
[data-theme="dark"] .toolbar-panel,
[data-theme="dark"] .notice-strip,
[data-theme="dark"] .thread-item,
[data-theme="dark"] .resource-card,
[data-theme="dark"] .stat-card {
    background: var(--panel);
}

.panel {
    padding: 1.15rem;
}

input,
select,
textarea {
    background-color: var(--glass);
    border-color: var(--line-strong);
    box-shadow: none;
}

select option {
    background: var(--panel-solid);
    color: var(--text);
}

[data-theme="dark"] select option {
    background: #1c221e;
}

.button,
button {
    box-shadow: none;
    font-weight: 750;
}

.button:hover,
button:hover {
    transform: translateY(-1px);
}

.button.primary {
    background: var(--primary-strong);
    border-color: var(--primary-strong);
    box-shadow: 0 12px 26px rgba(13, 148, 136, 0.18);
}

.library-toolbar,
.forum-toolbar {
    padding: 0.95rem;
}

.library-toolbar::before,
.forum-toolbar::before {
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--amber));
}

.filters {
    grid-template-columns: minmax(260px, 1fr) 170px 170px auto;
}

.tag-row {
    gap: 0.42rem;
}

.tag-row a,
.sort-links a,
.tabs a {
    background: var(--panel-soft);
    border-color: var(--line);
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.2;
    box-shadow: none;
}

.tag-row a:hover,
.tag-row a.active,
.sort-links a.active,
.tabs a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

[data-theme="dark"] .tag-row a:hover,
[data-theme="dark"] .tag-row a.active,
[data-theme="dark"] .sort-links a.active,
[data-theme="dark"] .tabs a.active {
    color: #061413;
}

.resource-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.resource-card {
    display: grid;
    grid-template-rows: auto 1fr;
}

.resource-card:hover {
    transform: translateY(-4px);
}

.resource-card::before {
    display: none;
}

.resource-card .cover {
    aspect-ratio: 16 / 8.4;
    background: var(--panel-soft);
}

.resource-body {
    padding: 0.86rem 0.9rem 0.95rem;
    gap: 0.5rem;
}

.resource-body h2 {
    font-size: 1.04rem;
}

.resource-body p {
    font-size: 0.92rem;
    min-height: 2.9rem;
}

.resource-card .meta-line {
    gap: 0.35rem;
}

.resource-card .meta-line span,
.type-badge {
    max-width: 100%;
    background: transparent;
    border-color: var(--line);
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
}

.tag-row.compact a {
    max-width: 100%;
    padding: 0.22rem 0.48rem;
    font-size: 0.82rem;
    white-space: nowrap;
}

.card-stats {
    margin-top: 0.35rem;
    padding-top: 0.58rem;
    font-size: 0.84rem;
}

.resource-hero {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 1.35rem;
    background: var(--panel-solid);
}

[data-theme="dark"] .resource-hero {
    background: var(--panel);
}

.resource-hero > img {
    aspect-ratio: 4 / 3;
    box-shadow: none;
}

.resource-hero h1 {
    font-size: 1.9rem;
    margin-bottom: 0.7rem;
}

.resource-hero .tag-row {
    margin-top: 0.95rem;
    margin-bottom: 1rem;
    row-gap: 0.5rem;
}

.resource-hero .button-row {
    margin-top: 0.65rem;
    gap: 0.75rem;
}

.resource-hero .button-row .button {
    min-width: 122px;
}

.comment {
    background: var(--panel-soft);
}

.comment-form textarea {
    min-height: 128px;
}

.thread-item {
    padding: 1rem 1rem 1rem 1.15rem;
    background: var(--panel-solid);
}

[data-theme="dark"] .thread-item {
    background: var(--panel);
}

.thread-item h2 {
    font-size: 1.08rem;
}

.thread-item p {
    font-size: 0.94rem;
}

.count-pill {
    background: var(--panel-soft);
    color: var(--primary);
}

.notice-strip a {
    background: transparent;
}

.mini-list a {
    background: var(--panel-soft);
    box-shadow: none;
}

.mini-list a:hover,
.mini-list a.active {
    transform: none;
}

.stat-grid {
    gap: 0.85rem;
}

.stat-card {
    padding: 1rem;
}

.stat-card strong {
    font-size: 1.7rem;
}

.tabs {
    margin-bottom: 1rem;
}

.table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    background: var(--panel-solid);
}

[data-theme="dark"] table {
    background: var(--panel);
}

th,
td {
    padding: 0.72rem;
}

tbody tr:hover {
    background: var(--primary-soft);
}

.role-pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    background: var(--panel-soft);
    color: var(--text);
    font-size: 0.84rem;
    white-space: nowrap;
}

.role-admin {
    border-color: color-mix(in srgb, var(--amber) 55%, var(--line));
    color: var(--amber);
}

.admin-user-toolbar .filters {
    grid-template-columns: minmax(220px, 1fr) auto;
}

.admin-users-panel small {
    margin-top: 0.18rem;
}

.site-footer {
    font-size: 0.92rem;
}

@media (max-width: 980px) {
    .filters,
    .admin-user-toolbar .filters {
        grid-template-columns: 1fr 1fr;
    }

    .resource-hero {
        grid-template-columns: 1fr;
    }

    .resource-hero > img {
        aspect-ratio: 16 / 9;
    }
}

@media (max-width: 720px) {
    .site-header {
        padding: 0.62rem 4vw;
    }

    .page-title {
        padding: 0.9rem;
    }

    .page-title h1 {
        font-size: 1.45rem;
    }

    .filters,
    .admin-user-toolbar .filters {
        grid-template-columns: 1fr;
    }

    .resource-grid {
        gap: 0.75rem;
    }

    .resource-card {
        grid-template-columns: 96px minmax(0, 1fr);
        grid-template-rows: auto;
    }

    .resource-card .cover {
        height: 100%;
        min-height: 126px;
        aspect-ratio: auto;
    }

    .resource-body {
        padding: 0.72rem;
    }

    .resource-body p {
        min-height: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .resource-card .tag-row.compact {
        max-height: 1.9rem;
        overflow: hidden;
    }

    .resource-hero h1 {
        font-size: 1.5rem;
    }

    .resource-hero .button-row .button {
        width: 100%;
    }

    .site-footer span:last-child {
        text-align: left;
    }
}

/* UI refresh v5: TouchGal-inspired home sections and cleaner controls */
.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1rem;
}

.home-hero-copy,
.home-quick-panel,
.quick-links,
.section-heading {
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

[data-theme="dark"] .home-hero-copy,
[data-theme="dark"] .home-quick-panel,
[data-theme="dark"] .quick-links,
[data-theme="dark"] .section-heading {
    background: var(--panel);
}

.home-hero-copy {
    position: relative;
    overflow: hidden;
    padding: 1.35rem;
}

.home-hero-copy::after {
    content: "";
    position: absolute;
    right: -80px;
    top: -90px;
    width: 250px;
    height: 250px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 14%, transparent);
    pointer-events: none;
}

.eyebrow {
    display: inline-flex;
    margin-bottom: 0.45rem;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.home-hero-copy h2 {
    position: relative;
    margin: 0 0 0.55rem;
    font-size: 2rem;
    line-height: 1.15;
    letter-spacing: 0;
}

.home-hero-copy p {
    position: relative;
    max-width: 680px;
    margin: 0;
    color: var(--muted);
}

.hero-actions {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1.1rem;
}

.home-quick-panel {
    display: grid;
    gap: 0.65rem;
    padding: 1rem;
}

.quick-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.78rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}

.quick-stat strong {
    font-size: 1.45rem;
    line-height: 1;
}

.quick-stat span {
    color: var(--muted);
    font-size: 0.92rem;
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.quick-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
    color: var(--text);
    font-weight: 800;
}

.quick-links a:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-1px);
}

[data-theme="dark"] .quick-links a:hover {
    color: #061413;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    margin: 1rem 0;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.24rem;
    letter-spacing: 0;
}

.section-heading .eyebrow {
    margin-bottom: 0.16rem;
}

.file-upload-control {
    display: flex;
    align-items: center;
    gap: 0.72rem;
    min-height: 48px;
    padding: 0.45rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--glass);
}

input[type="file"],
.native-file-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.file-pick-button {
    min-height: 36px;
    padding: 0.42rem 0.78rem;
}

.file-name {
    min-width: 0;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.55rem 0.9rem;
    background: var(--panel-soft);
    color: var(--muted);
    font-weight: 800;
}

.status-pill.success {
    border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
    color: var(--primary);
    background: var(--primary-soft);
}

.profile-page > .panel:first-child {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 54%, transparent), transparent 58%),
        var(--panel-solid);
}

[data-theme="dark"] .profile-page > .panel:first-child {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 54%, transparent), transparent 58%),
        var(--panel);
}

@media (max-width: 980px) {
    .home-hero {
        grid-template-columns: 1fr;
    }

    .home-quick-panel {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 720px) {
    .home-hero-copy {
        padding: 1rem;
    }

    .home-hero-copy h2 {
        font-size: 1.45rem;
    }

    .home-quick-panel,
    .quick-links {
        grid-template-columns: 1fr;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .file-upload-control {
        align-items: stretch;
        flex-direction: column;
    }

    .file-name {
        white-space: normal;
    }

    .status-pill {
        width: 100%;
    }
}

/* UI refresh v6: compact header tools and hero search */
.site-header {
    gap: 0.75rem;
}

.site-nav {
    flex: 1;
    justify-content: center;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 0.42rem;
}

.icon-button,
.avatar-button {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    padding: 0;
}

.icon-button:hover,
.avatar-button:hover {
    border-color: var(--line);
    background: var(--panel-soft);
    text-decoration: none;
    transform: translateY(-1px);
}

.icon-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-theme {
    width: auto;
    min-width: 72px;
}

.avatar-button img {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
    border: 2px solid color-mix(in srgb, var(--primary) 45%, var(--line));
}

.user-menu {
    position: relative;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.65rem);
    right: 0;
    z-index: 60;
    width: 220px;
    display: none;
    padding: 0.55rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-solid);
    box-shadow: var(--shadow-lift);
}

[data-theme="dark"] .user-dropdown {
    background: #1b1d20;
}

.user-dropdown.open {
    display: grid;
    gap: 0.18rem;
    animation: menu-in 140ms var(--ease) both;
}

.user-dropdown strong {
    padding: 0.55rem 0.65rem;
    color: var(--text);
}

.user-dropdown a {
    display: flex;
    align-items: center;
    min-height: 38px;
    border-radius: var(--radius);
    padding: 0.45rem 0.65rem;
    color: var(--text);
    font-weight: 700;
}

.user-dropdown a:hover {
    background: var(--panel-soft);
    text-decoration: none;
}

.home-hero {
    grid-template-columns: 1fr;
}

.home-quick-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-hero-copy {
    padding: 1.1rem;
}

.hero-search {
    position: relative;
    grid-template-columns: minmax(240px, 1fr) 170px 170px auto;
    margin-top: 1rem;
}

.hero-tags {
    margin-top: 0.85rem;
}

.search-page {
    position: relative;
    display: grid;
    gap: 0.9rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(31, 211, 190, 0.28);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(31, 211, 190, 0.14), transparent 38%),
        var(--glass-strong);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.search-page::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--cyan), var(--violet));
}

.search-panel {
    position: relative;
    z-index: 1;
    grid-template-columns: minmax(260px, 1fr) 180px 180px auto;
    padding-top: 0.15rem;
}

.search-tags {
    position: relative;
    z-index: 1;
    max-height: 118px;
    overflow: auto;
    padding-right: 0.25rem;
}

.search-summary {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.search-summary strong {
    color: var(--primary);
    font-size: 1.45rem;
}

.search-results {
    margin-top: 0.25rem;
}

.library-toolbar {
    display: none;
}

@keyframes menu-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .site-nav {
        justify-content: flex-end;
    }

    .hero-search {
        grid-template-columns: 1fr 1fr;
    }

    .search-panel {
        grid-template-columns: 1fr 1fr;
    }

    .home-quick-panel {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .site-header {
        flex-wrap: wrap;
    }

    .site-nav {
        flex: 1 0 100%;
        order: 3;
    }

    .header-tools {
        margin-left: auto;
    }

    .icon-theme .theme-label {
        display: none;
    }

    .icon-theme {
        min-width: 44px;
    }

    .user-dropdown {
        right: -0.25rem;
        width: min(86vw, 240px);
    }

    .hero-search,
    .search-panel,
    .home-quick-panel {
        grid-template-columns: 1fr;
    }

    .search-tags {
        max-height: 160px;
    }
}

/* UI refresh v8: richer home, custom selects, messages, notifications */
:root {
    --radius-lg: 16px;
}

.has-badge,
.avatar-button {
    position: relative;
}

.notify-badge,
.avatar-dot,
.message-contact-list b {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--panel-solid);
    background: var(--danger);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 850;
    line-height: 1;
    box-shadow: 0 8px 20px rgba(185, 28, 28, 0.28);
}

.notify-badge {
    top: -0.28rem;
    right: -0.28rem;
    min-width: 1.18rem;
    height: 1.18rem;
    padding: 0 0.22rem;
    border-radius: 999px;
}

.avatar-dot {
    right: 0;
    bottom: 0;
    width: 0.72rem;
    height: 0.72rem;
    border-radius: 999px;
}

.dropdown-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin: 0.25rem 0.2rem 0.45rem;
    padding: 0.62rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary-soft), transparent);
}

.dropdown-notice span {
    color: var(--muted);
    font-size: 0.86rem;
}

.dropdown-notice b,
.user-dropdown a span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.38rem;
    height: 1.38rem;
    margin-left: auto;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.78rem;
}

.native-select-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.custom-select {
    position: relative;
    width: 100%;
    min-width: 0;
    z-index: 5;
}

.custom-select.open {
    z-index: 90;
}

.custom-select-trigger {
    width: 100%;
    min-height: 48px;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.7rem 0.82rem 0.7rem 0.95rem;
    border-radius: 14px;
    background: color-mix(in srgb, var(--glass-strong) 86%, transparent);
    border-color: color-mix(in srgb, var(--line) 82%, var(--primary-soft));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.custom-select-trigger i {
    width: 0.64rem;
    height: 0.64rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 180ms var(--ease);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.custom-select.open .custom-select-trigger i {
    transform: rotate(225deg) translate(-2px, -2px);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    right: 0;
    display: none;
    max-height: 250px;
    overflow: auto;
    padding: 0.38rem;
    border: 1px solid color-mix(in srgb, var(--primary) 38%, var(--line));
    border-radius: 14px;
    background: var(--panel-solid);
    box-shadow: var(--shadow-lift);
}

[data-theme="dark"] .custom-select-options {
    background: #121b16;
}

.custom-select.open .custom-select-options {
    display: grid;
    gap: 0.18rem;
    animation: menu-in 150ms var(--ease) both;
}

.custom-select-option {
    width: 100%;
    min-height: 38px;
    justify-content: flex-start;
    border: 0;
    border-radius: 10px;
    background: transparent;
    box-shadow: none;
    color: var(--text);
    text-align: left;
}

.custom-select-option:hover,
.custom-select-option.selected {
    background: var(--primary);
    color: #fff;
    transform: none;
}

.search-page {
    overflow: visible;
}

.home-hero {
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
    gap: 1.1rem;
}

.home-hero-copy,
.home-quick-panel,
.quick-links,
.section-heading,
.home-panel,
.spotlight-card,
.collection-list-panel {
    border-radius: var(--radius-lg);
}

.home-hero-copy {
    min-height: 260px;
    padding: 1.65rem;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary) 18%, transparent), transparent 40%),
        linear-gradient(160deg, var(--panel-solid), color-mix(in srgb, var(--panel-soft) 72%, transparent));
}

[data-theme="dark"] .home-hero-copy {
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary) 16%, transparent), transparent 42%),
        linear-gradient(160deg, #172019, #101511);
}

.home-hero-copy::after {
    width: 52%;
    height: 190%;
    right: -18%;
    top: -45%;
    border-radius: 0;
    background: linear-gradient(115deg, transparent, color-mix(in srgb, var(--primary) 16%, transparent), transparent);
    transform: rotate(12deg);
    animation: sheen-slide 7s var(--ease) infinite alternate;
}

.home-hero-copy h2 {
    max-width: 760px;
    font-size: clamp(2rem, 4vw, 3.4rem);
}

.home-hero-copy p {
    font-size: 1.02rem;
}

.hero-actions .button {
    min-width: 116px;
}

.home-quick-panel {
    align-content: stretch;
    background:
        linear-gradient(180deg, var(--panel-solid), color-mix(in srgb, var(--panel-soft) 70%, transparent));
}

[data-theme="dark"] .home-quick-panel {
    background: linear-gradient(180deg, #161f18, #101511);
}

.quick-stat {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
}

.quick-stat::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--amber));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 260ms var(--ease);
}

.quick-stat:hover::after {
    transform: scaleX(1);
}

.home-showcase {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    gap: 1rem;
    margin: 1rem 0;
}

.spotlight-card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(260px, 0.95fr) minmax(0, 1fr);
    gap: 1rem;
    overflow: hidden;
    min-height: 310px;
    padding: 1rem;
    color: var(--text);
    background: var(--panel-solid);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

[data-theme="dark"] .spotlight-card,
[data-theme="dark"] .home-panel {
    background: var(--panel);
}

.spotlight-card:hover {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
    box-shadow: var(--shadow-lift);
    text-decoration: none;
}

.spotlight-card img {
    width: 100%;
    height: 100%;
    min-height: 270px;
    object-fit: cover;
    border-radius: 12px;
    background: var(--panel-soft);
}

.spotlight-card > div {
    display: grid;
    align-content: center;
    gap: 0.65rem;
    min-width: 0;
}

.spotlight-card h2 {
    margin: 0;
    font-size: 1.65rem;
    line-height: 1.2;
}

.spotlight-card p {
    margin: 0;
    color: var(--muted);
}

.spotlight-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.spotlight-meta span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.28rem 0.62rem;
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 0.88rem;
}

.home-side-stack {
    display: grid;
    gap: 1rem;
}

.home-panel {
    padding: 1rem;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.home-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.home-panel-head h2,
.home-panel-head h3 {
    margin: 0;
    font-size: 1.06rem;
}

.home-panel-head span,
.home-panel-head a {
    color: var(--muted);
    font-size: 0.9rem;
}

.rank-list,
.notice-mini-list,
.mini-resource-list {
    display: grid;
    gap: 0.5rem;
}

.rank-list a,
.notice-mini-list a,
.mini-resource-list a {
    display: grid;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    padding: 0.62rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-soft);
    color: var(--text);
}

.rank-list a {
    grid-template-columns: 1.8rem minmax(0, 1fr) auto;
}

.rank-list a:hover,
.notice-mini-list a:hover,
.mini-resource-list a:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    text-decoration: none;
}

.rank-list b {
    color: var(--primary);
}

.rank-list span,
.mini-resource-list span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-list em,
.notice-mini-list span {
    color: var(--muted);
    font-style: normal;
    font-size: 0.86rem;
}

.notice-mini-list a {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
}

.notice-mini-list strong {
    line-height: 1.25;
}

.home-discovery {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin: 1rem 0;
}

.category-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.category-links a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-soft);
    color: var(--text);
    font-weight: 800;
}

.category-links a:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
    transform: translateY(-1px);
}

.mini-resource-list a {
    grid-template-columns: 52px minmax(0, 1fr);
}

.mini-resource-list img {
    width: 52px;
    height: 42px;
    object-fit: cover;
    border-radius: 10px;
    background: var(--panel-soft);
}

.rating-panel {
    display: grid;
    gap: 1rem;
}

.rating-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.rating-head h2 {
    margin: 0;
}

.score-line {
    margin: 0;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
}

.score-line strong {
    color: var(--primary);
    font-size: 2.3rem;
}

.rating-compose {
    display: grid;
    gap: 0.85rem;
}

.rating-form {
    display: grid;
    grid-template-columns: minmax(180px, 240px) auto;
    gap: 0.65rem;
    align-items: center;
}

.comment-compose {
    padding: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
}

.comment-compose textarea {
    min-height: 116px;
    border-radius: 12px;
    background: var(--glass-strong);
}

.comment-compose .button {
    justify-self: end;
    min-width: 132px;
}

.comment-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.comment-toolbar > span {
    color: var(--muted);
}

.comment-list {
    display: grid;
    gap: 0.75rem;
}

.comment-card {
    margin-top: 0;
    border-top: 0;
    border-radius: 14px;
}

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

.message-sidebar,
.message-chat {
    min-height: 620px;
}

.message-contact-list {
    display: grid;
    gap: 0.55rem;
}

.message-contact-list a {
    position: relative;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 0.7rem;
    align-items: center;
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
    color: var(--text);
}

.message-contact-list a:hover,
.message-contact-list a.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    text-decoration: none;
}

.message-contact-list img,
.chat-head img,
.message > img {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
}

.message-contact-list strong,
.message-contact-list em {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-contact-list em {
    color: var(--muted);
    font-style: normal;
    font-size: 0.86rem;
}

.message-contact-list b {
    top: 0.35rem;
    right: 0.35rem;
    min-width: 1.2rem;
    height: 1.2rem;
    border-radius: 999px;
}

.message-chat {
    display: grid;
    grid-template-rows: auto minmax(300px, 1fr) auto;
    gap: 0.8rem;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
}

.chat-head h2 {
    margin: 0;
}

.chat-head span {
    color: var(--muted);
    font-size: 0.9rem;
}

.chat-thread {
    align-content: end;
    max-height: 56vh;
    overflow: auto;
    padding: 0.4rem 0.2rem 0.6rem;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
    width: min(76%, 620px);
    border: 0;
    background: transparent;
    padding: 0;
}

.message > div {
    padding: 0.72rem 0.86rem;
    border: 1px solid var(--line);
    border-radius: 16px 16px 16px 6px;
    background: var(--panel-soft);
}

.message.mine {
    justify-self: end;
    justify-content: flex-end;
    background: transparent;
    border: 0;
}

.message.mine > div {
    color: #fff;
    border-color: var(--primary);
    border-radius: 16px 16px 6px 16px;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
}

.message.mine span {
    color: rgba(255, 255, 255, 0.78);
}

.chat-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
}

.chat-compose textarea {
    min-height: 52px;
    max-height: 160px;
    border-radius: 14px;
}

.message-empty {
    align-self: center;
    justify-self: center;
    max-width: 360px;
    text-align: center;
    color: var(--muted);
}

.message-empty h2 {
    color: var(--text);
}

.collections-shell {
    display: grid;
    gap: 1rem;
}

.collection-list-panel {
    padding: 1rem;
}

.collection-tabs {
    display: flex;
    gap: 0.65rem;
    overflow-x: auto;
    padding-bottom: 0.1rem;
}

.collection-tabs a {
    flex: 0 0 min(240px, 72vw);
    display: grid;
    gap: 0.2rem;
    padding: 0.78rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
    color: var(--text);
}

.collection-tabs a:hover,
.collection-tabs a.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    text-decoration: none;
    transform: translateY(-1px);
}

.collection-tabs span {
    color: var(--muted);
    font-size: 0.86rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collections-layout {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.collection-create-panel {
    position: sticky;
    top: 92px;
}

.collection-content-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.collection-content-head h2 {
    margin: 0;
}

.collection-content-head p,
.collection-content-head > span {
    color: var(--muted);
}

@keyframes sheen-slide {
    from {
        transform: translate3d(0, 0, 0) rotate(12deg);
    }
    to {
        transform: translate3d(-24px, 12px, 0) rotate(12deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 980px) {
    .home-hero,
    .home-showcase,
    .home-discovery,
    .messages-layout,
    .collections-layout {
        grid-template-columns: 1fr;
    }

    .spotlight-card {
        grid-template-columns: 1fr;
    }

    .spotlight-card img {
        min-height: 220px;
        aspect-ratio: 16 / 8;
    }

    .collection-create-panel {
        position: static;
    }
}

@media (max-width: 720px) {
    .site-header {
        position: sticky;
    }

    .header-tools {
        position: static;
        gap: 0.28rem;
    }

    .icon-button,
    .avatar-button {
        width: 36px;
        height: 36px;
    }

    .user-dropdown {
        position: fixed;
        top: 64px;
        right: 4vw;
        width: min(92vw, 290px);
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }

    .home-hero-copy {
        min-height: 0;
        padding: 1.1rem;
    }

    .home-hero-copy h2 {
        font-size: 1.65rem;
    }

    .hero-actions,
    .hero-actions .button,
    .chat-compose,
    .rating-form,
    .comment-toolbar,
    .rating-head,
    .collection-content-head {
        display: grid;
        grid-template-columns: 1fr;
    }

    .home-quick-panel,
    .quick-links,
    .category-links {
        grid-template-columns: 1fr;
    }

    .home-showcase,
    .home-discovery {
        gap: 0.75rem;
    }

    .spotlight-card {
        min-height: 0;
        padding: 0.75rem;
    }

    .spotlight-card img {
        min-height: 170px;
    }

    .spotlight-card h2 {
        font-size: 1.28rem;
    }

    .message-sidebar,
    .message-chat {
        min-height: 0;
    }

    .message {
        width: 100%;
    }

    .chat-thread {
        max-height: 58vh;
    }

    .collection-tabs a {
        flex-basis: 78vw;
    }

    .custom-select-options {
        max-height: 220px;
    }
}
