:root {
  --navy:#1c274e; --green:#61ac31; --muted:#6b7690;
  --line:#dbe3ec; --soft:#f3f7fb; --amber:#d98b22;
}
* { box-sizing:border-box; }
body { margin:0; background:#f8fafc; color:var(--navy); font-family:"PingFang SC","Microsoft YaHei",system-ui,sans-serif; }
button,input,textarea { font:inherit; }
.topbar { height:76px; padding:0 28px; display:flex; align-items:center; justify-content:space-between; background:#fff; border-bottom:1px solid var(--line); position:sticky; top:0; z-index:5; }
.brand,.top-actions,.preview-actions { display:flex; align-items:center; gap:12px; }
.brand img { width:102px; height:48px; object-fit:contain; }
.brand>span { width:1px; height:35px; background:var(--line); }
.brand strong { display:block; font-size:18px; }
.brand small { display:block; color:var(--muted); margin-top:2px; }
.button { border:0; border-radius:9px; padding:0 15px; height:42px; display:inline-flex; align-items:center; justify-content:center; font-weight:600; cursor:pointer; line-height:1; text-decoration:none; }
.top-actions label { margin-top:0; }
.button:active { transform:translateY(1px); }
.primary { background:var(--green); color:#fff; }
.secondary { background:#fff; border:1px solid var(--line); color:var(--navy); }
.dark { background:var(--navy); color:#fff; }
.workspace { display:grid; grid-template-columns:380px minmax(680px,1fr); min-height:calc(100dvh - 76px); }
.panel { background:#fff; border-right:1px solid var(--line); }
.setup-panel { padding:26px 24px 50px; max-height:calc(100dvh - 76px); overflow:auto; position:sticky; top:76px; }
.panel-head,.section-row,.preview-toolbar { display:flex; justify-content:space-between; align-items:center; }
.eyebrow { color:var(--green); font:700 10px/1 ui-monospace,monospace; letter-spacing:.16em; }
.panel-head h1,.preview-toolbar h2 { margin:5px 0 0; }
.panel-head h1 { font-size:24px; }
.status { font-size:12px; color:var(--muted); background:var(--soft); padding:6px 9px; border-radius:7px; }
.control-section { padding-top:20px; margin-top:22px; border-top:1px solid var(--line); }
.section-row h2 { margin:0; font-size:18px; }
.section-row span { font-size:12px; color:var(--muted); }
label { display:block; color:var(--muted); font-size:13px; margin-top:16px; }
input,textarea { width:100%; margin-top:7px; padding:10px 11px; border:1px solid var(--line); border-radius:9px; color:var(--navy); outline:none; background:#fff; }
input:focus,textarea:focus { border-color:var(--green); box-shadow:0 0 0 3px rgba(97,172,49,.12); }
textarea { resize:vertical; line-height:1.5; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.student-list { display:grid; grid-template-columns:1fr 1fr; gap:7px; margin-top:12px; }
.record-actions { display:grid; grid-template-columns:1fr 1fr .72fr; gap:7px; margin-top:12px; }
.record-actions button { min-height:36px; border:1px solid var(--line); border-radius:8px; background:#fff; color:var(--navy); cursor:pointer; }
.record-actions button:first-child { border-color:var(--green); color:#397d18; background:#f5fbf1; }
.record-empty { grid-column:1/-1; padding:16px 10px; border:1px dashed var(--line); border-radius:8px; color:var(--muted); font-size:12px; text-align:center; }
.student-record { min-width:0; display:grid; grid-template-columns:minmax(0,1fr) 30px; border:1px solid transparent; border-radius:8px; background:var(--soft); overflow:hidden; }
.student-record.active { border-color:var(--green); background:#f5fbf1; }
.student-item { min-width:0; border:0; background:transparent; padding:9px 10px; text-align:left; color:var(--navy); cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.delete-record { border:0; background:transparent; color:#9aa3b4; cursor:pointer; font-size:17px; }
.delete-record:hover { color:#c94b4b; background:#fff1f1; }
.preview-area { padding:28px; min-width:0; }
.preview-toolbar { max-width:840px; margin:0 auto 18px; }
.preview-toolbar h2 { margin:5px 0 0; font-size:20px; }
.canvas-stage { display:flex; justify-content:center; align-items:flex-start; padding-bottom:40px; }
.feedback-card { width:780px; height:1040px; background:#fff; border:1px solid var(--line); box-shadow:0 18px 55px rgba(28,39,78,.12); padding:44px 48px 34px; display:flex; flex-direction:column; }
.card-empty { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--muted); gap:9px; }
.card-empty strong { color:var(--navy); font-size:20px; }
.card-empty span { font-size:13px; }
.card-head { height:94px; display:grid; grid-template-columns:144px 1px 1fr auto; gap:20px; border-bottom:2px solid var(--navy); }
.card-head img { width:132px; height:61px; object-fit:contain; }
.rule { background:var(--line); height:54px; }
.card-title strong { display:block; font-size:33px; }
.card-title small { font-size:13px; color:var(--muted); }
.date { font-size:17px; padding-top:4px; }
.student-band { height:104px; margin:20px 0 22px; background:var(--soft); border-radius:16px; padding:0 24px; display:grid; grid-template-columns:190px 1px 1fr auto; gap:18px; align-items:center; }
.student-band .rule { height:62px; }
.student-name strong { display:block; font-size:30px; }
.student-name small,.topic small { color:var(--muted); font-size:13px; }
.topic strong { display:block; font-size:20px; margin-top:7px; }
.attendance { border:1px solid var(--line); border-radius:8px; padding:8px 11px; font-size:13px; white-space:nowrap; }
.section { margin-bottom:18px; }
.section-head { height:31px; display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.section-head h3 { margin:0; font-size:19px; display:flex; align-items:center; gap:11px; }
.section-head h3:before { content:""; width:6px; height:24px; background:var(--green); border-radius:3px; }
.section-head span { font-size:13px; color:var(--muted); }
.box { border:1px solid var(--line); border-radius:15px; padding:16px 20px; }
.content-box { height:132px; overflow:hidden; }
.line-item { display:flex; align-items:center; gap:11px; margin:0 0 10px; font-size:14px; }
.line-item:before { content:""; width:6px; height:6px; border-radius:50%; background:var(--green); flex:none; }
.practice-box { height:225px; display:grid; grid-template-columns:1fr 1fr; grid-auto-rows:30px; column-gap:28px; align-content:start; overflow:hidden; }
.practice-row { display:grid; grid-template-columns:1fr auto; gap:9px; align-items:center; min-width:0; font-size:13px; }
.practice-row span:first-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.practice-row em { font-style:normal; font-weight:600; color:var(--green); }
.practice-row em:last-child { white-space:nowrap; }
.practice-row em:not(:first-child) { }
.practice-row .unfinished { color:var(--amber); }
.more-row span { color:var(--muted); font-weight:600; }
.more-row em { color:var(--muted)!important; }
.line-row { display:grid; grid-template-columns:1fr auto; align-items:center; min-width:0; margin:0 0 9px; font-size:14px; }
.line-row span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.line-row span:before { content:""; display:inline-block; width:6px; height:6px; border-radius:50%; background:var(--green); margin:0 11px 2px 0; }
.line-row em { display:none; }
.homework .practice-box { height:216px; }
.homework .practice-row em { color:var(--amber); }
.extra-box { height:88px; overflow:hidden; border:1px solid var(--line); border-radius:15px; padding:12px 16px; display:flex; justify-content:space-between; gap:18px; margin-bottom:14px; }
.extra-box small { color:var(--muted); }
.extra-box p { margin:5px 0 0; font-size:13px; line-height:1.55; overflow:hidden; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; overflow-wrap:anywhere; }
.qr-wrap { display:flex; align-items:center; gap:10px; flex:none; }
.qr-wrap img,.qr-wrap canvas { display:block; }
.with-extra .content-box { height:105px; }
.with-extra .practice-box { height:160px; }
.with-extra .homework .practice-box { height:140px; }
.empty-text { color:var(--muted); font-size:13px; }
.card-footer { margin-top:auto; border-top:1px solid var(--line); padding-top:14px; font-size:11px; color:var(--muted); display:flex; justify-content:space-between; }
.toast { position:fixed; right:24px; bottom:24px; background:var(--navy); color:#fff; padding:12px 16px; border-radius:9px; opacity:0; transform:translateY(8px); pointer-events:none; transition:.2s; }
.toast.show { opacity:1; transform:none; }
@media(max-width:1050px) {
  .workspace { grid-template-columns:340px minmax(560px,1fr); }
  .feedback-card { transform:scale(.82); transform-origin:top center; }
}
@media(max-width:760px) {
  .topbar { height:auto; padding:12px 16px; gap:12px; flex-wrap:wrap; }
  .workspace { display:block; }
  .setup-panel { position:static; max-height:none; }
  .preview-area { padding:20px 12px; }
  .preview-toolbar { align-items:flex-start; gap:12px; flex-wrap:wrap; }
  .canvas-stage { justify-content:flex-start; overflow:auto; }
  .feedback-card { transform:scale(.68); transform-origin:top left; flex:none; }
}
.button:disabled { opacity:.65; cursor:wait; transform:none; }

/* Long content expands the card instead of overlapping later sections. */
.feedback-card { height:auto; min-height:1040px; }
.content-box,
.homework .practice-box,
.with-extra .content-box,
.with-extra .practice-box,
.with-extra .homework .practice-box { height:auto; min-height:0; overflow:visible; }
.practice-box { height:auto; min-height:72px; grid-auto-rows:minmax(30px,auto); row-gap:4px; overflow:visible; }
.practice-row { min-height:30px; align-items:start; padding:5px 0; }
.practice-row span:first-child,
.line-row span { overflow:visible; text-overflow:clip; white-space:normal; overflow-wrap:anywhere; }
.line-row { min-height:24px; align-items:start; }
.extra-box { height:auto; min-height:88px; overflow:visible; }
.extra-box p { display:block; overflow:visible; -webkit-line-clamp:unset; overflow-wrap:anywhere; }
/* Every card frame grows with its content. */
.card-head { height:auto; min-height:94px; }
.student-band { height:auto; min-height:104px; padding-top:18px; padding-bottom:18px; }
.student-name strong,.topic strong { overflow-wrap:anywhere; }
.section { flex:none; }
.box { height:auto; min-height:0; overflow:visible; }
.content-box { min-height:90px; }
.practice-box { min-height:72px; }
.homework .practice-box { min-height:72px; }
.extra-box>div:first-child { min-width:0; flex:1; }
.card-footer { flex:none; }

/* Completed and unfinished practice are separate, equally weighted areas. */
.practice-groups { display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:start; }
.practice-group { min-width:0; border:1px solid var(--line); border-radius:15px; overflow:hidden; }
.group-title { min-height:46px; padding:0 16px; display:flex; align-items:center; justify-content:space-between; background:var(--soft); border-bottom:1px solid var(--line); }
.group-title strong { font-size:14px; }
.group-title span { color:var(--muted); font-size:11px; }
.completed-group .group-title { border-left:5px solid var(--green); }
.unfinished-group .group-title { border-left:5px solid var(--amber); }
.practice-group .practice-box { display:block; min-height:72px; padding:12px 16px; }
.practice-group .practice-row { display:block; padding:6px 0; }
.practice-group .practice-row em { display:none; }
@media(max-width:760px) { .practice-groups { grid-template-columns:1fr 1fr; } }

/* One practice frame, with completed items followed by unfinished items. */
.practice-stack { padding:0; overflow:hidden; }
.practice-part { min-width:0; }
.practice-part + .practice-part { border-top:1px solid var(--line); }
.practice-part .group-title { border-left:5px solid var(--green); border-bottom:1px solid var(--line); }
.unfinished-part .group-title { border-left-color:var(--amber); }
.practice-part .practice-box { display:block; min-height:0; padding:12px 20px 14px; }
.practice-part .practice-row { display:block; min-height:30px; padding:5px 0; }
.practice-part .practice-row em { display:none; }

/* Record toolbar and student rows use different visual roles. */
.record-actions { display:flex; grid-template-columns:none; align-items:center; gap:8px; padding:9px; border-radius:10px; background:var(--soft); }
.record-actions button { min-height:34px; border:0; border-radius:7px; padding:0 12px; background:#fff; color:var(--navy); cursor:pointer; font-size:12px; font-weight:600; box-shadow:0 1px 2px rgba(28,39,78,.08); }
.record-actions button:first-child { color:#fff; background:var(--green); box-shadow:none; }
.record-actions button:last-child { margin-left:auto; padding:0 7px; color:#bd4b4b; background:transparent; box-shadow:none; }
.student-list { grid-template-columns:1fr; }
.student-record { grid-template-columns:minmax(0,1fr) 34px; border:1px solid var(--line); border-radius:9px; background:#fff; }
.student-record.active { border-color:var(--green); background:#fff; box-shadow:0 0 0 2px rgba(97,172,49,.1); }
.student-item { padding:7px 9px; display:flex; align-items:center; gap:9px; }
.student-initial { width:28px; height:28px; border-radius:7px; display:grid; place-items:center; flex:none; background:#e9eef4; color:var(--muted); font-size:12px; font-weight:700; }
.student-record.active .student-initial { background:var(--green); color:#fff; }
.student-label { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; font-weight:600; }

/* Clear interaction feedback for record controls. */
.record-actions button { transition:background-color .16s,color .16s,box-shadow .16s,transform .12s; }
.record-actions button:hover { background:#eef2f7; box-shadow:0 4px 10px rgba(28,39,78,.12); }
.record-actions button:first-child:hover { background:#4d9828; box-shadow:0 5px 12px rgba(77,152,40,.24); }
.record-actions button:last-child:hover { color:#fff; background:#c94b4b; box-shadow:none; }
.record-actions button:active { transform:translateY(1px) scale(.98); box-shadow:none; }
.record-actions button:focus-visible { outline:3px solid rgba(97,172,49,.28); outline-offset:2px; }
.record-actions button:last-child:focus-visible { outline-color:rgba(201,75,75,.25); }
.student-record { transition:border-color .16s,background-color .16s,box-shadow .16s; }
.student-record:hover { border-color:#bdc9d7; background:#f8fafc; }
.student-record.active:hover { border-color:var(--green); background:#fff; }

/* Stronger hover states for the two primary record actions. */
.record-actions #addRecord { background:#58aa2e; color:#fff; border:1px solid #58aa2e; box-shadow:0 3px 8px rgba(77,152,40,.2); }
.record-actions #addRecord:hover { background:#397f1c; border-color:#397f1c; transform:translateY(-2px); box-shadow:0 8px 18px rgba(57,127,28,.3); }
.record-actions #loadDemo { background:#fff; color:var(--navy); border:1px solid #d7dfea; box-shadow:0 2px 6px rgba(28,39,78,.1); }
.record-actions #loadDemo:hover { background:var(--navy); color:#fff; border-color:var(--navy); transform:translateY(-2px); box-shadow:0 8px 18px rgba(28,39,78,.25); }
.record-actions #addRecord:active,.record-actions #loadDemo:active { transform:translateY(1px) scale(.98); box-shadow:none; }
