:root {
    --text-primary: #1d1d1f;
    --text-secondary: #5f6368;
    --text-tertiary: #77777d;
    --background: #f5f5f7;
    --surface: #ffffff;
    --surface-muted: #f8f8fa;
    --border: #d8d8dd;
    --border-subtle: #ececf0;
    --sidebar: #252b32;
    --sidebar-muted: #aeb5bd;
    --sidebar-active: #343c45;
    --blue: #0071e3;
    --blue-pressed: #0062c4;
    --green: #248a3d;
    --amber: #c76b00;
    --red: #d70015;
    --shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.22);
    --radius-small: 5px;
    --radius: 8px;
    --sidebar-width: 248px;
    --topbar-height: 64px;
    --motion-fast: 150ms;
    --motion-content: 300ms;
    --motion-modal: 350ms;
    --ease-standard: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-enter: cubic-bezier(0, 0, 0.2, 1);
    --ease-exit: cubic-bezier(0.4, 0, 1, 1);
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html {
    min-width: 320px;
    color: var(--text-primary);
    background: var(--background);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    line-height: 1.5;
}

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

input[type="checkbox"] {
    width: auto;
    min-height: auto;
    padding: 0;
}

button {
    -webkit-tap-highlight-color: transparent;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: -60px;
    left: 16px;
    z-index: 9000;
    padding: 10px 14px;
    color: #ffffff;
    background: var(--blue);
    border-radius: var(--radius-small);
    text-decoration: none;
}

.skip-link:focus {
    top: 12px;
}

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 500;
    display: flex;
    width: var(--sidebar-width);
    min-height: 100vh;
    flex-direction: column;
    color: #ffffff;
    background: var(--sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-row {
    display: flex;
    min-height: var(--topbar-height);
    align-items: center;
    gap: 11px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-row > div {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.brand-row strong {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-row span:not(.brand-mark) {
    color: var(--sidebar-muted);
    font-size: 11px;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    color: #ffffff;
    background: var(--green);
    border-radius: var(--radius);
}

.brand-mark svg {
    width: 19px;
    height: 19px;
}

.primary-nav {
    display: grid;
    gap: 4px;
    padding: 14px 10px;
}

.nav-item {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    color: #d6d9dd;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: color var(--motion-fast) linear, background-color var(--motion-fast) linear;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    color: var(--sidebar-muted);
}

.nav-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.nav-item.is-active {
    color: #ffffff;
    background: var(--sidebar-active);
    box-shadow: inset 3px 0 0 var(--green);
}

.nav-item.is-active svg {
    color: #55bd69;
}

.class-switcher {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    padding: 4px 10px 12px;
}

.sidebar-section-title {
    display: flex;
    min-height: 40px;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    color: var(--sidebar-muted);
    font-size: 12px;
    font-weight: 600;
}

.sidebar-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.sidebar-search svg {
    position: absolute;
    left: 11px;
    width: 15px;
    height: 15px;
    color: var(--sidebar-muted);
    pointer-events: none;
}

.sidebar-search input {
    width: 100%;
    height: 36px;
    padding: 0 10px 0 34px;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.17);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    outline: none;
}

.sidebar-search input::placeholder {
    color: #9da5ae;
}

.sidebar-search input:focus {
    border-color: rgba(85, 189, 105, 0.8);
    box-shadow: 0 0 0 3px rgba(85, 189, 105, 0.14);
}

.class-list {
    min-height: 0;
    overflow-y: auto;
    scrollbar-color: #59616a transparent;
    scrollbar-width: thin;
}

.class-list-item {
    display: grid;
    width: 100%;
    min-height: 48px;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 6px 9px;
    color: #d6d9dd;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: color var(--motion-fast) linear, background-color var(--motion-fast) linear;
}

.class-list-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.class-list-item.is-selected {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.11);
}

.class-list-item .class-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.class-list-item strong,
.class-list-item small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.class-list-item strong {
    font-size: 13px;
    font-weight: 500;
}

.class-list-item small {
    color: var(--sidebar-muted);
    font-size: 11px;
}

.online-count {
    min-width: 24px;
    padding: 2px 6px;
    color: #dcefe0;
    background: rgba(36, 138, 61, 0.3);
    border-radius: 980px;
    font-size: 11px;
    text-align: center;
}

.sidebar-empty {
    padding: 16px 10px;
    color: var(--sidebar-muted);
    font-size: 12px;
    text-align: center;
}

.sidebar-footer {
    display: flex;
    min-height: 54px;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-state {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--sidebar-muted);
    font-size: 12px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
}

.status-dot.is-online {
    background: #34c759;
}

.status-dot.is-offline {
    background: #ff3b30;
}

.status-dot.is-pending {
    background: #ff9f0a;
}

.workspace {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 300;
    display: flex;
    height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
}

.topbar-leading,
.topbar-actions {
    display: flex;
    min-width: 0;
    align-items: center;
}

.topbar-leading {
    gap: 10px;
}

.topbar-leading > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.topbar-leading strong {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    gap: 8px;
}

.eyebrow {
    margin: 0;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.connection-pill {
    display: flex;
    min-height: 34px;
    align-items: center;
    gap: 7px;
    padding: 0 11px;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border: 1px solid var(--border-subtle);
    border-radius: 980px;
    font-size: 12px;
}

.icon-button {
    display: inline-grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: color var(--motion-fast) linear, background-color var(--motion-fast) linear, border-color var(--motion-fast) linear;
}

.icon-button:hover {
    color: var(--text-primary);
    background: var(--surface-muted);
    border-color: var(--border-subtle);
}

.icon-button:active,
.button:active:not(:disabled) {
    transform: scale(0.98);
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

.icon-button.on-dark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    color: var(--sidebar-muted);
}

.icon-button.on-dark:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-close,
.mobile-menu {
    display: none;
}

.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: color var(--motion-fast) linear, background-color var(--motion-fast) linear, border-color var(--motion-fast) linear, transform 80ms var(--ease-standard);
}

.button svg {
    width: 17px;
    height: 17px;
}

.button.primary {
    color: #ffffff;
    background: var(--blue);
    border: 1px solid var(--blue);
}

.button.primary:hover {
    background: #0077ed;
    border-color: #0077ed;
}

.button.primary:active:not(:disabled) {
    background: var(--blue-pressed);
}

.button.secondary {
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border);
}

.button.secondary:hover {
    color: var(--blue);
    border-color: #8abdf0;
    background: #f7fbff;
}

.button.danger,
.button.danger-quiet {
    color: var(--red);
    border: 1px solid rgba(215, 0, 21, 0.24);
}

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

.button.danger:hover {
    background: #bd0013;
}

.button.danger-quiet {
    background: #fff8f8;
}

.button.danger-quiet:hover {
    background: #fff0f1;
    border-color: rgba(215, 0, 21, 0.42);
}

.button.full-width {
    width: 100%;
}

.button.align-start {
    align-self: flex-start;
}

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

.view {
    opacity: 0;
}

.view.is-active {
    opacity: 1;
    animation: view-enter var(--motion-content) var(--ease-enter) both;
}

@keyframes view-enter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-heading {
    display: flex;
    min-height: 66px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.page-heading > div:first-child {
    min-width: 0;
}

.page-heading h1 {
    margin: 3px 0 0;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.3;
}

.page-heading.with-actions {
    align-items: center;
}

.updated-time {
    padding-top: 20px;
    color: var(--text-tertiary);
    font-size: 12px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}

.metric-card {
    display: flex;
    min-width: 0;
    min-height: 116px;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
}

.metric-card > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.metric-card span:not(.metric-icon) {
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-card strong {
    overflow: hidden;
    margin-top: 3px;
    font-size: 25px;
    font-weight: 600;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-icon {
    display: grid;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    place-items: center;
    border-radius: 50%;
}

.metric-icon.blue { color: var(--blue); background: #eaf4ff; }
.metric-icon.green { color: var(--green); background: #eaf7ed; }
.metric-icon.amber { color: var(--amber); background: #fff4e5; }
.metric-icon.gray { color: #555b64; background: #eff0f2; }

.content-section,
.schedule-table-section,
.calendar-panel,
.calendar-inspector,
.form-column,
.notice-preview,
.settings-form {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
}

.section-heading {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.section-heading.compact {
    min-height: 60px;
}

.section-heading > div,
.form-section-heading {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.section-heading h2,
.form-section-heading h2,
.notice-preview h2,
.settings-group h2,
.calendar-inspector h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.section-heading span,
.form-section-heading span,
.settings-group > div:first-child span,
.inspector-heading > span {
    color: var(--text-secondary);
    font-size: 12px;
}

.data-table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th,
.data-table td {
    height: 54px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    height: 42px;
    color: var(--text-secondary);
    background: var(--surface-muted);
    font-size: 11px;
    font-weight: 600;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.class-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.class-avatar {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    color: #ffffff;
    background: #59616a;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
}

.state-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 12px;
}

.table-action {
    color: var(--blue);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 13px;
}

.table-action:hover {
    text-decoration: underline;
}

.table-empty {
    padding: 38px 20px !important;
    color: var(--text-secondary);
    text-align: center !important;
}

.segmented-control {
    display: inline-grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 3px;
    padding: 3px;
    margin-bottom: 14px;
    background: #e9e9ed;
    border-radius: var(--radius);
}

.segmented-control button {
    min-height: 36px;
    padding: 6px 14px;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: color var(--motion-fast) linear, background-color var(--motion-fast) linear, box-shadow var(--motion-fast) linear;
}

.segmented-control button:hover {
    color: var(--text-primary);
}

.segmented-control button.is-selected {
    color: var(--text-primary);
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.context-toolbar {
    display: flex;
    min-height: 54px;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 14px;
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}

.context-toolbar .toolbar-group {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
}

.context-toolbar .toolbar-group + .toolbar-group {
    padding-left: 12px;
    border-left: 1px solid var(--border-subtle);
}

.context-toolbar label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 12px;
}

.context-button {
    min-width: 42px;
    min-height: 34px;
    padding: 5px 10px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: color var(--motion-fast) linear, background-color var(--motion-fast) linear, border-color var(--motion-fast) linear;
}

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

.context-button.is-selected {
    color: var(--blue);
    background: #eef6ff;
    border-color: #a8cef4;
}

.schedule-grid-header,
.slot-row {
    display: grid;
    min-width: 760px;
    grid-template-columns: minmax(220px, 1.35fr) minmax(110px, 0.7fr) minmax(180px, 1.1fr) minmax(180px, 1.1fr) 44px;
    align-items: center;
    gap: 10px;
}

.schedule-table-section {
    overflow: hidden;
}

.schedule-grid-header {
    min-height: 40px;
    padding: 0 16px;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 11px;
    font-weight: 600;
}

.schedule-list {
    min-height: 220px;
    max-height: calc(100vh - 360px);
    overflow: auto;
}

.slot-row {
    min-height: 58px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-subtle);
    animation: row-enter 220ms var(--ease-enter) both;
}

@keyframes row-enter {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.slot-row:last-child {
    border-bottom: 0;
}

.time-range {
    display: grid;
    grid-template-columns: minmax(88px, 1fr) auto minmax(88px, 1fr);
    align-items: center;
    gap: 7px;
}

.time-range > span {
    color: var(--text-tertiary);
    text-align: center;
}

.empty-state {
    display: grid;
    min-height: 220px;
    place-items: center;
    padding: 24px;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state svg {
    display: block;
    width: 30px;
    height: 30px;
    margin: 0 auto 8px;
    color: var(--text-tertiary);
}

.field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
}

.field > span:first-child,
.toggle-row strong {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 11px;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    outline: none;
    transition: border-color var(--motion-fast) linear, box-shadow var(--motion-fast) linear, background-color var(--motion-fast) linear;
}

textarea {
    min-height: 118px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
}

.calendar-layout {
    display: grid;
    grid-template-columns: minmax(680px, 1fr) 330px;
    gap: 14px;
    align-items: start;
}

.month-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

.month-switcher strong {
    min-width: 116px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.calendar-panel {
    min-width: 0;
    overflow-x: auto;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    min-width: 680px;
    grid-template-columns: repeat(7, minmax(86px, 1fr));
}

.calendar-weekdays {
    min-height: 42px;
    align-items: center;
    color: var(--text-secondary);
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
}

.calendar-day {
    position: relative;
    min-height: 108px;
    padding: 9px;
    color: var(--text-primary);
    background: var(--surface);
    border: 0;
    border-right: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    text-align: left;
    transition: background-color var(--motion-fast) linear, box-shadow var(--motion-fast) linear;
}

.calendar-day:nth-child(7n) {
    border-right: 0;
}

.calendar-day:hover {
    background: #f7fbff;
}

.calendar-day.is-other-month {
    color: var(--text-tertiary);
    background: #fafafd;
}

.calendar-day.is-today .day-number {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    color: #ffffff;
    background: var(--blue);
    border-radius: 50%;
}

.calendar-day.is-selected {
    z-index: 1;
    box-shadow: inset 0 0 0 2px var(--blue);
}

.day-number {
    display: inline-grid;
    width: 26px;
    height: 26px;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
}

.event-tag {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    padding: 3px 5px;
    color: #14532d;
    background: #eaf7ed;
    border-radius: 4px;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-tag.holiday { color: #8a1520; background: #fff0f1; }
.event-tag.exam { color: #075a9c; background: #eaf4ff; }
.event-tag.special { color: #8a4b00; background: #fff4e5; }

.calendar-inspector {
    position: sticky;
    top: calc(var(--topbar-height) + 14px);
    padding: 18px;
}

.calendar-inspector fieldset {
    display: grid;
    gap: 14px;
    padding: 0;
    margin: 20px 0 0;
    border: 0;
}

.inspector-heading {
    display: flex;
    min-height: 48px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.inspector-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.form-layout {
    display: grid;
    grid-template-columns: minmax(420px, 0.9fr) minmax(380px, 1.1fr);
    gap: 14px;
    align-items: stretch;
}

.form-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 22px;
}

.form-section-heading {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

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

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

.notice-preview {
    display: grid;
    min-height: 440px;
    place-items: center;
    align-content: center;
    padding: 32px;
    background: #f0f1f3;
    text-align: center;
}

.notice-preview h2 {
    margin-top: 24px;
}

.notice-preview p {
    margin: 3px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.preview-window {
    width: min(100%, 560px);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    color: #ffffff;
    background: #202327;
    border: 5px solid #444950;
    border-radius: var(--radius);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
}

.preview-status {
    display: grid;
    grid-template-columns: 1fr minmax(150px, auto) 1fr;
    align-items: start;
    padding: 9px 13px;
    font-size: 9px;
}

.preview-status > span:last-child {
    text-align: right;
}

.preview-island {
    display: flex;
    min-height: 30px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 5px 13px;
    overflow: hidden;
    background: #050505;
    border-radius: 980px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-island svg {
    width: 13px;
    height: 13px;
    color: #64d2ff;
}

.preview-desktop {
    width: 72%;
    height: 52%;
    margin: 10% auto 0;
    background: #30343a;
    border: 1px solid #4a5058;
    border-radius: var(--radius);
}

.settings-form {
    overflow: hidden;
}

.settings-group {
    display: grid;
    grid-template-columns: minmax(180px, 0.65fr) minmax(320px, 1.35fr);
    gap: 40px;
    padding: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.settings-fields {
    display: grid;
    gap: 16px;
}

.input-with-actions {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-actions input {
    padding-right: 88px;
}

.icon-button.inset {
    position: absolute;
    right: 43px;
    width: 34px;
    height: 34px;
    flex-basis: 34px;
}

.icon-button.inset:last-child {
    right: 5px;
}

.toggle-row {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    cursor: pointer;
}

.toggle-row > span:first-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.toggle-row small {
    color: var(--text-secondary);
    font-size: 12px;
}

.toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.toggle-track {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex: 0 0 48px;
    background: #c7c7cc;
    border-radius: 980px;
    transition: background-color 180ms var(--ease-standard);
}

.toggle-track span {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
    transition: transform 180ms var(--ease-standard);
}

.toggle:checked + .toggle-track {
    background: #34c759;
}

.toggle:checked + .toggle-track span {
    transform: translateX(20px);
}

.toggle:focus-visible + .toggle-track {
    outline: 2px solid var(--blue);
    outline-offset: 3px;
}

.settings-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 24px;
}

.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    visibility: hidden;
    place-items: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms var(--ease-exit), visibility 0s linear 180ms;
}

.modal-layer.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 220ms var(--ease-enter), visibility 0s linear 0s;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal-window {
    position: relative;
    z-index: 1;
    display: grid;
    width: min(100%, 450px);
    max-height: calc(100vh - 32px);
    gap: 18px;
    padding: 24px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: var(--radius);
    box-shadow: var(--shadow-modal);
    transform: translateY(10px) scale(0.98);
    transition: transform var(--motion-modal) var(--ease-exit);
}

.modal-layer.is-open .modal-window {
    transform: translateY(0) scale(1);
    transition-timing-function: var(--ease-enter);
}

.login-window {
    width: min(100%, 400px);
}

.modal-window h2 {
    margin: 2px 0 0;
    font-size: 21px;
    font-weight: 600;
}

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

.modal-actions {
    justify-content: flex-end;
    padding-top: 4px;
}

.modal-icon {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    color: var(--blue);
    background: #eaf4ff;
    border-radius: 50%;
}

.modal-icon.warning {
    color: var(--amber);
    background: #fff4e5;
}

.confirm-window p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.form-error {
    margin: -6px 0 0;
    color: var(--red);
    font-size: 12px;
}

.toast-region {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 4000;
    display: grid;
    width: min(360px, calc(100vw - 32px));
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    min-height: 48px;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    animation: toast-enter var(--motion-content) var(--ease-enter) both;
    font-size: 13px;
}

.toast.is-leaving {
    animation: toast-exit 180ms var(--ease-exit) both;
}

.toast svg {
    width: 18px;
    height: 18px;
    color: var(--green);
}

.toast.is-error svg {
    color: var(--red);
}

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

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

.sidebar-scrim {
    display: none;
}

@supports not (backdrop-filter: blur(20px)) {
    .topbar,
    .modal-window,
    .toast {
        background: #ffffff;
    }
}

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

    .calendar-layout,
    .form-layout {
        grid-template-columns: 1fr;
    }

    .calendar-inspector {
        position: static;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 222px;
    }

    .topbar {
        padding: 0 18px;
    }

    .main-content {
        padding: 24px 20px 40px;
    }

    .settings-group {
        grid-template-columns: 1fr;
        gap: 18px;
    }
}

@media (max-width: 734px) {
    .sidebar {
        width: min(292px, calc(100vw - 48px));
        transform: translateX(-100%);
        transition: transform var(--motion-modal) var(--ease-exit);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        transition-timing-function: var(--ease-enter);
    }

    .sidebar-scrim {
        position: fixed;
        inset: 0;
        z-index: 450;
        display: block;
        visibility: hidden;
        background: rgba(0, 0, 0, 0.34);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms var(--ease-exit), visibility 0s linear 180ms;
    }

    body.sidebar-open .sidebar-scrim {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transition: opacity 220ms var(--ease-enter), visibility 0s linear 0s;
    }

    .workspace {
        margin-left: 0;
    }

    .sidebar-close,
    .mobile-menu {
        display: inline-grid;
    }

    .topbar {
        height: 58px;
        gap: 10px;
        padding: 0 12px;
    }

    .topbar-actions .connection-pill,
    #refresh-button,
    #global-save-button span {
        display: none;
    }

    #global-save-button {
        width: 40px;
        min-width: 40px;
        padding: 0;
    }

    .main-content {
        padding: 20px 14px 36px;
    }

    .page-heading {
        min-height: 56px;
        margin-bottom: 16px;
    }

    .page-heading h1 {
        font-size: 24px;
    }

    .updated-time {
        display: none;
    }

    .metric-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .metric-card {
        min-height: 94px;
    }

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

    .section-heading .button {
        width: 100%;
    }

    .data-table {
        min-width: 0;
        table-layout: fixed;
    }

    .data-table th,
    .data-table td {
        height: 50px;
        padding: 7px 8px;
        font-size: 11px;
    }

    .data-table th:nth-child(1) { width: 38%; }
    .data-table th:nth-child(2) { width: 24%; }
    .data-table th:nth-child(3) { width: 23%; }
    .data-table th:nth-child(6) { width: 15%; }
    .data-table th:nth-child(4),
    .data-table td:nth-child(4),
    .data-table th:nth-child(5),
    .data-table td:nth-child(5) {
        display: none;
    }

    .class-avatar {
        width: 26px;
        height: 26px;
        flex-basis: 26px;
    }

    .class-cell {
        gap: 6px;
    }

    .class-cell strong,
    .state-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .segmented-control {
        display: grid;
        width: 100%;
        grid-template-columns: 1fr;
    }

    .context-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .context-toolbar .toolbar-group + .toolbar-group {
        padding-top: 8px;
        padding-left: 0;
        border-top: 1px solid var(--border-subtle);
        border-left: 0;
    }

    .schedule-table-section {
        overflow-x: auto;
    }

    .schedule-list {
        max-height: none;
    }

    .field-grid.three-columns {
        grid-template-columns: 1fr;
    }

    .notice-preview {
        min-height: 320px;
        padding: 22px 14px;
    }

    .settings-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-actions .button {
        width: 100%;
    }

    .modal-window {
        padding: 20px;
    }

    .toast-region {
        right: 16px;
        bottom: 16px;
        left: 16px;
        width: auto;
    }
}

@media (prefers-contrast: more) {
    :root {
        --text-secondary: #3d3d42;
        --text-tertiary: #515158;
        --border: #85858c;
        --border-subtle: #b8b8be;
        --blue: #0058b0;
    }

    .metric-card,
    .content-section,
    .schedule-table-section,
    .calendar-panel,
    .calendar-inspector,
    .form-column,
    .notice-preview,
    .settings-form {
        border-color: var(--border);
    }
}

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

    .view.is-active,
    .slot-row,
    .toast,
    .toast.is-leaving {
        transform: none !important;
    }
}
