:root {
    color-scheme: light;
    --bg: #f3f0f1;
    --surface: #ffffff;
    --ink: #291e25;
    --muted: #5d5157;
    --line: #e9dfe3;
    --accent: #aa2a39;
    --accent-dark: #83202e;
    --radius: 10px;
    font-family: system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.55; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { color: inherit; font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
h1, h2, h3, p { margin: 0; }
svg { display: inline-block; width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }
:focus-visible { outline: 3px solid #a82b3c; outline-offset: 3px; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
}
.primary { color: white; background: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.secondary { background: var(--surface); border-color: var(--line); }
.secondary:hover { color: var(--accent-dark); border-color: #cb98a0; }
.text-button { padding: 5px 0; border: 0; background: none; color: var(--accent-dark); font-size: 1rem; font-weight: 700; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.icon-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
}
.icon-button:hover { background: #fbf1f3; color: var(--accent-dark); }
.workspace { min-height: calc(100vh - 65px); display: grid; grid-template-columns: 221px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 65px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: calc(100vh - 65px);
    height: calc(100dvh - 65px);
    padding: 19px 13px 15px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a { display: flex; gap: 11px; align-items: center; padding: 10px 12px; border-radius: 10px; font-weight: 650; font-size: 1rem; color: #53434c; }
.nav a[aria-current] { background: #f7e7e9; color: var(--accent-dark); }
.nav a:hover { background: #fbf0f2; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 15px; }
.storage { display: grid; gap: 9px; padding: 13px 12px; border: 1px solid #ecdde1; border-radius: 12px; background: #fbf4f5; }
.storage strong { font-size: 1rem; }
progress { display: block; width: 100%; height: 7px; accent-color: var(--accent); border: 0; border-radius: 8px; overflow: hidden; color: var(--accent); background: #efd6db; }
progress::-webkit-progress-bar { background: #efd6db; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 8px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 8px; }
.main-content { width: min(100%, 1510px); padding: 26px clamp(16px, 3vw, 38px) 45px; margin-inline: auto; }

.toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr minmax(240px, 510px) 1fr;
    align-items: center;
    gap: 14px;
    height: 65px;
    padding: 0 22px;
    border-top: 3px solid #aa2a39;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.console-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; color: white; background: var(--accent); }
.console-mark svg { width: 27px; height: 27px; }
.page-title { font-size: 1.7rem; margin-bottom: 14px; }
.files-section { background: white; border: 1px solid var(--line); border-radius: 11px; padding: 16px; margin-bottom: 17px; }
.section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.section-head h2 { display: flex; align-items: center; gap: 8px; font-size: 1.24rem; line-height: 1.35; }
.section-head h2 svg { color: var(--accent); }
.section-head h1 { font-size: 1.5rem; line-height: 1.3; overflow-wrap: anywhere; }
.section-head .button { margin-left: auto; }
.capacity { color: #654553; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

.search { display: flex; align-items: center; width: min(510px, 100%); min-width: 0; padding-left: 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); }
.search:focus-within { border-color: #aa2a39; box-shadow: 0 0 0 2px #e9b9c073; }
.search input { flex: 1; width: 0; min-height: 42px; border: 0; background: transparent; outline: 0; padding: 7px 8px; }
.search button { border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--accent-dark); padding: 0 13px; font-size: 1rem; font-weight: 700; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 196px), 1fr)); gap: 15px; }
.date-group + .date-group { margin-top: 24px; }
.date-group > h3 { margin-bottom: 9px; font-size: 1rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-toggle[aria-pressed="true"] { color: var(--accent-dark); background: #f7e7e9; border-color: #dfb2b8; }
.file-toggle[aria-pressed="true"] svg { fill: currentColor; }
.file-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 3px 10px #15315c08; }
.file-card:hover { border-color: #d8a7ad; }
.file-visual { position: relative; display: grid; place-items: center; height: 130px; margin: 8px 8px 0; border-radius: 11px; background: var(--tile, #edf1f9); }
.file-visual.pdf { --tile: #fff1ef; --file: #b83e49; --fold: #e47c85; }
.file-visual.slide { --tile: #fff1e2; --file: #a75023; --fold: #da8551; }
.file-visual.sheet { --tile: #e7f6ef; --file: #216749; --fold: #54a884; }
.file-visual.doc { --tile: #eaf1ff; --file: #2a5dbd; --fold: #6a95ee; }
.file-visual.bundle { --tile: #fff5d9; --file: #805117; --fold: #cf9b3e; }
.file-visual.image { --tile: #eeeafe; --file: #6647a3; --fold: #a18bd4; }
.file-visual.media { --tile: #e6f6f9; --file: #1f6372; --fold: #50a3b2; }
.paper {
    position: relative;
    display: grid;
    place-items: end center;
    padding-bottom: 10px;
    width: 66px;
    height: 79px;
    color: #fff;
    background: var(--file, #536884);
    border-radius: 7px 15px 7px 7px;
    clip-path: polygon(0 0, 73% 0, 100% 23%, 100% 100%, 0 100%);
}
.paper::after { content: ''; position: absolute; right: 0; top: 0; width: 16px; height: 16px; border-radius: 0 0 0 4px; background: var(--fold, #8ba0b9); }
.paper b { font-size: 1rem; letter-spacing: .06em; }
.file-tag { display: flex; align-items: center; gap: 4px; position: absolute; top: 8px; left: 8px; border-radius: 6px; padding: 3px 6px; font-size: 1rem; font-weight: 700; color: #354463; background: #fff; }
.file-tag svg { width: 16px; height: 16px; }
.file-body { padding: 11px 13px 9px; }
.file-open { display: block; border-radius: var(--radius); color: var(--accent-dark); }
.file-open:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.file-open:hover .file-visual { box-shadow: inset 0 0 0 2px #d8a7ad; }
.file-open:focus-visible { outline-offset: -2px; }
.file-open h3 { padding: 9px 13px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; font-weight: 750; }
.file-open + .file-body { padding-top: 2px; }
.file-author { margin-top: 6px; color: var(--muted); overflow-wrap: anywhere; }
.file-author strong { color: var(--ink); }
.file-stats { display: flex; flex-wrap: wrap; gap: 2px 11px; margin-top: 5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-stats span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.file-stats svg { width: 16px; height: 16px; }
.file-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; border-top: 1px solid #f2eaec; padding-top: 5px; }
.download-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--accent-dark); font-size: 1rem; font-weight: 700; padding: 6px 10px; margin-left: -10px; }
.download-link:hover { text-decoration: underline; }
.download-link svg { width: 17px; height: 17px; }
.file-menu { position: relative; }
.file-menu summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; top: 44px; right: 0; z-index: 3; width: max-content; max-width: 190px; padding: 5px; border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 6px 23px #192e5d24; background: white; }
.menu-panel button { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px; font-size: 1rem; }
.menu-panel button:hover { background: #fbf0f3; }
.menu-panel .danger { color: #ad303d; }
.file-details { display: grid; grid-template-columns: minmax(180px, 230px) minmax(0, 1fr); max-width: 920px; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.file-details .file-visual { height: auto; min-height: 166px; margin: 12px; }
.detail-body { min-width: 0; padding: 23px 24px 25px 12px; }
.detail-body h1 { font-size: clamp(1.35rem, 3vw, 1.85rem); line-height: 1.28; overflow-wrap: anywhere; }
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 17px; }
.detail-section { max-width: 920px; margin-top: 15px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); scroll-margin-top: 80px; }
.detail-section h2 { margin-bottom: 10px; font-size: 1.2rem; }
.preview-image, .preview-video { display: block; max-width: 100%; max-height: min(660px, 75vh); margin-inline: auto; }
.preview-audio, .preview-pdf { display: block; width: 100%; }
.preview-pdf { height: clamp(330px, 75vh, 760px); border: 1px solid var(--line); }
.preview-text { max-height: 60vh; overflow: auto; margin: 0; padding: 13px; background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; }
.discussion-text { margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.discussion-form { display: grid; gap: 8px; margin-top: 10px; }
.discussion-form .button { justify-self: start; }
.discussion-form textarea, .upload-note textarea { display: block; width: 100%; padding: 8px 10px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.upload-note { margin-top: 10px; }
.note-editor { margin-top: 10px; }
.note-editor summary { color: var(--accent-dark); font-weight: 650; }
.comment { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.comment time { margin-left: 5px; color: var(--muted); }
.empty-state { display: flex; align-items: center; gap: 11px; color: var(--muted); background: #fffafb; border: 1px dashed #e5cdd2; border-radius: var(--radius); }
.empty-state { min-height: 145px; justify-content: center; flex-direction: column; padding: 20px; }
.empty-state svg { width: 30px; height: 30px; color: #946373; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 13px; margin-top: 24px; }
.notice { padding: 11px 13px; margin-bottom: 14px; border-radius: 9px; background: #f9edef; }
.notice.error { background: #fff0ef; color: #8f2f37; }
.notice.success, .toast:not(:empty) { background: #e4f7ef; color: #17644a; }

.auth-layout { min-height: 100vh; display: grid; place-items: center; border-top: 3px solid var(--accent); }
.auth-content { width: min(100%, 465px); padding: 20px; }
.auth-panel { background: white; padding: clamp(18px, 4vw, 30px); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 8px 26px #293e6d0b; }
.auth-panel h1 { font-size: 1.52rem; margin: 13px 0 17px; }
.registration-scope { margin: -7px 0 16px; color: var(--accent-dark); font-weight: 650; }
.auth-panel .auth-switch { margin: 13px 0 0; }
.auth-switch a { color: var(--accent-dark); font-weight: 750; }
.auth-form, .auth-form label, .field { display: grid; gap: 7px; }
.auth-form { gap: 13px; }
.auth-form label, .field { font-size: 1rem; font-weight: 680; }
.auth-form input, .field input, .field select { width: 100%; min-height: 42px; border: 1px solid #ccd7eb; border-radius: 9px; padding: 8px 11px; background: white; font-size: 1rem; font-weight: 400; }
.field select { appearance: none; padding-right: 33px; background-image: linear-gradient(45deg, transparent 50%, #5d5157 50%), linear-gradient(135deg, #5d5157 50%, transparent 50%); background-position: right 17px center, right 12px center; background-size: 5px 5px; background-repeat: no-repeat; }
.auth-form .button { margin-top: 4px; }
.same-name summary { color: var(--accent-dark); }
.same-name label { margin-top: 8px; }
.captcha-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.captcha-refresh { display: block; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.captcha-refresh:hover { border-color: var(--accent); }
.captcha-refresh img { display: block; width: 144px; max-width: 38vw; height: 44px; object-fit: contain; }
.space-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.space-tabs a { padding: 6px 10px; border-radius: 7px; font-weight: 650; }
.space-tabs a[aria-current] { background: #f7e7e9; color: var(--accent-dark); }
.modal { width: min(500px, calc(100% - 28px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 19px; padding: 21px; color: var(--ink); box-shadow: 0 18px 60px #11214348; }
.modal::backdrop { background: #1423448a; }
.modal-head, .modal-actions { display: flex; align-items: center; gap: 10px; }
.modal-head { justify-content: space-between; margin-bottom: 15px; }
.modal-head h2 { font-size: 1.28rem; }
.modal-actions { justify-content: flex-end; margin-top: 16px; }
.file-picker { display: grid; place-items: center; gap: 6px; position: relative; margin-block: 14px; border: 1px dashed #d9b4bc; border-radius: 12px; padding: 18px 12px; background: #fdf6f7; text-align: center; cursor: pointer; overflow-wrap: anywhere; }
.file-picker:focus-within { outline: 3px solid #a82b3c; }
.file-picker input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.file-picker svg { color: var(--accent); width: 27px; height: 27px; }
#sharing-note { margin-top: 11px; color: var(--accent-dark); }
.upload-status { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9rem; overflow: auto; margin-top: 8px; font-size: 1rem; }
.toast:not(:empty) { position: fixed; bottom: 20px; right: 20px; z-index: 6; padding: 12px 17px; border-radius: 9px; font-weight: 750; box-shadow: 0 5px 20px #152d442c; }
.error-page { width: min(600px, calc(100% - 30px)); margin: 12vh auto; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.error-page h1 { font-size: 1.35rem; margin-bottom: 17px; }
.admin-toolbar { gap: 10px 20px; }
.admin-toolbar .search { flex: 1 1 230px; width: auto; max-width: 370px; margin-left: auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.student-table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
.student-table th, .student-table td { padding: 12px 13px; border-bottom: 1px solid var(--line); }
.student-table thead { background: #fbf0f2; }
.student-table tbody tr:nth-child(even) { background: #fdf8f9; }
.student-table tbody tr:last-child > * { border-bottom: 0; }
.home-columns { display: grid; grid-template-columns: minmax(0, 1fr) 242px; align-items: start; gap: 16px; }
.home-files { min-width: 0; }
.leaderboard-rail { min-width: 0; }
.leaderboard { padding: 15px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius); }
.leaderboard-rail > .leaderboard { position: fixed; bottom: 24px; width: 242px; max-height: calc(100dvh - 112px); overflow-y: auto; }
.leaderboard h2 { display: flex; align-items: center; gap: 8px; font-size: 1.125rem; }
.leaderboard h2 svg { color: var(--accent); }
.leaderboard p { margin-top: 9px; color: var(--muted); }
.leaderboard ol { list-style: none; margin: 8px 0 0; padding: 0; }
.leaderboard li { display: grid; grid-template-columns: 27px minmax(0, 1fr) auto; align-items: center; gap: 7px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.leaderboard li:last-child { border-bottom: 0; padding-bottom: 0; }
.leaderboard li strong { overflow-wrap: anywhere; }
.leader-rank { justify-self: start; min-width: 24px; padding-inline: 3px; border-radius: 5px; background: #f7e7e9; color: var(--accent-dark); font-weight: 700; text-align: center; }
.leader-views { color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 1040px) {
    .home-columns { grid-template-columns: minmax(0, 1fr); }
    .leaderboard-rail > .leaderboard { position: static; width: auto; max-height: none; }
}


@media (max-width: 880px) {
    .workspace { grid-template-columns: 180px minmax(0, 1fr); }
    .toolbar { grid-template-columns: 60px minmax(0, 1fr) auto; }
    .file-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
}
@media (max-width: 650px) {
    .workspace { display: block; }
    .toolbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px; padding-inline: 9px; height: 59px; }
    .toolbar .console-mark { width: 33px; height: 35px; }
    .toolbar .console-mark svg { width: 23px; height: 23px; }
    .toolbar .button { padding-inline: 8px; }
    .toolbar-actions { gap: 2px; }
    .toolbar-actions .icon-button { width: 38px; }
    .toolbar-actions .primary svg, .search > svg { display: none; }
    .search { padding-left: 0; }
    .search button { padding-inline: 6px; }
    .sidebar { position: static; height: auto; border: 0; border-bottom: 1px solid var(--line); padding: 8px 9px; gap: 8px; }
    .sidebar-bottom { display: block; }
    .storage { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 9px; padding: 7px 8px; }
    .storage progress { width: 55px; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav a { gap: 5px; padding: 7px 6px; }
    .nav a svg { width: 17px; height: 17px; }
    .main-content { padding: 13px 9px 34px; }
    .files-section { padding: 10px; }
    .section-head .button { min-height: 36px; padding: 4px 7px; }
    .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .file-visual { height: 103px; margin: 6px 6px 0; }
    .file-body { padding-inline: 8px; }
    .file-open h3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; min-height: 3.65em; padding-inline: 8px; overflow-wrap: anywhere; }
    .file-details { grid-template-columns: 1fr; }
    .file-details .file-visual { min-height: 125px; }
    .detail-body { padding: 2px 12px 16px; }
    .detail-actions .button { padding-inline: 10px; }
}
@media (max-width: 350px) {
    .file-grid { grid-template-columns: 1fr; }
}
