* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', 'Noto Sans Thai', sans-serif; background: #f5f6fa; color: #222; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #1e3a5f; color: #fff; }
.topbar h1 { font-size: 1.1rem; margin: 0; font-weight: 600; }
.back { color: #cfe3ff; text-decoration: none; font-size: .9rem; }

/* home */
main#home { max-width: 760px; margin: 24px auto; padding: 0 16px; }
.course-card { background: #fff; border-radius: 12px; padding: 16px 20px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.course-card h2 { margin: 4px 0 12px; font-size: 1.2rem; color: #1e3a5f; }
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li { border-bottom: 1px solid #eee; }
.lesson-list li:last-child { border-bottom: none; }
.lesson-list a { display: flex; align-items: center; gap: 10px; padding: 10px 4px; text-decoration: none; color: #222; }
.lesson-list a:hover { background: #eef4ff; }
.lesson-list .empty { color: #999; padding: 10px 4px; }
.lesson-list .meta { margin-left: auto; color: #888; font-size: .85rem; white-space: nowrap; }

/* split view */
#split { display: flex; height: calc(100vh - 46px); }
#pane-pdf { width: 50%; min-width: 340px; border-right: 1px solid #d5dbe5; display: flex; flex-direction: column; background: #eceff4; }
.pdf-controls { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: #dde3ec; flex-wrap: wrap; }
.pdf-controls #pdf-ind { min-width: 64px; text-align: center; font-size: .9rem; }
.pdf-view { overflow: auto; flex: 1; text-align: center; }
#pdf-canvas { margin: 8px auto; box-shadow: 0 2px 10px rgba(0,0,0,.25); background: #fff; }
#pane-text { width: 50%; overflow-y: auto; padding: 16px 22px 40vh; }

.lesson-text .section { background: #fff; border-radius: 10px; padding: 14px 18px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.sec-head { display: flex; align-items: center; gap: 10px; border-bottom: 1px dashed #ccc; padding-bottom: 8px; margin-bottom: 10px; cursor: pointer; }
.sec-chip { background: #1e3a5f; color: #fff; font-size: .8rem; border-radius: 999px; padding: 3px 10px; }
.sec-read { margin-left: auto; font-size: .85rem; color: #666; }
.sec-done.done { background: #cde8cd; border-color: #7bbf7b; }

.block { margin: 12px 0; }
.box-label { font-size: .78rem; font-weight: 700; color: #1e3a5f; letter-spacing: .5px; margin-bottom: 6px; }
pre.tree { font-family: Consolas, 'Courier New', monospace; background: #f7f4ee; border: 1px solid #e2dccd; border-radius: 8px; padding: 12px; overflow-x: auto; white-space: pre; line-height: 1.5; }
.matlab-box { background: #f4f6f8; border: 1px solid #cfd6de; border-radius: 8px; padding: 10px 12px; }
pre.code { font-family: Consolas, monospace; background: #1e1e1e; color: #d4d4d4; padding: 12px; border-radius: 6px; overflow-x: auto; white-space: pre; }
.outbox summary { cursor: pointer; color: #1e5f2f; font-size: .9rem; margin-top: 6px; }
.outbox pre { background: #1e1e1e; color: #9cdcfe; padding: 10px; border-radius: 6px; overflow-x: auto; }
.exercise-box { background: #fffaf0; border: 1px solid #e8d5a8; border-radius: 8px; padding: 10px 12px; }
.exercise-box .answer { background: #eef7ee; border-radius: 6px; padding: 8px 12px; margin-top: 8px; }
.exercise-box .answer.hidden { display: none; }
.selfmark { margin-top: 8px; font-size: .9rem; }
.mark.active { background: #1e3a5f; color: #fff; }
.markstate { font-weight: 700; }
.teacher-box { background: #fff3cd; border: 1px solid #e6c25a; border-radius: 8px; padding: 10px 12px; }
.teacher-box .box-label { color: #8a6d00; }

.btn { cursor: pointer; border: 1px solid #b8c2d0; background: #fff; color: #222; border-radius: 6px; padding: 4px 10px; font-size: .85rem; font-family: inherit; }
.btn:hover { background: #eef4ff; }
.fold-btn { margin-left: auto; display: none; }

/* phone: slide on top sticky collapsible, text below */
@media (max-width: 767px) {
  #split { flex-direction: column; height: auto; display: block; }
  #pane-pdf { width: 100%; min-width: 0; position: sticky; top: 0; z-index: 10; border-right: none; border-bottom: 2px solid #1e3a5f; }
  #pane-pdf .pdf-view { max-height: 45vh; overflow: auto; }
  #pane-pdf.folded .pdf-view { display: none; }
  .fold-btn { display: inline-block; }
  #pane-text { width: 100%; padding: 12px 12px 40vh; }
}
