:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel-strong: #1f2937;
  --ink: #eef4ff;
  --muted: #9aa8bd;
  --line: #2f3b4c;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --green: #087f5b;
  --danger: #fb923c;
  --change-bg: #050816;
  --change-text: #fde68a;
  --event-bg: #0f766e;
  --event-text: #ecfeff;
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  background: #111827;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 48px;
}

body.slideshow-mode {
  overflow: hidden;
}

body.slideshow-mode .topbar {
  display: none;
}

body.slideshow-mode .footer {
  display: none;
}

body.slideshow-mode main {
  width: 100vw;
  height: 100vh;
  margin: 0;
}

.page,
.login-panel,
.admin-workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(16px, 3vw, 28px);
}

.footer {
  width: min(1180px, calc(100% - 32px));
  margin: -24px auto 32px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.global-error {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid #7c2d12;
  background: #431407;
  color: #fed7aa;
  padding: 12px 16px;
  font-weight: 800;
  text-align: center;
}

.is-hidden {
  display: none !important;
}

.nav,
.admin-tabs,
.button-row,
.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-button,
.admin-tab,
.filter-tab,
.ghost-button,
.primary-button,
.danger-button,
.text-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f1623;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 700;
}

.nav-button.is-active,
.admin-tab.is-active,
.filter-tab.is-active,
.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

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

.danger-button {
  color: var(--danger);
  border-color: #9a3412;
  background: #28130a;
}

.text-button {
  min-height: 34px;
  color: var(--danger);
  padding: 0 10px;
}

.view-tools,
.admin-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.compact {
  min-width: 150px;
}

label {
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 800;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

.day-tabs {
  display: grid;
  grid-template-columns: repeat(10, minmax(96px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.day-tab {
  display: grid;
  gap: 4px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1623;
  color: var(--ink);
  text-align: left;
  padding: 10px;
}

.day-tab span {
  color: var(--muted);
  font-size: 12px;
}

.day-tab.is-active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 2px var(--blue);
}

.schedule-shell {
  overflow-x: auto;
}

.page-view .schedule-shell {
  min-height: min(68vh, 820px);
}

.schedule-grid {
  display: grid;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  gap: 1px;
}

.schedule-grid.class-columns {
  width: 100%;
  min-width: 780px;
  height: min(68vh, 820px);
  grid-template-columns: 78px repeat(var(--class-count), minmax(108px, 1fr));
  grid-template-rows: 42px repeat(9, minmax(54px, 1fr));
}

.schedule-grid.slideshow-grid {
  width: 100%;
  min-width: 0;
  height: 100%;
  border-color: #334155;
  grid-template-columns: minmax(68px, 6vw) repeat(var(--class-count), minmax(0, 1fr));
  grid-template-rows: minmax(38px, 5.3vh) repeat(9, minmax(0, 1fr));
}

.corner-cell,
.period-head,
.class-head,
.lesson-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  background: #101826;
  text-align: center;
}

.corner-cell,
.period-head,
.class-head {
  color: #dbeafe;
  font-weight: 800;
}

.row-head {
  color: #a5b4fc;
}

.lesson-cell {
  align-content: center;
  gap: 5px;
  padding: 8px;
  line-height: 1.25;
  font-size: clamp(14px, 1.08vw, 18px);
}

.lesson-cell strong,
.event-cell strong,
.base-merge-cell strong {
  overflow-wrap: anywhere;
}

.lesson-cell small,
.event-cell small,
.base-merge-cell small,
.list-item span {
  color: inherit;
  font-size: 12px;
  opacity: 0.82;
}

.lesson-cell.is-change {
  background: var(--change-bg);
  color: var(--change-text);
}

.lesson-cell.is-covered {
  background: #263241;
}

.event-cell,
.base-merge-cell {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  margin: 6px;
  padding: 8px;
  border-radius: 8px;
  background: var(--event-bg);
  color: var(--event-text);
  text-align: center;
  box-shadow: 0 12px 28px rgba(18, 61, 69, 0.22);
  line-height: 1.25;
  overflow: hidden;
}

.event-cell {
  z-index: 3;
}

.event-cell strong,
.base-merge-cell strong {
  display: block;
  width: 100%;
  max-height: 2.25em;
  overflow: hidden;
  font-size: var(--merge-title-size, 24px);
  line-height: 1.08;
}

.event-cell small,
.base-merge-cell small {
  display: block;
  width: 100%;
  max-height: 2.5em;
  overflow: hidden;
  font-size: var(--merge-meta-size, 12px);
  font-weight: 800;
}

.slideshow-grid .corner-cell,
.slideshow-grid .period-head,
.slideshow-grid .class-head {
  font-size: clamp(14px, 1.25vw, 22px);
}

.slideshow-grid .lesson-cell {
  padding: 5px;
  gap: 2px;
  font-size: clamp(15px, 1.25vw, 22px);
}

.slideshow-grid .lesson-cell small {
  font-size: clamp(10px, 0.8vw, 14px);
}

.slideshow-grid .event-cell,
.slideshow-grid .base-merge-cell {
  margin: 5px;
  padding: 8px;
}

.slideshow-grid .event-cell strong,
.slideshow-grid .base-merge-cell strong {
  font-size: var(--merge-title-size, 28px);
}

.slideshow-grid .event-cell small,
.slideshow-grid .base-merge-cell small {
  font-size: var(--merge-meta-size, 12px);
}

.base-merge-cell {
  z-index: 2;
  background: #334155;
  color: #e0f2fe;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.28);
}

.slideshow-page {
  padding: 0;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  background: #070b12;
  border-color: #1e293b;
  border-radius: 0;
  border: 0;
}

.slideshow-frame {
  height: 100vh;
  display: grid;
  grid-template-rows: minmax(76px, 12vh) minmax(0, 1fr);
  gap: clamp(10px, 1.4vh, 18px);
  padding: clamp(14px, 2.2vw, 30px);
  background: #070b12;
}

.slideshow-top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
}

.slideshow-top h2 {
  font-size: clamp(30px, 4vw, 64px);
}

.slideshow-meta {
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 14px;
  color: #cbd5e1;
  background: #0f172a;
  font-weight: 800;
}

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

.slideshow-stage {
  display: grid;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

.notice-slide {
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: stretch;
  gap: clamp(18px, 3vh, 34px);
  height: 100%;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: clamp(28px, 6vw, 72px);
  background: #101826;
}

.notice-slide h3 {
  margin: 0;
  color: #f8fafc;
  font-size: clamp(42px, 7vw, 92px);
  letter-spacing: 0;
  text-align: center;
}

.notice-slide p {
  margin: 0;
  color: #dbeafe;
  font-size: var(--notice-body-size, 42px);
  line-height: 1.45;
  overflow: hidden;
}

.login-panel {
  max-width: 420px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.admin-workspace {
  display: grid;
  gap: 18px;
}

.admin-tabs {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.admin-panel {
  display: grid;
  gap: 18px;
}

.subsection {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

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

.form-grid.two {
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.2fr);
}

textarea {
  min-height: 132px;
  padding: 12px;
  resize: vertical;
}

.notice-preview {
  min-height: 190px;
}

.notice-preview-card {
  display: grid;
  gap: 14px;
  height: 100%;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1220;
  padding: 18px;
  overflow: hidden;
}

.notice-preview-card h4 {
  margin: 0;
  text-align: center;
  color: #f8fafc;
  font-size: 28px;
  letter-spacing: 0;
}

.notice-preview-card p {
  margin: 0;
  color: #dbeafe;
  font-size: var(--notice-preview-size, 42px);
  line-height: 1.35;
}

.period-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.special-editor {
  overflow-x: auto;
}

.special-grid {
  display: grid;
  min-width: 860px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  gap: 1px;
  grid-template-columns: 76px repeat(var(--class-count), minmax(116px, 1fr));
  grid-template-rows: 42px repeat(9, 58px);
}

.special-head,
.special-input {
  display: grid;
  place-items: center;
  min-width: 0;
  background: #101826;
}

.special-head {
  color: #dbeafe;
  font-weight: 800;
}

.special-input {
  padding: 6px;
}

.special-input input {
  width: 100%;
  min-height: 38px;
  padding: 8px;
  text-align: center;
}

.period-input {
  display: grid;
  gap: 6px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(80px, 1fr));
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.check-item input {
  width: 18px;
  min-height: 18px;
}

.list {
  display: grid;
  gap: 8px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #101826;
}

.list-item.is-active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.list-item > div {
  display: grid;
  gap: 4px;
}

.empty,
.message {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 760px) {
  .topbar,
  .view-tools,
  .admin-head {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    display: grid;
    grid-template-columns: 1fr;
  }

  .form-grid,
  .form-grid.two,
  .period-editor,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .page,
  .login-panel,
  .admin-workspace {
    padding: 16px;
  }
}
