:root {
  --green: #1f7a4d;
  --green-dark: #145c39;
  --green-soft: #e9f5ee;
  --green-line: #cfe6d8;
  --ink: #17251d;
  --muted: #718077;
  --line: #e5ebe6;
  --bg: #f7faf8;
  --danger: #b23a3a;
  --white: #ffffff;
  --shadow: 0 10px 30px rgba(23, 67, 44, 0.07);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--green); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
img { max-width: 100%; }

.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 224px;
  background: var(--white); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 26px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--green); color: white; display: grid; place-items: center;
  font-weight: 700; font-size: 17px;
}
.brand-text b { display: block; color: var(--green); font-size: 16px; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  border: 0; background: transparent; color: var(--green);
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: 12px; font-size: 15px; text-align: left; font-weight: 600;
}
.nav-item:hover { background: #f1f8f4; }
.nav-item.active { background: var(--green-soft); color: var(--green-dark); }
.nav-item .ico { width: 20px; text-align: center; font-size: 17px; }
.sidebar-foot { margin-top: auto; padding: 0 6px; }
.sidebar-user { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.sidebar-user b { color: var(--ink); display: block; font-size: 13px; }

.main { margin-left: 224px; min-height: 100vh; }
.topbar {
  height: 68px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 30px; position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-title small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 8px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 28px 30px 60px; max-width: 1240px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 25px; color: var(--ink); }
.page-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.btn {
  border: 1px solid var(--green); background: var(--green); color: #fff;
  border-radius: 10px; padding: 9px 16px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; transition: .15s;
}
.btn:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--green); border-color: var(--green-line); }
.btn.ghost:hover { background: var(--green-soft); }
.btn.soft { background: var(--green-soft); color: var(--green-dark); border-color: transparent; }
.btn.danger { background: #fff; color: var(--danger); border-color: #efd3d3; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; justify-content: center; }

.icon-btn { border: 1px solid var(--line); background: #fff; width: 34px; height: 34px; border-radius: 10px; color: var(--muted); }
.icon-btn:hover { color: var(--green); border-color: var(--green-line); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card-sub { color: var(--muted); font-size: 12px; }
.card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.pack-card { cursor: pointer; transition: .15s; position: relative; overflow: hidden; }
.pack-card:hover { transform: translateY(-2px); border-color: var(--green-line); }
.pack-card .arrow { color: var(--green); font-size: 18px; }
.pack-cover {
  height: 72px; border-radius: 12px; margin: -4px -4px 14px;
  background: linear-gradient(120deg, #eef8f2, #f8fcfa);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  color: var(--green); font-weight: 700;
}
.pack-cover .big { font-size: 26px; opacity: .9; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  border-radius: 999px; background: var(--green-soft); color: var(--green-dark);
  font-size: 11px; font-weight: 600;
}
.tag.gray { background: #f2f4f2; color: #6f7b73; }
.tag.warn { background: #fdf4e4; color: #9a6a16; }
.tag.danger { background: #fbecec; color: #a53737; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.text-green { color: var(--green); }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

.empty {
  padding: 42px 20px; text-align: center; color: var(--muted);
  background: #fbfdfb; border: 1px dashed var(--line); border-radius: 14px; font-size: 13px;
}
.empty b { color: var(--ink); display: block; margin-bottom: 6px; font-size: 15px; }

.progress { height: 7px; background: #edf2ee; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.progress.lg { height: 10px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: #fbfdfb; border: 1px solid var(--line); border-radius: 12px;
}
.list-row:hover { border-color: var(--green-line); }
.list-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-size: 17px; flex: none; }
.list-main { min-width: 0; flex: 1; }
.list-main b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-main span { color: var(--muted); font-size: 12px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; color: #536158; margin-bottom: 6px; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; border: 1px solid #dce5df; background: #fff; border-radius: 10px;
  padding: 10px 12px; color: var(--ink); outline: none; transition: .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,122,77,.08); }
.textarea { min-height: 86px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: #647269; font-weight: 600; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid #f0f4f1; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }

.check-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; max-height: 340px; overflow: auto; padding: 4px; }
.check-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check-item:hover { border-color: var(--green-line); background: #fbfdfb; }
.check-item input { accent-color: var(--green); }

.dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(680px, calc(100vw - 36px));
  box-shadow: 0 26px 80px rgba(10, 40, 24, .22); color: var(--ink);
}
.dialog::backdrop { background: rgba(12, 30, 20, .34); backdrop-filter: blur(2px); }
.dialog.wide { width: min(980px, calc(100vw - 36px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 22px 0; }
.dialog-head h3 { font-size: 18px; }
.dialog-body { padding: 18px 22px 22px; max-height: calc(100vh - 160px); overflow: auto; }
.dialog-close { border: 0; background: #f4f7f5; color: #6b786f; width: 32px; height: 32px; border-radius: 9px; font-size: 18px; }
.dialog-close:hover { background: #eaf1ec; color: var(--green); }

.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #fff; padding: 28px;
}
.login-wrap { width: min(960px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; gap: 0; border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); background: #fff; }
.login-art { background: linear-gradient(150deg, #eaf7ef, #f9fdfb 60%, #fff); padding: 52px 46px; display: flex; flex-direction: column; justify-content: space-between; min-height: 520px; }
.login-art .brand-mark { width: 46px; height: 46px; border-radius: 14px; font-size: 21px; }
.login-art h1 { color: var(--green-dark); font-size: 32px; line-height: 1.35; margin-top: 38px; letter-spacing: .5px; }
.login-art p { color: #587061; font-size: 14px; margin-top: 14px; max-width: 330px; }
.login-art .bullets { display: flex; flex-direction: column; gap: 12px; margin-top: 30px; color: #3e5f4c; font-size: 13px; }
.login-art .bullets span::before { content: "✓"; color: var(--green); font-weight: 700; margin-right: 8px; }
.login-panel { padding: 48px 44px; display: flex; flex-direction: column; justify-content: center; }
.login-panel h2 { font-size: 23px; margin-bottom: 6px; }
.login-panel .lead { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border: 1px solid var(--line); padding: 4px; border-radius: 11px; margin-bottom: 20px; }
.seg button { border: 0; background: transparent; padding: 8px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.seg button.active { background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.login-note { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }
.login-note a { font-weight: 600; }

.toast-stack { position: fixed; right: 22px; top: 20px; display: flex; flex-direction: column; gap: 9px; z-index: 1000; }
.toast { background: #193b28; color: #fff; border-radius: 10px; padding: 11px 15px; font-size: 13px; box-shadow: 0 12px 30px rgba(10,40,24,.25); animation: toast-in .18s ease-out; max-width: 360px; }
.toast.error { background: #8f3030; }
@keyframes toast-in { from { transform: translateY(-6px); opacity: .5; } to { transform: none; opacity: 1; } }

.video-dialog { width: min(960px, calc(100vw - 28px)); }
.video-stage { position: relative; background: #0d1511; border-radius: 14px; overflow: hidden; }
.video-stage video { display: block; width: 100%; max-height: 66vh; background: #0d1511; }
.quiz-overlay { position: absolute; inset: 0; background: rgba(8, 22, 14, .72); display: flex; align-items: center; justify-content: center; padding: 18px; }
.quiz-card { width: min(560px, 100%); background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.quiz-card h4 { font-size: 16px; margin-bottom: 14px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.quiz-option:hover { border-color: var(--green-line); background: #fbfdfb; }
.quiz-option input { margin-top: 4px; accent-color: var(--green); }
.quiz-msg { min-height: 20px; margin-top: 10px; font-size: 12px; color: var(--danger); }
.video-meta { padding: 14px 4px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.pdf-dialog { width: min(1040px, calc(100vw - 24px)); }
.pdf-stage { background: #f1f4f2; border-radius: 12px; padding: 12px; max-height: 72vh; overflow: auto; text-align: center; }
.pdf-stage img { display: block; margin: 0 auto; max-height: 68vh; width: auto; max-width: 100%; box-shadow: 0 8px 26px rgba(0,0,0,.1); }
.pdf-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }

.homework-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.hw-image-wrap { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #f6f8f6; cursor: crosshair; }
.hw-image-wrap img { display: block; width: 100%; height: auto; }
.hw-mark { position: absolute; transform: translate(-50%, -50%); font-size: 28px; font-weight: 900; line-height: 1; text-shadow: 0 2px 8px rgba(255,255,255,.9); pointer-events: none; }
.hw-mark.check { color: #13884d; }
.hw-mark.cross { color: #c33a3a; }
.mark-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mark-tool.armed { background: var(--green); color: #fff; border-color: var(--green); }
.mark-tool.cross-armed { background: #b23a3a; color: #fff; border-color: #b23a3a; }

.progress-line { display: flex; align-items: center; gap: 10px; }
.progress-line .progress { flex: 1; }
.progress-line span { width: 44px; text-align: right; font-size: 12px; color: var(--muted); }

.video-list-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid #f0f4f1; }
.video-list-row:last-child { border-bottom: 0; }
.video-list-row .idx { width: 30px; height: 30px; border-radius: 9px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.video-list-row .info { flex: 1; min-width: 0; }
.video-list-row .info b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-list-row .info .progress { margin-top: 7px; max-width: 300px; }

.subject-section { margin-bottom: 28px; }
.subject-head { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.subject-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }
.subject-head h2 { font-size: 17px; }

.upload-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.upload-progress { margin-top: 12px; display: none; }
.upload-progress.on { display: block; }
.upload-progress .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.stat-block { background: #fbfdfb; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat-block b { font-size: 20px; color: var(--green-dark); }
.stat-block span { font-size: 12px; color: var(--muted); display: block; }

.submission-box { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #fbfdfb; }
.mark-legend { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--muted); }
.mark-legend b { font-size: 18px; }
.mark-legend .ok { color: #13884d; }
.mark-legend .no { color: #c33a3a; }

@media (max-width: 900px) {
  .sidebar { position: static; width: auto; padding: 14px; flex-direction: row; align-items: center; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { flex: none; }
  .brand-text span { display: none; }
  .nav { flex-direction: row; flex: 1; }
  .nav-item { padding: 9px 12px; font-size: 13px; white-space: nowrap; }
  .sidebar-foot { margin: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  .sidebar-user { display: none; }
  .main { margin-left: 0; }
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; height: 58px; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { min-height: auto; padding: 32px; }
  .login-art h1 { font-size: 26px; margin-top: 22px; }
  .login-art .bullets { display: none; }
  .login-panel { padding: 30px; }
}
@media (max-width: 600px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .check-list { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 21px; }
  .dialog-body { padding: 16px; }
}

/* Full-screen paper viewer and question hotspots */
.page-viewer {
  width: 100vw; max-width: none; height: 100vh; max-height: none;
  margin: 0; padding: 0; border: 0; border-radius: 0; background: #e9efeb;
}
.page-viewer::backdrop { background: #dfe8e2; }
.viewer-bar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; gap: 12px; position: relative; z-index: 5;
}
.viewer-bar h3 { font-size: 16px; margin: 0; }
.viewer-bar .small { display: block; margin-top: 2px; }
.page-scroll {
  height: calc(100vh - 64px); overflow-y: auto; padding: 20px 12px 48px;
  scroll-behavior: smooth; overscroll-behavior: contain;
}
.paper-page {
  position: relative; width: min(900px, 100%); margin: 0 auto 24px;
  background: #fff; box-shadow: 0 10px 30px rgba(20, 60, 38, .14);
  border-radius: 4px; overflow: hidden;
}
.paper-page img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.page-hotspot-layer { position: absolute; inset: 0; pointer-events: none; }
.page-hotspot {
  pointer-events: auto; position: absolute; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid #139b63; border-radius: 999px;
  background: #1fbc7a; color: #fff; padding: 5px 10px;
  font-size: 12px; font-weight: 700; line-height: 1;
  box-shadow: 0 3px 10px rgba(20, 112, 70, .28); white-space: nowrap;
  cursor: pointer; min-height: 28px;
}
.page-hotspot:hover { background: #14945f; }
.hotspot-play { font-size: 9px; }
@media (max-width: 600px) {
  .page-scroll { padding: 10px 6px 32px; }
  .paper-page { margin-bottom: 12px; }
  .page-hotspot { font-size: 11px; padding: 5px 8px; min-height: 26px; }
}

/* Full-screen homework grading */
.dialog.grading-dialog {
  width: 100vw; max-width: none; height: 100vh; max-height: none;
  margin: 0; border-radius: 0; background: #eef2ef;
}
.dialog.grading-dialog .dialog-body {
  max-height: calc(100vh - 72px); overflow-y: auto;
  background: #eef2ef; padding: 16px 12px 40px;
}
.grading-pages { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.grading-pages .hw-image-wrap { width: 100%; box-shadow: 0 8px 24px rgba(20, 60, 38, .12); }

/* Grading tool states */
.dialog.grading-dialog.marking .grading-pages .hw-image-wrap { cursor: crosshair; }
.dialog.grading-dialog.deleting .grading-pages .hw-image-wrap { cursor: default; }
.grading-dialog .hw-mark { pointer-events: auto; cursor: pointer; z-index: 2; }
#deleteMarkMode.delete-armed { background: #b23a3a; border-color: #b23a3a; color: #fff; }

/* Keep grading tools visible while scrolling the paper */
.dialog.grading-dialog .mark-toolbar {
  position: sticky;
  top: -16px;
  z-index: 8;
  background: #eef2ef;
  margin: -16px -12px 12px;
  padding: 14px 12px 10px;
  border-bottom: 1px solid #dbe5df;
  box-shadow: 0 6px 14px rgba(20, 60, 38, .06);
}
.dialog.grading-dialog .mark-toolbar .btn { flex: 0 0 auto; }
