:root {
  --primary: #0e9f6e;
  --primary-deep: #0b7a55;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --text: #1c2530;
  --muted: #7b8794;
  --border: #e6ebf0;
  --danger: #e5484d;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, .10);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

button, input, select { font-family: inherit; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 400px at 50% -120px, rgba(14, 159, 110, .10), transparent 70%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 56px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand .logo { width: 28px; height: 28px; color: var(--primary); }
.brand h1 { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: .5px; }
.brand .datetime {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.weeknav { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  font-size: 20px; line-height: 1;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.nav-btn:hover { background: #f0f4f7; }
.nav-btn:active { transform: scale(.94); }

.week-label {
  min-width: 104px;
  padding: 7px 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.week-label:hover { border-color: var(--primary); color: var(--primary); }

.today-btn {
  padding: 7px 13px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.today-btn:hover { background: var(--primary-deep); }
.today-btn.dim { opacity: .55; }

.icon-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { background: #f0f4f7; color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.configured { color: var(--primary); border-color: rgba(14,159,110,.45); }

/* ---------- 星期标签 ---------- */
.daytabs {
  display: flex;
  gap: 6px;
  padding: 14px 18px 4px;
  overflow-x: auto;
}
.tab {
  flex: 1;
  min-width: 58px;
  padding: 8px 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: all .15s;
}
.tab .wn { font-size: 14px; font-weight: 600; }
.tab .wd { font-size: 10.5px; font-weight: 500; opacity: .75; }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tab.active .wd { opacity: .9; }
.tab.today:not(.active) { color: var(--primary); border-color: rgba(14,159,110,.45); background: rgba(14,159,110,.06); }

/* ---------- 容器 ---------- */
.container { max-width: 1040px; margin: 0 auto; padding: 12px 18px 24px; }

/* ---------- 周课表（桌面） ---------- */
.week-grid {
  display: grid;
  grid-template-columns: 64px repeat(5, 1fr);
  gap: 8px;
  min-width: 620px;
}
.grid-wrap { overflow-x: auto; }

.corner, .dayhead, .period {
  display: flex;
  align-items: center;
  justify-content: center;
}
.corner { font-size: 12px; color: var(--muted); }

.dayhead {
  flex-direction: column;
  gap: 2px;
  padding: 8px 4px;
  font-size: 15px; font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.dayhead .wn { font-size: 15px; font-weight: 700; }
.dayhead .wd { font-size: 11px; font-weight: 600; color: var(--muted); }
.dayhead.today .wd { color: rgba(255, 255, 255, .85); }
.dayhead.today {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(14,159,110,.25);
}

.period {
  flex-direction: column;
  padding: 6px 2px;
  font-size: 14px; font-weight: 700;
  color: var(--text);
}
.period .std-time { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }

.cell {
  position: relative;
  min-height: 74px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: box-shadow .15s, border-color .15s, transform .1s;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  animation: rise .35s ease both;
}
.cell:hover { border-color: rgba(14,159,110,.45); box-shadow: var(--shadow-md); z-index: 1; }
.cell:active { transform: scale(.985); }
.cell.empty { background: #fbfcfd; }
.cell.empty .t { opacity: .55; }

.cell .t { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.cell .plus {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px; color: #c4ccd6;
  opacity: 0;
  transition: opacity .15s;
}
.cell.empty:hover .plus { opacity: 1; }

/* 课程卡片 */
.course {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 9px;
  border-radius: 9px;
  background: var(--cBg);
  color: var(--c);
  border-left: 3px solid var(--c);
  line-height: 1.15;
  position: relative;
}
.course .c-cls { font-size: 15px; font-weight: 700; }
.course .c-loc { font-size: 12px; opacity: .82; }
.course.faded { opacity: .45; filter: saturate(.4); }

.badge {
  position: absolute;
  top: -7px; right: -6px;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.badge.in { background: var(--primary); }
.badge.out { background: #f59e0b; }

/* ---------- 单日视图（手机） ---------- */
.day-view { display: flex; flex-direction: column; gap: 10px; }

.day-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: box-shadow .15s, border-color .15s;
  animation: rise .35s ease both;
}
.day-row:active { transform: scale(.99); }

.d-time {
  flex: 0 0 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: #f6f8fa;
  border-right: 1px solid var(--border);
  border-radius: 13px 0 0 13px;
  padding: 10px 6px;
}
.d-time .dpn { font-size: 15px; font-weight: 700; color: var(--text); }
.d-time .dt { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.d-slot {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 10px 12px;
}
.d-slot .course { width: 100%; }
.d-slot .no-class { color: #c4ccd6; font-size: 14px; }

/* ---------- 提示行 ---------- */
.hint-line {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0 0;
}

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .40);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade .18s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow-md);
  max-height: 88vh;
  overflow-y: auto;
  animation: pop .2s ease;
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.modal label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.modal input[type="text"],
.modal select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  background: #fbfcfd;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.modal input:focus, .modal select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,159,110,.14); background: #fff; }

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.seg label {
  margin: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.seg input { display: none; }
.seg input:checked + span { color: var(--primary); }
.seg label:has(input:checked) { border-color: var(--primary); background: rgba(14,159,110,.08); color: var(--primary); }

.modal .hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}
.modal-actions button, .menu-item {
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: background .15s, transform .1s;
}
.modal-actions button:active, .menu-item:active { transform: scale(.97); }
.modal-actions button.primary, .menu-item.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.modal-actions button.primary:hover { background: var(--primary-deep); }
.modal-actions button.danger, .menu-item.danger { color: var(--danger); border-color: rgba(229,72,77,.35); }
.menu-item.danger:hover { background: rgba(229,72,77,.08); }

.menu-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.menu-item { width: 100%; text-align: center; }

.week-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
  margin-top: 14px;
  padding: 2px;
}
.week-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.week-item:hover { border-color: var(--primary); }
.week-item .wk-name { display: flex; align-items: center; }
.week-item .wk-today { font-size: 10px; color: var(--primary); background: rgba(14,159,110,.12); padding: 1px 6px; border-radius: 6px; margin-left: 6px; font-weight: 600; }
.week-item .wk-range { font-size: 12px; color: var(--muted); font-weight: 500; }
.week-item.active { border-color: var(--primary); background: rgba(14,159,110,.08); color: var(--primary); }
.week-item.active .wk-range { color: var(--primary); }

.swap-src {
  background: #f6f8fa;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.5;
}
.swap-src small { color: var(--muted); }

.conflict {
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(245,158,11,.10);
  border: 1px solid rgba(245,158,11,.4);
  font-size: 13px;
  line-height: 1.6;
}
.conflict button { margin-top: 8px; margin-right: 8px; }

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sync-actions button {
  flex: 1;
  min-width: 96px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: border-color .15s, color .15s;
}
.sync-actions button:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(10px);
  background: #1c2530;
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  z-index: 60;
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 动画 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- 响应式 ---------- */
@media (min-width: 768px) {
  .daytabs { display: none; }
}
@media (max-width: 767px) {
  .topbar { padding: 6px 8px; gap: 8px; }
  .brand { gap: 6px; }
  .brand .logo { width: 24px; height: 24px; }
  .brand h1 { font-size: 16px; }
  .brand .datetime { font-size: 11px; }
  .weeknav { gap: 4px; }
  .nav-btn, .icon-btn { width: 30px; height: 30px; }
  .week-label { min-width: 0; padding: 6px 7px; font-size: 13px; }
  .today-btn { padding: 6px 8px; font-size: 13px; }
  .container { padding: 8px 14px 20px; }
}
