:root {
    --page-bg: #f5f7fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #17212f;
    --muted: #657282;
    --line: #dfe5ed;
    --line-strong: #c8d2df;
    --accent: #2aabee;
    --accent-soft: #e8f6fe;
    --danger: #9a4247;
    color: var(--text);
    background: var(--page-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

main {
    width: min(calc(100% - 32px), 1240px);
    margin: 0 auto;
    padding: 32px 0 56px;
}

h1,
h2 {
    margin: 0;
    line-height: 1.15;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.15rem;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 1px solid var(--text);
    border-radius: 12px;
    background: var(--text);
    color: #ffffff;
    cursor: pointer;
    padding: 10px 16px;
}

button:hover {
    background: #2b3543;
}

label {
    display: grid;
    gap: 6px;
    color: #475363;
    font-size: 0.9rem;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
    padding: 10px 11px;
}

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

textarea {
    min-height: 320px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9rem;
}

.page-header {
    display: grid;
    grid-template-columns: 168px minmax(0, 880px);
    justify-content: center;
    gap: 24px;
    width: 100%;
    margin: 0 auto 22px;
}

.page-header > div {
    grid-column: 2;
}

.page-header h1 {
    font-size: 2.25rem;
}

#import-spec-form {
    display: none;
}

.editor-layout {
    display: grid;
    grid-template-columns: 168px minmax(0, 880px);
    justify-content: center;
    gap: 24px;
    align-items: start;
}

.section-nav {
    position: sticky;
    top: 24px;
    display: grid;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 32px rgba(20, 31, 43, 0.06);
}

.section-nav a {
    border-radius: 12px;
    color: var(--muted);
    padding: 10px 11px;
    text-decoration: none;
    font-size: 0.94rem;
    font-weight: 700;
}

.section-nav a:hover {
    background: var(--accent-soft);
    color: var(--text);
}

.editor-form {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.editor-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 32px rgba(20, 31, 43, 0.06);
}

.tab-button {
    position: relative;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    padding: 15px 12px 16px;
    font-weight: 800;
}

.tab-button:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.tab-button.is-active {
    color: var(--text);
}

.tab-button.is-active::after {
    position: absolute;
    right: 22%;
    bottom: 0;
    left: 22%;
    height: 4px;
    border-radius: 999px 999px 0 0;
    background: var(--accent);
    content: "";
}

.tab-panel {
    display: grid;
    gap: 16px;
}

.tab-panel[hidden] {
    display: none;
}

.editor-section,
.notice {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    padding: 18px;
    box-shadow: 0 10px 26px rgba(20, 31, 43, 0.045);
}

.editor-section {
    display: grid;
    gap: 16px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.notice {
    margin-bottom: 18px;
}

.notice h2 {
    margin-bottom: 8px;
}

.field-grid {
    display: grid;
    gap: 12px;
}

.row-list {
    display: grid;
    gap: 12px;
}

.editor-row {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-muted);
    padding: 14px;
}

.instructor-row {
    border-left: 4px solid var(--accent);
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.lesson-block-grid {
    grid-template-columns: minmax(180px, 1fr) minmax(120px, 160px) minmax(120px, 160px) auto;
}

.two-column {
    grid-template-columns: minmax(0, 1fr) 160px;
}

.with-remove {
    grid-template-columns: minmax(0, 1fr) 160px auto;
}

.location-grid {
    grid-template-columns: minmax(0, 1fr) 160px auto;
}

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

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

.stacked-fields {
    display: grid;
    gap: 12px;
    border-top: 1px solid #ebe5da;
    padding-top: 16px;
}

.stacked-fields:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.secondary-button {
    justify-self: start;
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--text);
}

.secondary-button:hover {
    border-color: #aeb9c7;
    background: var(--surface-muted);
}

.remove-button {
    align-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: end;
    width: calc(1.5em + 22px);
    height: calc(1.5em + 22px);
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--danger);
    padding: 0;
}

.remove-button:hover {
    border-color: #bd6b70;
    background: #fff4f2;
    color: #9f2d2d;
}

.remove-icon {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.group-grid .remove-button {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
}

.row-actions .remove-button {
    align-self: center;
}

.raw-spec-status {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.raw-editor-section {
    display: grid;
    gap: 16px;
}

.raw-tools {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.file-picker {
    min-width: min(100%, 420px);
}

.file-picker input::file-selector-button {
    margin-right: 10px;
    border: 0;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    padding: 7px 10px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.schedule-grid {
    margin: 22px 0;
    width: min(calc(100vw - 64px), 1680px);
    margin-left: 50%;
    transform: translateX(-50%);
    overflow-x: auto;
    border: 1px solid #ddd7cc;
    border-radius: 8px;
    background: #fffdf8;
}

.schedule-table {
    width: 100%;
    min-width: 1120px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.schedule-corner,
.schedule-time {
    width: 112px;
    padding: 12px;
    color: #46515c;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: left;
    vertical-align: top;
}

.schedule-corner {
    background: #f4f0e8;
    border-right: 1px solid #ddd7cc;
    border-bottom: 1px solid #ddd7cc;
    vertical-align: bottom;
}

.schedule-time {
    background: #fffaf0;
    border-right: 1px solid #ebe5da;
}

.schedule-day-heading {
    background: #f4f0e8;
    padding: 10px 12px;
    border-bottom: 1px solid #ddd7cc;
    color: #27323d;
    font-size: 1rem;
    font-weight: 800;
    text-align: left;
}

.schedule-room-heading {
    background: #f4f0e8;
    padding: 8px 10px;
    border-bottom: 1px solid #ddd7cc;
    color: #52606d;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: left;
}

.schedule-day-heading,
.schedule-room-heading,
.schedule-cell {
    border-left: 1px solid #ebe5da;
}

.schedule-table tbody tr + tr .schedule-time,
.schedule-table tbody tr + tr .schedule-cell {
    border-top: 1px solid #ebe5da;
}

.schedule-cell {
    height: 112px;
    padding: 6px;
    vertical-align: top;
}

.lesson-card {
    border: 1px solid #d7e1d6;
    border-left: 4px solid #4d7c5c;
    border-radius: 6px;
    background: #ffffff;
    padding: 8px 9px;
    overflow-wrap: break-word;
}

.lesson-card h3 {
    margin: 0 0 5px;
    font-size: 0.9rem;
    line-height: 1.2;
}

.lesson-card p {
    margin: 0;
    color: #52606d;
    font-size: 0.78rem;
    line-height: 1.35;
}

@media (max-width: 720px) {
    main {
        width: min(calc(100% - 24px), 980px);
        padding-top: 24px;
    }

    .page-header {
        display: block;
        width: 100%;
    }

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

    .editor-layout {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .section-nav {
        position: static;
        display: flex;
        overflow-x: auto;
        padding: 6px;
    }

    .section-heading {
        display: grid;
    }

    .editor-tabs {
        border-radius: 16px;
    }

    .lesson-block-grid,
    .location-grid,
    .two-column,
    .with-remove,
    .instructor-grid,
    .group-grid {
        grid-template-columns: 1fr;
    }

    .group-grid .remove-button {
        grid-column: auto;
        grid-row: auto;
    }

    .schedule-grid {
        width: calc(100vw - 24px);
    }
}
