/* 小课堂 · 全站样式
   设计意图：延续课件的暖纸与墨绿，但用圆角、留白与轻投影把它做成「产品」而不是「讲义」；
   顶部栏用半透明毛玻璃常驻，不做传统横条导航。 */

:root {
  --paper: #F4EFE4;
  --paper-2: #ECE4D3;
  --card: #FFFCF5;
  --ink: #1E302A;
  --green: #1D5342;
  --green-2: #2A6B54;
  --red: #C1503A;
  --muted: #6C7A70;
  --line: rgba(30, 48, 42, .14);
  --soft: rgba(30, 48, 42, .07);
  --shadow: 0 20px 44px -22px rgba(30, 48, 42, .45);
  --shadow-sm: 0 10px 24px -18px rgba(30, 48, 42, .5);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "JetBrains Mono", monospace;
  --radius: 16px;
}

* { box-sizing: border-box; }

/* 关键：hidden 属性必须压过下面各组件的 display，否则登录页与后台会同时出现 */
[hidden] { display: none !important; }

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

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(rgba(30, 48, 42, .075) .7px, transparent .7px) 0 0 / 10px 10px,
    radial-gradient(1200px 700px at 12% -10%, rgba(255, 255, 255, .85), transparent 62%),
    radial-gradient(900px 600px at 100% 0%, rgba(193, 80, 58, .06), transparent 60%),
    var(--paper);
}

a { color: var(--green); }

h1, h2, h3, h4 { margin: 0; line-height: 1.28; letter-spacing: -.01em; }

p { margin: 0; }

::selection { background: rgba(193, 80, 58, .18); }

/* ---------- 顶部栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 30px;
  background: rgba(244, 239, 228, .84);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid rgba(30, 48, 42, .07);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .04em;
  color: var(--green);
  text-decoration: none;
}

.brand i {
  position: relative;
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--green);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .08);
}

.brand i::before,
.brand i::after {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  width: 2px;
  background: var(--paper);
  border-radius: 2px;
}

.brand i::before { left: 8px; }
.brand i::after { right: 8px; }

.topbar .spacer { flex: 1; }

.topbar .meta {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 通用控件 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s, border-color .18s, color .18s, transform .18s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: #FBF7EE;
  box-shadow: 0 12px 22px -14px rgba(29, 83, 66, .8);
}

.btn.primary:hover { background: var(--green-2); border-color: var(--green-2); }

.btn.ghost {
  border-color: var(--line);
  color: var(--green);
  background: rgba(255, 252, 245, .6);
}

.btn.ghost:hover { background: #fff; border-color: rgba(29, 83, 66, .35); }

.btn.danger { color: var(--red); border-color: rgba(193, 80, 58, .32); background: rgba(255, 252, 245, .6); }
.btn.danger:hover { background: rgba(193, 80, 58, .08); }

.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.icon { padding: 7px 10px; }

.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field > label { font-size: 12.5px; letter-spacing: .04em; color: var(--muted); font-weight: 600; }

input[type=text],
input[type=password],
textarea,
select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

textarea { resize: vertical; line-height: 1.6; font-family: var(--mono); font-size: 13px; }

input:focus, textarea:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(29, 83, 66, .1);
}

.hint { font-size: 12.5px; color: var(--muted); }

.empty {
  padding: 54px 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(30, 48, 42, .22);
  border-radius: var(--radius);
  background: rgba(255, 252, 245, .5);
}

.empty b { display: block; margin-bottom: 6px; font-size: 17px; color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  padding: 11px 20px;
  border-radius: 99px;
  background: var(--ink);
  color: #F8F3E7;
  font-size: 13.5px;
  box-shadow: 0 18px 36px -18px rgba(0, 0, 0, .7);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity .24s, transform .24s;
}

.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }

/* ---------- 首页 ---------- */

.page { max-width: 1180px; margin: 0 auto; padding: 34px 30px 90px; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 26px 0 34px;
  border-bottom: 1px solid var(--line);
}

.hero .eyebrow {
  font-size: 12px;
  letter-spacing: .22em;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
}

.hero h1 {
  margin: 10px 0 8px;
  font-family: var(--serif);
  font-size: 52px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.hero .sub { max-width: 640px; color: #47584E; font-size: 16px; }

.hero .nums { display: flex; gap: 30px; }

.hero .num b {
  display: block;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.hero .num span { font-size: 12.5px; color: var(--muted); letter-spacing: .06em; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 38px 0 18px;
}

.section-head h2 { font-size: 20px; font-weight: 700; }
.section-head span { font-size: 13px; color: var(--muted); }

.courses {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(292px, 1fr));
  gap: 22px;
}

.course-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: transform .24s cubic-bezier(.2, .8, .2, 1), box-shadow .24s;
}

.course-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }

.course-card .cover {
  position: relative;
  height: 128px;
  padding: 16px 18px;
  display: flex;
  align-items: flex-end;
  color: #fff;
  overflow: hidden;
}

.course-card .cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 120% at 100% 0%, rgba(255, 255, 255, .22), transparent 55%);
}

.course-card .cover .idx {
  position: absolute;
  right: 14px;
  top: 6px;
  font-family: var(--serif);
  font-size: 68px;
  line-height: 1;
  opacity: .18;
  letter-spacing: -.04em;
}

.course-card .cover .kicker {
  position: relative;
  z-index: 1;
  font-size: 11.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  opacity: .78;
}

.course-card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }

.course-card h3 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }

.course-card .desc {
  font-size: 13.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
}

.course-card .foot-line {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}

.course-card .foot-line b { color: var(--green); font-variant-numeric: tabular-nums; }

.page-foot {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

/* ---------- 观看页 ---------- */

.watch {
  display: grid;
  grid-template-columns: 306px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(255, 252, 245, .78);
  backdrop-filter: blur(8px);
}

.side-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--soft); }

.side-head .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 14px;
}

.side-head .back:hover { color: var(--green); }

.side-head h2 { font-size: 19px; font-weight: 700; line-height: 1.4; }

.side-head .count { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

.side-list { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 24px; }

.lesson-item {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: background .16s, border-color .16s;
}

.lesson-item:hover { background: rgba(29, 83, 66, .055); }

.lesson-item.on {
  background: rgba(29, 83, 66, .09);
  border-color: rgba(29, 83, 66, .18);
}

.lesson-item .no {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid rgba(30, 48, 42, .22);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.lesson-item.on .no { background: var(--green); border-color: var(--green); color: #FBF7EE; }

.lesson-item.done .no { border-color: var(--green); color: var(--green); }

.lesson-item .tx { min-width: 0; }

.lesson-item .tx b {
  display: block;
  font-size: 13.8px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}

.lesson-item .tx small { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.stage-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 245, .72);
  backdrop-filter: blur(10px);
}

.stage-bar .now { min-width: 0; flex: 1; }

.stage-bar .now b {
  display: block;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-bar .now small { display: block; font-size: 11.5px; color: var(--muted); }

.frame-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 14px 16px 16px;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }

.frame-wrap:fullscreen { margin: 0; border-radius: 0; }
.frame-wrap:fullscreen iframe { height: 100vh; }

.frame-wrap .empty {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 0;
  border-radius: 0;
  background: var(--card);
  text-align: center;
}

.frame-wrap.loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid rgba(29, 83, 66, .18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.menu-btn { display: none; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(20, 32, 27, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}

.scrim.on { opacity: 1; pointer-events: auto; }

/* ---------- 后台 ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.login-card {
  width: min(400px, 100%);
  padding: 30px 28px 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.login-card h1 { font-family: var(--serif); font-size: 30px; letter-spacing: -.02em; }

.login-card p { margin: 8px 0 22px; font-size: 13.5px; color: var(--muted); }

.login-card .field + .field { margin-top: 14px; }

.login-card .btn { width: 100%; margin-top: 18px; padding: 12px; }

.admin { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }

.rail {
  border-right: 1px solid var(--line);
  background: rgba(255, 252, 245, .6);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail .rail-title {
  padding: 0 10px 12px;
  font-size: 11.5px;
  letter-spacing: .18em;
  color: var(--muted);
  text-transform: uppercase;
}

.rail button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: #3C4F45;
  cursor: pointer;
  text-align: left;
}

.rail button:hover { background: rgba(29, 83, 66, .06); }

.rail button.on { background: rgba(29, 83, 66, .1); border-color: rgba(29, 83, 66, .16); color: var(--green); font-weight: 700; }

.rail .rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

.main { padding: 26px 32px 90px; max-width: 1120px; }

.main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }

.main-head h1 { font-family: var(--serif); font-size: 32px; letter-spacing: -.02em; }

.main-head p { margin-top: 6px; font-size: 13.5px; color: var(--muted); }

.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }

.stat-pill {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 252, 245, .7);
  font-size: 12.5px;
  color: var(--muted);
}

.stat-pill b { color: var(--green); font-variant-numeric: tabular-nums; }

.course-row {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--card);
  overflow: hidden;
}

.course-row-head { display: flex; align-items: center; gap: 13px; padding: 14px 18px; }

.course-row-head .swatch {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12);
}

.course-row-head .info { min-width: 0; flex: 1; }

.course-row-head .info b { display: block; font-size: 15.5px; }

.course-row-head .info small { display: block; font-size: 12px; color: var(--muted); }

.course-row-head .info small code {
  font-family: var(--mono);
  background: var(--soft);
  padding: 1px 5px;
  border-radius: 5px;
}

.course-row-head .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.badge.on { color: var(--green); border-color: rgba(29, 83, 66, .3); background: rgba(29, 83, 66, .07); }

.lessons { border-top: 1px solid var(--soft); padding: 6px 0 10px; }

.lesson-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
}

.lesson-row:hover { background: rgba(29, 83, 66, .035); }

.lesson-row .ord {
  flex: none;
  width: 20px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
}

.lesson-row input[type=text] { padding: 7px 10px; border-radius: 9px; font-size: 13.5px; background: #fff; }

.lesson-row .size { flex: none; width: 62px; font-size: 11.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.lesson-row .lacts { display: flex; gap: 4px; flex: none; }

.dropzone {
  margin: 12px 18px 18px;
  padding: 22px;
  border: 1.5px dashed rgba(29, 83, 66, .3);
  border-radius: 13px;
  background: rgba(29, 83, 66, .03);
  text-align: center;
  transition: background .18s, border-color .18s;
}

.dropzone.hot { background: rgba(29, 83, 66, .09); border-color: var(--green); }

.dropzone b { display: block; font-size: 14px; margin-bottom: 4px; }

.dropzone small { display: block; font-size: 12px; color: var(--muted); }

.dropzone .row { margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.tag-row { display: flex; gap: 8px; flex-wrap: wrap; }

.tag-row .swatch-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.tag-row .swatch-btn.on { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(30, 48, 42, .12); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 32, 27, .38);
  backdrop-filter: blur(3px);
}

.modal[hidden] { display: none; }

.modal-box {
  width: min(560px, 96vw);
  max-height: 88vh;
  overflow: auto;
  padding: 24px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.modal-box h2 { font-size: 21px; }

.modal-box .sub { margin: 6px 0 18px; font-size: 13px; color: var(--muted); }

.modal-box .field + .field { margin-top: 13px; }

.modal-acts { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 252, 245, .8);
}

.seg button {
  padding: 6px 13px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}

.seg button.on { background: var(--green); color: #FBF7EE; }

/* ---------- 响应式 ---------- */

@media (max-width: 960px) {
  .hero { flex-direction: column; align-items: flex-start; gap: 20px; }
  .hero h1 { font-size: 40px; }

  /* 竖屏不做抽屉：课件在上、章节在下，一屏里看得到全貌 */
  .watch { display: flex; flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .stage { order: 1; }
  .side {
    order: 2;
    position: static;
    width: auto;
    max-width: none;
    transform: none;
    box-shadow: none;
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(255, 252, 245, .55);
  }
  .side-list { overflow: visible; padding: 8px 12px 30px; }
  .menu-btn { display: none; }
  .scrim { display: none; }
  .admin { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail .rail-title { display: none; }
  .rail .rail-foot { margin: 0 0 0 auto; flex-direction: row; }
  .main { padding: 20px 16px 70px; }
  .frame-wrap { flex: none; aspect-ratio: 16 / 9; margin: 12px 10px; }
  .stage-bar { height: auto; padding: 10px 12px; flex-wrap: wrap; }
}

@media (max-width: 700px) {
  .main-head { flex-direction: column; align-items: flex-start; gap: 12px; }
}

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .page { padding: 20px 16px 70px; }
  .courses { grid-template-columns: 1fr; }
  .hero h1 { font-size: 34px; }
  .main-head .btn { width: 100%; }
  .course-row-head { flex-wrap: wrap; }
  .course-row-head .acts { width: 100%; justify-content: flex-start; }

  /* 课件行改成两行：序号 + 名称在上，操作在下，避免输入框被挤成一条 */
  .lesson-row { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; align-items: center; }
  .lesson-row .lacts { grid-column: 1 / -1; flex-wrap: wrap; }
  .lesson-row .size { display: none; }
  .dropzone { padding: 18px 14px; }
}
