/* 我的课表 - 淡蓝主题，简洁直观 */
:root {
  --bg: #EDF4FB;
  --card: #FFFFFF;
  --primary: #5B9BD5;
  --primary-d: #3A7CB8;
  --primary-l: #E8F1FA;
  --text: #2C3E50;
  --muted: #7A8BA0;
  --line: #E1EBF5;
  --danger: #D96C4F;
  --ok: #5FAE7E;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
button { font-family: inherit; }
a { color: var(--primary-d); }
.hidden { display: none !important; }

/* ---------- 顶栏 + 标签 ---------- */
.head { position: sticky; top: 0; z-index: 50; background: var(--card); box-shadow: 0 1px 4px rgba(59,124,184,.10); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.brand { font-size: 17px; font-weight: 700; color: var(--primary-d); line-height: 1.2; }
.brand small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }
.tabs { display: flex; border-top: 1px solid var(--line); }
.tab {
  flex: 1; max-width: 140px; padding: 11px 8px; border: none; background: none;
  font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary-d); font-weight: 600; border-bottom-color: var(--primary); }

main { padding: 12px; max-width: 1080px; margin: 0 auto; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--primary-d);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer; line-height: 1.3;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-d); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 周次导航 ---------- */
.week-nav {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px;
}
.wk-arrow {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--primary-d); font-size: 18px; cursor: pointer; flex: none;
}
.wk-title { font-size: 17px; font-weight: 700; }
.wk-dates { font-size: 12px; color: var(--muted); }
.wk-strip { display: flex; gap: 4px; flex-wrap: wrap; width: 100%; }
.wk-dot {
  min-width: 27px; height: 27px; padding: 0 6px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12px; cursor: pointer;
}
.wk-dot.has-class { color: var(--primary-d); border-color: #BFD9F0; background: var(--primary-l); }
.wk-dot.current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }

/* ---------- 周视图网格 ---------- */
.timetable-wrap { overflow-x: auto; background: var(--card); border-radius: 12px; padding: 10px; }
.tgrid { display: grid; grid-template-columns: 58px repeat(7, minmax(92px, 1fr)); gap: 5px; min-width: 780px; }
.tcorner { font-size: 11px; color: var(--muted); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; }
.tday { text-align: center; font-size: 13px; font-weight: 600; padding: 8px 0 4px; border-radius: 8px; }
.tday span { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.tday.today { background: var(--primary-l); color: var(--primary-d); }
.tday i { font-style: normal; font-size: 10px; background: var(--primary); color: #fff; border-radius: 8px; padding: 1px 6px; margin-left: 2px; }
.tlabels { display: flex; flex-direction: column; gap: 5px; }
.tlabel {
  border-radius: 6px; background: #F4F8FC; font-size: 10px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.1;
}
.tlabel b { font-size: 12px; color: var(--text); }
.tlabel em { font-style: normal; color: #B7C6D6; font-size: 9px; }
.tcol { position: relative; background: #F7FAFD; border-radius: 6px; }

.pblock {
  position: absolute; left: 2px; right: 2px; border-radius: 8px; padding: 5px 6px; overflow: hidden;
  cursor: pointer; border-left: 3px solid rgba(30,60,90,.18);
  box-shadow: 0 1px 3px rgba(30,60,90,.10); z-index: 1; transition: transform .08s;
}
.pblock:hover { transform: scale(1.02); z-index: 2; }
.pb-name { font-size: 12.5px; font-weight: 700; line-height: 1.3; word-break: break-all; }
.pb-meta { font-size: 10.5px; color: #46586C; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.pb-week { font-size: 9.5px; color: #5E748B; margin-top: 1px; }
.pblock.short .pb-week { display: none; }
.pblock.tiny .pb-meta { display: none; }

/* ---------- 今日视图 ---------- */
.hero-card {
  background: linear-gradient(135deg, var(--primary) 0%, #7FB5E5 100%); color: #fff;
  border-radius: 14px; padding: 18px; margin-bottom: 12px; box-shadow: 0 3px 10px rgba(59,124,184,.25);
}
.hero-date { font-size: 14px; opacity: .94; }
.hero-cd { font-size: 20px; font-weight: 700; margin-top: 6px; line-height: 1.4; }
.tclass {
  display: flex; gap: 12px; background: var(--card); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; align-items: center;
}
.tclass.done { opacity: .55; }
.tc-time { min-width: 86px; text-align: center; }
.tc-time b { display: block; font-size: 13px; }
.tc-time span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.tc-badge { display: inline-block; font-size: 10px; border-radius: 8px; padding: 1px 8px; margin-top: 4px; }
.bg-done { background: #EEF2F6; color: #9AA9BB; }
.bg-now { background: #E3F4E8; color: var(--ok); }
.bg-up { background: var(--primary-l); color: var(--primary-d); }
.tc-info { flex: 1; min-width: 0; }
.tc-name { font-size: 15px; font-weight: 700; }
.tc-meta { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.tclass-empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }

/* ---------- 其他课程 ---------- */
.extra-card {
  background: var(--card); border-radius: 12px; padding: 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px; cursor: pointer; border: none; width: 100%; text-align: left;
}
.extra-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.extra-name { font-weight: 700; font-size: 15px; }
.extra-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.extra-week-badge { margin-left: auto; font-size: 11px; background: #FFF6E5; color: #C79A3B; border-radius: 10px; padding: 2px 10px; flex: none; }

/* ---------- 通用面板 ---------- */
.panel { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.panel h2 { font-size: 16px; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.6; }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,45,60,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: 88vh;
  overflow-y: auto; padding: 18px; box-shadow: 0 10px 40px rgba(30,45,60,.25);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.modal-head h3 { font-size: 17px; }
.modal-close { border: none; background: none; font-size: 22px; color: var(--muted); cursor: pointer; padding: 4px; }
.field { margin: 10px 0; }
.field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; background: #FBFDFF; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #BFD9F0; border-color: var(--primary); }
.field textarea { min-height: 52px; resize: vertical; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

.slot-row { border: 1px dashed #C9DCEF; border-radius: 10px; padding: 10px; margin: 8px 0; background: #FAFCFE; }
.slot-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.slot-head b { font-size: 13px; color: var(--primary-d); }
.sl-del { border: none; background: none; color: var(--danger); font-size: 12px; cursor: pointer; }
.weeks-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.weeks-grid label {
  font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 3px;
  background: #F2F7FC; border-radius: 6px; padding: 2px 7px; border: 1px solid var(--line); cursor: pointer;
}
.weeks-grid input { margin: 0; }
.color-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.sw.on { border-color: #2C3E50; }

.qk-panel { border: 1px solid #FFE1B8; background: #FFF8EE; border-radius: 10px; padding: 10px; margin-top: 12px; }
.qk-panel h4 { font-size: 13px; color: #B07A2E; margin-bottom: 6px; }
.scope-radios { display: flex; gap: 12px; font-size: 13px; margin: 6px 0; flex-wrap: wrap; }
.scope-radios label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.qk-hint { font-size: 11px; color: #B07A2E; margin-bottom: 4px; }

.modal-actions { display: flex; gap: 10px; margin-top: 16px; position: sticky; bottom: -18px; background: #fff; padding: 12px 0 6px; }
.modal-actions .btn { flex: 1; padding: 11px; }

/* ---------- 导入 ---------- */
.dropzone {
  border: 2px dashed var(--primary); border-radius: 12px; padding: 28px 16px; text-align: center;
  cursor: pointer; margin: 12px 0; background: #FBFDFF;
}
.dropzone.drag { background: var(--primary-l); }
.dz-icon { font-size: 34px; }
.dropzone p { margin-top: 6px; font-size: 14px; }
.parse-status {
  background: var(--primary-l); border-radius: 10px; padding: 12px; font-size: 13px;
  color: var(--primary-d); margin: 10px 0; line-height: 1.6;
}
.parse-status.err { background: #FDEEEA; color: var(--danger); }
.preview-head { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 8px; }
.preview-head h3 { font-size: 15px; }
.ptable-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.ptable th { background: #F4F8FC; color: var(--muted); font-weight: 500; padding: 8px 6px; white-space: nowrap; text-align: left; }
.ptable td { padding: 6px; border-top: 1px solid var(--line); }
.ptable input, .ptable select { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 7px; font-size: 13px; background: #FBFDFF; }
.ptable input.pv-name { min-width: 110px; }
.ptable input.pv-teacher, .ptable input.pv-loc { min-width: 80px; }
.ptable input.pv-wk { min-width: 110px; }
.ptable .pv-del { border: none; background: none; color: var(--danger); font-size: 14px; cursor: pointer; padding: 4px; }
.import-mode { display: flex; gap: 16px; margin: 14px 0; font-size: 14px; }
.pv-periods-note { background: #F2F8FD; border: 1px solid #C9DCEF; border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.import-mode label { display: flex; align-items: center; gap: 5px; cursor: pointer; }

/* ---------- 设置 ---------- */
.settings-btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.settings-btn-row .btn { flex: 1; min-width: 120px; }
.periods-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.periods-table th { background: #F4F8FC; color: var(--muted); font-weight: 500; padding: 7px 6px; }
.periods-table td { padding: 5px 6px; border-top: 1px solid var(--line); }
.periods-table input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.p-del { border: none; background: none; color: var(--danger); font-size: 14px; cursor: pointer; padding: 4px; }

/* ---------- 帮助页 ---------- */
.help-ol { margin: 6px 0 0 18px; font-size: 13px; line-height: 1.9; }
.help-detail summary { font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text); list-style-position: inside; }
.help-detail .muted { margin-top: 6px; }
.help-detail[open] summary { color: var(--primary-d); margin-bottom: 2px; }

/* ---------- 欢迎页（首次访问） ---------- */
.welcome {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.welcome-card {
  background: #fff; border-radius: 18px; padding: 26px 22px; max-width: 420px; width: 100%;
  box-shadow: 0 10px 40px rgba(30,45,60,.15); text-align: center;
}
.welcome-card h2 { font-size: 19px; margin-bottom: 8px; color: var(--primary-d); }
.welcome-card .muted { margin-bottom: 18px; }
.welcome-card .btn { display: block; width: 100%; margin-bottom: 10px; padding: 12px; }

/* ---------- Toast ---------- */
#toast-root {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 999;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(92vw, 520px); pointer-events: none;
}
.toast {
  background: #33475B; color: #fff; border-radius: 20px; padding: 10px 18px;
  font-size: 13px; max-width: 100%; box-shadow: 0 4px 16px rgba(0,0,0,.2); animation: toastin .25s; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* ---------- 添加到主屏幕引导 ---------- */
.install-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; background: #fff;
  border-radius: 16px 16px 0 0; box-shadow: 0 -4px 20px rgba(30,45,60,.15);
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
}
.install-banner h4 { font-size: 15px; margin-bottom: 8px; }
.install-banner ol { margin: 0 0 10px 18px; font-size: 13px; line-height: 1.9; }
.install-banner .ib-actions { display: flex; gap: 10px; }
.install-banner .btn { flex: 1; }

/* ---------- 手机端 ---------- */
@media (max-width: 640px) {
  main { padding: 8px; }
  .topbar { padding: 8px 12px; }
  .brand { font-size: 16px; }
  .hero-cd { font-size: 17px; }
  .wk-strip { max-height: 84px; overflow-y: auto; }
  .modal { padding: 14px; }
  .field-row { flex-direction: column; gap: 0; }
}
