:root {
  --bg: #f6f4ec;
  --surface: #fffdf8;
  --surface-2: #f2f5e9;
  --ink: #2c3529;
  --ink-soft: #46523f;
  --muted: #7d8575;
  --line: #e7e4d8;
  --accent: #7ba05b;
  --btn: #3b7dd8;
  --btn-hover: #2f6cc2;
  --accent-soft: #edf3e3;
  --teal: #4f9d92;
  --teal-soft: #e4f2ef;
  --gold: #c4934a;
  --ok: #5e9d6e;
  --danger: #c75d56;
  --radius: 8px;
  --shadow: 0 16px 40px rgba(64, 82, 51, 0.10);
  --pill: 999px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; letter-spacing: 0; }
p { margin: 0 0 12px; }
code { font-family: Consolas, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.brand-text { font-weight: 800; font-size: 15px; }
.site-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.site-nav a { padding: 8px 12px; border-radius: var(--pill); color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.site-nav a:hover { background: var(--surface-2); text-decoration: none; }
.site-nav .nav-cta { background: var(--btn); color: #fff; }
.site-nav .nav-cta:hover { background: var(--btn-hover); }
.site-nav .nav-muted { color: var(--muted); }

.page { max-width: 1100px; margin: 0 auto; padding: 8px 20px 64px; }

.hero { padding: 34px 0 22px; max-width: 760px; }
.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  padding: 5px 12px;
  border-radius: var(--pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.hero h1 { font-size: clamp(32px, 4.8vw, 48px); font-weight: 900; }
.hero-sub { max-width: 560px; color: var(--muted); font-size: 15px; }

.campus-banner {
  position: relative;
  max-width: 860px;
  margin: 6px 0 24px;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.campus-banner img { width: 100%; height: 230px; object-fit: cover; }
.campus-banner-tag {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 6px 14px;
  border-radius: var(--pill);
  background: rgba(255, 253, 248, 0.92);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(64, 82, 51, 0.16);
}

.query-panel { max-width: 760px; }
.query-form {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr auto;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.query-form label span, .form-stack label span, .form-row label span { display: block; margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.query-form select, .query-form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
}
.query-form select:focus, .query-form input:focus, .form-stack input:focus, .form-stack select:focus, .form-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.query-form button, .btn-primary, .btn-secondary, .btn-ghost {
  border: 0;
  border-radius: var(--pill);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.query-form button { background: var(--btn); color: #fff; white-space: nowrap; }
.query-form button:hover { background: var(--btn-hover); }
.btn-primary { background: var(--btn); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--btn-hover); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.hint { color: var(--muted); font-size: 12px; margin: 10px 2px 0; }

.bed-board {
  margin-top: 18px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.building-photo {
  width: 100%;
  height: 190px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid var(--line);
}
.board-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.board-head h2 { font-size: 22px; }
.board-head p { margin: 0; color: var(--muted); font-size: 13px; }
.board-tag {
  display: inline-block;
  padding: 5px 12px;
  border-radius: var(--pill);
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.bed-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bed-cell {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 78px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
}
.bed-cell.free { border: 1.5px dashed #cdd9bd; color: var(--ink-soft); background: var(--surface-2); }
.bed-cell.taken { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.bed-cell .bed-state { font-size: 12px; opacity: 0.85; }
.board-note { margin: 16px 0 0; color: var(--muted); font-size: 13px; }

.guide-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 760px;
  margin-top: 26px;
}
.guide-strip div { display: flex; align-items: center; gap: 10px; padding: 13px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 22px rgba(64, 82, 51, 0.06); }
.guide-strip strong { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; }
.guide-strip span { font-size: 12px; color: var(--ink-soft); font-weight: 600; }

.register-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  max-width: 760px;
  margin-bottom: 22px;
  padding: 20px 24px;
  border: 1px solid #dbe5cc;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  box-shadow: 0 10px 26px rgba(64, 82, 51, 0.08);
}
.register-cta .eyebrow { margin-bottom: 6px; background: rgba(255, 255, 255, 0.7); }
.register-cta h2 { color: var(--ink); font-size: 23px; margin: 0 0 4px; }
.register-cta p { color: #6d7863; margin: 0; font-size: 14px; line-height: 1.6; }
.cta-btn {
  flex: none;
  display: inline-block;
  padding: 13px 30px;
  border-radius: var(--pill);
  background: var(--btn);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(59, 125, 216, 0.28);
}
.cta-btn:hover { background: var(--btn-hover); text-decoration: none; }

.auth-wrap { max-width: 560px; margin: 26px auto 0; }
.auth-card {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card.wide { max-width: 700px; margin: 0 auto; }
.auth-card h1 { font-size: 28px; }
.auth-card h2 { font-size: 20px; margin-top: 6px; }
.auth-sub { color: var(--muted); font-size: 14px; }
.auth-link { margin-top: 16px; color: var(--muted); font-size: 14px; }
.auth-link a { font-weight: 700; }

.form-stack { display: grid; gap: 14px; margin-top: 18px; }
.form-stack input, .form-stack select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 15px;
}
.form-stack input:disabled { background: var(--surface-2); color: var(--muted); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.form-row label { flex: 1; }
.form-row select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius); }

.notice-warning {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #f2d0cb;
  border-radius: var(--radius);
  background: #fdf2f0;
}
.notice-warning strong { display: block; color: var(--danger); font-size: 14px; }
.notice-warning span { display: block; margin-top: 3px; color: #a05a55; font-size: 13px; line-height: 1.6; }

.bed-picker { margin-top: 4px; }
.picker-empty { color: var(--muted); font-size: 13px; background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; text-align: center; }
.picker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.picker-cell {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 78px;
  border-radius: var(--radius);
  border: 1.5px dashed #cdd9bd;
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
}
.picker-cell.occupied { border: 1px solid var(--line); background: var(--surface); color: var(--muted); opacity: 0.7; cursor: not-allowed; }
.picker-cell.selected { border: 2px solid var(--teal); background: var(--teal-soft); color: var(--teal); }
.picker-cell .picker-state { font-size: 12px; opacity: 0.8; }

.flash {
  margin: 12px 0;
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}
.flash-error { background: #fdf2f0; border: 1px solid #f2d0cb; color: #a54842; }
.flash-success { background: var(--teal-soft); border: 1px solid #c5e5df; color: var(--teal); }
.flash-info { background: #f0ede5; border: 1px solid var(--line); color: var(--ink-soft); }

.member-page { max-width: 760px; margin: 0 auto; }
.member-page.narrow { max-width: 620px; }
.empty-card { max-width: 560px; margin: 40px auto; padding: 30px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty-card h1 { font-size: 24px; }
.empty-inline { color: var(--muted); font-size: 14px; padding: 18px 0; }

.dorm-card { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.dorm-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.dorm-card h1 { font-size: 24px; }
.dorm-card-head p:last-child { color: var(--muted); }
.info-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 18px 0 0; }
.info-list div { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.info-list dt { color: var(--muted); font-size: 12px; }
.info-list dd { margin: 3px 0 0; font-weight: 700; }

.roommate-card, .change-card { margin-top: 18px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title h2 { font-size: 19px; margin: 0; }
.roommate-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.roommate-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.roommate-item.is-me { border-color: #bfe1dc; background: var(--teal-soft); }
.bed-chip { flex: none; display: inline-grid; place-items: center; min-width: 46px; height: 34px; padding: 0 8px; border-radius: var(--pill); background: var(--accent); color: #fff; font-size: 13px; font-weight: 800; }
.mate-info { flex: 1; min-width: 0; }
.mate-info strong { display: block; font-size: 15px; }
.mate-info em { font-style: normal; color: var(--teal); font-weight: 800; font-size: 12px; margin-left: 4px; }
.mate-info span { color: var(--muted); font-size: 13px; word-break: break-all; }
.copy-btn { flex: none; padding: 8px 16px; border: 0; border-radius: var(--pill); background: var(--btn); color: #fff; font-weight: 800; cursor: pointer; }
.copy-btn.copied { background: var(--ok); }
.profile-link { margin-top: 18px; text-align: center; }

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 26px 20px 40px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.admin-body { background: #f1f2ec; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1200px; margin: 0 auto; padding: 16px 20px; }
.admin-main { max-width: 1200px; margin: 0 auto; padding: 10px 20px 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 16px 0 20px; }
.admin-head h1 { font-size: 26px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat-card { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 6px; font-size: 30px; font-weight: 900; color: var(--accent); }
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar select, .filter-bar input { padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 14px; }
.row-actions { display: flex; gap: 10px; align-items: center; }
.inline-form { display: inline; }
.link-danger { background: none; border: 0; color: var(--danger); font-size: 13px; font-weight: 700; cursor: pointer; padding: 0; }
.link-btn { background: none; border: 0; color: var(--teal); font-size: 13px; font-weight: 700; cursor: pointer; padding: 0; }
.delete-form { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }

@media (max-width: 720px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .site-nav { width: 100%; justify-content: space-between; }
  .site-nav a { flex: 1; text-align: center; padding: 9px 6px; }
  .query-form { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .bed-grid, .picker-grid { grid-template-columns: repeat(2, 1fr); }
  .guide-strip { grid-template-columns: 1fr 1fr; }
  .register-cta { flex-direction: column; align-items: stretch; text-align: center; }
  .cta-btn { text-align: center; }
  .campus-banner img { height: 160px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .info-list { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; align-items: stretch; }
  .site-footer { flex-direction: column; }
}
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(44, 53, 41, 0.46);
  overflow-y: auto;
}
.modal-hidden { display: none; }
.modal-dialog {
  width: min(94vw, 560px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(44, 53, 41, 0.28);
}
.modal-dialog h2 { font-size: 24px; }
.modal-dialog p { color: var(--ink-soft); font-size: 14px; line-height: 1.75; }
.modal-qr-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 6px; }
.modal-qr-row figure, .modal-qr-single { margin: 0; padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); text-align: center; }
.modal-qr-row img, .modal-qr-single img { width: 100%; border-radius: var(--radius); background: #fff; }
.modal-qr-row figcaption, .modal-qr-single figcaption { margin-top: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.modal-qr-single { max-width: 300px; margin: 14px auto; }
.notice-body { margin-top: 8px; padding-top: 4px; }
.highlight { color: var(--accent); font-weight: 900; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

.footer-links { display: flex; gap: 14px; }
.footer-links a { color: var(--muted); font-size: 12px; }
.footer-links a:hover { color: var(--accent); text-decoration: none; }

.contact-qr { max-width: 760px; margin-top: 30px; }
.qr-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.qr-card { margin: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.qr-card img { width: 100%; border-radius: var(--radius); background: #fff; }
.qr-card figcaption { margin-top: 12px; }
.qr-card strong { display: block; font-size: 15px; }
.qr-card span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 720px) {
  .modal-qr-row { grid-template-columns: 1fr; }
  .modal-actions { grid-template-columns: 1fr; }
  .qr-cards { grid-template-columns: 1fr; }
  .site-footer { gap: 10px; }
}
.field-with-btn { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.field-with-btn label { min-width: 0; }
.btn-mini {
  flex: none;
  padding: 11px 16px;
  border: 0;
  border-radius: var(--pill);
  background: var(--btn);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.btn-mini:hover { background: var(--btn-hover); }
.modal-actions-single { grid-template-columns: 1fr; }
.modal-dialog-narrow { width: min(92vw, 430px); }

.dept-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  max-width: 760px;
  margin-top: 30px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.dept-copy h2 { font-size: 24px; }
.dept-copy p { color: var(--muted); font-size: 14px; }
.dept-qr { flex: none; width: 180px; margin: 0; text-align: center; }
.dept-qr img { width: 100%; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); }
.dept-qr figcaption { margin-top: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
@media (max-width: 720px) {
  .dept-banner { flex-direction: column; text-align: center; }
  .dept-qr { width: 220px; }
  .field-with-btn { grid-template-columns: 1fr; }
}
.remember-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; cursor: pointer; }
.remember-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--btn); }
#query { scroll-margin-top: 24px; }