:root {
  color-scheme: light;
  --navy: #12355b;
  --navy-dark: #0b2540;
  --gold: #c7922e;
  --paper: #ffffff;
  --canvas: #f2f5f7;
  --ink: #1f2933;
  --muted: #5f6c78;
  --line: #d7dee5;
  --success: #16754a;
  --danger: #b42318;
  --warning-bg: #fff8e7;
  font-family: "Microsoft JhengHei UI", "Noto Sans TC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.65; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
[hidden] { display: none !important; }

.site-header {
  display: flex; align-items: center; gap: 16px; padding: 26px max(24px, calc((100vw - 1000px) / 2));
  color: white; background: linear-gradient(125deg, var(--navy-dark), var(--navy));
  border-bottom: 4px solid var(--gold);
}
.site-header h1 { margin: 0; font-size: clamp(1.45rem, 4vw, 2rem); letter-spacing: .04em; }
.school-name { margin: 0 0 2px; font-size: .9rem; letter-spacing: .12em; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid #ffffff80; border-radius: 50%; font-size: 1.45rem; font-weight: 700; }

.layout { width: min(1000px, calc(100% - 32px)); margin: 28px auto 60px; display: grid; gap: 22px; }
.notice, .card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px #10243a0b; }
.notice { padding: 20px 26px; border-left: 5px solid var(--gold); background: var(--warning-bg); }
.notice h2 { margin: 0 0 8px; font-size: 1.05rem; color: var(--navy); }
.notice ul { margin: 0; padding-left: 1.4rem; }
.card { padding: clamp(22px, 4vw, 34px); }

.step-heading { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.step-heading > span { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; background: var(--navy); color: white; font-weight: 800; }
.step-heading p { margin: 0; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .08em; }
.step-heading h2 { margin: 0; color: var(--navy-dark); font-size: 1.25rem; }

.mode-switch { display: flex; gap: 8px; margin-bottom: 24px; }
.mode-switch button { flex: 1; border: 1px solid #aab7c2; border-radius: 9px; padding: 12px 20px; background: white; color: var(--navy); font-weight: 800; }
.mode-switch button.mode-active { border-color: var(--navy); background: var(--navy); color: white; }

.calendar-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.calendar-toolbar h2 { margin: 0; color: var(--navy-dark); font-size: 1.25rem; }
.primary, .secondary { border-radius: 9px; padding: 10px 16px; font-weight: 800; }
.primary { border: 1px solid var(--navy); background: var(--navy); color: white; }
.primary:hover { background: var(--navy-dark); }
.secondary { border: 1px solid #aab7c2; background: white; color: var(--navy); }

.calendar-status { min-height: 1.7rem; margin: 0 0 12px; color: var(--muted); }
.loading-status { margin: -8px 0 14px; color: var(--muted); font-weight: 700; }
.loading-status small { font-weight: 400; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day-name { padding: 8px 0; color: var(--muted); text-align: center; font-weight: 800; }
.day-name.weekend { color: var(--danger); }
.empty-cell { min-height: 100px; }
.calendar-cell { min-height: 112px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.calendar-cell:hover:not(.closed-cell):not(.past-cell) { border-color: var(--navy); box-shadow: 0 4px 12px #10243a1a; }
.calendar-cell.past-cell { background: #e9eef2; color: #9aa6ae; opacity: .65; }
.calendar-cell.closed-cell { background: #eef2f5; color: #7b8790; }
.date-num { color: var(--navy-dark); font-weight: 800; }
.closed-cell .date-num, .past-cell .date-num { color: inherit; }
.close-badge { float: right; max-width: 75%; padding: 2px 5px; border-radius: 5px; background: #dce4ea; color: var(--muted); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-list { display: grid; gap: 5px; margin-top: 9px; }
.room-tag { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 4px 6px; border: 1px solid #acd8c3; border-radius: 6px; background: #f1fbf6; color: var(--success); font-size: .75rem; font-weight: 750; text-align: left; }
.room-tag.partial { border-color: #efc58d; background: #fff8ec; color: #9a5a12; }
.room-tag.full, .room-tag.range-disabled { border-color: #efb8b3; background: #fff2f0; color: #8f3d37; cursor: not-allowed; }
.room-tag:disabled { opacity: .7; }

.dialog { width: min(720px, calc(100% - 30px)); max-height: calc(100vh - 40px); overflow: auto; border: 0; border-radius: 16px; padding: 0; box-shadow: 0 24px 80px #07192b55; }
.dialog::backdrop { background: #07192b99; backdrop-filter: blur(3px); }
.dialog-inner { padding: 30px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; color: white; background: var(--navy); }
.dialog-header.green { background: var(--success); }
.dialog-header.warning { color: #4a3500; background: #f5c451; }
.dialog-header h2 { margin: 0; font-size: 1.2rem; }
.dialog-close { border: 0; background: none; color: inherit; font-size: 1.7rem; line-height: 1; }
.dialog-body { padding: 24px; }
.dialog-small { width: min(480px, calc(100% - 30px)); }
.selection { margin: 0 0 18px; padding: 12px 14px; border-radius: 8px; background: #edf5fb; color: var(--navy); }
.form-field { display: grid; gap: 6px; color: var(--navy-dark); font-weight: 700; }
.form-field.full { grid-column: 1 / -1; }
.required { color: var(--danger); }
.warning { display: block; margin-top: 8px; color: var(--danger); }
.check-row { display: flex; gap: 8px; align-items: center; margin-top: 16px; font-weight: 800; }
.check-row input { width: auto; }
.dialog-message { width: min(420px, calc(100% - 30px)); text-align: center; }
.dialog-message h2 { margin: 0 0 20px; color: var(--navy-dark); font-size: 1.15rem; }
.alert-info { margin: 0 0 18px; padding: 12px 14px; border-radius: 8px; background: #edf5fb; color: var(--navy); }
.field { display: grid; gap: 6px; color: var(--navy-dark); font-weight: 700; }
.field > span { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full-width { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid #b8c4ce; border-radius: 8px; background: white; padding: 10px 12px; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid #cfe2f5; border-color: var(--navy); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.policy { max-height: 165px; overflow: auto; padding: 15px; border: 1px solid #eee; border-radius: 8px; background: #fff; font-size: .85rem; line-height: 1.6; }
.policy ol { margin: 0; padding-left: 1.4rem; }
.form-check { display: flex; gap: 8px; align-items: center; margin-top: 16px; font-weight: 800; }
.form-check input { width: auto; }
.message-dialog { text-align: center; }
.message-dialog .dialog-inner { padding: 32px 24px 24px; }
.message-dialog h2 { margin: 0 0 20px; color: var(--navy-dark); font-size: 1.15rem; }

@media (max-width: 700px) {
  .layout { width: min(100% - 20px, 1000px); margin-top: 18px; }
  .notice { padding: 18px; }
  .card { padding: 18px; }
  .calendar-grid { gap: 5px; }
  .calendar-cell, .empty-cell { min-height: 86px; }
  .room-tag { padding: 3px 4px; font-size: .65rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-width { grid-column: auto; }
  .form-field.full { grid-column: auto; }
  .dialog-inner { padding: 22px 18px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}
