:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --line: #dce2ec;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #15803d;
  --shadow: 0 14px 35px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Apple SD Gothic Neo",
    "Noto Sans KR",
    Arial,
    sans-serif;
  background: var(--bg);
}

body.book-drag-active {
  cursor: grabbing;
  user-select: none;
}

/* iPhone Safari가 전화번호/날짜를 자동 링크로 인식하면서 생기는 밑줄 제거 */
a[x-apple-data-detectors],
a[href^="tel"],
a[href^="sms"],
a[href^="mailto"] {
  color: inherit !important;
  font: inherit !important;
  text-decoration: none !important;
  border-bottom: 0 !important;
}

.admin-item,
.admin-item *,
.admin-user-row,
.admin-user-row * {
  text-decoration: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 44px);
  color: white;
  background: linear-gradient(135deg, #102a62, #2563eb);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: -1px;
}

.topbar p {
  margin: 6px 0 0;
  opacity: 0.9;
}

.user-box {
  text-align: right;
  font-size: 14px;
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 24px auto 60px;
}

.card,
.admin-section-card {
  margin-bottom: 22px;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 560px;
  margin: 36px auto;
}

.hidden {
  display: none !important;
}

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

.message {
  min-height: 24px;
  color: var(--primary-dark);
  font-weight: 700;
}

hr {
  margin: 24px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.form-grid,
.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 13px;
  color: var(--text);
  font-size: 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
}

input[type="file"] {
  padding: 10px;
}

.file-select-row {
  display: flex;
  gap: 10px;
}

.file-select-row .file-select-label {
  flex: 1;
  min-width: 0;
}

.admin-form-buttons {
  display: flex;
  gap: 10px;
}

.admin-form-buttons button {
  flex: 1;
}

.admin-materials-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--card, #f7f7f7);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.admin-material-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-material-row a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-select-label {
  display: block;
  width: 100%;
  padding: 12px 13px;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.file-select-label:hover {
  background: #f8fafc;
}

button {
  padding: 12px 14px;
  color: white;
  font-size: 16px;
  font-weight: 800;
  background: var(--primary);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: #475569;
}

button.secondary:hover {
  background: #334155;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #b91c1c;
}

button.small {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
}

.section-title {
  margin: 4px 0 20px;
}

.section-title h2 {
  margin: 0;
  font-size: 29px;
}

.section-title p {
  margin: 7px 0 0;
  color: var(--muted);
}

.testament-section {
  margin-bottom: 38px;
}

.admin-testament-section {
  margin-bottom: 0;
}

.testament-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
  padding-bottom: 9px;
  border-bottom: 3px solid #2563eb;
}

.testament-title-row h2 {
  margin: 0;
  font-size: 28px;
}

.testament-title-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.testament-overall-progress {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 270px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.testament-overall-progress:empty {
  display: none;
}

.testament-overall-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.testament-overall-bar {
  width: 150px;
  height: 9px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 999px;
}

.testament-overall-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: inherit;
}

.testament-overall-progress b {
  min-width: 38px;
  color: var(--primary-dark);
  font-size: 16px;
  text-align: right;
}

.testament-overall-progress em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

/* 관리자 섹션 제목 */

.admin-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-bottom: 18px;
}

.admin-heading h2 {
  margin: 0;
  font-size: 29px;
}

.admin-heading p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}


#adminSection > .card.admin-section-card > .admin-heading {
  margin-bottom: 13px;
  padding-bottom: 9px;
  border-bottom: 3px solid #2563eb;
}

/* 책 추가 / 강의 추가, 순서변경 두 칸 배열 */

.admin-two-column-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 22px;
}

/*
  책 추가와 강의 추가 카드의 높이를 동일하게 유지하고,
  버튼은 항상 카드 맨 아래 같은 위치에 맞춥니다.
*/

.admin-two-column-row > .admin-form-card {
  display: flex;
  flex-direction: column;
}

.admin-form-card {
  margin-bottom: 0;
}

.admin-form-card .admin-heading h2 {
  font-size: 25px;
}

.admin-two-column-row > .admin-form-card .admin-form-grid {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
}

.admin-two-column-row > .admin-form-card .admin-form-grid button {
  margin-top: auto;
}

/* 구약 / 신약 / 기타 책 순서변경 2칸 배열 */

.admin-book-order-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  align-items: start;
  margin-bottom: 22px;
}

.admin-book-order-row > .admin-form-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* 회원 승인 */

.admin-list {
  display: grid;
  gap: 9px;
  width: 100%;
  max-width: 100%;
  max-height: 320px;
  padding-right: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #eef2f7;
}

.admin-list::-webkit-scrollbar {
  width: 8px;
  height: 0;
}

.admin-list::-webkit-scrollbar-track {
  background: #eef2f7;
  border-radius: 99px;
}

.admin-list::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 99px;
}

.admin-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 10px 12px;
  overflow: hidden;
  background: white;
  border: 1px solid #e8edf5;
  border-radius: 14px;
  box-shadow: none;
}

.admin-user-row {
  display: grid;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.admin-user-row-top {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.admin-user-row-bottom {
  grid-template-columns: auto minmax(0, 1fr);
}

.admin-user-name,
.admin-phone,
.admin-until {
  display: inline-block;
  min-width: 0;
  white-space: nowrap;
}

.admin-user-name {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
}

.admin-username {
  margin-left: 2px;
  color: var(--muted);
  font-weight: 700;
}

.admin-phone {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.admin-until {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-user-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
}

.admin-user-actions-placeholder {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-user-actions button {
  min-height: 0;
  padding: 7px 9px;
  font-size: 13px;
  line-height: 1;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  background: #e0ecff;
  border-radius: 999px;
}

.badge.ok {
  color: var(--ok);
  background: #dcfce7;
}

.badge.blocked {
  color: var(--danger);
  background: #fee2e2;
}

.badge.pending {
  color: #b45309;
  background: #fef3c7;
}

/* 책 카드: 항상 4칸 */

.book-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.book-tile {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.book-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.15);
}

.book-tile-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.book-tile-image-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #e5e7eb;
}

.book-tile-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-tile-empty-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  background: #eef2f7;
}

.book-tile-body {
  padding: 14px;
}

.book-tile-body h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
}

.book-tile-body p {
  min-height: 38px;
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.book-tile-body span {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
}

.book-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.book-total-progress {
  margin-top: 10px;
}

.book-total-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.book-total-progress-head b {
  color: var(--primary-dark);
  font-size: 13px;
}

.book-total-progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 999px;
}

.book-total-progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: inherit;
}

.book-grid-drag-handle,
.book-edit-button,
.book-delete-button {
  position: absolute;
  top: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 66px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  border-radius: 9px;
  touch-action: none;
  user-select: none;
}

.book-edit-button {
  right: 82px;
}

.book-grid-drag-handle {
  left: 8px;
  color: #1d4ed8;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  cursor: grab;
}

.book-grid-drag-handle:hover {
  background: #bfdbfe;
}

.book-grid-drag-handle:active {
  cursor: grabbing;
}

.book-delete-button {
  right: 8px;
}

.book-button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 12px;
  font-size: 15px;
  font-weight: 900;
}

.book-button-text {
  font-size: 12px;
  font-weight: 800;
}

.book-empty-box {
  grid-column: 1 / -1;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
}

/* 구약 / 신약 책 순서변경 */

.admin-book-order-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  padding-right: 6px;
  overflow-y: auto;
}

.admin-book-order-empty {
  padding: 16px;
  color: var(--muted);
  text-align: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.admin-book-order-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
}

.book-order-handle {
  min-height: 38px;
  padding: 7px 9px;
  color: #1d4ed8;
  font-size: 12px;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  border-radius: 9px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.book-order-handle:active {
  cursor: grabbing;
}

.book-order-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.book-order-info b {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-order-info span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-order-message {
  min-height: 22px;
  margin: 0 0 25px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}

.book-order-message.error {
  color: var(--danger);
}

/* lessons.html 기존 화면 유지용 */

.lesson-page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin: 4px 0 18px;
}

.lesson-page-head h2 {
  margin: 0;
  font-size: 30px;
}

.lesson-page-head p {
  margin: 7px 0 0;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  color: white;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  background: #475569;
  border-radius: 12px;
  white-space: nowrap;
}

.lesson-grid-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.lesson-detail-card {
  min-width: 0;
  overflow: hidden;
  background: white;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.lesson-thumbnail-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  background: #e5e7eb;
  border: 0;
  border-radius: 0;
}

.lesson-thumbnail-button img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.lesson-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 66px;
  height: 66px;
  padding-left: 4px;
  color: white;
  font-size: 26px;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.lesson-detail-body {
  padding: 16px;
}

.lesson-detail-body h3 {
  min-height: 46px;
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
}

.video-overlay {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  padding: 18px;
  color: white;
  background: #000;
  overscroll-behavior: contain;
}

.video-overlay-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
  max-width: 1480px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px 24px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
}

.video-overlay-title-wrap {
  min-width: 0;
}

.video-overlay-label {
  margin: 0 0 4px;
  color: #b7c8ef;
  font-size: 13px;
  font-weight: 800;
}

.video-overlay-header h2 {
  overflow: hidden;
  margin: 0;
  font-size: clamp(18px, 2.5vw, 28px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-material-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.book-material-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
}

.video-close-button {
  flex: 0 0 auto;
  min-width: 92px;
  background: #dc2626;
  pointer-events: auto;
}

.video-overlay-player-area {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: min(1480px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 8px 0;
}

.video-overlay-player {
  width: min(100%, calc((100vh - 55px) * 16 / 9), 1280px);
  width: min(100%, calc((100dvh - 55px) * 16 / 9), 1280px);
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 55px);
  max-height: calc(100dvh - 55px);
  background: black;
  border-radius: 14px;
  overflow: hidden;
}

.video-overlay-player iframe,
.video-overlay-player #videoOverlayPlayer {
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: black;
  border: 0;
}

.video-overlay-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.video-overlay-footer button {
  width: 100%;
  pointer-events: auto;
}

#videoOverlayProgress {
  font-weight: 700;
  opacity: 0.85;
}

/* 아이폰 Safari 선택 영역 방지 */

.book-grid,
.book-grid *,
.admin-book-order-list,
.admin-book-order-list * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.book-tile,
.book-tile-link,
.book-tile-image-wrap,
.book-tile-image,
.book-tile-body,
.book-grid-drag-handle,
.book-delete-button {
  -webkit-user-drag: none;
}

@media (max-width: 900px) {
  .admin-two-column-row,
  .admin-book-order-row {
    gap: 14px;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-box {
    text-align: left;
  }

  main {
    width: min(100% - 16px, 1180px);
    margin-top: 12px;
  }

  .card,
  .admin-section-card {
    padding: 16px;
    border-radius: 18px;
  }

  .section-title h2,
  .testament-title-row h2 {
    font-size: 23px;
  }

  .testament-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .testament-overall-progress {
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    gap: 6px;
    font-size: 12px;
  }

  .testament-overall-bar {
    flex: 1;
    width: auto;
    min-width: 90px;
    height: 8px;
  }

  .testament-overall-progress b {
    min-width: 34px;
    font-size: 14px;
  }

  .testament-overall-progress em {
    display: none;
  }

  .admin-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .admin-heading h2 {
    font-size: 24px;
  }

  .admin-heading p {
    font-size: 13px;
  }

  .admin-two-column-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
  }

  .admin-book-order-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
  }

  .admin-form-card {
    padding: 12px;
    border-radius: 15px;
  }

  .admin-form-card .admin-heading h2 {
    font-size: 19px;
  }

  .admin-form-card .admin-heading p {
    display: none;
  }

  .admin-form-grid {
    gap: 7px;
  }

  .admin-two-column-row > .admin-form-card .admin-form-grid {
    gap: 7px;
  }

  .admin-form-grid input,
  .admin-form-grid select,
  .admin-form-grid button,
  .admin-form-grid .file-select-label {
    padding: 9px 8px;
    font-size: 12px;
  }

  .admin-list {
    max-height: 300px;
    padding-right: 4px;
    overflow-x: hidden;
  }

  .admin-item {
    gap: 6px;
    padding: 8px 7px;
    min-width: 0;
    box-shadow: none;
  }

  .admin-user-row {
    gap: 5px;
  }

  .admin-user-row-top {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .admin-user-row-bottom {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .admin-user-name {
    font-size: 11px;
  }

  .admin-phone {
    font-size: 10px;
  }

  .admin-until {
    font-size: 10px;
  }

  .admin-username {
    margin-left: 1px;
  }

  .badge {
    padding: 2px 5px;
    font-size: 10px;
  }

  .admin-user-actions {
    gap: 3px;
  }

  .admin-user-actions-placeholder {
    font-size: 10px;
  }

  .admin-user-actions button {
    padding: 6px 6px;
    font-size: 10px;
    border-radius: 7px;
  }

  .book-grid {
    gap: 7px;
  }

  .book-tile {
    border-radius: 10px;
  }

  .book-tile-body {
    padding: 8px;
  }

  .book-tile-body h3 {
    font-size: 13px;
    word-break: keep-all;
  }

  .book-tile-body p {
    display: none;
  }

  .book-tile-body span {
    font-size: 10px;
  }

  .book-total-progress {
    margin-top: 6px;
  }

  .book-total-progress-head {
    margin-bottom: 3px;
    font-size: 8px;
  }

  .book-total-progress-head b {
    font-size: 9px;
  }

  .book-total-progress-bar {
    height: 5px;
  }

  .book-grid-drag-handle,
  .book-edit-button,
  .book-delete-button {
    top: 4px;
    width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border-radius: 7px;
  }

  .book-grid-drag-handle {
    left: 4px;
  }

  .book-edit-button {
    right: 32px;
  }

  .book-delete-button {
    right: 4px;
  }

  .book-button-icon {
    min-width: 0;
    font-size: 14px;
  }

  .book-button-text {
    display: none;
  }

  .admin-book-order-item {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 5px;
  }

  .book-order-handle {
    padding: 7px;
    font-size: 10px;
  }

  .lesson-page-head {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 10px;
  }

  .lesson-grid-detail {
    gap: 8px;
  }

  .lesson-detail-card {
    border-radius: 12px;
  }

  .lesson-play-icon {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  .lesson-detail-body {
    padding: 10px;
  }

  .lesson-detail-body h3 {
    min-height: 40px;
    font-size: 14px;
  }

  .video-overlay {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  .video-overlay-header {
    align-items: flex-start;
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 12px 20px;
  }

  .video-overlay-label {
    margin-bottom: 2px;
    font-size: 11px;
  }

  .video-overlay-header h2 {
    font-size: 17px;
    line-height: 1.25;
    white-space: normal;
  }

  .video-close-button {
    min-width: 62px;
    min-height: 36px;
    padding: 8px 8px;
    font-size: 12px;
    border-radius: 10px;
  }

  .video-overlay-player-area {
    padding: 4px 0;
  }

  .video-overlay-player {
    width: min(100%, calc((100vh - 20px) * 16 / 9), 1280px);
    width: min(100%, calc((100dvh - 20px) * 16 / 9), 1280px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 8px;
  }

  .video-overlay-footer button {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 10px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .video-overlay {
    padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  }

  .video-overlay-header {
    padding: max(6px, env(safe-area-inset-top)) 10px 16px;
  }

  .video-overlay-label {
    display: none;
  }

  .video-overlay-header h2 {
    font-size: 15px;
  }

  .video-close-button {
    min-width: 58px;
    min-height: 32px;
    padding: 6px 8px;
    font-size: 11px;
    border-radius: 9px;
  }

  .video-overlay-player {
    width: min(100%, calc((100vh - 20px) * 16 / 9));
    width: min(100%, calc((100dvh - 20px) * 16 / 9));
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  .video-overlay-footer {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  }

  .video-overlay-footer button {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 9px;
  }
}

/* 시청기록 / 이어보기 */

.admin-watch-history-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.watch-history-card {
  margin-bottom: 24px;
}

.watch-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 9px;
  border-bottom: 3px solid #2563eb;
}

.watch-history-head h2 {
  margin: 0;
  font-size: 25px;
}

.admin-watch-history-head h2 {
  font-size: 21px;
}

.watch-history-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.watch-history-list {
  display: grid;
  gap: 8px;
}

.watch-history-empty {
  padding: 15px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.watch-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  color: var(--text);
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.watch-history-item:hover {
  background: #eef5ff;
}

.watch-history-open {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
  padding: 2px;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.watch-history-open:hover {
  background: transparent;
}

.watch-history-delete {
  min-width: 48px;
  padding: 8px 9px;
  white-space: nowrap;
}

.watch-history-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: white;
  font-size: 12px;
  font-weight: 900;
  background: #2563eb;
  border-radius: 999px;
}

.watch-history-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.watch-history-main b,
.watch-history-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watch-history-main b {
  font-size: 14px;
}

.watch-history-main span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.watch-history-status {
  display: grid;
  justify-items: end;
  gap: 3px;
  white-space: nowrap;
}

.watch-history-status b {
  color: var(--primary-dark);
  font-size: 13px;
}

.watch-history-status em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.watch-history-date {
  color: #64748b;
}

.lesson-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.lesson-progress-label {
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.lesson-progress-label.complete {
  color: var(--ok);
}

.lesson-progress-resume {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 6px 10px;
  color: #ffffff;
  background: #2563eb;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 1;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.lesson-progress-resume:hover,
.lesson-progress-resume:active,
.lesson-progress-resume:focus,
.lesson-progress-resume:focus-visible {
  color: #ffffff;
  background: #2563eb;
  opacity: 1;
  outline: none;
  text-decoration: none;
}

.lesson-progress-bar {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 99px;
}

.lesson-progress-bar span {
  display: block;
  height: 100%;
  background: #2563eb;
  border-radius: 99px;
}

@media (max-width: 560px) {
  .watch-history-card {
    margin-bottom: 18px;
  }

  .watch-history-head h2 {
    font-size: 22px;
  }

  .watch-history-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    padding: 7px;
  }

  .watch-history-open {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 7px;
    padding: 1px;
  }

  .watch-history-delete {
    min-width: 42px;
    padding: 7px 7px;
    font-size: 11px;
  }

  .watch-history-status {
    grid-column: 2;
    grid-template-columns: auto auto;
    justify-content: space-between;
    justify-items: start;
  }

  .watch-history-date {
    grid-column: 1 / -1;
  }

  .watch-history-main b {
    font-size: 13px;
  }

  .watch-history-main span,
  .watch-history-status b,
  .watch-history-status em {
    font-size: 11px;
  }

  .lesson-progress-row {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
  }

  .lesson-progress-label {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
  }

  .lesson-progress-resume {
    flex: 0 0 auto;
    margin-left: auto;
    max-width: 64%;
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 8px;
  }

}


@media (max-width: 420px) {
  .testament-overall-label {
    font-size: 11px;
  }

  .testament-overall-progress {
    gap: 5px;
  }
}
