:root {
    --bg: #f4f7f6;
    --surface: #ffffff;
    --ink: #1f2a2e;
    --muted: #66757b;
    --line: #d9e2df;
    --teal: #0f766e;
    --teal-dark: #115e59;
    --gold: #b7791f;
    --red: #b42318;
    --green: #15803d;
    --shadow: 0 12px 34px rgba(31, 42, 46, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    letter-spacing: 0;
}

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

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

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.muted {
    color: var(--muted);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 14px;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
    font-weight: 700;
}

.button.primary {
    border-color: var(--teal);
    color: #fff;
    background: var(--teal);
}

.button.primary:hover {
    background: var(--teal-dark);
}

.button.danger {
    border-color: #f2c2bd;
    color: var(--red);
    background: #fff7f6;
}

.button.full {
    width: 100%;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 64px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
}

.brand img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: cover;
}

.brand-mark,
.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: #fff;
    background: var(--teal);
    font-weight: 900;
}

.topnav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    color: var(--muted);
    font-size: 14px;
}

.footer {
    padding: 32px 18px 42px;
    color: var(--muted);
    text-align: center;
}

.flash,
.notice {
    width: min(1100px, calc(100% - 28px));
    margin: 14px auto;
    border-radius: 8px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: #fff;
}

.flash-success,
.notice.success {
    border-color: #b7e4c7;
    color: var(--green);
    background: #f0fff4;
}

.flash-danger,
.notice.danger {
    border-color: #f2c2bd;
    color: var(--red);
    background: #fff7f6;
}

.page-shell,
.admin-shell {
    width: min(1180px, calc(100% - 28px));
    margin: 28px auto;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.section-title {
    margin-bottom: 16px;
}

.section-title h2 {
    margin: 0;
    font-size: 22px;
}

.section-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 14px;
}

.compact-form {
    margin-bottom: 18px;
}

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

.span-2 {
    grid-column: span 2;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
}

.install-page,
.login-page {
    background: #eef5f1;
}

.install-shell,
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 14px;
}

.install-card,
.login-panel {
    width: min(760px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-panel {
    width: min(440px, 100%);
}

.install-heading,
.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.install-heading .brand-mark,
.login-brand .brand-mark {
    width: 48px;
    height: 48px;
    font-size: 22px;
}

.install-heading h1,
.login-brand h1 {
    margin: 0;
    font-size: 26px;
}

.install-heading p,
.login-brand p {
    margin: 5px 0 0;
    color: var(--muted);
}

.install-form {
    display: grid;
    gap: 22px;
}

.install-form h2 {
    margin-bottom: -4px;
    font-size: 18px;
}

.login-form {
    display: grid;
    gap: 16px;
}

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

.role-picker button {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    color: var(--muted);
    background: #fff;
    cursor: pointer;
}

.role-picker button.active {
    border-color: var(--teal);
    color: #fff;
    background: var(--teal);
}

.profile-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 22px;
    border-radius: 8px;
    padding: 24px;
    color: #fff;
    background: #1f3b36;
}

.teacher-hero {
    background: #40351f;
}

.profile-hero h1 {
    margin-bottom: 8px;
    font-size: 32px;
}

.profile-hero p {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
}

.avatar {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    object-fit: cover;
    flex: 0 0 auto;
}

.avatar.large {
    width: 82px;
    height: 82px;
    font-size: 32px;
}

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

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

.hot-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-left: 22px;
}

.hot-list li::marker {
    color: var(--gold);
    font-weight: 900;
}

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

.album-grid figure {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.album-grid img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.album-grid figcaption {
    padding: 10px;
    color: var(--muted);
}

.mini-list,
.note-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.mini-list article,
.note-list article {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfdfc;
}

.mini-list p,
.note-list p {
    margin: 8px 0;
}

.mini-list small,
.note-list small {
    color: var(--muted);
}

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

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.schedule-table th,
.schedule-table td {
    border: 1px solid var(--line);
    padding: 10px;
    vertical-align: top;
    background: #fff;
}

.schedule-table th {
    color: var(--ink);
    background: #edf7f4;
}

.schedule-table td strong,
.schedule-table td span,
.schedule-table td small {
    display: block;
}

.schedule-table td small {
    color: var(--muted);
}

.admin-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.admin-sidebar {
    position: sticky;
    top: 86px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fff;
    box-shadow: var(--shadow);
}

.admin-sidebar h1 {
    margin-bottom: 16px;
    font-size: 22px;
}

.admin-sidebar nav {
    display: grid;
    gap: 6px;
}

.admin-sidebar a {
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--muted);
}

.admin-sidebar a.active,
.admin-sidebar a:hover {
    color: #fff;
    background: var(--teal);
}

.admin-main {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.metric-grid div,
.stat-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fff;
}

.metric-grid span,
.stat-grid span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
}

.metric-grid strong,
.stat-grid strong {
    font-size: 28px;
}

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

.user-admin-card,
.media-admin-card {
    display: grid;
    gap: 14px;
}

.user-admin-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-admin-head span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.media-admin-card {
    grid-template-columns: 180px minmax(0, 1fr) auto;
    align-items: start;
}

.media-admin-card img {
    width: 180px;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    object-fit: cover;
}

.danger-form {
    margin-top: 10px;
}

.protection-panel {
    display: grid;
    gap: 14px;
}

.note-admin-card h2 {
    font-size: 18px;
}

.note-admin-card h2 span {
    color: var(--muted);
    font-weight: 400;
}

.protected-content {
    border-radius: 8px;
    padding: 12px;
    color: var(--muted);
    background: #f1f5f4;
}

.screen-page {
    min-height: 100vh;
    color: #f8faf9;
    background: #0f1f1d;
}

.screen-shell {
    min-height: 100vh;
    padding: 24px;
}

.screen-topline {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.screen-topline span {
    color: #9cc6bf;
    font-weight: 700;
}

.screen-topline h1 {
    margin: 2px 0 0;
    font-size: clamp(36px, 5vw, 72px);
}

.screen-clock {
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 12px 16px;
    color: #d8ebe6;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 800;
}

.screen-logout {
    color: #d8ebe6;
}

.screen-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr 0.9fr;
    grid-auto-rows: minmax(160px, auto);
    gap: 16px;
}

.screen-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
}

.screen-card h2 {
    margin-bottom: 14px;
    color: #d8ebe6;
    font-size: 22px;
}

.album-card {
    grid-row: span 2;
}

.schedule-card {
    grid-column: 1 / -1;
}

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

.stat-grid div {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
}

.stat-grid span {
    color: #9cc6bf;
}

.stat-grid strong {
    color: #fff;
}

.album-carousel {
    position: relative;
    height: 100%;
    min-height: 360px;
}

.album-carousel figure {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    transition: opacity 600ms ease;
}

.album-carousel figure.active {
    opacity: 1;
}

.album-carousel img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
}

.album-carousel figcaption {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    border-radius: 8px;
    padding: 12px;
    color: #fff;
    background: rgba(0, 0, 0, 0.48);
}

.album-carousel figcaption span {
    display: block;
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.8);
}

.empty-visual {
    display: grid;
    place-items: center;
    height: 100%;
    min-height: 320px;
    border: 1px dashed rgba(255, 255, 255, 0.24);
    border-radius: 8px;
    color: #9cc6bf;
}

.roll-name {
    display: grid;
    place-items: center;
    min-height: 130px;
    margin-bottom: 16px;
    border-radius: 8px;
    color: #fff;
    background: rgba(183, 121, 31, 0.22);
    font-size: clamp(34px, 5vw, 64px);
    font-weight: 900;
}

.roll-name.rolling {
    animation: pulseName 180ms linear infinite;
}

@keyframes pulseName {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.roll-button {
    width: 100%;
    min-height: 54px;
    font-size: 18px;
}

.screen-hot {
    font-size: 22px;
}

.screen-hot a,
.screen-hot span {
    color: #fff;
}

.screen-editor {
    margin-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    padding-top: 12px;
}

.screen-editor summary {
    color: #d8ebe6;
    cursor: pointer;
    font-weight: 800;
}

.screen-edit-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.screen-edit-row {
    display: grid;
    grid-template-columns: minmax(130px, 1.2fr) minmax(150px, 1.4fr) 70px auto auto;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}

.links-card .screen-edit-row {
    grid-template-columns: minmax(100px, 1fr) minmax(150px, 1.4fr) 70px 70px auto auto;
}

.screen-edit-row input {
    min-width: 0;
    border-color: rgba(255, 255, 255, 0.18);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.screen-edit-row input::placeholder {
    color: rgba(255, 255, 255, 0.58);
}

.screen-edit-row .check-row {
    color: #d8ebe6;
    white-space: nowrap;
}

.screen-delete-row {
    display: flex;
    justify-content: flex-end;
}

.weather-now {
    display: flex;
    align-items: center;
    gap: 16px;
}

.weather-now strong {
    font-size: clamp(48px, 6vw, 84px);
    color: #fff;
}

.weather-now span,
.weather-now small {
    display: block;
}

.weather-now small {
    margin-top: 6px;
    color: #9cc6bf;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
}

.quick-grid a {
    display: grid;
    gap: 8px;
    place-items: center;
    min-height: 100px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.quick-grid b {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--gold);
}

.screen-page .schedule-table th,
.screen-page .schedule-table td {
    border-color: rgba(255, 255, 255, 0.16);
    color: #edf7f4;
    background: rgba(255, 255, 255, 0.06);
}

.screen-page .schedule-table th {
    background: rgba(15, 118, 110, 0.38);
}

.screen-page .schedule-table td small,
.screen-page .schedule-table .muted {
    color: #9cc6bf;
}

@media (max-width: 980px) {
    .content-grid,
    .admin-shell,
    .screen-grid {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
    }

    .admin-sidebar nav {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }

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

    .media-admin-card img {
        width: 100%;
    }

    .screen-topline {
        grid-template-columns: 1fr;
    }

    .album-card,
    .schedule-card {
        grid-row: auto;
        grid-column: auto;
    }
}

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px;
    }

    .page-shell,
    .admin-shell {
        width: min(100% - 20px, 1180px);
        margin: 18px auto;
    }

    .install-card,
    .login-panel,
    .panel,
    .profile-hero {
        padding: 16px;
    }

    .form-grid,
    .role-picker,
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .profile-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .screen-shell {
        padding: 14px;
    }

    .screen-hot {
        font-size: 18px;
    }

    .screen-edit-row,
    .links-card .screen-edit-row {
        grid-template-columns: 1fr;
    }
}
