:root {
    color-scheme: light;
    --ink: #1f2933;
    --muted: #64748b;
    --line: #d8dee8;
    --panel: #ffffff;
    --bg: #f5f7fb;
    --primary: #1769aa;
    --primary-dark: #0f4c81;
    --accent: #27856d;
    --warn: #b86e00;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Tahoma, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

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

a:hover {
    text-decoration: underline;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 68px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

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

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

.brand-mark {
    align-items: center;
    background: var(--primary);
    border-radius: 8px;
    color: #fff;
    display: inline-flex;
    font-weight: 700;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.brand small {
    color: var(--muted);
    display: block;
    font-size: 12px;
}

.top-actions {
    align-items: center;
    display: flex;
    gap: 10px;
}

.workspace {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: calc(100vh - 68px);
}

.sidebar {
    background: #102033;
    padding: 18px 14px;
}

.sidebar a {
    border-radius: 8px;
    color: #dbeafe;
    display: block;
    margin-bottom: 6px;
    padding: 10px 12px;
    text-decoration: none;
}

.sidebar a:hover {
    background: #203a5c;
}

.content {
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px;
    width: 100%;
}

.workspace:not(:has(.sidebar)) {
    display: block;
}

.hero-panel,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.hero-panel {
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr);
}

.page-title {
    margin: 0 0 18px;
}

.grid {
    display: grid;
    gap: 16px;
}

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

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

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

.grid.five {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

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

.metric strong {
    display: block;
    font-size: 26px;
}

.button,
button,
input[type="submit"] {
    background: var(--primary);
    border: 0;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    min-height: 40px;
    padding: 8px 14px;
    text-decoration: none;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.button.ghost {
    background: #e9eef6;
    color: var(--ink);
}

.button.danger,
button.danger {
    background: var(--danger);
}

.button.small,
button.small {
    min-height: 32px;
    padding: 5px 10px;
}

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

.form-grid .full,
.full {
    grid-column: 1 / -1;
}

label {
    color: #334155;
    display: grid;
    gap: 6px;
    font-weight: 600;
}

input,
select,
textarea {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    min-height: 40px;
    padding: 8px 10px;
    width: 100%;
}

textarea {
    min-height: 98px;
}

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

.pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.pagination a,
.pagination span,
.pagination strong {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    min-width: 34px;
    padding: 6px 10px;
    text-align: center;
}

.pagination strong {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

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

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

th {
    color: #475569;
    font-size: 13px;
}

.notice {
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.notice.success {
    background: #e8f7ef;
    color: #135c3f;
}

.notice.error {
    background: #fff0f0;
    color: var(--danger);
}

.notice.info {
    background: #eaf3ff;
    color: #164f83;
}

.status {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    padding: 3px 8px;
}

.status.active,
.status.approved,
.status.confirmed,
.status.studying,
.status.graded,
.status.score_published {
    background: #e8f7ef;
    color: #135c3f;
}

.status.pending,
.status.pending_verification,
.status.draft,
.status.started {
    background: #fff7e6;
    color: #8a5200;
}

.status.suspended,
.status.rejected,
.status.cancelled,
.status.deleted {
    background: #fff0f0;
    color: var(--danger);
}

.toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.inline-field {
    display: inline-grid;
    gap: 4px;
}

.form-grid.compact {
    gap: 8px;
    grid-template-columns: 1fr;
    margin-top: 8px;
}

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

.sortable-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sortable-list li {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 10px;
}

.watermark-box {
    background: repeating-linear-gradient(135deg, #f8fafc, #f8fafc 18px, #edf2f7 18px, #edf2f7 36px);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.code-editor,
.code-answer {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    line-height: 1.55;
    tab-size: 4;
}

.code-editor {
    min-height: 180px;
    overflow: auto;
    resize: vertical;
    white-space: pre;
}

.code-editor-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.code-tab-button {
    min-width: 58px;
    padding: 6px 12px;
}

.code-answer {
    margin: 0 0 16px;
    max-width: 100%;
    overflow: auto;
    white-space: pre-wrap;
    word-break: normal;
}

.photo-gallery {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.photo-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.photo-card img {
    aspect-ratio: 4 / 3;
    background: #eef2f7;
    display: block;
    object-fit: cover;
    width: 100%;
}

.photo-meta,
.photo-card form {
    padding: 12px;
}

.photo-edit {
    border-top: 1px solid var(--line);
    padding: 0 12px 12px;
}

.photo-meta h3 {
    font-size: 16px;
    margin-bottom: 6px;
}

.no-copy img {
    -webkit-user-drag: none;
    user-select: none;
}

.photo-viewer {
    background: #eef2f7;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    min-height: 320px;
    place-items: center;
    overflow: hidden;
}

.photo-viewer img {
    display: block;
    max-height: 72vh;
    max-width: 100%;
    object-fit: contain;
}

.own-gallery img,
.own-photo-view img {
    -webkit-touch-callout: default;
    user-select: auto;
}

@media (max-width: 820px) {
    .workspace {
        display: block;
    }

    .sidebar {
        display: flex;
        overflow-x: auto;
    }

    .sidebar a {
        white-space: nowrap;
    }

    .hero-panel,
    .grid.two,
    .grid.three,
    .grid.four,
    .grid.five,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 18px;
    }
}
