/* 白色治愈系 · 移动优先；CSS 变量便于移植到小程序（px→rpx） */
:root {
  --bg: #f6f8fa;
  --card: #ffffff;
  --ink: #1f2a30;
  --ink-2: #5b6b74;
  --ink-3: #93a3ab;
  --line: #e8eef1;
  --accent: #4a9d8f;
  --accent-soft: #e8f4f1;
  --danger: #c05a5a;
  --danger-soft: #fbecec;
  --ok: #3f8f6b;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(31, 42, 48, .06);
  --shadow-sm: 0 2px 8px rgba(31, 42, 48, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 关键：作者样式里的 display:flex 会盖掉 hidden 属性的 UA 规则，这里强制兜底 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(246, 248, 250, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand h1 { font-size: 16px; font-weight: 650; margin: 0; letter-spacing: .3px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---------- 布局 ---------- */
.wrap {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 15px 16px 16px;
  border: 1px solid rgba(232, 238, 241, .8);
}
.card.collapsed .grid2,
.card.collapsed .hint { display: none; }

.card-title {
  margin: 0 0 12px;
  font-size: 14px; font-weight: 650; color: var(--ink);
  display: flex; align-items: baseline; gap: 8px;
}
.card-title small {
  font-weight: 400; font-size: 12px; color: var(--ink-3);
  margin-left: auto;
}

/* ---------- 表单 ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 12px; color: var(--ink-2); }

input, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
  -webkit-appearance: none;
}
input:focus, textarea:focus {
  border-color: #b9d9d2;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(74, 157, 143, .1);
}
textarea {
  resize: vertical;
  min-height: 96px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.7;
}

/* ---------- 按钮 ---------- */
.row { display: flex; align-items: center; }
.row.gap { gap: 9px; margin-top: 12px; }
.row.wrapx { flex-wrap: wrap; align-items: flex-start; }

/* 课程工具条：按钮保持内容宽度并自动换行，「下单」单独占一行 */
#courseTools { gap: 8px; }
#courseTools button { flex: 0 0 auto; }
#courseTools #btnOrder { flex: 0 0 auto; }
/* 窄屏：下单按钮独占一整行，方便拇指点 */
@media (max-width: 560px) {
  #courseTools #btnOrder { flex: 1 1 100%; margin-top: 2px; }
}
.row.end { justify-content: flex-end; }

button {
  font: inherit; font-size: 14px; font-weight: 550;
  border: 0; border-radius: 11px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform .08s, opacity .15s, background .15s;
  white-space: nowrap;
}
button:active:not(:disabled) { transform: scale(.975); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }

.primary { background: var(--accent); color: #fff; box-shadow: 0 2px 10px rgba(74, 157, 143, .25); }
.accent { background: var(--ink); color: #fff; }
.ghost { background: #f1f5f7; color: var(--ink-2); }
.ghost:hover:not(:disabled) { background: #e9eff2; }

/* ---------- 进度 ---------- */
.progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.bar {
  flex: 1; height: 6px; border-radius: 99px;
  background: #eef2f4; overflow: hidden;
}
.bar > i {
  display: block; height: 100%; width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #6fb8ab, var(--accent));
  transition: width .25s ease;
}
#progText { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 课程列表 ---------- */
.course-list { display: flex; flex-direction: column; gap: 10px; }

.acct {
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  background: #fcfdfd;
}
.acct-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: #f7fafb;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.acct-name {
  font-weight: 600; font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-meta { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.acct.failed .acct-head { background: var(--danger-soft); }
.acct.failed .acct-meta { color: var(--danger); }

.course {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 12px;
  border-top: 1px solid #f2f6f8;
  cursor: pointer;
  transition: background .12s;
}
.course:first-of-type { border-top: 0; }
.course:active { background: #f6faf9; }
.course.checked { background: #fbfefd; }

.box {
  flex: 0 0 auto;
  width: 21px; height: 21px;
  margin-top: 1px;
  border: 1.6px solid #cfdbe0;
  border-radius: 7px;
  background: #fff;
  display: grid; place-items: center;
  transition: background .12s, border-color .12s;
}
.course.checked .box { background: var(--accent); border-color: var(--accent); }
.box::after {
  content: "";
  width: 11px; height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(.5px, -1px) scale(0);
  transition: transform .12s;
}
.course.checked .box::after { transform: rotate(-45deg) translate(.5px, -1px) scale(1); }

.course-body { flex: 1; min-width: 0; }
.course-name { font-size: 14px; word-break: break-word; }
.course-note { font-size: 12px; color: var(--ink-3); margin-top: 3px; word-break: break-all; }
.course-note.ok { color: var(--ok); }
.course-note.err { color: var(--danger); }

.empty {
  margin: 0; padding: 22px 6px;
  text-align: center; color: var(--ink-3); font-size: 13px;
}
.hint { margin: 10px 0 0; font-size: 12px; color: var(--ink-3); word-break: break-all; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; max-height: 46vh; border: 1px solid var(--line); border-radius: 12px;
  -webkit-overflow-scrolling: touch; }
table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 12.5px; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid #f2f6f8; }
th { position: sticky; top: 0; z-index: 1; background: #f7fafb; }
/* 首列粘住，横向滚动时还能看到账号 */
th:first-child, td:first-child {
  position: sticky; left: 0; background: #fff; box-shadow: 1px 0 0 var(--line);
}
th:first-child { background: #f7fafb; z-index: 2; }
th {
  position: sticky; top: 0;
  background: #f7fafb; font-weight: 600; color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
tr:last-child td { border-bottom: 0; }
td.wrap-cell { white-space: normal; min-width: 160px; }
td.ok { color: var(--ok); }
td.err { color: var(--danger); }

details { margin-top: 10px; }
summary { font-size: 12.5px; color: var(--ink-2); cursor: pointer; padding: 4px 0; }
pre {
  margin: 8px 0 0;
  padding: 11px 12px;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 11px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink-2);
  overflow: auto;
  max-height: 240px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- toast / modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: rgba(31, 42, 48, .92); color: #fff;
  font-size: 13.5px; padding: 10px 18px; border-radius: 99px;
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 60; max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(31, 42, 48, .32);
  display: grid; place-items: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }
.modal-box {
  width: 100%; max-width: 400px;
  background: #fff; border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-box h3 { margin: 0 0 8px; font-size: 15.5px; }
.modal-box p {
  margin: 0 0 18px; font-size: 13.5px; color: var(--ink-2);
  max-height: 42vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
