/* 叮铃课表 - 浅色主题样式 */
:root {
  --primary: #5B8FF9;
  --primary-dark: #3a6fd9;
  --text: #1f2329;
  --text-soft: #8a9099;
  --line: #eceef1;
  --bg: #ffffff;
  --card: #ffffff;
  --danger: #ff5b5b;
  --shadow: 0 2px 12px rgba(0, 0, 0, .06);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.4;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 30px rgba(0, 0, 0, .05);
  overflow: hidden;
  /* 课表 / 周历条共用的列布局变量（媒体查询里按屏幕覆盖） */
  --time-col: 52px;
  --day-min: 46px;
  --day-cols: 7;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; background: #fff; flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; flex-direction: column; gap: 2px; }
.week-num { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.week-num span { color: var(--primary); }
.topbar .today-date { font-size: 12px; color: var(--text-soft); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.tb-btn {
  border: none; background: #f3f5f8; color: var(--text);
  height: 34px; padding: 0 12px; border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s;
}
.tb-btn:active { transform: scale(.94); }
.tb-add { width: 34px; padding: 0; font-size: 22px; line-height: 1; background: var(--primary); color: #fff; }
.tb-menu { font-size: 20px; width: 34px; padding: 0; }

/* ---------- 周历条 ---------- */
/* 周历条与下方课表网格严格按列对齐：第一列=时间列宽，其余=可见天数（1fr 等分） */
.weekstrip {
  display: grid;
  grid-template-columns: var(--time-col) repeat(var(--day-cols, 7), 1fr);
  align-items: stretch; background: #fff; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.ws-nav { display: flex; align-items: center; justify-content: center; }
.week-nav {
  border: none; background: #fff; color: var(--text-soft);
  flex: 1 1 0; min-width: 0; padding: 0; height: 100%; font-size: 18px; cursor: pointer;
}
.week-nav:active { background: #f3f5f8; }
.week-day {
  min-width: 0; text-align: center; padding: 7px 0 8px; overflow: hidden;
  cursor: pointer; border-radius: 8px; margin: 4px 2px; transition: .15s;
}
.week-day .wd-name { font-size: 12px; color: var(--text-soft); white-space: nowrap; }
.week-day .wd-date { font-size: 13px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.week-day.today { background: var(--primary); }
.week-day.today .wd-name, .week-day.today .wd-date { color: #fff; }

/* ---------- 顶栏 / 周历条 按 Tab 显隐 ---------- */
/* 课表(schedule)：完整顶栏 + 周历条（默认） */
/* 今日(today) / 待办(todo)：仅保留左上角「第 N 周 + 日期」，隐藏右侧按钮与周历条 */
#app.tab-today .topbar-right,
#app.tab-todo .topbar-right { display: none; }
#app.tab-today .weekstrip,
#app.tab-todo .weekstrip { display: none; }
/* 我的(me)：隐藏整个顶栏与周历条 */
#app.tab-me .topbar { display: none; }
#app.tab-me .weekstrip { display: none; }

/* ---------- 屏幕容器 ---------- */
.screen { flex: 1 1 auto; overflow: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.hidden { display: none !important; }

/* ---------- 课表网格 ---------- */
.grid-scroll { height: 100%; overflow: auto; }
.grid {
  display: grid; height: 100%; min-width: 0;
  grid-template-columns: var(--time-col, 52px) repeat(var(--day-cols, 7), minmax(var(--day-min, 46px), 1fr));
}

.grid-corner {
  position: sticky; top: 0; left: 0; z-index: 4;
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-soft); border-bottom: 1px solid var(--line);
}
.grid-head {
  position: sticky; top: 0; z-index: 3; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--line);
}
.section-cell {
  position: sticky; left: 0; z-index: 2; background: #fff;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2px 0;
}
.section-num { font-size: 13px; font-weight: 700; color: var(--text); }
.section-time { font-size: 9px; color: var(--text-soft); text-align: center; line-height: 1.1; white-space: pre; }

.cell-empty {
  border-right: 1px solid #f4f5f7; border-bottom: 1px solid #f4f5f7;
  cursor: pointer;
}
.cell-empty:active { background: #f7f9fc; }

.course-card {
  margin: 3px 4px; padding: 6px 7px; color: #fff; overflow: hidden;
  background-image: linear-gradient(rgba(255, 255, 255, .16), rgba(255, 255, 255, .16));
  box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
  display: flex; flex-direction: column; justify-content: center;
  cursor: pointer; transition: transform .12s;
}
.course-card:active { transform: scale(.97); }
.cc-name { font-size: 12.5px; font-weight: 800; text-shadow: 0 1px 2px rgba(0, 0, 0, .18); line-height: 1.25; overflow-wrap: anywhere; }
.cc-teacher { font-size: 10.5px; opacity: .95; margin-top: 2px; text-shadow: 0 1px 2px rgba(0, 0, 0, .18); overflow-wrap: anywhere; }
.cc-loc { font-size: 10px; opacity: .9; margin-top: 1px; text-shadow: 0 1px 2px rgba(0, 0, 0, .18); overflow-wrap: anywhere; }

/* ---------- 今日视图 ---------- */
.today-wrap { padding: 14px; }
.today-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.today-date { font-size: 18px; font-weight: 800; }
.today-tag { font-size: 12px; color: #fff; background: var(--primary); padding: 3px 10px; border-radius: 20px; }
.today-cards { display: flex; flex-direction: column; gap: 12px; }
.today-card {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  border-left: 5px solid var(--primary); cursor: pointer;
}
.tc-time { font-size: 12px; color: var(--text-soft); text-align: center; white-space: pre; flex: 0 0 52px; font-weight: 700; }
.tc-info { flex: 1; min-width: 0; }
.tc-name { font-size: 16px; font-weight: 800; }
.tc-sub { font-size: 12px; color: var(--text-soft); margin-top: 3px; }
.tc-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }

/* ---------- 待办 ---------- */
.todo-wrap { padding: 14px; position: relative; min-height: 100%; }
.todo-list { display: flex; flex-direction: column; gap: 10px; }
.todo-card { display: flex; align-items: flex-start; gap: 10px; background: var(--card); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); cursor: pointer; }
.todo-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #cfd4db; flex: 0 0 auto; margin-top: 1px; }
.todo-check.on { background: var(--primary); border-color: var(--primary); position: relative; }
.todo-check.on::after { content: '✓'; color: #fff; font-size: 12px; position: absolute; top: -1px; left: 3px; }
.todo-info { flex: 1; min-width: 0; }
.todo-title { font-size: 15px; font-weight: 700; }
.todo-card.done .todo-title { text-decoration: line-through; color: var(--text-soft); }
.todo-meta { font-size: 11px; color: var(--primary); margin-top: 3px; }
.todo-note { font-size: 12px; color: var(--text-soft); margin-top: 3px; }
.todo-del { border: none; background: transparent; color: var(--text-soft); font-size: 20px; cursor: pointer; flex: 0 0 auto; line-height: 1; }

.fab-mini {
  position: fixed; right: 18px; bottom: 78px; width: 50px; height: 50px;
  border-radius: 50%; border: none; background: var(--primary); color: #fff;
  font-size: 26px; box-shadow: 0 4px 14px rgba(91, 143, 249, .5); cursor: pointer; z-index: 20;
  max-width: calc(480px - 18px);
}

/* ---------- 我的 ---------- */
.me-wrap { padding: 16px; }
.me-card { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); cursor: pointer; }
.me-avatar { width: 58px; height: 58px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; background-size: cover; background-position: center; flex: 0 0 auto; }
.me-meta { min-width: 0; }
.me-nick { font-size: 18px; font-weight: 800; }
.me-school { font-size: 13px; color: var(--text-soft); margin-top: 3px; }
.me-group { margin-top: 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.me-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.me-row:last-child { border-bottom: none; }
.me-row:active { background: #f7f9fc; }
.me-ico { font-size: 18px; width: 24px; text-align: center; }
.me-row-t { flex: 1; }
.me-row-label { font-size: 15px; font-weight: 600; }
.me-row-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.me-arrow { color: var(--text-soft); font-size: 18px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  display: flex; align-items: stretch; background: #fff; border-top: 1px solid var(--line);
  flex: 0 0 auto; padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 0; cursor: pointer; color: var(--text-soft); }
.tab-ico { font-size: 20px; filter: grayscale(1); opacity: .6; }
.tab-txt { font-size: 11px; }
.tab.active { color: var(--primary); }
.tab.active .tab-ico { filter: none; opacity: 1; }

/* ---------- 弹窗 / 抽屉 ---------- */
#modalRoot { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex;
  align-items: center; justify-content: center; padding: 20px; pointer-events: auto;
  animation: fade .16s ease; opacity: 1;
}
.overlay.closing { opacity: 0; }
.overlay-bottom { align-items: flex-end; padding: 0; }
.panel {
  background: #fff; border-radius: 16px; width: 100%; max-width: 440px;
  max-height: 86vh; overflow: auto; padding: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
  animation: pop .18s ease;
}
.panel-bottom {
  border-radius: 18px 18px 0 0; max-width: 480px; padding-bottom: 28px;
  transform: translateY(0); animation: slideup .22s ease;
  max-height: 90vh;
}
.overlay-bottom.closing .panel-bottom { transform: translateY(100%); transition: transform .16s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.96); opacity: .6; } to { transform: scale(1); opacity: 1; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-title { font-size: 17px; font-weight: 800; }
.panel-close { border: none; background: transparent; font-size: 26px; color: var(--text-soft); cursor: pointer; line-height: 1; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--text-soft); font-weight: 600; }
.field-input {
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-size: 14px; outline: none; width: 100%; background: #fafbfc; color: var(--text);
}
.field-input:focus { border-color: var(--primary); background: #fff; }
textarea.field-input { resize: vertical; font-family: inherit; }
.field-range { width: 100%; accent-color: var(--primary); }
.switch-field { flex-direction: row; align-items: center; justify-content: space-between; }
.switch { width: 46px; height: 26px; border-radius: 20px; background: #d8dce2; position: relative; transition: .2s; flex: 0 0 auto; }
.switch.on { background: var(--primary); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch.on .switch-knob { left: 23px; }

/* 课时时间编辑 */
.slots-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.slot-row { display: flex; align-items: center; gap: 8px; }
.slot-idx { flex: 0 0 46px; font-size: 13px; color: var(--text-soft); font-weight: 600; }
.slot-time { flex: 1; min-width: 0; padding: 7px 8px; font-size: 13px; }
.slot-tilde { color: var(--text-soft); flex: 0 0 auto; }

/* 课程时间：卡片化列表 */
.time-cards { gap: 12px; }
.time-card { background: var(--card); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.tc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tc-name { font-size: 15px; font-weight: 700; color: var(--text); }
.tc-tag { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eef2f7; color: var(--text-soft); flex: 0 0 auto; }
.tc-tag.builtin { background: #eaf1ff; color: var(--primary); }
.tc-table { display: flex; flex-direction: column; gap: 3px; }
.tc-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-soft); }
.tc-i { flex: 0 0 18px; text-align: center; color: var(--text-soft); font-weight: 600; }
.tc-t { font-variant-numeric: tabular-nums; color: var(--text); }
.tc-more { font-size: 12px; color: var(--text-soft); padding-top: 2px; }
.tc-acts { display: flex; gap: 10px; margin-top: 12px; }
.tc-acts .btn { flex: 1; margin-top: 0; padding: 10px 0; }
.tc-edit-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }

.btn {
  border: none; border-radius: 10px; padding: 12px 16px; font-size: 14px;
  font-weight: 700; cursor: pointer; background: #f0f2f5; color: var(--text); transition: .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: #f0f2f5; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-block { width: 100%; margin-top: 4px; }
.form-err { color: var(--danger); font-size: 12px; min-height: 0; }

/* 颜色选择 */
.color-picker { display: flex; flex-direction: column; gap: 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.swatch.on { border-color: var(--text); transform: scale(1.1); }
.color-custom { display: flex; align-items: center; gap: 10px; }
.color-input { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; }
.color-preview { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); }
.color-custom-tip { font-size: 12px; color: var(--text-soft); }

/* 课程详情 */
.detail-box { display: flex; flex-direction: column; gap: 14px; }
.detail-head { border-radius: 12px; padding: 16px; color: #fff; }
.detail-name { font-size: 18px; font-weight: 800; text-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.detail-sub { font-size: 12px; opacity: .95; margin-top: 4px; text-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.detail-rows { display: flex; flex-direction: column; gap: 10px; }
.detail-row { display: flex; gap: 12px; font-size: 14px; }
.dr-k { color: var(--text-soft); width: 48px; flex: 0 0 auto; }
.dr-v { flex: 1; }
.detail-actions { display: flex; gap: 10px; }
.detail-actions .btn { flex: 1; }

/* 确认框 */
.confirm-box { text-align: center; }
.confirm-title { font-size: 16px; font-weight: 800; margin-bottom: 8px; }
.confirm-text { font-size: 13px; color: var(--text-soft); margin-bottom: 16px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

/* 菜单 */
.menu-box { display: flex; flex-direction: column; gap: 12px; }
.menu-hint { font-size: 12px; color: var(--text-soft); }
.menu-list { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow: auto; }
.menu-row { display: flex; align-items: center; gap: 12px; padding: 12px; background: #f7f9fc; border-radius: 12px; cursor: pointer; }
.menu-row.active { background: #eaf1ff; }
.menu-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex: 0 0 auto; }
.menu-t { flex: 1; }
.menu-name { font-size: 15px; font-weight: 700; }
.menu-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.menu-check { color: var(--primary); font-size: 18px; }
.menu-actions { display: flex; gap: 10px; margin-top: 4px; }
.menu-actions .btn { flex: 1; }

/* 导入导出 */
.io-box { display: flex; flex-direction: column; gap: 10px; }
.io-section-title { font-size: 13px; font-weight: 700; color: var(--text-soft); margin-top: 6px; }
.io-tip { font-size: 12px; line-height: 1.5; color: var(--text-soft); background: #f3f5f8; border-radius: 10px; padding: 10px 12px; }
.io-row { display: flex; gap: 10px; }
.io-row .btn { flex: 1; }
.io-file { font-size: 13px; }
.share-box { text-align: center; display: flex; flex-direction: column; gap: 12px; }
.share-title { font-size: 16px; font-weight: 800; }
.share-id { font-size: 13px; color: var(--text-soft); }
.share-id-label { font-size: 12px; color: var(--text-soft); text-align: left; }
.share-input { border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; width: 100%; background: #fafbfc; }
.share-id-input { text-align: center; font-size: 18px; font-weight: 800; letter-spacing: 2px; color: var(--primary); background: #fff; }
.share-info { text-align: left; background: #f8f9fa; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--text); line-height: 1.6; }
.share-course-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.share-course-tag { font-size: 11.5px; padding: 2px 7px; border-radius: 4px; background: #fff; line-height: 1.5; }

/* 关于 */
.about-box { text-align: center; display: flex; flex-direction: column; gap: 8px; padding: 10px 0; }
.about-logo { font-size: 22px; font-weight: 800; color: var(--primary); }
.about-ver { font-size: 12px; color: var(--text-soft); }
.about-desc { font-size: 13px; color: var(--text); line-height: 1.6; }
.about-link { font-size: 12px; color: var(--primary); }

/* 空状态 */
.empty-state { text-align: center; color: var(--text-soft); padding: 50px 20px; font-size: 14px; line-height: 1.8; }
.empty-state small { font-size: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.9); background: rgba(0, 0, 0, .82); color: #fff;
  padding: 12px 20px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .25s;
  pointer-events: none; z-index: 200; max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast-error { background: rgba(220, 60, 60, .92); }

/* ---------- 响应式适配（手机 / 桌面） ---------- */
/* 手机：满宽并缩小最小列宽，保证整周课表不横向溢出、完整显示 */
@media (max-width: 600px) {
  #app { max-width: 100%; --day-min: 34px; --time-col: 42px; }
  .course-card { padding: 4px 4px; }
  .section-time { font-size: 8.5px; }
  .section-num { font-size: 12px; }
  .week-day .wd-name { font-size: 11px; }
  .week-day .wd-date { font-size: 12px; }
  .week-day { margin: 3px 1px; padding: 6px 0 7px; }
}

/* 桌面：铺满屏幕，课表卡片随宽度拉长适配；其余页面限宽居中 */
@media (min-width: 768px) {
  #app { max-width: none; width: 100%; box-shadow: none; --day-min: 46px; --time-col: 64px; }
  .grid-head { font-size: 15px; }
  .week-day .wd-name { font-size: 13px; }
  .week-day .wd-date { font-size: 14px; }
  .today-wrap, .todo-wrap, .me-wrap { max-width: 1080px; margin: 0 auto; width: 100%; }
  .panel { max-width: 720px; }
  .panel-bottom { max-width: 720px; margin: 0 auto; }
  .topbar { padding: 18px 22px 12px; }
  .weekstrip { padding: 0 6px; }
}
