:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
  --surface: rgba(255, 255, 255, 0.7);
  --surface-hover: rgba(255, 255, 255, 0.85);
  --surface-tint: rgba(14, 165, 233, 0.05);
  --surface-soft: rgba(0, 0, 0, 0.02);
  --border: rgba(0, 0, 0, 0.07);
  --border-hover: rgba(0, 0, 0, 0.15);
  --text: #334155;
  --text-muted: #64748b;
  --text-strong: #0f172a;
  
  /* 各板块强调色 */
  --study-start: #8b5cf6;
  --study-end: #ec4899;
  --campus-start: #0284c7;
  --campus-end: #3b82f6;
  --energy-start: #ea580c;
  --energy-end: #ca8a04;
  --sync-start: #059669;
  --sync-end: #0d9488;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 15px 35px rgba(148, 163, 184, 0.12);
}

body.dark-theme {
  color-scheme: dark;
  --bg: #07090e;
  --bg-gradient: none;
  --surface: rgba(17, 24, 39, 0.55);
  --surface-hover: rgba(31, 41, 55, 0.65);
  --surface-tint: rgba(55, 65, 81, 0.15);
  --surface-soft: rgba(255, 255, 255, 0.02);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --text-strong: #ffffff;
  
  /* 各板块强调色 */
  --study-start: #a855f7;
  --study-end: #ec4899;
  --campus-start: #0ea5e9;
  --campus-end: #3b82f6;
  --energy-start: #f97316;
  --energy-end: #eab308;
  --sync-start: #10b981;
  --sync-end: #14b8a6;
  
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  line-height: 1.5;
  transition: background-color 0.4s ease, background-image 0.4s ease, color 0.4s ease;
}

/* 霓虹极光背景特效 */
.nebula-glow {
  position: fixed;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(160px);
  z-index: -10;
  opacity: 0.08;
  pointer-events: none;
  animation: drift 25s infinite alternate ease-in-out;
  transition: opacity 0.4s ease;
}
body.dark-theme .nebula-glow {
  opacity: 0.15;
}
.nebula-glow.purple {
  background: radial-gradient(circle, var(--study-start) 0%, transparent 70%);
  top: -10%;
  left: -10%;
}
.nebula-glow.blue {
  background: radial-gradient(circle, var(--campus-start) 0%, transparent 70%);
  bottom: -10%;
  right: -10%;
  animation-delay: -12s;
}
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(8%, 8%) scale(1.15); }
}

/* 大框架布局 */
.shell {
  width: min(1800px, 96vw);
  margin: 0 auto;
  padding: 24px 0 64px;
}

/* 右侧核心内容包裹层 */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  flex: 1;
}

/* 顶部/左侧自适应 header */
.app-header {
  backdrop-filter: blur(20px);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--campus-start), var(--campus-end));
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 8px 16px rgba(14, 165, 233, 0.25);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--campus-start);
  font-weight: 700;
}
h1 {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-strong) 40%, var(--campus-start));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}
.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.quick-nav {
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  gap: 4px;
}
body.dark-theme .quick-nav {
  background: rgba(255, 255, 255, 0.03);
}
.quick-nav a {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
}
.quick-nav a:hover {
  color: var(--text-strong);
  background: rgba(0, 0, 0, 0.04);
}
body.dark-theme .quick-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.quick-nav a.active {
  color: #fff !important;
  background: linear-gradient(135deg, var(--campus-start), var(--campus-end));
  box-shadow: 0 6px 12px rgba(14, 165, 233, 0.25);
}

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

/* 按钮与输入框通用 */
button, input, select {
  font-family: inherit;
  outline: none;
}

button {
  height: 40px;
  padding: 0 20px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--campus-start), var(--campus-end));
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 6px 15px rgba(14, 165, 233, 0.2);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(14, 165, 233, 0.3);
}
button:active:not(:disabled) {
  transform: translateY(0);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.ghost {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}
button.ghost:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.04);
  border-color: var(--border-hover);
  box-shadow: none;
  color: var(--text-strong);
}
body.dark-theme button.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

input[type="text"], input[type="password"], input[type="search"], input[type="month"], select {
  height: 40px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-strong);
  padding: 0 14px;
  font-size: 13px;
  transition: var(--transition);
}
input:focus, select:focus {
  border-color: var(--campus-start);
  background: var(--surface);
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.15);
}

/* 标签页与过渡动画 */
.app-section, #overview, #authPanel {
  display: none !important;
  opacity: 0;
  transform: scale(0.98) translateY(12px);
}
.app-section.active-tab, #authPanel.active-tab {
  display: flex !important;
  flex-direction: column;
  gap: 24px;
  opacity: 1;
  transform: scale(1) translateY(0);
  animation: slideUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
#overview.active-tab {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 16px;
  margin-bottom: 24px;
  opacity: 1;
  transform: scale(1) translateY(0);
  animation: slideUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes slideUp {
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* 总览卡片 */
.overview-card {
  min-height: 124px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.overview-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
}
.overview-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 15px 30px rgba(148, 163, 184, 0.2);
}
body.dark-theme .overview-card:hover {
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.35);
}
.overview-card.tone-study::before { background: linear-gradient(90deg, var(--study-start), var(--study-end)); }
.overview-card.tone-campus::before { background: linear-gradient(90deg, var(--campus-start), var(--campus-end)); }
.overview-card.tone-energy::before { background: linear-gradient(90deg, var(--energy-start), var(--energy-end)); }
.overview-card.tone-sync::before { background: linear-gradient(90deg, var(--sync-start), var(--sync-end)); }

.overview-card span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.overview-card strong {
  font-size: 26px;
  font-weight: 800;
  margin: 8px 0;
}
.overview-card.tone-study strong { background: linear-gradient(135deg, var(--text-strong) 30%, #ec4899); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.overview-card.tone-campus strong { background: linear-gradient(135deg, var(--text-strong) 30%, #3b82f6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.overview-card.tone-energy strong { background: linear-gradient(135deg, var(--text-strong) 30%, #f97316); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.overview-card.tone-sync strong { background: linear-gradient(135deg, var(--text-strong) 30%, #10b981); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.overview-card small {
  font-size: 11px;
  color: var(--text-muted);
}

/* 门禁系统 (#appGate) - 默认完全隐藏 */
#appGate {
  display: none !important;
}

/* 当 data-app-locked 为 true 时，强制隐藏除 appGate 以外的所有内容 */
body[data-app-locked="true"] .app-header {
  display: none !important;
}
body[data-app-locked="true"] .main-content > :not(#appGate) {
  display: none !important;
}

body[data-app-locked="true"] #appGate {
  display: flex !important;
  max-width: 440px;
  width: 100%;
  margin: 100px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px;
  box-shadow: var(--shadow);
  flex-direction: column;
  gap: 24px;
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.app-gate h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-strong);
}
.app-gate p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.app-gate .auth-note, .auth-panel .auth-note {
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.app-login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 连接学校账号面板 */
.auth-panel {
  max-width: 440px;
  width: 100%;
  margin: 12px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 30px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-panel h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-strong);
}
.auth-panel p {
  font-size: 12px;
  color: var(--text-muted);
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-form .remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0;
}
.login-form .remember input {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  accent-color: var(--campus-start);
}
.auth-actions {
  display: flex;
  justify-content: flex-end;
}

/* 状态提示 */
.status {
  margin: 16px 0;
}
.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 13px;
  color: var(--text-strong);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
}
.notice.success {
  border-left: 4px solid var(--sync-start);
  background: rgba(16, 185, 129, 0.05);
}
.notice.error {
  border-left: 4px solid #ef4444;
  background: rgba(239, 68, 68, 0.05);
}
.notice.info {
  border-left: 4px solid var(--campus-start);
  background: rgba(14, 165, 233, 0.05);
}

/* 板块头部 (Section Head) */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
.section-head h2 {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-strong) 60%, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.section-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.section-tools > span {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-soft);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* 数据网格/卡片容器 (.panel) */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.panel-head h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-strong);
}
.panel-head > span {
  font-size: 12px;
  color: var(--text-muted);
}

/* 指标指标栏 (.metrics) */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: var(--transition);
}
.metric:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}
.metric span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.metric strong {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0;
  color: var(--text-strong);
}
.metric small {
  font-size: 11px;
  color: var(--text-muted);
}

/* 强调高亮指标卡 */
.metric-balance {
  background: radial-gradient(circle at top right, rgba(14, 165, 233, 0.08), transparent 70%), var(--surface);
  border-color: rgba(14, 165, 233, 0.2);
}
.metric-balance strong {
  color: var(--campus-start);
  text-shadow: 0 0 12px rgba(14, 165, 233, 0.1);
}

/* 课表工具条 & 网格 */
.timetable-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.timetable-toolbar select {
  min-width: 120px;
}
.timetable-toolbar input[type="search"] {
  min-width: 180px;
}
.timetable-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.timetable-summary-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}
.timetable-summary-card span {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.timetable-summary-card strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 2px 0;
}
.timetable-summary-card small {
  font-size: 10px;
  color: var(--text-muted);
}

/* 课表网格 */
.timetable-grid-wrap {
  overflow-x: auto;
}
.semester-board {
  display: grid;
  grid-template-columns: repeat(var(--day-count, 7), minmax(130px, 1fr));
  gap: 12px;
  padding: 4px;
}
.semester-board.day-count-1 { grid-template-columns: repeat(1, minmax(130px, 1fr)); }
.semester-board.day-count-2 { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
.semester-board.day-count-3 { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
.semester-board.day-count-4 { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
.semester-board.day-count-5 { grid-template-columns: repeat(5, minmax(130px, 1fr)); }
.semester-board.day-count-6 { grid-template-columns: repeat(6, minmax(130px, 1fr)); }
.semester-board.day-count-7 { grid-template-columns: repeat(7, minmax(130px, 1fr)); }
.day-column {
  background: rgba(0, 0, 0, 0.015);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
}
body.dark-theme .day-column {
  background: rgba(255, 255, 255, 0.015);
}
.day-column.today {
  background: rgba(139, 92, 246, 0.04);
  border-color: rgba(139, 92, 246, 0.35);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.05);
}
.day-column-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.day-column-head strong {
  font-size: 13px;
  color: var(--text-strong);
}
.day-column-head span {
  display: none;
}
.day-column-head em {
  font-size: 10px;
  color: var(--text-muted);
  font-style: normal;
}
.day-course-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 课程卡片 */
.semester-course {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: 8px;
  padding: 8px 10px;
  transition: var(--transition);
}
body.dark-theme .semester-course {
  background: rgba(255, 255, 255, 0.02);
}
.semester-course:hover {
  transform: translateY(-2px);
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.12);
}
body.dark-theme .semester-course:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}
.semester-course.tone-1 { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.04); }
.semester-course.tone-2 { border-left-color: #10b981; background: rgba(16, 185, 129, 0.04); }
.semester-course.tone-3 { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.04); }
.semester-course.tone-4 { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.04); }
.semester-course.tone-5 { border-left-color: #8b5cf6; background: rgba(139, 92, 246, 0.04); }
.semester-course.tone-6 { border-left-color: #ec4899; background: rgba(236, 72, 153, 0.04); }
.semester-course.tone-7 { border-left-color: #06b6d4; background: rgba(6, 182, 212, 0.04); }

.semester-course-main strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.3;
}
.course-time-pill {
  display: inline-block;
  font-size: 9px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.03);
  padding: 1px 4px;
  border-radius: 4px;
  margin-top: 4px;
}
body.dark-theme .course-time-pill {
  background: rgba(255, 255, 255, 0.04);
}
.course-facts {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  color: var(--text-muted);
}
.course-more {
  margin-top: 6px;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}
.course-more summary {
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  outline: none;
}
.course-more dl {
  margin-top: 4px;
  font-size: 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.course-more dl div {
  display: flex;
  justify-content: space-between;
}
.course-more dt {
  color: var(--text-muted);
}
.course-more dd {
  color: var(--text-strong);
  font-weight: 600;
}

/* 学业二级区域 */
.study-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

/* 课程清单 */
.course-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}
.course-list-card {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
}
body.dark-theme .course-list-card {
  background: rgba(255, 255, 255, 0.02);
}
.course-list-card:hover {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--border-hover);
}
body.dark-theme .course-list-card:hover {
  background: rgba(255, 255, 255, 0.04);
}
.course-list-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.course-list-title strong {
  font-size: 13px;
  color: var(--text-strong);
}
.course-list-title span {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.03);
  padding: 1px 6px;
  border-radius: 4px;
}
body.dark-theme .course-list-title span {
  background: rgba(255, 255, 255, 0.04);
}
.course-list-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* 空教室 */
.free-room-panel {
  display: flex;
  flex-direction: column;
}
.free-room-head {
  margin-bottom: 12px;
}
.free-room-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.free-room-controls select {
  min-width: 100px;
}
.free-section-tools {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.dark-theme .free-section-tools {
  background: rgba(255, 255, 255, 0.015);
}
.free-section-tools .field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}
.free-section-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.section-chip {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
  transition: var(--transition);
}
body.dark-theme .section-chip {
  background: rgba(255, 255, 255, 0.02);
}
.section-chip span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.section-chip small {
  font-size: 9px;
  color: var(--text-muted);
}
.section-chip.active {
  background: rgba(14, 165, 233, 0.08);
  border-color: var(--campus-start);
}
.section-chip.active span {
  color: var(--text-strong);
}
.free-section-presets {
  display: flex;
  gap: 6px;
}
.free-section-presets button {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 11px;
}
.free-room-summary {
  margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}
.free-room-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}
.free-building-card {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
body.dark-theme .free-building-card {
  background: rgba(255, 255, 255, 0.015);
}
.free-building-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.free-building-head strong {
  font-size: 14px;
  color: var(--text-strong);
}
.free-building-head span {
  font-size: 10px;
  color: var(--text-muted);
}
.free-room-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.free-room-chip {
  background: rgba(14, 165, 233, 0.06);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: 6px;
  padding: 4px 8px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  transition: var(--transition);
}
.free-room-chip:hover {
  background: rgba(14, 165, 233, 0.12);
  border-color: var(--campus-start);
  transform: scale(1.05);
}
.free-room-chip strong {
  font-size: 11px;
  color: var(--text-strong);
}
.free-room-chip em {
  font-size: 8px;
  color: var(--text-muted);
  font-style: normal;
}

/* 一卡通面板，采用高自适应列 */
.identity-card-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: start;
}
.campus-id-card {
  background: linear-gradient(135deg, rgba(23, 28, 41, 0.82) 0%, rgba(10, 13, 20, 0.96) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  aspect-ratio: 1.58 / 1;
  width: 100%;
}
.campus-id-card::after {
  content: '';
  position: absolute;
  top: 24px;
  right: 24px;
  width: 42px;
  height: 32px;
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  border-radius: 6px;
  opacity: 0.8;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.4);
}
.campus-id-card-top {
  display: flex;
  gap: 16px;
}
.campus-id-avatar {
  width: 56px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: #111;
}
.campus-id-card-top span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--campus-start);
  font-weight: 700;
  display: block;
}
.campus-id-card-top strong {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  display: block;
  margin-top: 2px;
}
.campus-id-card-top em {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
  font-family: monospace;
  font-style: normal;
}
.campus-id-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}
.campus-id-facts div {
  display: flex;
  flex-direction: column;
}
.campus-id-facts span {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.6);
}
.campus-id-facts strong {
  font-size: 11px;
  color: #fff;
  margin-top: 1px;
  font-weight: 600;
}
.campus-id-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
}
.campus-id-footer span {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
}
.campus-id-footer button {
  height: 24px;
  padding: 0 8px;
  font-size: 10px;
  border-radius: 4px;
}

/* 个人二维码/条形码面板 */
.campus-id-code-panel {
  display: flex;
  flex-direction: column;
}
.campus-id-code-head {
  margin-bottom: 12px;
}
.identity-code-actions {
  display: flex;
  gap: 4px;
}
.identity-code-actions button {
  height: 28px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: 6px;
}
.identity-code-actions button.active {
  background: var(--campus-start);
  color: #fff;
}
.identity-code-stage {
  flex: 1;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  place-items: center;
  min-height: 140px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
}
.identity-code-stage img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
}
.identity-code-stage .empty {
  color: #6b7280;
}
.identity-code-meta {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* 人脸照片 */
.identity-face-head {
  margin-bottom: 12px;
}
.identity-face-actions {
  display: flex;
  gap: 6px;
}
.identity-face-actions button {
  height: 28px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: 6px;
}
.identity-face-layout {
  display: flex;
  gap: 16px;
  align-items: center;
}
.identity-face-photo-frame {
  width: 90px;
  height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.identity-face-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.identity-face-photo-frame::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--campus-start), transparent);
  box-shadow: 0 0 6px var(--campus-start);
  animation: scan 3s infinite linear;
}
.identity-face-photo-frame .empty {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  padding: 4px;
}
.identity-face-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.identity-face-details div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.identity-face-details span {
  font-size: 11px;
  color: var(--text-muted);
}
.identity-face-details strong {
  font-size: 12px;
  color: var(--text-strong);
}
.identity-face-details strong[data-tone="ok"] {
  color: var(--sync-start);
}
.identity-face-details strong[data-tone="warn"] {
  color: var(--energy-start);
}
.identity-face-details strong[data-tone="bad"] {
  color: #ef4444;
}
.identity-face-notice {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
  border-top: 1px dashed var(--border);
  padding-top: 4px;
}

/* 公寓住宿 */
.accommodation-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.accommodation-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  align-items: start;
}
.accommodation-primary {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.accommodation-primary span {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.accommodation-primary strong {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-strong);
  margin: 4px 0;
}
.accommodation-primary small {
  font-size: 11px;
  color: var(--text-muted);
}
.accommodation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}
.accommodation-grid div {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}
body.dark-theme .accommodation-grid div {
  background: rgba(255, 255, 255, 0.015);
}
.accommodation-grid span {
  font-size: 10px;
  color: var(--text-muted);
}
.accommodation-grid strong {
  font-size: 13px;
  color: var(--text-strong);
  margin-top: 2px;
  font-weight: 600;
}

/* 宿友列表 */
.roommate-block {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.roommate-block .subsection-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.roommate-block h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-strong);
}
.roommate-block span {
  font-size: 11px;
  color: var(--text-muted);
}
.roommate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.roommate-card {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}
body.dark-theme .roommate-card {
  background: rgba(255, 255, 255, 0.02);
}
.roommate-card:hover {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--border-hover);
}
body.dark-theme .roommate-card:hover {
  background: rgba(255, 255, 255, 0.04);
}
.roommate-card strong {
  font-size: 13px;
  color: var(--text-strong);
}
.roommate-card span {
  font-size: 11px;
  color: var(--campus-start);
  margin-top: 2px;
  font-weight: 600;
}
.roommate-card small {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 一卡通与水费账单双栏 */
.workspace {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}
.scroll-list {
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}
.bill-list {
  display: flex;
  flex-direction: column;
}
.bill-card {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition);
}
body.dark-theme .bill-card {
  background: rgba(255, 255, 255, 0.02);
}
.bill-card:hover {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
body.dark-theme .bill-card:hover {
  background: rgba(255, 255, 255, 0.04);
}
.bill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bill-row span {
  font-size: 12px;
  color: var(--text-muted);
}
.bill-row strong {
  font-size: 13px;
  color: var(--text-strong);
  font-weight: 600;
}

/* 能耗账户/房间信息 */
.identity {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.identity div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
}
.identity span {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.identity strong {
  font-size: 15px;
  color: var(--text-strong);
  margin-top: 2px;
  font-weight: 600;
}

/* 能耗工作区 */
.energy-workspace {
  margin-top: 0;
}
.meter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.meter-card {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: var(--transition);
}
body.dark-theme .meter-card {
  background: rgba(255, 255, 255, 0.02);
}
.meter-card:hover {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--border-hover);
}
body.dark-theme .meter-card:hover {
  background: rgba(255, 255, 255, 0.04);
}
.meter-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.meter-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-strong);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 9px;
  font-weight: 700;
}
.badge.online {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}
body.dark-theme .badge.online {
  color: #34d399;
}
.badge.online::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulse 1.6s infinite ease-in-out;
}
.badge.offline {
  background: rgba(156, 163, 175, 0.1);
  color: #9ca3af;
}
.badge.offline::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #9ca3af;
}
.meter-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.meter-row span {
  color: var(--text-muted);
}
.meter-row strong {
  color: var(--text-strong);
  font-weight: 600;
}

/* 套餐备注 */
.package-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.package-card {
  background: rgba(0, 0, 0, 0.015);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
body.dark-theme .package-card {
  background: rgba(255, 255, 255, 0.015);
}

/* 占位提示 */
.empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.005);
  border: 1px dashed var(--border);
  border-radius: 12px;
  width: 100%;
}
body.dark-theme .empty {
  background: rgba(255, 255, 255, 0.01);
}

/* 统一身份认证登录面板 */
#authPanel[data-connected="true"] .login-form {
  display: none !important;
}
#authPanel[data-connected="true"] .auth-actions {
  display: flex !important;
}
#authPanel[data-connected="false"] .auth-actions,
#authPanel[data-connected="relogin"] .auth-actions {
  display: none !important;
}
#authPanel[data-connected="false"] .login-form,
#authPanel[data-connected="relogin"] .login-form {
  display: flex !important;
}

/* 兜底隐藏支持 */
[hidden] {
  display: none !important;
}

/* 自适应媒体查询 (PC 大屏布局升级为侧边栏) */
@media (min-width: 1024px) {
  .shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 32px;
    padding: 32px 0 64px;
  }
  .app-header {
    position: sticky;
    top: 32px;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px 20px;
    border-radius: 20px;
  }
  .app-header .brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .app-header .brand > div:last-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .app-header .header-subtitle {
    display: block;
  }
  
  .quick-nav {
    flex-direction: column;
    width: 100%;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 0;
  }
  .quick-nav a {
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    padding-left: 16px;
    border-radius: 10px;
    font-size: 14px;
  }
  .actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }
  .actions button {
    width: 100%;
  }
}

/* 中屏媒体查询 */
@media (max-width: 1023px) {
  .shell {
    padding: 16px 16px 88px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .app-header {
    position: sticky;
    top: 12px;
    z-index: 100;
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .quick-nav {
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    z-index: 100;
    background: var(--surface);
    box-shadow: 0 10px 30px rgba(148, 163, 184, 0.15);
  }
  body.dark-theme .quick-nav {
    background: rgba(10, 13, 20, 0.85);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
  .quick-nav a {
    flex: 1;
    height: 38px;
    font-size: 12px;
  }
  #overview.active-tab {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .study-secondary, .workspace {
    grid-template-columns: 1fr;
  }
  .identity-card-panel {
    grid-template-columns: 1fr;
  }
  .accommodation-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* 小屏手机适配 */
@media (max-width: 640px) {
  .app-header .brand {
    gap: 8px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
  h1 {
    font-size: 16px;
  }
  .metrics, .timetable-summary, .free-room-summary, .identity {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .app-gate, .auth-panel {
    padding: 24px 20px;
    margin-top: 32px;
  }
  #overview.active-tab {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .roommate-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 宽屏对称对称布局 */
@media (min-width: 1200px) {
  .study-secondary, .workspace {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 24px;
  }
}

/* Layout refresh: balanced overview, calmer surfaces, resilient breakpoints. */
:root {
  --bg: #eef3f8;
  --bg-gradient:
    linear-gradient(135deg, #f8fafc 0%, #eef4fa 45%, #e6eef7 100%);
  --surface: rgba(255, 255, 255, 0.82);
  --surface-hover: rgba(255, 255, 255, 0.94);
  --surface-soft: rgba(15, 23, 42, 0.035);
  --border: rgba(15, 23, 42, 0.09);
  --border-hover: rgba(15, 23, 42, 0.17);
  --text: #334155;
  --text-muted: #64748b;
  --text-strong: #0f172a;
  --hgu-maroon: #7c1f27;
  --hgu-maroon-deep: #5f141d;
  --hgu-gold: #b49a5a;
  --hgu-gold-soft: rgba(180, 154, 90, 0.16);
  --radius-lg: 16px;
  --radius-md: 12px;
  --page-gap: 20px;
  --shadow: 0 18px 42px rgba(31, 41, 55, 0.08);
  --shadow-soft: 0 10px 24px rgba(31, 41, 55, 0.065);
}

body.dark-theme {
  --bg: #0b1018;
  --bg-gradient:
    linear-gradient(135deg, #0b1018 0%, #111827 52%, #0d1623 100%);
  --surface: rgba(17, 24, 39, 0.78);
  --surface-hover: rgba(30, 41, 59, 0.88);
  --surface-soft: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.09);
  --border-hover: rgba(255, 255, 255, 0.18);
  --hgu-maroon: #d58a91;
  --hgu-maroon-deep: #f0a0a6;
  --hgu-gold: #d4bb7a;
  --hgu-gold-soft: rgba(212, 187, 122, 0.16);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.25);
}

html {
  scroll-behavior: smooth;
}

body {
  background-attachment: fixed;
  text-rendering: geometricPrecision;
  font-size: 16px;
}

.nebula-glow {
  display: none;
}

.shell {
  width: min(1680px, calc(100vw - 32px));
  padding: 22px 0 48px;
}

.main-content {
  gap: var(--page-gap);
  width: 100%;
}

.app-header,
.overview-card,
.auth-panel,
.panel,
.metric,
.identity div,
.notice {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.app-header,
.panel,
.metric,
.auth-panel,
.overview-card,
.notice {
  border-radius: var(--radius-lg);
}

.app-header {
  background: var(--surface);
  border-color: rgba(124, 31, 39, 0.12);
  overflow: hidden;
  position: relative;
}

.app-header::after {
  content: "";
  position: absolute;
  right: -72px;
  bottom: 96px;
  width: 210px;
  height: 210px;
  background: url("./assets/hgu-emblem.png") center / contain no-repeat;
  opacity: 0.045;
  pointer-events: none;
}

.brand,
.actions {
  position: relative;
  z-index: 1;
}

.brand-mark {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 5px;
  background: #fff;
  border: 1px solid rgba(124, 31, 39, 0.18);
  box-shadow: 0 16px 30px rgba(124, 31, 39, 0.16);
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.eyebrow {
  color: var(--hgu-maroon);
}

h1 {
  background: linear-gradient(135deg, var(--text-strong) 42%, var(--hgu-maroon));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.quick-nav {
  background: var(--surface-soft);
}

.quick-nav a {
  min-width: 0;
  white-space: nowrap;
  font-size: 15px;
}

.quick-nav a.active {
  background: linear-gradient(135deg, var(--hgu-maroon), #1d8ed2);
  box-shadow: 0 10px 24px rgba(124, 31, 39, 0.18);
}

button {
  background: linear-gradient(135deg, var(--hgu-maroon), #1d8ed2);
  box-shadow: 0 8px 18px rgba(124, 31, 39, 0.18);
}

button:hover:not(:disabled) {
  box-shadow: 0 12px 24px rgba(124, 31, 39, 0.24);
}

button,
input[type="text"],
input[type="password"],
input[type="search"],
input[type="month"],
select {
  max-width: 100%;
  font-size: 14px;
}

button {
  min-width: 0;
  white-space: nowrap;
  font-size: 14px;
}

.section-head {
  align-items: flex-end;
  border-bottom-color: var(--border);
}

.section-tools,
.timetable-toolbar,
.free-room-controls,
.identity-code-actions,
.identity-face-actions {
  min-width: 0;
}

.panel,
.metric,
.overview-card {
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.panel:hover,
.metric:hover,
.overview-card:hover {
  background: var(--surface-hover);
}

#overview.active-tab {
  gap: 16px;
  margin-bottom: 0;
}

.overview-card {
  min-height: 142px;
  padding: 22px 24px;
  justify-content: center;
  gap: 14px;
  border-color: rgba(124, 31, 39, 0.1);
}

.overview-card::before {
  display: none;
}

.overview-card strong {
  font-size: 36px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.overview-card.tone-study strong {
  background: linear-gradient(135deg, var(--text-strong) 28%, var(--hgu-maroon));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overview-card.tone-campus strong {
  background: linear-gradient(135deg, var(--text-strong) 28%, #1d8ed2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overview-card.tone-energy strong {
  background: linear-gradient(135deg, var(--text-strong) 28%, var(--hgu-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overview-card small {
  font-size: 13px;
  line-height: 1.55;
}

.auth-panel {
  max-width: 520px;
  margin: 0 auto;
  padding: 26px 28px;
  gap: 18px;
  border-color: rgba(124, 31, 39, 0.1);
  overflow: hidden;
  position: relative;
}

.auth-panel::after {
  content: "";
  position: absolute;
  right: -54px;
  bottom: -64px;
  width: 180px;
  height: 180px;
  background: url("./assets/hgu-emblem.png") center / contain no-repeat;
  opacity: 0.05;
  pointer-events: none;
}

.auth-panel > * {
  position: relative;
  z-index: 1;
}

.gate-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  align-self: flex-start;
  padding: 8px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(124, 31, 39, 0.16);
  box-shadow: 0 18px 36px rgba(124, 31, 39, 0.14);
}

body[data-app-locked="true"] #appGate {
  overflow: hidden;
  position: relative;
  border-color: rgba(124, 31, 39, 0.14);
}

body[data-app-locked="true"] #appGate::after {
  content: "";
  position: absolute;
  right: -76px;
  bottom: -88px;
  width: 230px;
  height: 230px;
  background: url("./assets/hgu-emblem.png") center / contain no-repeat;
  opacity: 0.04;
  pointer-events: none;
}

body[data-app-locked="true"] #appGate > * {
  position: relative;
  z-index: 1;
}

.status {
  margin: 0;
}

.notice {
  min-height: 54px;
  box-shadow: var(--shadow-soft);
}

.metrics {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.metric {
  min-height: 128px;
  justify-content: space-between;
}

.metric strong {
  font-size: 28px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.metric span,
.overview-card span {
  font-size: 13px;
  letter-spacing: 0.35px;
}

.metric small,
.panel-head > span,
.notice {
  font-size: 13px;
}

.workspace,
.study-secondary,
.identity-card-panel {
  gap: var(--page-gap);
}

.scroll-list,
.course-list,
.free-room-list {
  scrollbar-width: thin;
}

@media (min-width: 1024px) {
  .shell {
    grid-template-columns: 252px minmax(0, 1fr);
    gap: var(--page-gap);
    padding: 14px 0 48px;
  }

  .app-header {
    top: 14px;
    height: auto;
    min-height: 0;
    align-items: center;
    justify-content: flex-start;
    gap: 24px;
    padding: 28px 20px 24px;
    text-align: center;
  }

  .quick-nav {
    margin-top: 4px;
    position: relative;
    z-index: 1;
  }

  .actions {
    margin-top: 0;
  }

  .app-header .brand {
    align-items: center;
    gap: 14px;
    width: 100%;
  }

  .app-header .brand > div:last-child {
    align-items: center;
  }

  .app-header .brand-mark {
    width: 68px;
    height: 68px;
  }

  .app-header h1 {
    font-size: 25px;
  }

  .app-header .eyebrow {
    font-size: 13px;
    letter-spacing: 0.8px;
  }

  .app-header .header-subtitle {
    font-size: 14px;
  }

  .quick-nav a {
    justify-content: center;
    padding-left: 0;
    font-size: 16px;
  }

  .actions button {
    height: 44px;
    font-size: 15px;
  }

  body[data-route="overview"] .main-content {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.85fr);
    grid-template-areas:
      "overview auth"
      "status status";
    align-content: start;
    align-items: start;
    gap: 16px var(--page-gap);
  }

  body[data-route="overview"] #overview.active-tab {
    grid-area: overview;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body[data-route="overview"] #authPanel.active-tab {
    grid-area: auth;
    width: 100%;
    max-width: none;
    min-height: 0;
    align-self: start;
    justify-content: flex-start;
  }

  body[data-route="overview"] #status {
    grid-area: status;
  }

  body:not([data-route="overview"]) #overview.active-tab {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
  }
}

@media (min-width: 1280px) {
  .identity-card-panel {
    grid-template-columns: minmax(320px, 0.95fr) minmax(300px, 0.9fr) minmax(360px, 1.15fr);
  }

  .campus-metrics,
  .academic-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1500px) {
  body[data-route="overview"] .main-content {
    grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.85fr);
  }
}

@media (max-width: 1023px) {
  .shell {
    width: 100%;
    padding: 16px 16px 92px;
  }

  .main-content {
    margin-top: 8px;
  }

  .app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    top: 10px;
    border-radius: 16px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .app-header::after {
    display: none;
  }

  .brand {
    min-width: 0;
  }

  .brand > div:last-child {
    min-width: 0;
  }

  .brand h1,
  .header-subtitle,
  .eyebrow {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    max-width: 52vw;
  }

  .actions button {
    height: 36px;
    padding: 0 12px;
  }

  .quick-nav {
    top: auto;
    border-radius: 16px;
    padding: 6px;
    gap: 6px;
  }

  .quick-nav a {
    height: 40px;
    padding: 0 8px;
  }

  #overview.active-tab {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px;
  }

  .overview-card {
    min-height: 136px;
    padding: 18px;
  }

  .overview-card strong {
    font-size: 31px;
  }

  .auth-panel,
  .panel {
    padding: 22px;
  }

  .section-head {
    align-items: flex-start;
  }

  .section-tools {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: none;
  }

  .actions button {
    width: 100%;
  }

  .section-tools,
  .timetable-toolbar,
  .free-room-controls,
  .identity-code-actions,
  .identity-face-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .section-tools > *,
  .timetable-toolbar > *,
  .free-room-controls > *,
  .identity-code-actions > *,
  .identity-face-actions > * {
    width: 100%;
  }

  .identity-face-layout,
  .campus-id-card-top,
  .campus-id-footer,
  .bill-row,
  .free-building-head {
    align-items: flex-start;
  }

  .identity-face-layout {
    flex-direction: column;
  }

  .identity-face-photo-frame {
    width: 108px;
    height: 144px;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 12px 12px 92px;
  }

  .app-header,
  .auth-panel,
  .panel,
  .metric,
  .overview-card,
  .notice {
    border-radius: 14px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    padding: 4px;
  }

  .quick-nav {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .quick-nav a {
    font-size: 12px;
  }

  #overview.active-tab,
  .metrics,
  .timetable-summary,
  .free-room-summary,
  .identity,
  .roommate-list,
  .accommodation-grid,
  .meter-list {
    grid-template-columns: 1fr !important;
  }

  #overview.active-tab {
    gap: 12px;
  }

  .overview-card {
    min-height: 116px;
    padding: 15px 18px;
    gap: 8px;
  }

  .overview-card strong {
    font-size: 27px;
  }

  .overview-card span,
  .overview-card small {
    font-size: 12px;
  }

  .auth-panel,
  .panel {
    padding: 18px;
  }

  .metric {
    min-height: 112px;
    padding: 18px;
  }

  .campus-id-card {
    aspect-ratio: auto;
    min-height: 220px;
  }
}

/* Campus identity card redesign: merged profile and dynamic code. */
.identity-card-panel {
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.85fr) !important;
}

.campus-id-card {
  aspect-ratio: auto;
  min-height: 360px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 24px;
  padding: 26px;
  border-radius: 22px;
  border: 1px solid rgba(124, 31, 39, 0.16);
  background:
    radial-gradient(circle at 8% 0%, rgba(124, 31, 39, 0.14), transparent 32%),
    radial-gradient(circle at 72% 10%, rgba(29, 142, 210, 0.1), transparent 30%),
    radial-gradient(circle at 100% 100%, rgba(180, 154, 90, 0.16), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96) 54%, rgba(240, 247, 251, 0.94));
  box-shadow: 0 24px 54px rgba(31, 41, 55, 0.13);
  isolation: isolate;
}

.campus-id-card::before {
  content: '';
  position: absolute;
  left: 42px;
  right: auto;
  bottom: 18px;
  width: 300px;
  height: 300px;
  background: url("./assets/hgu-emblem.png") center / contain no-repeat;
  opacity: 0.045;
  pointer-events: none;
  filter: saturate(0.85);
}

.campus-id-card::after {
  display: none;
}

.campus-id-profile,
.campus-id-code-panel {
  position: relative;
  z-index: 1;
}

.campus-id-profile {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.campus-id-card-top {
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.campus-id-avatar {
  width: 76px;
  height: 98px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(15, 23, 42, 0.06);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}

.campus-id-card-top span {
  display: inline-flex;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(124, 31, 39, 0.08);
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--hgu-maroon);
}

.campus-id-card-top strong {
  font-size: 34px;
  line-height: 1.1;
  margin-top: 10px;
  color: var(--text-strong);
}

.campus-id-card-top em {
  font-size: 14px;
  margin-top: 8px;
  color: var(--text);
}

.campus-id-facts {
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(124, 31, 39, 0.12);
}

.campus-id-facts div {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(124, 31, 39, 0.08);
}

.campus-id-facts span {
  font-size: 13px;
  color: var(--text-muted);
}

.campus-id-facts strong {
  font-size: 16px;
  color: var(--text-strong);
  margin-top: 3px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.campus-id-footer {
  gap: 14px;
  margin-top: auto;
  padding-top: 18px;
}

.campus-id-footer span {
  font-size: 14px;
  color: var(--text-muted);
}

.campus-id-footer button {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 10px;
}

.campus-id-code-panel {
  min-width: 0;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(29, 142, 210, 0.13);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 14px 28px rgba(15, 23, 42, 0.06);
}

.campus-id-code-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.campus-id-code-head h2 {
  color: var(--text-strong);
  font-size: 22px;
  line-height: 1.1;
}

.identity-code-actions {
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.identity-code-actions button {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 9px;
}

.identity-code-actions button.active {
  background: linear-gradient(135deg, var(--hgu-maroon), #1d8ed2);
}

.identity-code-stage {
  min-height: 210px;
  padding: 18px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 252, 255, 0.92));
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
}

.identity-code-stage img {
  max-height: 186px;
}

.identity-code-meta {
  font-size: 13px;
  line-height: 1.45;
  margin-top: 12px;
}

body.dark-theme .campus-id-card {
  border-color: rgba(213, 138, 145, 0.2);
  background:
    radial-gradient(circle at 10% 0%, rgba(213, 138, 145, 0.16), transparent 34%),
    radial-gradient(circle at 72% 10%, rgba(82, 169, 224, 0.13), transparent 30%),
    radial-gradient(circle at 92% 10%, rgba(212, 187, 122, 0.15), transparent 28%),
    linear-gradient(135deg, rgba(17, 24, 39, 0.94), rgba(8, 13, 23, 0.96));
}

body.dark-theme .campus-id-code-panel,
body.dark-theme .campus-id-facts div {
  background: rgba(15, 23, 42, 0.62);
  border-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 1180px) {
  .identity-card-panel {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 760px) {
  .campus-id-card {
    grid-template-columns: 1fr;
    gap: 18px;
    min-height: 0;
    padding: 18px;
  }

  .campus-id-card::before {
    left: 18px;
    right: auto;
    bottom: 18px;
    width: 220px;
    height: 220px;
  }

  .campus-id-card-top {
    align-items: flex-start;
  }

  .campus-id-card-top strong {
    font-size: 26px;
  }

  .campus-id-facts {
    grid-template-columns: 1fr;
  }

  .campus-id-code-head,
  .campus-id-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .identity-code-actions {
    justify-content: stretch;
    width: 100%;
  }

  .identity-code-actions button {
    flex: 1 1 0;
  }

  .identity-code-stage {
    min-height: 180px;
  }
}

/* Compact water-code metric card. */
.metric-water-code {
  min-height: 112px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label action"
    "code meta";
  align-items: end;
  gap: 12px 14px;
  overflow: hidden;
  border-color: rgba(29, 142, 210, 0.18);
  background:
    linear-gradient(135deg, rgba(29, 142, 210, 0.08), rgba(124, 31, 39, 0.05)),
    var(--surface);
}

.metric-water-code:hover {
  border-color: rgba(29, 142, 210, 0.3);
}

.metric-water-code .metric-title-row {
  display: contents;
}

.metric-water-code .metric-title-row span {
  grid-area: label;
  align-self: start;
  color: #315a80;
  font-size: 13px;
  line-height: 1.2;
}

.metric-water-code .metric-action {
  grid-area: action;
  justify-self: end;
  align-self: start;
  height: 30px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(29, 142, 210, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #1b6d9d;
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.metric-water-code .metric-action::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  box-sizing: border-box;
}

.metric-water-code .metric-action:hover:not(:disabled) {
  background: rgba(29, 142, 210, 0.12);
  border-color: rgba(29, 142, 210, 0.34);
  box-shadow: none;
}

.metric-water-code .metric-action:disabled {
  opacity: 0.68;
  box-shadow: none;
}

.metric-water-code .metric-action[aria-busy="true"]::before {
  animation: water-code-refresh 0.8s linear infinite;
}

.metric-water-code #waterCodeText {
  grid-area: code;
  align-self: end;
  margin: 0;
  color: var(--text-strong);
  font-size: 34px;
  line-height: 0.95;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric-water-code #waterCodeRemark {
  grid-area: meta;
  justify-self: end;
  align-self: end;
  max-width: 150px;
  margin: 0 0 1px;
  padding: 5px 9px;
  border: 1px solid rgba(29, 142, 210, 0.16);
  border-radius: 999px;
  background: rgba(29, 142, 210, 0.1);
  color: #1b6d9d;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  text-align: right;
}

body.dark-theme .metric-water-code {
  border-color: rgba(82, 169, 224, 0.2);
  background:
    linear-gradient(135deg, rgba(82, 169, 224, 0.13), rgba(213, 138, 145, 0.08)),
    var(--surface);
}

body.dark-theme .metric-water-code .metric-title-row span {
  color: #9ccced;
}

body.dark-theme .metric-water-code .metric-action {
  border-color: rgba(82, 169, 224, 0.28);
  background: rgba(15, 23, 42, 0.55);
  color: #9ccced;
}

body.dark-theme .metric-water-code #waterCodeRemark {
  border-color: rgba(82, 169, 224, 0.24);
  background: rgba(82, 169, 224, 0.14);
  color: #9ccced;
}

@keyframes water-code-refresh {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 420px) {
  .metric-water-code {
    grid-template-areas:
      "label action"
      "code code"
      "meta meta";
    align-items: start;
    gap: 9px 12px;
  }

  .metric-water-code #waterCodeRemark {
    justify-self: start;
    max-width: 100%;
    text-align: left;
  }
}

@media (max-width: 560px) {
  .metric-water-code {
    min-height: 104px;
    padding: 16px;
  }

  .metric-water-code #waterCodeText {
    font-size: 30px;
  }

  .metric-water-code .metric-action {
    height: 28px;
    padding: 0 10px;
  }
}

/* Electric meter presentation for the energy dashboard. */
.meter-list {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: start;
}

.meter-card {
  min-height: 236px;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  border-color: rgba(49, 90, 128, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 247, 251, 0.96)),
    var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    0 18px 38px rgba(31, 41, 55, 0.1);
  position: relative;
  overflow: hidden;
}

.meter-card::before,
.meter-card::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #a9b7c5 58%, #6b7d90);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.24);
  top: 14px;
}

.meter-card::before {
  left: 14px;
}

.meter-card::after {
  right: 14px;
}

.meter-card:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 246, 251, 0.98)),
    var(--surface);
  border-color: rgba(29, 142, 210, 0.24);
}

.meter-shell-top {
  min-height: 28px;
  padding: 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.meter-shell-top .meter-name {
  min-width: 0;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.meter-face {
  padding: 14px;
  border: 1px solid rgba(49, 90, 128, 0.12);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(49, 90, 128, 0.08), rgba(16, 185, 129, 0.05)),
    rgba(255, 255, 255, 0.72);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 12px;
  align-items: center;
}

.meter-display {
  min-height: 76px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background:
    linear-gradient(180deg, rgba(222, 235, 224, 0.96), rgba(184, 206, 189, 0.96));
  box-shadow:
    inset 0 2px 5px rgba(15, 23, 42, 0.16),
    inset 0 -1px 0 rgba(255, 255, 255, 0.38);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.meter-display span {
  color: rgba(15, 23, 42, 0.58);
  font-size: 11px;
  font-weight: 800;
}

.meter-display strong {
  margin-top: 4px;
  color: #0b1628;
  font-family: "Consolas", "SFMono-Regular", monospace;
  font-size: 25px;
  line-height: 1.05;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.meter-dial {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 8px solid rgba(255, 255, 255, 0.74);
  background:
    conic-gradient(from -38deg, #10b981 0 72deg, #dbeafe 72deg 278deg, #f59e0b 278deg 360deg);
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.08),
    0 8px 18px rgba(15, 23, 42, 0.1);
  position: relative;
}

.meter-dial::before {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 1px 4px rgba(15, 23, 42, 0.12);
}

.meter-dial i {
  position: absolute;
  left: 50%;
  top: 16px;
  width: 3px;
  height: 24px;
  border-radius: 999px;
  background: #0f172a;
  transform: translateX(-50%) rotate(32deg);
  transform-origin: 50% 18px;
  z-index: 1;
}

.meter-dial i::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #0f172a;
  transform: translateX(-50%);
}

.meter-specs {
  display: grid;
  gap: 8px;
}

.meter-row {
  min-width: 0;
  padding: 0 2px;
  align-items: baseline;
  gap: 10px;
}

.meter-row span {
  font-size: 12px;
  font-weight: 700;
}

.meter-row strong {
  min-width: 0;
  text-align: right;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.meter-terminals {
  height: 18px;
  margin: 2px 10px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.meter-terminals i {
  border-radius: 999px 999px 4px 4px;
  background:
    linear-gradient(180deg, rgba(49, 90, 128, 0.14), rgba(49, 90, 128, 0.26));
  border: 1px solid rgba(49, 90, 128, 0.14);
}

body.dark-theme .meter-card {
  border-color: rgba(82, 169, 224, 0.2);
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.96)),
    var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 38px rgba(0, 0, 0, 0.24);
}

body.dark-theme .meter-card:hover {
  background:
    linear-gradient(180deg, rgba(21, 31, 48, 0.98), rgba(11, 18, 31, 0.98)),
    var(--surface);
}

body.dark-theme .meter-face {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.62);
}

body.dark-theme .meter-display {
  border-color: rgba(190, 230, 201, 0.2);
  background:
    linear-gradient(180deg, rgba(158, 188, 164, 0.9), rgba(112, 144, 119, 0.9));
}

@media (max-width: 560px) {
  .meter-list {
    grid-template-columns: 1fr !important;
  }

  .meter-card {
    min-height: 224px;
    padding: 15px;
  }

  .meter-face {
    grid-template-columns: minmax(0, 1fr) 58px;
  }

  .meter-dial {
    width: 54px;
    height: 54px;
    border-width: 7px;
  }

  .meter-display strong {
    font-size: 22px;
  }
}

/* Final layout polish: stable desktop sidebar and compact sync status. */
.status {
  display: flex;
  align-items: flex-start;
  min-height: 0;
  margin: 0;
}

.status:empty {
  display: none;
}

.notice {
  width: fit-content;
  max-width: min(100%, 720px);
  min-height: 0;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.055);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
}

.notice::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--text-muted);
  box-shadow: 0 0 0 4px rgba(100, 116, 139, 0.12);
}

.notice.ok,
.notice.success {
  border-color: rgba(16, 185, 129, 0.2);
  border-left: 1px solid rgba(16, 185, 129, 0.2);
  background: rgba(236, 253, 245, 0.78);
  color: #065f46;
}

.notice.ok::before,
.notice.success::before {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}

.notice.error {
  border-color: rgba(239, 68, 68, 0.22);
  border-left: 1px solid rgba(239, 68, 68, 0.22);
  background: rgba(254, 242, 242, 0.86);
  color: #991b1b;
}

.notice.error::before {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.13);
}

.notice.info {
  border-left: 1px solid rgba(29, 142, 210, 0.18);
}

body.dark-theme .notice {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(17, 24, 39, 0.76);
  color: var(--text);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

body.dark-theme .notice.ok,
body.dark-theme .notice.success {
  border-color: rgba(52, 211, 153, 0.2);
  color: #bbf7d0;
  background: rgba(6, 78, 59, 0.34);
}

body.dark-theme .notice.error {
  border-color: rgba(248, 113, 113, 0.26);
  color: #fecaca;
  background: rgba(127, 29, 29, 0.34);
}

.section-tools > span.is-synced,
.panel-head > span.is-synced {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  border-color: rgba(16, 185, 129, 0.22);
  background: rgba(236, 253, 245, 0.78);
  color: #047857;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.08);
}

.section-tools > span.is-synced::before,
.panel-head > span.is-synced::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}

body.dark-theme .section-tools > span.is-synced,
body.dark-theme .panel-head > span.is-synced {
  border-color: rgba(52, 211, 153, 0.22);
  background: rgba(6, 78, 59, 0.34);
  color: #bbf7d0;
  box-shadow: none;
}

@media (min-width: 1024px) {
  html,
  body {
    height: 100%;
  }

  body:not([data-app-locked="true"]) {
    overflow: hidden;
  }

  body:not([data-app-locked="true"]) .shell {
    width: min(1760px, calc(100vw - 32px));
    height: 100dvh;
    padding: 16px 0;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 22px;
    align-items: stretch;
  }

  body:not([data-app-locked="true"]) .app-header {
    position: sticky;
    top: 16px;
    height: calc(100dvh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 34px 24px 28px;
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    text-align: center;
  }

  body:not([data-app-locked="true"]) .app-header::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  body:not([data-app-locked="true"]) .app-header::after {
    right: -78px;
    bottom: 104px;
    width: 230px;
    height: 230px;
  }

  body:not([data-app-locked="true"]) .app-header .brand {
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
  }

  body:not([data-app-locked="true"]) .app-header .brand > div:last-child {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
  }

  body:not([data-app-locked="true"]) .app-header .brand-mark {
    width: 72px;
    height: 72px;
  }

  body:not([data-app-locked="true"]) .app-header h1 {
    font-size: 27px;
  }

  body:not([data-app-locked="true"]) .app-header .eyebrow {
    font-size: 13px;
    letter-spacing: 0;
  }

  body:not([data-app-locked="true"]) .app-header .header-subtitle {
    font-size: 14px;
  }

  body:not([data-app-locked="true"]) .quick-nav {
    width: 100%;
    margin: 10px 0 0;
    padding: 8px;
    border: 0;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.035);
    flex-direction: column;
    gap: 4px;
  }

  body.dark-theme:not([data-app-locked="true"]) .quick-nav {
    background: rgba(255, 255, 255, 0.045);
  }

  body:not([data-app-locked="true"]) .quick-nav a {
    width: 100%;
    height: 52px;
    padding: 0 12px;
    border-radius: 13px;
    justify-content: center;
    font-size: 16px;
  }

  body:not([data-app-locked="true"]) .quick-nav a.active {
    box-shadow: 0 12px 26px rgba(124, 31, 39, 0.2);
  }

  body:not([data-app-locked="true"]) .actions {
    width: 100%;
    margin-top: 4px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body:not([data-app-locked="true"]) .actions button {
    width: 100%;
    height: 46px;
    border-radius: 13px;
  }

  body:not([data-app-locked="true"]) .main-content {
    height: calc(100dvh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 0 10px 40px 0;
  }

  body:not([data-app-locked="true"]) .main-content::-webkit-scrollbar {
    width: 10px;
  }

  body:not([data-app-locked="true"]) .main-content::-webkit-scrollbar-track {
    background: transparent;
  }

  body:not([data-app-locked="true"]) .main-content::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
    background-color: rgba(100, 116, 139, 0.32);
  }

  body:not([data-app-locked="true"]) .main-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(100, 116, 139, 0.46);
  }

  body[data-route="overview"]:not([data-app-locked="true"]) .main-content {
    height: calc(100dvh - 32px);
    overflow-y: auto;
    align-content: start;
  }

  body[data-route="overview"] #status {
    align-self: start;
  }
}

@media (min-width: 1024px) and (max-height: 760px) {
  body:not([data-app-locked="true"]) .app-header {
    padding: 22px 20px;
    gap: 14px;
  }

  body:not([data-app-locked="true"]) .app-header .brand-mark {
    width: 60px;
    height: 60px;
  }

  body:not([data-app-locked="true"]) .app-header h1 {
    font-size: 24px;
  }

  body:not([data-app-locked="true"]) .quick-nav a {
    height: 44px;
  }

  body:not([data-app-locked="true"]) .actions button {
    height: 42px;
  }
}

@media (max-width: 1023px) {
  .status {
    width: 100%;
  }

  .notice {
    width: 100%;
    border-radius: 16px;
  }
}

/* Overview dashboard refresh. */
#overview.active-tab {
  align-items: stretch;
}

.overview-card {
  min-height: 166px;
  padding: 22px 24px;
  justify-content: space-between;
  gap: 16px;
  border-radius: 20px;
}

.overview-card-wide {
  grid-column: 1 / -1;
}

.overview-card-main {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.overview-card span {
  letter-spacing: 0;
}

.overview-card strong {
  margin: 0;
  font-size: clamp(31px, 2.35vw, 42px);
  line-height: 1.02;
  letter-spacing: 0;
  white-space: nowrap;
}

.overview-card small {
  max-width: 100%;
  color: #526987;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overview-detail-grid,
.overview-detail-list {
  min-width: 0;
  display: grid;
  gap: 9px;
}

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

.overview-detail-list div,
.overview-detail-grid div {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(49, 90, 128, 0.08);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.46);
}

.overview-detail-list dt,
.overview-detail-grid dt {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.overview-detail-list dd,
.overview-detail-grid dd {
  margin-top: 4px;
  color: var(--text-strong);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.overview-card-wide {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(420px, 1.18fr);
  align-items: center;
}

.overview-card.tone-sync {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(420px, 1.28fr);
  align-items: center;
  min-height: 142px;
}

.overview-card.tone-sync .overview-detail-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.overview-card.tone-sync strong {
  font-size: clamp(30px, 2.1vw, 38px);
}

.overview-card.tone-study {
  background:
    linear-gradient(135deg, rgba(124, 31, 39, 0.085), rgba(29, 142, 210, 0.055)),
    var(--surface);
}

.overview-card.tone-campus {
  background:
    linear-gradient(135deg, rgba(29, 142, 210, 0.075), rgba(16, 185, 129, 0.04)),
    var(--surface);
}

.overview-card.tone-energy {
  background:
    linear-gradient(135deg, rgba(180, 154, 90, 0.11), rgba(124, 31, 39, 0.035)),
    var(--surface);
}

.overview-card.tone-sync {
  background:
    linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(29, 142, 210, 0.04)),
    var(--surface);
}

body.dark-theme .overview-detail-list div,
body.dark-theme .overview-detail-grid div {
  border-color: rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.035);
}

body.dark-theme .overview-card small {
  color: var(--text-muted);
}

/* Account connection card refresh. */
.auth-panel {
  min-height: 0;
  border-radius: 22px;
  padding: 30px 30px 28px;
  gap: 20px;
}

.auth-panel h2 {
  font-size: 24px;
  line-height: 1.15;
}

.auth-panel > div:first-child {
  display: grid;
  gap: 14px;
}

#authStatusText {
  display: grid;
  gap: 12px;
  color: var(--text);
}

.auth-status-lede {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.2);
  background: rgba(236, 253, 245, 0.76);
  color: #047857;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
}

.auth-status-lede::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}

.auth-login-hint {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.16);
  background: rgba(254, 242, 242, 0.72);
  color: #991b1b;
  line-height: 1.55;
}

.auth-session-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-session-chip {
  min-width: 0;
  min-height: 72px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.52);
  display: grid;
  align-content: center;
  gap: 5px;
}

.auth-session-chip strong {
  color: var(--text-strong);
  font-size: 13px;
  line-height: 1.25;
}

.auth-session-chip em {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  font-style: normal;
  overflow-wrap: anywhere;
}

.auth-session-chip.ok {
  border-color: rgba(16, 185, 129, 0.22);
  background: rgba(236, 253, 245, 0.72);
}

.auth-session-chip.ok em {
  color: #047857;
}

.auth-session-chip.warn {
  border-color: rgba(245, 158, 11, 0.24);
  background: rgba(255, 251, 235, 0.76);
}

.auth-session-chip.warn em {
  color: #92400e;
}

.auth-session-chip.bad {
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(254, 242, 242, 0.76);
}

.auth-session-chip.bad em {
  color: #991b1b;
}

.auth-session-chip.idle {
  background: rgba(248, 250, 252, 0.72);
}

.auth-actions {
  justify-content: flex-start;
}

.auth-actions button {
  height: 48px;
  padding: 0 22px;
  border-radius: 14px;
}

.auth-panel .auth-note {
  margin-top: 4px;
  padding-top: 16px;
  line-height: 1.6;
}

body.dark-theme .auth-status-lede {
  border-color: rgba(52, 211, 153, 0.2);
  background: rgba(6, 78, 59, 0.34);
  color: #bbf7d0;
}

body.dark-theme .auth-login-hint {
  border-color: rgba(248, 113, 113, 0.26);
  background: rgba(127, 29, 29, 0.34);
  color: #fecaca;
}

body.dark-theme .auth-session-chip {
  background: rgba(255, 255, 255, 0.035);
}

body.dark-theme .auth-session-chip.ok {
  background: rgba(6, 78, 59, 0.3);
}

body.dark-theme .auth-session-chip.warn {
  background: rgba(120, 53, 15, 0.3);
}

body.dark-theme .auth-session-chip.bad {
  background: rgba(127, 29, 29, 0.3);
}

@media (min-width: 1024px) {
  body[data-route="overview"]:not([data-app-locked="true"]) .main-content {
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.7fr);
    gap: 22px;
  }

  body[data-route="overview"] #overview.active-tab {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 20px;
  }

  body[data-route="overview"] #authPanel.active-tab {
    align-self: start;
    min-height: 360px;
  }
}

@media (max-width: 1180px) {
  .overview-card-wide,
  .overview-card.tone-sync {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .overview-detail-grid,
  .overview-card.tone-sync .overview-detail-list {
    grid-template-columns: 1fr;
  }

  .auth-session-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) and (max-width: 1400px) {
  .auth-session-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .overview-card {
    min-height: 0;
    padding: 20px;
    border-radius: 18px;
  }

  .overview-card strong {
    font-size: 32px;
  }

  .overview-detail-list,
  .overview-detail-grid,
  .overview-card.tone-sync .overview-detail-list {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 22px;
  }
}

/* Academic page refresh: compact metrics and timetable-first schedule board. */
.academic-section .section-head {
  padding: 20px 24px;
  border: 1px solid rgba(49, 90, 128, 0.08);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(124, 31, 39, 0.055), rgba(29, 142, 210, 0.045)),
    rgba(255, 255, 255, 0.56);
  box-shadow: var(--shadow-soft);
}

.academic-section .section-head h2 {
  font-size: clamp(24px, 2.2vw, 34px);
  letter-spacing: 0;
}

.academic-controls {
  gap: 12px;
}

.academic-controls button {
  height: 44px;
  border-radius: 14px;
}

.academic-metrics {
  gap: 14px;
}

.academic-metrics .metric {
  min-height: 108px;
  padding: 18px 20px;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(248, 250, 252, 0.68)),
    var(--surface);
}

.academic-metrics .metric strong {
  margin: 8px 0 4px;
  font-size: clamp(28px, 2.1vw, 36px);
  line-height: 1;
  letter-spacing: 0;
}

.academic-metrics .metric small {
  font-size: 12px;
}

.academic-metrics .metric:nth-child(4) strong {
  font-size: clamp(22px, 1.6vw, 28px);
  line-height: 1.12;
}

.timetable-panel {
  padding: 28px;
  border-radius: 24px;
  overflow: visible;
}

.timetable-panel-head {
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 18px;
}

.timetable-title {
  min-width: 240px;
  display: grid;
  gap: 6px;
}

.timetable-title h2 {
  font-size: 24px;
  line-height: 1.15;
}

.timetable-title span {
  color: #526987;
  font-weight: 700;
}

.timetable-toolbar {
  margin-left: auto;
  display: grid;
  grid-template-columns: max-content max-content max-content minmax(220px, 1fr);
  gap: 10px;
  align-items: center;
}

.timetable-toolbar select,
.timetable-toolbar input[type="search"] {
  height: 44px;
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.86);
}

.timetable-summary {
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}

.timetable-summary-card {
  min-height: 90px;
  padding: 16px 18px;
  border-radius: 18px;
  border-color: rgba(49, 90, 128, 0.09);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(241, 245, 249, 0.72)),
    var(--surface-soft);
}

.timetable-summary-card span {
  color: #667b99;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.timetable-summary-card strong {
  margin: 6px 0 4px;
  font-size: 22px;
  line-height: 1.1;
}

.timetable-summary-card small {
  color: #526987;
  font-size: 12px;
  line-height: 1.35;
}

.timetable-grid-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  padding-bottom: 6px;
}

.semester-board {
  min-width: 1640px;
  display: grid;
  grid-template-columns: repeat(var(--day-count, 7), minmax(218px, 1fr));
  gap: 12px;
  padding: 2px;
  align-items: start;
}

.day-column {
  min-width: 0;
  min-height: 480px;
  padding: 12px;
  border-radius: 20px;
  border-color: rgba(49, 90, 128, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 250, 252, 0.58));
  gap: 12px;
  scroll-snap-align: start;
}

.day-column.today {
  background:
    linear-gradient(180deg, rgba(240, 249, 255, 0.88), rgba(250, 245, 255, 0.58));
  border-color: rgba(124, 31, 39, 0.24);
  box-shadow: inset 0 0 0 1px rgba(124, 31, 39, 0.06);
}

.day-column.selected {
  border-color: rgba(29, 142, 210, 0.28);
}

.day-column-head {
  min-height: 54px;
  padding: 0 2px 10px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 2;
  border-radius: 14px 14px 10px 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.72));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.day-column-head strong {
  font-size: 17px;
  line-height: 1.1;
}

.day-column-head span {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.day-column.today .day-column-head span {
  color: var(--hgu-maroon);
}

.day-column-head em {
  min-width: 34px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(49, 90, 128, 0.08);
  color: #526987;
  font-size: 11px;
  font-weight: 800;
}

.day-column.today .day-column-head em {
  background: rgba(124, 31, 39, 0.1);
  color: var(--hgu-maroon);
}

.day-course-list {
  gap: 10px;
}

.day-course-list .empty {
  min-height: 94px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.62);
}

.semester-course {
  --accent: #1d8ed2;
  --course-bg: rgba(29, 142, 210, 0.075);
  min-height: 96px;
  padding: 0;
  border: 1px solid rgba(49, 90, 128, 0.1);
  border-left: 0;
  border-radius: 16px;
  background: var(--course-bg);
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.045);
}

.semester-course:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  background: var(--course-bg);
}

.semester-course.tone-1 { --accent: #0ea5e9; --course-bg: rgba(14, 165, 233, 0.085); }
.semester-course.tone-2 { --accent: #10b981; --course-bg: rgba(16, 185, 129, 0.08); }
.semester-course.tone-3 { --accent: #f59e0b; --course-bg: rgba(245, 158, 11, 0.09); }
.semester-course.tone-4 { --accent: #ef4444; --course-bg: rgba(239, 68, 68, 0.075); }
.semester-course.tone-5 { --accent: #8b5cf6; --course-bg: rgba(139, 92, 246, 0.08); }
.semester-course.tone-6 { --accent: #ec4899; --course-bg: rgba(236, 72, 153, 0.075); }
.semester-course.tone-7 { --accent: #06b6d4; --course-bg: rgba(6, 182, 212, 0.08); }

.semester-course.next-course {
  border-color: rgba(16, 185, 129, 0.34);
  box-shadow: 0 12px 24px rgba(16, 185, 129, 0.12);
}

.course-time-rail {
  padding: 12px 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 18%, white), rgba(255, 255, 255, 0.38));
  border-right: 1px solid rgba(49, 90, 128, 0.08);
  display: grid;
  align-content: start;
  gap: 6px;
  text-align: center;
}

.course-time-rail strong {
  color: var(--text-strong);
  font-size: 12px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.course-time-rail span {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.course-time-rail::after {
  content: "";
  width: 8px;
  height: 8px;
  margin: 4px auto 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.semester-course-body {
  min-width: 0;
  padding: 11px 12px;
}

.semester-course-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.semester-course-main strong {
  min-width: 0;
  color: var(--text-strong);
  font-size: 14px;
  line-height: 1.28;
  font-weight: 900;
  letter-spacing: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.next-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
  font-size: 10px;
  line-height: 1;
  font-style: normal;
  font-weight: 900;
}

.course-meta-line {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
}

.course-meta-line span {
  min-width: 0;
  max-width: 100%;
  color: #526987;
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-meta-line .course-location {
  color: var(--text);
  font-weight: 800;
}

.course-facts {
  margin-top: 9px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
}

.course-facts span {
  min-width: 0;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  color: #526987;
  font-size: 10px;
  line-height: 1.25;
  font-weight: 700;
}

.course-more {
  display: none;
  margin-top: 9px;
  padding-top: 8px;
}

.semester-course:hover .course-more,
.semester-course:focus-within .course-more {
  display: block;
}

.course-more summary {
  width: fit-content;
  color: #526987;
  font-size: 11px;
  font-weight: 800;
}

.course-more dl {
  margin-top: 8px;
  gap: 5px;
}

.course-more dl div {
  gap: 8px;
}

.study-secondary {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr);
}

.course-list-card,
.free-building-card {
  border-radius: 16px;
}

body.dark-theme .academic-section .section-head,
body.dark-theme .academic-metrics .metric,
body.dark-theme .timetable-summary-card,
body.dark-theme .day-column {
  background: rgba(17, 24, 39, 0.72);
}

body.dark-theme .semester-course {
  background: color-mix(in srgb, var(--accent) 18%, rgba(17, 24, 39, 0.86));
  border-color: rgba(255, 255, 255, 0.07);
}

body.dark-theme .course-time-rail {
  background: color-mix(in srgb, var(--accent) 22%, rgba(15, 23, 42, 0.7));
}

body.dark-theme .course-facts span,
body.dark-theme .day-course-list .empty {
  background: rgba(255, 255, 255, 0.045);
}

@media (max-width: 1420px) {
  .timetable-toolbar {
    grid-template-columns: max-content max-content max-content minmax(220px, 1fr);
    width: 100%;
  }

  .timetable-toolbar input[type="search"] {
    grid-column: auto;
  }

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

  .semester-board {
    min-width: 1540px;
    grid-template-columns: repeat(var(--day-count, 7), minmax(204px, 1fr));
  }
}

@media (max-width: 760px) {
  .academic-section .section-head,
  .timetable-panel {
    padding: 18px;
  }

  .academic-section .section-head h2 {
    font-size: 26px;
  }

  .timetable-panel-head {
    gap: 14px;
  }

  .timetable-title {
    min-width: 0;
  }

  .timetable-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .timetable-toolbar input[type="search"] {
    grid-column: 1 / -1;
  }

  .timetable-toolbar select,
  .timetable-toolbar input[type="search"] {
    min-width: 0;
    height: 42px;
    padding-inline: 12px;
  }

  .academic-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .academic-metrics .metric {
    min-height: 96px;
    padding: 14px;
  }

  .academic-metrics .metric strong,
  .academic-metrics .metric:nth-child(4) strong {
    font-size: 26px;
    line-height: 1.05;
  }

  .timetable-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    margin-bottom: 16px;
  }

  .timetable-summary-card:first-child {
    grid-column: 1 / -1;
  }

  .timetable-summary-card {
    min-height: 80px;
    padding: 12px;
    border-radius: 15px;
  }

  .timetable-summary-card strong {
    font-size: 18px;
  }

  .timetable-summary-card small {
    font-size: 11px;
  }

  .semester-board {
    min-width: 0;
    width: max-content;
    grid-template-columns: repeat(var(--day-count, 7), minmax(238px, 82vw));
    gap: 10px;
  }

  .study-secondary {
    grid-template-columns: 1fr;
  }

  .day-column {
    min-height: 420px;
    padding: 10px;
  }

  .semester-course {
    grid-template-columns: 54px minmax(0, 1fr);
  }
}

@media (max-width: 420px) {
  .academic-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .semester-board {
    grid-template-columns: repeat(var(--day-count, 7), minmax(236px, 86vw));
  }

  .timetable-title h2 {
    font-size: 21px;
  }

  .timetable-summary-card strong {
    font-size: 17px;
  }

  .academic-metrics .metric strong,
  .academic-metrics .metric:nth-child(4) strong {
    font-size: 23px;
  }
}

/* Final mobile shell fit: keep the sidebar controls inside the viewport. */
@media (max-width: 760px) {
  .shell {
    width: 100%;
    padding: 12px 12px 96px;
    gap: 16px;
  }

  .app-header {
    position: static;
    display: grid !important;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    padding: 18px;
    overflow: hidden;
    text-align: center;
  }

  .app-header .brand {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-width: 0;
    text-align: center;
  }

  .app-header .brand > div:last-child {
    min-width: 0;
    display: grid;
    justify-items: center;
    gap: 2px;
  }

  .app-header .brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    padding: 5px;
  }

  .app-header h1 {
    font-size: 24px;
    line-height: 1.05;
  }

  .app-header .eyebrow {
    font-size: 13px;
    letter-spacing: 0;
  }

  .app-header .header-subtitle {
    font-size: 13px;
  }

  .app-header .brand h1,
  .app-header .eyebrow,
  .app-header .header-subtitle {
    white-space: normal;
  }

  .app-header .actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-width: none;
  }

  .app-header .actions button {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 8px;
    white-space: nowrap;
  }

  .quick-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .quick-nav a {
    min-width: 0;
    padding: 0 6px;
  }
}

@media (max-width: 380px) {
  .app-header {
    padding: 16px;
  }

  .app-header .actions button {
    font-size: 12px;
    padding: 0 6px;
  }
}

/* Enhanced form controls */
.native-control-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  clip-path: inset(50%) !important;
}

.enhanced-control {
  position: relative;
  display: inline-flex;
  width: max-content;
  min-width: 0;
  max-width: 100%;
  isolation: isolate;
  flex: 0 0 auto;
  justify-self: start;
}

.control-month {
  min-width: 0;
}

.campus-controls .control-select {
  min-width: 0;
}

.free-room-controls .control-select {
  min-width: 0;
}

.timetable-toolbar .control-select {
  min-width: 0;
}

.control-trigger,
.control-trigger:hover:not(:disabled),
.control-trigger:active:not(:disabled),
.control-option,
.control-option:hover:not(:disabled),
.month-option,
.month-option:hover:not(:disabled),
.month-nav,
.month-nav:hover:not(:disabled),
.month-action,
.month-action:hover:not(:disabled) {
  transform: none;
}

.control-trigger {
  width: max-content;
  height: 44px;
  min-width: 0;
  max-width: 100%;
  padding: 0 12px 0 14px;
  border: 1px solid rgba(124, 31, 39, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.78)),
    var(--surface);
  color: var(--text-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 8px 18px rgba(31, 41, 55, 0.06);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
  line-height: 1;
}

.control-trigger:hover:not(:disabled) {
  border-color: rgba(29, 142, 210, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 249, 255, 0.84)),
    var(--surface-hover);
  color: var(--text-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 12px 24px rgba(29, 142, 210, 0.12);
}

.control-trigger:focus-visible,
.enhanced-control.is-open .control-trigger {
  border-color: rgba(29, 142, 210, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(240, 249, 255, 0.88)),
    var(--surface-hover);
  box-shadow: 0 0 0 4px rgba(29, 142, 210, 0.12), 0 12px 28px rgba(31, 41, 55, 0.1);
}

.control-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.78;
  transition: transform 0.18s ease;
  flex: 0 0 auto;
}

.enhanced-control.is-open .control-chevron {
  transform: rotate(225deg) translate(-2px, -2px);
}

.control-calendar-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border: 1.8px solid currentColor;
  border-radius: 5px;
  opacity: 0.82;
  flex: 0 0 auto;
}

.control-calendar-icon::before {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 5px;
  height: 1.8px;
  background: currentColor;
  border-radius: 999px;
}

.control-calendar-icon::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 5px 0 0 currentColor, 10px 0 0 currentColor;
}

.control-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  width: max-content;
  min-width: 0;
  max-width: min(340px, calc(100vw - 32px));
  max-height: 320px;
  overflow: auto;
  padding: 7px;
  border: 1px solid rgba(124, 31, 39, 0.13);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px) scale(0.98);
  transform-origin: top left;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.control-menu.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.control-option {
  width: auto;
  min-width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  justify-content: flex-start;
  font-weight: 750;
  text-align: left;
  white-space: nowrap;
}

.control-option:hover:not(:disabled) {
  background: rgba(29, 142, 210, 0.08);
  color: var(--text-strong);
  box-shadow: none;
}

.control-option.is-selected {
  background: linear-gradient(135deg, rgba(124, 31, 39, 0.92), rgba(29, 142, 210, 0.88));
  color: #fff;
  box-shadow: 0 8px 18px rgba(124, 31, 39, 0.16);
}

.control-option:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.month-menu {
  width: 322px;
  max-width: min(322px, calc(100vw - 32px));
  padding: 14px;
}

.month-menu-head {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.month-year {
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 850;
  text-align: center;
}

.month-nav {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.78);
  color: var(--text);
  box-shadow: none;
}

.month-nav::before {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(135deg);
}

.month-nav.next::before {
  transform: rotate(-45deg);
}

.month-nav:hover:not(:disabled) {
  border-color: rgba(29, 142, 210, 0.26);
  background: rgba(240, 249, 255, 0.9);
  color: var(--text-strong);
  box-shadow: none;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.month-option {
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  font-weight: 800;
}

.month-option:hover:not(:disabled) {
  border-color: rgba(29, 142, 210, 0.18);
  background: rgba(29, 142, 210, 0.08);
  color: var(--text-strong);
  box-shadow: none;
}

.month-option.is-current:not(.is-selected) {
  border-color: rgba(124, 31, 39, 0.2);
  color: var(--hgu-maroon);
  background: rgba(124, 31, 39, 0.055);
}

.month-option.is-selected {
  border-color: rgba(15, 23, 42, 0.08);
  background: linear-gradient(135deg, var(--hgu-maroon), #1d8ed2);
  color: #fff;
  box-shadow: 0 10px 22px rgba(124, 31, 39, 0.2);
}

.month-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.month-action {
  height: 36px;
  min-width: 80px;
  padding: 0 14px;
  border-radius: 12px;
  box-shadow: none;
  font-size: 13px;
}

.month-action.ghost {
  background: transparent;
}

.enhanced-control.is-disabled {
  opacity: 0.56;
}

body.dark-theme .control-trigger {
  border-color: rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.72)),
    var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 12px 28px rgba(0, 0, 0, 0.22);
}

body.dark-theme .control-trigger:hover:not(:disabled),
body.dark-theme .control-trigger:focus-visible,
body.dark-theme .enhanced-control.is-open .control-trigger {
  border-color: rgba(96, 165, 250, 0.38);
  background:
    linear-gradient(180deg, rgba(51, 65, 85, 0.92), rgba(15, 23, 42, 0.82)),
    var(--surface-hover);
}

body.dark-theme .control-menu {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.94);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.38);
}

body.dark-theme .control-option:hover:not(:disabled),
body.dark-theme .month-option:hover:not(:disabled),
body.dark-theme .month-nav:hover:not(:disabled) {
  background: rgba(96, 165, 250, 0.12);
}

body.dark-theme .month-nav {
  background: rgba(255, 255, 255, 0.045);
}

body.dark-theme .month-option.is-current:not(.is-selected) {
  border-color: rgba(240, 160, 166, 0.22);
  color: #fecdd3;
  background: rgba(124, 31, 39, 0.2);
}

@media (max-width: 1420px) {
  .timetable-toolbar .control-select {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .enhanced-control {
    width: 100%;
    min-width: 0;
  }

  .control-trigger {
    height: 42px;
    padding-inline: 12px;
  }

  .timetable-toolbar .control-select,
  .free-room-controls .control-select,
  .campus-controls .control-select,
  .control-month {
    min-width: 0;
  }

  .month-menu {
    width: min(322px, calc(100vw - 32px));
  }
}

/* Course list refresh */
.course-list-panel {
  display: flex;
  flex-direction: column;
  min-height: clamp(560px, 66vh, 860px);
  overflow: hidden;
}

.course-list-panel .panel-head {
  align-items: center;
  margin-bottom: 16px;
}

.course-list-panel .panel-head h2 {
  font-size: 24px;
}

.course-list-panel .panel-head span {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(29, 142, 210, 0.08);
  color: #315a80;
  font-weight: 850;
}

.course-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  grid-auto-rows: minmax(154px, auto);
  gap: 12px;
  align-content: start;
  min-height: clamp(420px, 46vh, 680px);
  max-height: clamp(520px, 62vh, 820px);
  overflow-y: auto;
  padding: 2px 8px 8px 2px;
  scrollbar-width: thin;
}

.course-list-card {
  --accent: #1d8ed2;
  min-width: 0;
  border: 1px solid rgba(49, 90, 128, 0.1);
  border-radius: 18px;
  padding: 0;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, rgba(255, 255, 255, 0.9)), rgba(255, 255, 255, 0.74)),
    var(--surface);
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(31, 41, 55, 0.055);
}

.course-list-card.tone-1 { --accent: #0ea5e9; }
.course-list-card.tone-2 { --accent: #10b981; }
.course-list-card.tone-3 { --accent: #f59e0b; }
.course-list-card.tone-4 { --accent: #ef4444; }
.course-list-card.tone-5 { --accent: #8b5cf6; }
.course-list-card.tone-6 { --accent: #ec4899; }
.course-list-card.tone-7 { --accent: #06b6d4; }

.course-list-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 11%, rgba(255, 255, 255, 0.92)), rgba(255, 255, 255, 0.82)),
    var(--surface-hover);
  box-shadow: 0 16px 34px rgba(31, 41, 55, 0.095);
}

.course-list-accent {
  padding: 16px 10px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 22%, white), rgba(255, 255, 255, 0.35));
  border-right: 1px solid rgba(49, 90, 128, 0.08);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.course-list-accent span {
  color: color-mix(in srgb, var(--accent) 70%, #0f172a);
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
}

.course-list-accent strong {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-strong);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 950;
  box-shadow: inset 0 0 0 1px rgba(49, 90, 128, 0.08);
}

.course-list-content {
  min-width: 0;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.course-list-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.course-list-title div {
  min-width: 0;
}

.course-list-title strong {
  display: block;
  margin-top: 4px;
  color: var(--text-strong);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 950;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.course-list-title > div > span {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: color-mix(in srgb, var(--accent) 72%, #526987);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 900;
}

.course-list-title em {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #315a80;
  font-size: 11px;
  line-height: 1;
  font-style: normal;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(49, 90, 128, 0.08);
}

.course-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: inherit;
}

.course-list-meta span {
  min-width: 0;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: #526987;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-session-list {
  display: grid;
  gap: 7px;
}

.course-session-list div {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "day time"
    "day place";
  gap: 2px 10px;
  padding: 9px 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 0 0 1px rgba(49, 90, 128, 0.055);
}

.course-session-list strong {
  grid-area: day;
  align-self: center;
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 950;
  white-space: nowrap;
}

.course-session-list span {
  grid-area: time;
  min-width: 0;
  color: #315a80;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-session-list em {
  grid-area: place;
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.25;
  font-style: normal;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dark-theme .course-list-panel .panel-head span {
  background: rgba(96, 165, 250, 0.14);
  color: #bfdbfe;
}

body.dark-theme .course-list-card {
  background: color-mix(in srgb, var(--accent) 14%, rgba(17, 24, 39, 0.84));
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .course-list-card:hover {
  background: color-mix(in srgb, var(--accent) 18%, rgba(17, 24, 39, 0.88));
}

body.dark-theme .course-list-accent {
  background: color-mix(in srgb, var(--accent) 22%, rgba(15, 23, 42, 0.78));
  border-right-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .course-list-accent span {
  color: #e5e7eb;
}

body.dark-theme .course-list-accent strong,
body.dark-theme .course-list-title em,
body.dark-theme .course-list-meta span,
body.dark-theme .course-session-list div {
  background: rgba(255, 255, 255, 0.055);
}

@media (min-width: 1280px) {
  .study-secondary {
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  }
}

@media (max-width: 760px) {
  .course-list-panel {
    min-height: 0;
  }

  .course-list {
    grid-template-columns: 1fr;
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .course-list-card {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .course-list-accent {
    padding-inline: 8px;
  }
}

/* Split study and free-room pages */
.academic-section .course-list-panel {
  min-height: clamp(460px, 48vh, 720px);
}

.academic-section .course-list {
  min-height: clamp(320px, 34vh, 560px);
  max-height: none;
}

.rooms-section {
  min-width: 0;
}

.rooms-section .section-head {
  padding: 20px 24px;
  border: 1px solid rgba(49, 90, 128, 0.08);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(29, 142, 210, 0.065), rgba(124, 31, 39, 0.04)),
    rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-soft);
}

.rooms-section .section-head h2 {
  font-size: clamp(24px, 2.2vw, 34px);
  letter-spacing: 0;
}

.free-room-page-actions {
  gap: 12px;
}

.free-room-page-actions button {
  height: 44px;
  border-radius: 14px;
}

.free-room-page-actions span {
  max-width: min(420px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rooms-section .free-room-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: clamp(720px, calc(100dvh - 128px), 1080px);
  padding: 28px;
  border-radius: 24px;
  overflow: visible;
}

.rooms-section .free-room-head {
  align-items: flex-start;
  margin-bottom: 0;
  gap: 18px;
}

.rooms-section .free-room-head > div:first-child {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.rooms-section .free-room-head h2 {
  font-size: 24px;
  line-height: 1.15;
}

.rooms-section .free-room-head span {
  color: #526987;
  font-weight: 700;
}

.rooms-section .free-room-controls {
  margin-left: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(168px, max-content));
  gap: 10px;
  align-items: center;
}

.rooms-section .free-room-controls .control-trigger {
  min-width: 168px;
}

.rooms-section .free-section-tools {
  margin: 0;
  padding: 18px;
  border-radius: 20px;
  border-color: rgba(49, 90, 128, 0.09);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(241, 245, 249, 0.72)),
    var(--surface-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
}

.rooms-section .free-section-tools .field-label {
  margin-bottom: 10px;
  color: #526987;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.rooms-section .free-section-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
}

.rooms-section .section-chip {
  min-width: 0;
  min-height: 72px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  justify-content: center;
  gap: 4px;
}

.rooms-section .section-chip:hover {
  border-color: rgba(29, 142, 210, 0.28);
  background: rgba(240, 249, 255, 0.84);
}

.rooms-section .section-chip input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #1d8ed2;
}

.rooms-section .section-chip span {
  color: #315a80;
  font-size: 13px;
  font-weight: 900;
}

.rooms-section .section-chip small {
  color: #526987;
  font-size: 11px;
  font-weight: 700;
}

.rooms-section .section-chip.active {
  border-color: rgba(29, 142, 210, 0.46);
  background:
    linear-gradient(135deg, rgba(29, 142, 210, 0.14), rgba(16, 185, 129, 0.08)),
    rgba(240, 249, 255, 0.92);
  box-shadow: 0 10px 22px rgba(29, 142, 210, 0.12);
}

.rooms-section .section-chip.active span {
  color: var(--text-strong);
}

.rooms-section .free-section-presets {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 8px;
}

.rooms-section .free-section-presets button {
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 850;
}

.rooms-section .free-room-summary {
  margin: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.rooms-section .free-room-summary .metric {
  min-height: 128px;
  padding: 20px;
  border-radius: 20px;
}

.rooms-section .free-room-summary .metric strong {
  margin: 8px 0 4px;
  font-size: clamp(28px, 2.1vw, 38px);
  line-height: 1.05;
}

.rooms-section .free-room-summary .metric:nth-child(4) strong {
  font-size: clamp(22px, 1.55vw, 30px);
  line-height: 1.12;
}

.rooms-section .free-room-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  grid-auto-rows: max-content;
  gap: 16px;
  align-content: start;
  flex: 1 1 auto;
  min-height: clamp(360px, 38vh, 680px);
  max-height: none;
  overflow: visible;
  padding: 0;
}

.rooms-section .free-room-list > .empty {
  grid-column: 1 / -1;
  min-height: 260px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(241, 245, 249, 0.56)),
    var(--surface-soft);
}

.rooms-section .free-building-card {
  min-width: 0;
  min-height: 190px;
  padding: 18px;
  border-radius: 20px;
  border-color: rgba(49, 90, 128, 0.1);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(248, 250, 252, 0.72)),
    var(--surface);
  box-shadow: 0 10px 24px rgba(31, 41, 55, 0.055);
}

.rooms-section .free-building-card:hover {
  transform: translateY(-2px);
  border-color: rgba(29, 142, 210, 0.28);
  box-shadow: 0 16px 34px rgba(31, 41, 55, 0.09);
}

.rooms-section .free-building-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding-bottom: 12px;
}

.rooms-section .free-building-head > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.rooms-section .free-building-head > div:last-child {
  min-width: 76px;
  justify-items: end;
  text-align: right;
}

.rooms-section .free-building-head strong {
  min-width: 0;
  color: var(--text-strong);
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.rooms-section .free-building-head > div:last-child strong {
  font-size: 22px;
  line-height: 1;
}

.rooms-section .free-building-head span {
  color: #526987;
  font-size: 12px;
  font-weight: 750;
}

.rooms-section .free-room-chip-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}

.rooms-section .free-room-chip {
  min-width: 0;
  min-height: 56px;
  padding: 8px 9px;
  border-radius: 13px;
  align-items: flex-start;
  justify-content: center;
  background: rgba(240, 249, 255, 0.78);
  border-color: rgba(29, 142, 210, 0.16);
}

.rooms-section .free-room-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(29, 142, 210, 0.34);
  box-shadow: 0 8px 18px rgba(29, 142, 210, 0.12);
}

.rooms-section .free-room-chip strong {
  max-width: 100%;
  color: var(--text-strong);
  font-size: 14px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rooms-section .free-room-chip em {
  max-width: 100%;
  color: #526987;
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dark-theme .rooms-section .section-head,
body.dark-theme .rooms-section .free-section-tools,
body.dark-theme .rooms-section .section-chip,
body.dark-theme .rooms-section .free-room-list > .empty,
body.dark-theme .rooms-section .free-building-card {
  background: rgba(17, 24, 39, 0.72);
  border-color: rgba(255, 255, 255, 0.08);
}

body.dark-theme .rooms-section .free-room-head span,
body.dark-theme .rooms-section .free-section-tools .field-label,
body.dark-theme .rooms-section .section-chip small,
body.dark-theme .rooms-section .free-building-head span,
body.dark-theme .rooms-section .free-room-chip em {
  color: #bfdbfe;
}

body.dark-theme .rooms-section .section-chip:hover,
body.dark-theme .rooms-section .section-chip.active,
body.dark-theme .rooms-section .free-room-chip {
  background: rgba(96, 165, 250, 0.11);
}

body.dark-theme .rooms-section .section-chip span {
  color: #e5e7eb;
}

@media (max-width: 1180px) {
  .rooms-section .free-room-head,
  .rooms-section .free-section-tools {
    grid-template-columns: 1fr;
  }

  .rooms-section .free-room-controls {
    width: 100%;
    margin-left: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rooms-section .free-room-controls .enhanced-control,
  .rooms-section .free-room-controls .control-trigger {
    width: 100%;
    min-width: 0;
  }

  .rooms-section .free-section-presets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .rooms-section .section-head,
  .rooms-section .free-room-panel {
    padding: 18px;
  }

  .rooms-section .section-head h2,
  .rooms-section .free-room-head h2 {
    font-size: 26px;
  }

  .rooms-section .free-room-panel {
    min-height: 0;
    gap: 16px;
  }

  .rooms-section .free-room-controls,
  .rooms-section .free-section-tools,
  .rooms-section .free-section-presets,
  .rooms-section .free-room-summary {
    grid-template-columns: 1fr !important;
  }

  .rooms-section .free-section-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rooms-section .free-room-summary .metric {
    min-height: 104px;
    padding: 16px;
  }

  .rooms-section .free-room-summary .metric strong,
  .rooms-section .free-room-summary .metric:nth-child(4) strong {
    font-size: 26px;
  }

  .rooms-section .free-room-list {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .rooms-section .free-room-chip-list {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  }

  .quick-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .quick-nav a {
    font-size: 11px;
    padding: 0 4px;
  }
}

/* CSP-safe timetable column counts */
.semester-board.day-count-1 { grid-template-columns: repeat(1, minmax(218px, 1fr)); }
.semester-board.day-count-2 { grid-template-columns: repeat(2, minmax(218px, 1fr)); }
.semester-board.day-count-3 { grid-template-columns: repeat(3, minmax(218px, 1fr)); }
.semester-board.day-count-4 { grid-template-columns: repeat(4, minmax(218px, 1fr)); }
.semester-board.day-count-5 { grid-template-columns: repeat(5, minmax(218px, 1fr)); }
.semester-board.day-count-6 { grid-template-columns: repeat(6, minmax(218px, 1fr)); }
.semester-board.day-count-7 { grid-template-columns: repeat(7, minmax(218px, 1fr)); }

@media (max-width: 1420px) {
  .semester-board.day-count-1 { grid-template-columns: repeat(1, minmax(204px, 1fr)); }
  .semester-board.day-count-2 { grid-template-columns: repeat(2, minmax(204px, 1fr)); }
  .semester-board.day-count-3 { grid-template-columns: repeat(3, minmax(204px, 1fr)); }
  .semester-board.day-count-4 { grid-template-columns: repeat(4, minmax(204px, 1fr)); }
  .semester-board.day-count-5 { grid-template-columns: repeat(5, minmax(204px, 1fr)); }
  .semester-board.day-count-6 { grid-template-columns: repeat(6, minmax(204px, 1fr)); }
  .semester-board.day-count-7 { grid-template-columns: repeat(7, minmax(204px, 1fr)); }
}

@media (max-width: 760px) {
  .semester-board.day-count-1 { grid-template-columns: repeat(1, minmax(238px, 82vw)); }
  .semester-board.day-count-2 { grid-template-columns: repeat(2, minmax(238px, 82vw)); }
  .semester-board.day-count-3 { grid-template-columns: repeat(3, minmax(238px, 82vw)); }
  .semester-board.day-count-4 { grid-template-columns: repeat(4, minmax(238px, 82vw)); }
  .semester-board.day-count-5 { grid-template-columns: repeat(5, minmax(238px, 82vw)); }
  .semester-board.day-count-6 { grid-template-columns: repeat(6, minmax(238px, 82vw)); }
  .semester-board.day-count-7 { grid-template-columns: repeat(7, minmax(238px, 82vw)); }
}

@media (max-width: 420px) {
  .semester-board.day-count-1 { grid-template-columns: repeat(1, minmax(236px, 86vw)); }
  .semester-board.day-count-2 { grid-template-columns: repeat(2, minmax(236px, 86vw)); }
  .semester-board.day-count-3 { grid-template-columns: repeat(3, minmax(236px, 86vw)); }
  .semester-board.day-count-4 { grid-template-columns: repeat(4, minmax(236px, 86vw)); }
  .semester-board.day-count-5 { grid-template-columns: repeat(5, minmax(236px, 86vw)); }
  .semester-board.day-count-6 { grid-template-columns: repeat(6, minmax(236px, 86vw)); }
  .semester-board.day-count-7 { grid-template-columns: repeat(7, minmax(236px, 86vw)); }
}

#themeToggleButton {
  width: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 999px;
  font-size: 0;
  display: grid;
  place-items: center;
}

#themeToggleButton::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: inset -6px -4px 0 0 rgba(255, 255, 255, 0.9);
}

body.dark-theme #themeToggleButton::before {
  width: 16px;
  height: 16px;
  background: currentColor;
  box-shadow:
    0 -11px 0 -7px currentColor,
    0 11px 0 -7px currentColor,
    11px 0 0 -7px currentColor,
    -11px 0 0 -7px currentColor,
    8px 8px 0 -7px currentColor,
    -8px -8px 0 -7px currentColor,
    8px -8px 0 -7px currentColor,
    -8px 8px 0 -7px currentColor;
}

/* Mobile ergonomics refresh: compact shell, readable type, resilient controls. */
@media (max-width: 760px) {
  :root {
    --mobile-page-x: 14px;
    --mobile-nav-height: 66px;
    --mobile-card-radius: 20px;
  }

  html {
    scroll-padding-top: 0;
  }

  body {
    background-attachment: scroll;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  body:not([data-app-locked="true"]) .shell {
    width: 100%;
    padding: 10px var(--mobile-page-x) calc(var(--mobile-nav-height) + 24px + env(safe-area-inset-bottom, 0px));
    gap: 14px;
  }

  body[data-app-locked="true"] .shell {
    min-height: 100dvh;
    width: 100%;
    padding: 20px var(--mobile-page-x);
    display: grid;
    place-items: center;
  }

  body[data-app-locked="true"] #appGate {
    width: min(100%, 390px);
    margin: 0 auto;
    padding: 28px 22px 24px;
    border-radius: 24px;
    gap: 18px;
  }

  .gate-logo {
    width: 76px;
    height: 76px;
  }

  .main-content {
    gap: 16px;
    margin-top: 0;
  }

  .app-section.active-tab,
  #authPanel.active-tab {
    gap: 16px;
  }

  .app-header {
    position: sticky;
    top: 8px;
    z-index: 90;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    padding: 18px 16px 16px;
    border-radius: 22px;
    overflow: hidden;
    text-align: center;
    box-shadow: 0 12px 30px rgba(31, 41, 55, 0.1);
  }

  .app-header .brand {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 44px;
    text-align: center;
  }

  .app-header .brand > div:last-child {
    min-width: 0;
    display: grid;
    justify-items: center;
    gap: 2px;
  }

  .app-header .brand-mark {
    width: 54px;
    height: 54px;
    flex: 0 0 auto;
    padding: 5px;
  }

  .app-header h1 {
    font-size: 24px;
    line-height: 1.08;
  }

  .app-header .eyebrow,
  .app-header .header-subtitle {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app-header .eyebrow {
    font-size: 12px;
    letter-spacing: 0;
  }

  .app-header .header-subtitle {
    font-size: 13px;
  }

  .app-header .actions {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    max-width: none;
    position: static;
  }

  .app-header .actions button,
  button,
  input[type="text"],
  input[type="password"],
  input[type="search"],
  input[type="month"],
  select,
  .control-trigger {
    min-height: 42px;
    border-radius: 13px;
    font-size: 14px;
  }

  .app-header .actions button {
    width: 100%;
    min-width: 0;
    padding: 0 10px;
  }

  #themeToggleButton {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 0;
    color: #526987;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(49, 90, 128, 0.12);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.88),
      0 8px 18px rgba(31, 41, 55, 0.08);
  }

  #themeToggleButton::before {
    content: "";
    width: 17px;
    height: 17px;
    border-radius: 999px;
    background: currentColor;
    box-shadow: inset -6px -4px 0 0 rgba(255, 255, 255, 0.9);
  }

  body.dark-theme #themeToggleButton {
    color: #fde68a;
    background: rgba(15, 23, 42, 0.68);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  }

  body.dark-theme #themeToggleButton::before {
    width: 15px;
    height: 15px;
    background: currentColor;
    box-shadow:
      0 -10px 0 -6px currentColor,
      0 10px 0 -6px currentColor,
      10px 0 0 -6px currentColor,
      -10px 0 0 -6px currentColor,
      7px 7px 0 -6px currentColor,
      -7px -7px 0 -6px currentColor,
      7px -7px 0 -6px currentColor,
      -7px 7px 0 -6px currentColor;
  }

  #refreshButton {
    width: min(100%, 260px);
    justify-self: center;
  }

  .quick-nav {
    position: fixed;
    z-index: 120;
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    padding: 6px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(124, 31, 39, 0.12);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  body.dark-theme .quick-nav {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  }

  .quick-nav a {
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 3px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0;
  }

  .quick-nav a.active {
    box-shadow: 0 10px 22px rgba(124, 31, 39, 0.22);
  }

  .section-head,
  .academic-section .section-head,
  .rooms-section .section-head {
    padding: 18px;
    border-radius: 22px;
    gap: 14px;
    align-items: flex-start;
  }

  .section-head h2,
  .academic-section .section-head h2,
  .rooms-section .section-head h2 {
    font-size: 28px;
    line-height: 1.12;
    letter-spacing: 0;
    overflow-wrap: anywhere;
  }

  .eyebrow {
    letter-spacing: 0;
    text-transform: none;
  }

  .section-tools,
  .timetable-toolbar,
  .free-room-controls,
  .identity-code-actions,
  .identity-face-actions {
    gap: 8px;
  }

  .section-tools > *,
  .timetable-toolbar > *,
  .free-room-controls > *,
  .identity-code-actions > *,
  .identity-face-actions > *,
  .enhanced-control,
  .control-trigger {
    width: 100%;
    min-width: 0;
    justify-self: stretch;
  }

  .academic-controls,
  .free-room-page-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .academic-controls button,
  .free-room-page-actions button {
    height: 42px;
    border-radius: 13px;
  }

  .academic-controls > span,
  .free-room-page-actions > span,
  .section-tools > span,
  .panel-head > span {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 999px;
    line-height: 1.2;
    white-space: normal;
  }

  .campus-controls,
  .energy-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .campus-controls span,
  .energy-controls span,
  .timetable-toolbar input[type="search"] {
    grid-column: 1 / -1;
  }

  .energy-controls .control-month {
    grid-column: 1 / -1;
  }

  .campus-controls button,
  .energy-controls button {
    width: 100%;
  }

  .panel,
  .metric,
  .overview-card,
  .auth-panel,
  .notice {
    border-radius: var(--mobile-card-radius);
  }

  .panel,
  .auth-panel {
    padding: 18px;
  }

  .panel-head {
    gap: 10px;
    margin-bottom: 16px;
    align-items: flex-start;
  }

  .panel-head h2 {
    font-size: 18px;
    line-height: 1.2;
  }

  .metric {
    min-height: 104px;
    padding: 16px;
    justify-content: space-between;
  }

  .metric span,
  .overview-card span {
    font-size: 12px;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
  }

  .metric strong {
    margin: 8px 0 4px;
    font-size: 28px;
    line-height: 1.05;
    letter-spacing: 0;
  }

  .metric small,
  .overview-card small,
  .panel-head > span,
  .notice {
    font-size: 12px;
  }

  #overview.active-tab {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .overview-card {
    min-height: 0;
    padding: 18px;
    gap: 14px;
  }

  .overview-card strong {
    white-space: normal;
    font-size: 30px;
    line-height: 1.06;
  }

  .overview-detail-grid,
  .overview-detail-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .overview-detail-grid div,
  .overview-detail-list div {
    min-width: 0;
    padding: 10px 12px;
    border-radius: 14px;
  }

  .timetable-panel,
  .rooms-section .free-room-panel {
    padding: 16px;
    border-radius: 22px;
  }

  .timetable-panel-head,
  .rooms-section .free-room-head {
    gap: 14px;
  }

  .timetable-title h2,
  .rooms-section .free-room-head h2 {
    font-size: 22px;
  }

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

  .timetable-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .timetable-summary-card {
    min-height: 78px;
    padding: 12px;
    border-radius: 16px;
  }

  .timetable-summary-card strong {
    font-size: 18px;
  }

  .timetable-grid-wrap {
    margin-inline: -2px;
    padding: 2px 0 12px;
  }

  .semester-board {
    min-width: 0;
    width: max-content;
    gap: 10px;
    grid-template-columns: repeat(var(--day-count, 7), minmax(292px, 82vw));
  }

  .day-column {
    min-height: 360px;
    padding: 10px;
    border-radius: 18px;
  }

  .day-column-head {
    min-height: 48px;
  }

  .semester-course {
    min-height: 92px;
    grid-template-columns: 50px minmax(0, 1fr);
    border-radius: 15px;
  }

  .semester-course-body {
    padding: 10px;
  }

  .course-time-rail {
    padding: 10px 6px;
  }

  .course-list {
    gap: 10px;
  }

  .course-list-card {
    grid-template-columns: 56px minmax(0, 1fr);
    border-radius: 18px;
  }

  .course-list-content {
    padding: 14px 12px 13px;
  }

  .course-list-title {
    gap: 8px;
  }

  .course-list-title strong {
    font-size: 16px;
  }

  .course-list-title em {
    padding: 5px 8px;
  }

  .rooms-section .free-section-tools {
    padding: 14px;
    border-radius: 18px;
  }

  .rooms-section .free-section-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .rooms-section .section-chip {
    min-height: 66px;
    border-radius: 14px;
  }

  .rooms-section .free-section-presets {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  .rooms-section .free-section-presets button {
    min-height: 38px;
    padding: 0 8px;
  }

  .rooms-section .free-room-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .rooms-section .free-room-summary .metric:nth-child(4) {
    grid-column: 1 / -1;
  }

  .rooms-section .free-room-summary .metric {
    min-height: 98px;
    padding: 15px;
  }

  .rooms-section .free-room-list {
    gap: 12px;
  }

  .rooms-section .free-building-card {
    min-height: 0;
    padding: 16px;
    border-radius: 18px;
  }

  .rooms-section .free-building-head {
    gap: 10px;
  }

  .rooms-section .free-room-chip-list {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 7px;
  }

  .rooms-section .free-room-chip {
    min-height: 54px;
    border-radius: 13px;
  }

  .identity-card-panel {
    gap: 16px;
  }

  .campus-id-card {
    padding: 18px;
    gap: 16px;
    border-radius: 22px;
  }

  .campus-id-card-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
  }

  .campus-id-card-top strong {
    font-size: 27px;
  }

  .campus-id-avatar {
    width: 72px;
    height: 92px;
  }

  .campus-id-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
    padding-top: 14px;
  }

  .campus-id-facts div {
    padding: 9px 10px;
  }

  .campus-id-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
  }

  .campus-id-code-panel {
    padding: 14px;
    border-radius: 18px;
  }

  .campus-id-code-head {
    gap: 10px;
  }

  .identity-code-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .identity-code-actions button {
    min-width: 0;
    padding: 0 8px;
  }

  .identity-code-stage {
    min-height: 164px;
    padding: 14px;
  }

  .identity-face-layout {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }

  .identity-face-photo-frame {
    width: 104px;
    height: 136px;
  }

  .identity-face-details {
    min-width: 0;
  }

  .identity-face-details div {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 8px;
  }

  .accommodation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .accommodation-grid div,
  .roommate-card {
    border-radius: 14px;
  }

  .workspace,
  .energy-workspace {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .scroll-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .bill-list {
    gap: 8px;
  }

  .bill-card,
  .package-card {
    margin-bottom: 0;
    padding: 13px 14px;
    border-radius: 15px;
  }

  .bill-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
  }

  .bill-row span,
  .bill-row strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .identity {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .identity div {
    border-radius: 16px;
    padding: 14px 16px;
  }

  .meter-card {
    border-radius: 18px;
  }

  .notice {
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
  }

  .empty {
    min-height: 88px;
    padding: 20px 14px;
    border-radius: 16px;
    display: grid;
    place-items: center;
  }

  .overview-card:hover,
  .metric:hover,
  .panel:hover,
  .course-list-card:hover,
  .rooms-section .free-building-card:hover,
  .semester-course:hover {
    transform: none;
  }
}

@media (max-width: 420px) {
  body:not([data-app-locked="true"]) .shell {
    --mobile-page-x: 12px;
  }

  .section-head h2,
  .academic-section .section-head h2,
  .rooms-section .section-head h2 {
    font-size: 25px;
  }

  .quick-nav a {
    height: 42px;
    font-size: 11px;
  }

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

  .app-header .actions button {
    font-size: 13px;
  }

  .academic-metrics,
  .timetable-summary,
  .rooms-section .free-room-summary,
  .campus-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .semester-board {
    grid-template-columns: repeat(var(--day-count, 7), minmax(280px, 84vw));
  }

  .campus-id-card-top,
  .campus-id-footer,
  .identity-face-layout {
    grid-template-columns: 1fr;
  }

  .campus-id-avatar,
  .identity-face-photo-frame {
    justify-self: start;
  }

  .campus-id-facts,
  .accommodation-grid {
    grid-template-columns: 1fr !important;
  }

  .metric-water-code {
    grid-template-areas:
      "label"
      "action"
      "code"
      "meta";
    grid-template-columns: 1fr;
  }

  .metric-water-code .metric-action,
  .metric-water-code #waterCodeRemark {
    justify-self: start;
  }
}

/* Mobile control refinements: keep icons compact and action rows untangled. */
@media (max-width: 760px) {
  .section-tools,
  .timetable-toolbar,
  .free-room-controls,
  .identity-code-actions,
  .identity-face-actions {
    align-items: stretch;
  }

  .academic-controls,
  .free-room-page-actions {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .academic-controls > span,
  .free-room-page-actions > span,
  .section-tools > span,
  .panel-head > span {
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .academic-controls > span.is-synced,
  .free-room-page-actions > span.is-synced,
  .section-tools > span.is-synced,
  .panel-head > span.is-synced {
    justify-content: flex-start;
  }

  .campus-controls,
  .energy-controls,
  .timetable-toolbar,
  .rooms-section .free-room-controls {
    gap: 10px;
  }

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

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

  .campus-controls > span,
  .energy-controls > span {
    grid-column: 1 / -1;
  }

  .campus-controls .control-select,
  .campus-controls .control-month,
  .energy-controls .control-month,
  .timetable-toolbar .control-select,
  .free-room-controls .control-select {
    width: 100%;
    min-width: 0;
  }

  .energy-controls .control-month {
    grid-column: 1 / -1;
  }

  .control-trigger {
    height: 48px;
    min-height: 48px;
    width: 100%;
    padding: 0 14px;
    border-radius: 16px;
    border-color: rgba(124, 31, 39, 0.14);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.72)),
      var(--surface);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.88),
      0 8px 18px rgba(31, 41, 55, 0.055);
  }

  .control-trigger:hover:not(:disabled),
  .control-trigger:focus-visible,
  .enhanced-control.is-open .control-trigger {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(240, 249, 255, 0.82)),
      var(--surface-hover);
  }

  .control-trigger .control-value {
    display: block;
    width: auto;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #40556d;
    font-size: 14px;
    font-weight: 850;
    line-height: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .control-trigger .control-chevron {
    display: block;
    width: 8px;
    height: 8px;
    min-width: 8px;
    min-height: 8px;
    padding: 0;
    border: 0;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #6b7f96;
    opacity: 0.9;
    flex: 0 0 auto;
    transform: rotate(45deg);
  }

  .enhanced-control.is-open .control-chevron {
    transform: rotate(225deg) translate(-2px, -2px);
  }

  .control-trigger .control-calendar-icon {
    display: block;
    position: relative;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    padding: 0;
    border: 1.8px solid currentColor;
    border-radius: 5px;
    background: transparent;
    box-shadow: none;
    color: #6b7f96;
    opacity: 0.86;
    flex: 0 0 auto;
  }

  .control-trigger .control-calendar-icon::before {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    top: 5px;
    height: 1.8px;
    border: 0;
    background: currentColor;
    border-radius: 999px;
  }

  .control-trigger .control-calendar-icon::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 9px;
    width: 3px;
    height: 3px;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 5px 0 0 currentColor, 10px 0 0 currentColor;
  }

  .campus-controls button,
  .energy-controls button,
  .academic-controls button,
  .free-room-page-actions button {
    min-height: 48px;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 850;
  }

  .campus-controls button.ghost,
  .energy-controls button.ghost,
  .academic-controls button.ghost,
  .free-room-page-actions button.ghost {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(248, 250, 252, 0.68)),
      var(--surface);
    border-color: rgba(49, 90, 128, 0.13);
    color: var(--text-strong);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.82),
      0 8px 18px rgba(31, 41, 55, 0.05);
  }

  .campus-controls > span,
  .energy-controls > span {
    min-height: 42px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.58);
    border-color: rgba(49, 90, 128, 0.1);
    color: #40556d;
    font-weight: 760;
  }

  .campus-controls > #campusSyncText {
    min-height: 34px;
    gap: 8px;
    padding: 6px 12px;
    border-style: dashed;
    background: rgba(255, 255, 255, 0.42);
    font-size: 12px;
  }

  .campus-controls > #campusSyncText::before {
    content: "当前范围";
    color: var(--text-muted);
    font-weight: 760;
  }

  .timetable-toolbar,
  .rooms-section .free-room-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timetable-toolbar input[type="search"] {
    grid-column: 1 / -1;
  }

  .rooms-section .section-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .rooms-section .free-room-page-actions > span {
    max-width: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  body.dark-theme .control-trigger {
    background:
      linear-gradient(180deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.78)),
      var(--surface);
  }

  body.dark-theme .control-trigger .control-value,
  body.dark-theme .control-trigger .control-chevron,
  body.dark-theme .control-trigger .control-calendar-icon {
    color: #dbeafe;
  }

  body.dark-theme .campus-controls button.ghost,
  body.dark-theme .energy-controls button.ghost,
  body.dark-theme .academic-controls button.ghost,
  body.dark-theme .free-room-page-actions button.ghost {
    background: rgba(15, 23, 42, 0.62);
    border-color: rgba(255, 255, 255, 0.09);
    color: #e5e7eb;
  }

  body.dark-theme .campus-controls > span,
  body.dark-theme .energy-controls > span {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(255, 255, 255, 0.08);
    color: #bfdbfe;
  }

  body.dark-theme .campus-controls > #campusSyncText {
    background: rgba(15, 23, 42, 0.36);
  }
}

@media (max-width: 420px) {
  .app-header .actions {
    grid-template-columns: 1fr;
  }

  #themeToggleButton {
    grid-column: auto;
  }

  #refreshButton {
    grid-column: 1 / -1;
  }

  .campus-controls,
  .energy-controls,
  .timetable-toolbar,
  .rooms-section .free-room-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .campus-controls button,
  .energy-controls button,
  .campus-controls .control-select,
  .campus-controls .control-month,
  .rooms-section .free-room-controls .control-select {
    grid-column: auto;
  }

  .energy-controls .control-month,
  .campus-controls > #campusSyncText,
  .timetable-toolbar input[type="search"] {
    grid-column: 1 / -1;
  }
}

/* Header placement polish: desktop sidebar tools and compact mobile top bar. */
@media (min-width: 1024px) {
  body:not([data-app-locked="true"]) .actions {
    margin-top: auto;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
  }

  body:not([data-app-locked="true"]) #themeToggleButton {
    grid-column: 1;
    grid-row: 1;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    justify-self: start;
  }

  body:not([data-app-locked="true"]) #refreshButton {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
  }

  body:not([data-app-locked="true"]) #appLogoutButton:not([hidden]) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-header {
    gap: 8px;
    padding: 12px 14px;
    border-radius: 20px;
  }

  .app-header .brand {
    width: 100%;
    max-width: 290px;
    min-height: 50px;
    justify-self: center;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 46px;
    text-align: left;
  }

  .app-header .brand > div:last-child {
    justify-items: start;
    gap: 0;
  }

  .app-header .brand-mark {
    width: 44px;
    height: 44px;
    padding: 4px;
  }

  .app-header h1 {
    font-size: 22px;
    line-height: 1.02;
  }

  .app-header .eyebrow {
    font-size: 11px;
    line-height: 1.12;
  }

  .app-header .header-subtitle {
    font-size: 12px;
    line-height: 1.2;
  }

  .app-header .actions {
    grid-template-columns: 1fr;
    gap: 0;
  }

  #themeToggleButton {
    top: 12px;
    right: 14px;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  #refreshButton {
    width: min(100%, 230px);
    height: 40px;
    min-height: 40px;
    border-radius: 14px;
  }
}

@media (max-width: 420px) {
  .app-header {
    gap: 7px;
    padding: 10px 12px;
  }

  .app-header .brand {
    max-width: 280px;
    min-height: 46px;
    gap: 8px;
    padding: 0 40px;
  }

  .app-header .brand-mark {
    width: 40px;
    height: 40px;
  }

  .app-header h1 {
    font-size: 21px;
  }

  .app-header .eyebrow {
    font-size: 10.5px;
  }

  .app-header .header-subtitle {
    font-size: 11.5px;
  }

  #themeToggleButton {
    top: 10px;
    right: 12px;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
  }

  #refreshButton {
    width: min(100%, 220px);
    height: 38px;
    min-height: 38px;
  }
}

/* Mobile header final: one-line brand and tools. */
@media (max-width: 760px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    min-height: 58px;
    text-align: left;
  }

  .app-header .brand {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    max-width: none;
    min-height: 0;
    justify-self: stretch;
    justify-content: flex-start;
    gap: 8px;
    padding: 0;
    text-align: left;
  }

  .app-header .brand > div:last-child {
    display: block;
    min-width: 0;
  }

  .app-header .brand-mark {
    width: 34px;
    height: 34px;
    padding: 3px;
  }

  .app-header .eyebrow {
    display: block;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--hgu-maroon);
    font-size: 14px;
    line-height: 1.1;
    font-weight: 850;
  }

  .app-header h1,
  .app-header .header-subtitle {
    display: none;
  }

  .app-header .actions {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    display: grid !important;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: end;
    gap: 8px;
  }

  #refreshButton {
    grid-column: 1;
    grid-row: 1;
    width: 82px;
    min-width: 82px;
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 13px;
    font-size: 13px;
    font-weight: 850;
  }

  #themeToggleButton {
    grid-column: 2;
    grid-row: 1;
    position: static !important;
    top: auto;
    right: auto;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
  }
}

@media (max-width: 360px) {
  .app-header {
    gap: 8px;
    padding-inline: 10px;
  }

  .app-header .brand {
    gap: 6px;
  }

  .app-header .brand-mark,
  #themeToggleButton {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }

  .app-header .eyebrow {
    max-width: 112px;
    font-size: 13px;
  }

  #refreshButton {
    width: 76px;
    min-width: 76px;
    height: 32px;
    min-height: 32px;
}
}

/* 强制重置锁定（解锁前）的整体大框架布局，防止在宽屏下由于 grid 列导致页面挤压错位 */
body[data-app-locked="true"] .shell {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  padding: 24px !important;
  box-sizing: border-box !important;
  margin: 0 auto !important;
  background: transparent !important;
}

body[data-app-locked="true"] .main-content {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100% !important;
  max-width: 440px !important;
  margin: 0 !important;
  padding: 0 !important;
}

body[data-app-locked="true"] #appGate {
  margin: 0 !important;
  width: 100% !important;
  max-width: 440px !important;
  display: flex !important;
}

