:root {
  --blue: #374f7f;
  --blue-dark: #2c4272;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --ok: #16a34a;
  --warn: #b45309;
  --bad: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.5; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.clickable { cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.card.clickable:hover { border-color: var(--blue); box-shadow: 0 2px 10px rgba(55,79,127,.12); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }

.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--blue); background: var(--blue); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--blue); }
.btn.secondary:hover { background: #eef2f8; }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: .35rem .7rem; font-size: .85rem; }
.btn.link { background: none; border: none; color: var(--blue); padding: 0; font-weight: 500; }

.chip { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef2f8; color: var(--blue); letter-spacing: .02em; }
.chip.ok { background: #dcfce7; color: #166534; }
.chip.warn { background: #fef3c7; color: #92400e; }
.chip.off { background: #f1f5f9; color: var(--muted); }

.progress { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--blue); border-radius: 4px; transition: width .3s; }

.notice { padding: .7rem 1rem; border-radius: 8px; border: 1px solid; margin-bottom: 1rem; }
.notice.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.notice.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.notice.bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=number], input[type=url], textarea, select {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: .85rem; }
.fields { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; align-items: flex-start; gap: .55rem; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.check input { margin-top: .25rem; }
.check.correct { border-color: #86efac; background: #f0fdf4; }
.check.wrong { border-color: #fecaca; background: #fef2f2; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code { background: #f1f5f9; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }

video { width: 100%; max-height: 480px; background: #000; border-radius: var(--radius); }
.shot { margin: 0; }
.shot-img { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; touch-action: pan-y pinch-zoom; }
.shot img { display: block; width: 100%; max-height: 72vh; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.shot figcaption { margin-top: .6rem; font-size: 1rem; }
.shot-nav { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .75rem; }
.shot-nav .btn { min-width: 3.25rem; min-height: 2.75rem; }
.dots { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem; }
.dots i { width: .5rem; height: .5rem; border-radius: 50%; background: #cbd5e1; }
.dots i.seen { background: #94a3b8; }
.dots i.on { background: var(--blue); width: 1.1rem; border-radius: .25rem; }
.dots .small { margin-left: .35rem; }
.btn.block { display: block; width: 100%; text-align: center; }

.zoom { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, .96); display: flex; flex-direction: column; }
.zoom-stage { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; touch-action: pan-x pan-y pinch-zoom; }
.zoom-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.zoom-close { position: absolute; top: .6rem; right: .6rem; z-index: 1; width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 1.2rem; cursor: pointer; }
.zoom-bar { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom)); color: #fff; }
.zoom-bar .btn { min-width: 3.25rem; min-height: 2.75rem; }
body.zoomed { overflow: hidden; }

.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-card { background: var(--surface); border-radius: 16px; width: 100%; max-width: 480px; max-height: calc(100vh - 2rem); overflow: auto; padding: 1.5rem 1.4rem 1.25rem; box-shadow: 0 20px 50px rgba(15, 23, 42, .25); animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.done { text-align: left; }
.done h2 { text-align: center; margin-top: .75rem; }
.done > p { text-align: center; }
.done-score { width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: conic-gradient(var(--ok) 0 100%, #e2e8f0 0); padding: 7px; }
.done-score span { width: 100%; height: 100%; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; color: var(--ok); }
.done-level { display: flex; gap: .85rem; align-items: center; background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; margin: .5rem 0 1rem; }
.done h3 { margin-top: .25rem; }
.done-list { margin: 0 0 .75rem; padding-left: 1.15rem; font-size: .92rem; }
.done-list li { margin-bottom: .35rem; }
.done-cheer { font-weight: 600; color: var(--blue); text-align: center; }
.done-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: .75rem; }
.done-actions .btn { min-height: 2.75rem; flex: 1; min-width: 9rem; display: inline-flex; align-items: center; justify-content: center; }

.lesson-menu > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: .75rem; font-weight: 600; }
.lesson-menu > summary .small { white-space: nowrap; font-weight: 400; }
.lesson-menu > summary::-webkit-details-marker { display: none; }
.lesson-menu > summary::after { content: '▾'; color: var(--muted); }
.lesson-menu[open] > summary::after { content: '▴'; }
.lesson-menu[open] > summary { margin-bottom: .6rem; }
.course-desc { margin-top: .5rem; }
@media (min-width: 761px) {
  .lesson-menu > summary { display: none; }
  .two-col > .lesson-menu { align-self: start; position: sticky; top: 1rem; }
}
@media (max-width: 760px) {
  .wide-only { display: none; }
  .container { padding: 1rem 12px 3rem; }
  .card { padding: .9rem 1rem; }
  body.in-course .page-head, body.in-course #level-panel { display: none; }
  .page-head h1 { font-size: 1.35rem; }
  .back { margin-bottom: .5rem; }
  .course-head h2 { font-size: 1.1rem; }
  .course-desc { display: none; }
  .lesson-nav li { padding: .75rem; }
  .shot { margin: 0 -1rem; }
  .shot img { border-left: 0; border-right: 0; border-radius: 0; max-height: none; }
  .shot figcaption { padding: 0 1rem; }
  .check { padding: .75rem; }
  #quiz-form .btn, #quiz-result .btn { width: 100%; margin-top: .5rem; min-height: 2.75rem; }
}
.shot-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: .6rem; }
.shot-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem; }
.shot-item img { display: block; width: 100%; height: 110px; object-fit: cover; object-position: top; border-radius: 6px; background: #f1f5f9; margin-bottom: .35rem; }
.shot-item input { font-size: .82rem; }
.dropzone { border: 2px dashed var(--border); border-radius: 8px; padding: .7rem .9rem; color: var(--muted); font-size: .85rem; text-align: center; outline: none; }
.dropzone:focus, .dropzone.over { border-color: var(--blue); color: var(--blue); background: #eef2f8; }

.level-big { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 1.5rem; font-weight: 700; }
.level-big.unrated { background: #cbd5e1; color: #475569; font-size: .8rem; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; padding: .6rem .9rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }

.lesson-nav { list-style: none; padding: 0; margin: 0; }
.lesson-nav li { padding: .6rem .75rem; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: .5rem; }
.lesson-nav li:hover { background: #eef2f8; }
.lesson-nav li.active { background: var(--blue); color: #fff; }

.two-col { display: grid; gap: 1rem; grid-template-columns: 280px 1fr; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

.footer { margin-top: 3rem; font-size: .8rem; color: var(--muted); text-align: center; }
