:root {
  color-scheme: dark;
  --ink: #f6f1e7;
  --muted: #a9a49a;
  --bg: #10100e;
  --panel: #191815;
  --panel-2: #22201c;
  --line: rgba(246, 241, 231, 0.12);
  --accent: #e05a47;
  --accent-2: #ef8f61;
  --ok: #88b89b;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 14% 2%, rgba(224,90,71,.12), transparent 30rem), var(--bg); }
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.shell { min-height: 100vh; }
.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 10; backdrop-filter: blur(18px); background: rgba(16,16,14,.8); border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #13120f; font: 800 17px/1 Georgia, serif; }
.brand-copy strong { display: block; font-size: 14px; letter-spacing: .08em; }
.brand-copy span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.button { border: 0; border-radius: 12px; min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; background: var(--ink); color: #181612; font-weight: 750; transition: transform .15s ease, opacity .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button.secondary { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
.button.ghost { background: transparent; color: var(--muted); padding-inline: 10px; }
.button.danger { background: rgba(224,90,71,.12); color: #ff9b8c; border: 1px solid rgba(224,90,71,.22); }
.button.full { width: 100%; }
.button.small { min-height: 36px; padding-inline: 12px; border-radius: 10px; font-size: 13px; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1.05fr) minmax(420px,.95fr); }
.login-story { padding: clamp(48px, 8vw, 112px); display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; background: linear-gradient(140deg, rgba(224,90,71,.12), transparent 42%); }
.wordmark { font: 600 clamp(32px, 4vw, 62px)/.92 Georgia, serif; letter-spacing: -.045em; max-width: 620px; }
.wordmark em { color: var(--accent-2); font-style: italic; }
.story-bottom { max-width: 540px; }
.eyebrow { margin: 0 0 14px; color: var(--accent-2); text-transform: uppercase; font-size: 11px; letter-spacing: .17em; font-weight: 800; }
.story-bottom h1 { font-size: clamp(30px, 4vw, 56px); line-height: 1.05; letter-spacing: -.045em; margin: 0 0 18px; }
.story-bottom p { color: var(--muted); line-height: 1.7; margin: 0; max-width: 470px; }
.login-side { min-height: 100vh; background: #f0ebe1; color: #171612; display: grid; place-items: center; padding: 32px; }
.login-card { width: min(420px,100%); }
.mobile-brand { display: none; margin-bottom: 48px; }
.login-card h2 { font-size: 32px; letter-spacing: -.04em; margin: 0 0 10px; }
.login-card > p { color: #6e6a63; margin: 0 0 32px; line-height: 1.6; }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-size: 13px; font-weight: 750; }
.field input, .field textarea { width: 100%; min-height: 50px; border-radius: 12px; border: 1px solid #d2ccc0; background: #faf7f1; color: #171612; padding: 0 14px; outline: none; }
.field textarea { padding: 13px 14px; resize: vertical; line-height: 1.6; }
.field input:focus, .field textarea:focus { border-color: #8e8678; box-shadow: 0 0 0 3px rgba(224,90,71,.12); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 58px; }
.password-toggle { position: absolute; right: 8px; top: 7px; height: 36px; border: 0; background: transparent; color: #726c62; cursor: pointer; font-weight: 700; font-size: 12px; }
.login-side .button { background: #181612; color: white; }
.login-error { min-height: 20px; margin: -4px 0 10px; color: #b14235; font-size: 13px; }
.demo-box { margin-top: 24px; padding-top: 20px; border-top: 1px solid #d8d1c5; }
.demo-box > span { display: block; color: #7f786d; font-size: 12px; margin-bottom: 10px; }
.demo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-login { border: 1px solid #cec6b8; background: transparent; color: #4c473f; border-radius: 999px; padding: 8px 11px; cursor: pointer; font-size: 12px; font-weight: 750; }

main { padding: 58px 0 90px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 36px; }
.hero h1 { margin: 0; font-size: clamp(34px, 5vw, 62px); line-height: 1; letter-spacing: -.055em; }
.hero p { color: var(--muted); margin: 14px 0 0; line-height: 1.6; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { min-width: 112px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(25,24,21,.78); }
.stat strong { display: block; font-size: 24px; }
.stat span { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }

.lesson-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.lesson-card { min-width: 0; border: 1px solid var(--line); background: var(--panel); border-radius: 20px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; transition: transform .18s ease, border-color .18s ease; }
.lesson-card:hover { transform: translateY(-3px); border-color: rgba(246,241,231,.26); }
.lesson-cover { aspect-ratio: 16/10; display: flex; flex-direction: column; justify-content: space-between; padding: 18px; background: linear-gradient(145deg, #4e2924, #171613 70%); }
.lesson-card:nth-child(2) .lesson-cover { background: linear-gradient(145deg, #3d3428, #171613 70%); }
.lesson-card:nth-child(3) .lesson-cover { background: linear-gradient(145deg, #273a3b, #171613 70%); }
.lesson-index { color: rgba(255,255,255,.7); font: italic 16px Georgia, serif; }
.play-badge { align-self: flex-end; width: 48px; aspect-ratio: 1; border-radius: 50%; background: rgba(246,241,231,.94); color: #151411; display: grid; place-items: center; font-size: 15px; }
.lesson-body { padding: 20px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag { padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; letter-spacing: .03em; }
.lesson-body h2 { margin: 0 0 9px; font-size: 19px; letter-spacing: -.02em; }
.lesson-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.empty { padding: 52px 24px; text-align: center; border: 1px dashed var(--line); border-radius: 20px; color: var(--muted); }

.admin-layout { display: grid; grid-template-columns: 290px minmax(0,1fr); gap: 22px; align-items: start; }
.admin-tabs { display: inline-flex; gap: 5px; padding: 5px; margin: -8px 0 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.admin-tab { min-height: 38px; padding: 0 15px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 750; }
.admin-tab.active { background: var(--ink); color: #171612; }
.panel { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; overflow: hidden; }
.panel-title { padding: 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-title h2 { margin: 0; font-size: 16px; }
.student-list { padding: 8px; }
.student-row { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; background: transparent; color: var(--ink); border-radius: 13px; padding: 11px; cursor: pointer; text-align: left; }
.student-row:hover, .student-row.active { background: var(--panel-2); }
.avatar { width: 38px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: #34302a; color: var(--ink); font-weight: 800; font-size: 13px; flex: 0 0 auto; }
.student-row-copy { min-width: 0; flex: 1; }
.student-row-copy strong, .student-row-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-row-copy strong { font-size: 13px; }
.student-row-copy span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.count { color: var(--muted); font-size: 11px; }
.permission-head { padding: 24px; display: flex; justify-content: space-between; gap: 20px; align-items: center; border-bottom: 1px solid var(--line); }
.permission-head h2 { margin: 0 0 5px; font-size: 22px; }
.permission-head p { color: var(--muted); margin: 0; font-size: 12px; }
.permission-list { padding: 8px; }
.permission-item { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; padding: 17px 16px; border-bottom: 1px solid var(--line); }
.permission-item:last-child { border-bottom: 0; }
.permission-item strong { display: block; font-size: 14px; }
.permission-item span { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.switch { appearance: none; width: 48px; height: 28px; border-radius: 999px; background: #393630; position: relative; cursor: pointer; transition: background .15s ease; }
.switch::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #aaa49a; top: 3px; left: 3px; transition: transform .15s ease, background .15s ease; }
.switch:checked { background: rgba(136,184,155,.45); }
.switch:checked::after { transform: translateX(20px); background: #d9f3e3; }
.system-note { margin-top: 18px; color: var(--muted); font-size: 11px; text-align: right; }
.lesson-manager { width: 100%; }
.content-list { padding: 4px 18px 10px; }
.content-row { display: grid; grid-template-columns: 46px minmax(0,1fr) auto; gap: 16px; align-items: center; padding: 20px 4px; border-bottom: 1px solid var(--line); }
.content-row:last-child { border-bottom: 0; }
.content-number { color: var(--accent-2); font: italic 18px Georgia, serif; }
.content-copy { min-width: 0; }
.content-copy .tags { margin-bottom: 8px; }
.content-copy h3 { margin: 0 0 5px; font-size: 17px; }
.content-copy p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.content-status { display: block; margin-top: 9px; color: #7eaa8f; font-size: 10px; }
.content-actions { display: flex; gap: 7px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.74); display: grid; place-items: center; padding: 18px; animation: fade .15s ease; }
.modal { width: min(760px,100%); max-height: min(900px, calc(100vh - 36px)); overflow: auto; background: #1c1b18; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; background: rgba(28,27,24,.94); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.icon-button { width: 38px; aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer; }
.lesson-detail video { display: block; width: 100%; aspect-ratio: 16/9; background: #080808; }
.video-frame { width: 100%; aspect-ratio: 16/9; background: #080808; }
.video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.video-empty { width: 100%; aspect-ratio: 16/6; display: grid; place-items: center; background: #11110f; color: var(--muted); font-size: 13px; }
.detail-content { padding: 24px; }
.detail-content h1 { margin: 6px 0 10px; font-size: clamp(28px,5vw,42px); letter-spacing: -.04em; }
.detail-lede { color: var(--muted); line-height: 1.65; margin: 0 0 24px; }
.info-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.info-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 17px; }
.info-box span { display: block; color: var(--accent-2); font-size: 10px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; margin-bottom: 9px; }
.info-box p { margin: 0; font-size: 13px; line-height: 1.65; }
.written-material { margin-top: 14px; padding: clamp(20px, 4vw, 30px); border: 1px solid var(--line); border-radius: 18px; background: #f0ebe1; color: #1b1915; }
.written-material > span { display: block; margin-bottom: 18px; color: #ad4437; font-size: 10px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.written-material p { margin: 0 0 14px; font-size: 14px; line-height: 1.8; }
.written-material p:last-child { margin-bottom: 0; }
.form-modal { width: min(460px,100%); }
.form-body { padding: 22px; }
.form-body .field input, .form-body .field textarea { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
.editor-modal { width: min(780px,100%); }
.editor-body { padding-bottom: 30px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.label-note { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 500; }
.form-error { color: #ff9587; font-size: 12px; min-height: 18px; margin-bottom: 8px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 100; transform: translate(-50%, 24px); opacity: 0; pointer-events: none; background: #eee9df; color: #151411; border-radius: 999px; padding: 11px 16px; font-size: 12px; font-weight: 750; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%,0); }
@keyframes fade { from { opacity: 0; } }

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .login-side { min-height: 100vh; padding: 28px 22px; }
  .mobile-brand { display: flex; color: #171612; }
  .mobile-brand .brand-mark { background: #171612; color: #f6f1e7; }
  .lesson-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .admin-layout { grid-template-columns: 1fr; }
  .student-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 12px; }
  .student-row { min-width: 190px; }
}

@media (max-width: 600px) {
  .wrap { width: min(100% - 24px,1120px); }
  .topbar-inner { min-height: 64px; }
  .brand-copy span, .user-label { display: none; }
  .hero { align-items: start; flex-direction: column; }
  .hero h1 { font-size: 38px; }
  .stats { width: 100%; }
  .stat { flex: 1; }
  main { padding-top: 36px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .lesson-cover { aspect-ratio: 16/8.4; }
  .permission-head { align-items: start; flex-direction: column; }
  .permission-head .button { width: 100%; }
  .content-row { grid-template-columns: 34px minmax(0,1fr); align-items: start; }
  .content-actions { grid-column: 2; }
  .content-actions .button { flex: 1; }
  .info-grid { grid-template-columns: 1fr; }
  .detail-content { padding: 20px; }
  .header-actions .button { min-height: 38px; padding-inline: 11px; font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

button:disabled, input:disabled { cursor: not-allowed; opacity: .55; }

.auth-tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 28px; border-radius: 12px; background: #ded7ca; }
.auth-tab { min-width: 88px; min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: #6e675d; cursor: pointer; font-size: 14px; font-weight: 800; }
.auth-tab.active { background: #fffdf8; color: #171612; box-shadow: 0 2px 10px rgba(33,27,20,.08); }
.field label { font-size: 14px; }
.auth-notice { margin: 0 0 16px; padding: 13px 14px; border-radius: 11px; background: #dce9df; color: #30543b; font-size: 14px; line-height: 1.55; }
.form-help { margin: 15px 0 0 !important; color: #766f65 !important; font-size: 13px; text-align: center; }
.text-button { width: 100%; margin-top: 14px; border: 0; background: transparent; color: #625c53; cursor: pointer; font-size: 14px; font-weight: 750; text-align: center; }
.text-button:hover { text-decoration: underline; }

.loading-page, .status-page { min-height: 100vh; padding: 28px; display: grid; place-items: center; }
.loading-page { align-content: center; gap: 15px; color: var(--muted); text-align: center; }
.loading-mark { width: 58px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #171612; font: 800 23px/1 Georgia, serif; animation: pulse 1.1s ease-in-out infinite alternate; }
.loading-page p { margin: 0; font-size: 14px; }
.status-card { width: min(560px, 100%); padding: clamp(28px, 6vw, 54px); border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: var(--shadow); text-align: center; }
.status-icon { width: 56px; aspect-ratio: 1; display: grid; place-items: center; margin: 0 auto 24px; border-radius: 50%; background: rgba(239,143,97,.12); color: var(--accent-2); font-size: 24px; }
.status-card h1 { margin: 0 0 16px; font-size: clamp(27px, 5vw, 40px); letter-spacing: -.04em; }
.status-card > p:not(.eyebrow) { margin: 0 auto 22px; color: var(--muted); line-height: 1.7; }
.status-email { width: fit-content; max-width: 100%; margin: 0 auto 24px; padding: 10px 14px; overflow: hidden; text-overflow: ellipsis; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.status-card .button + .button { margin-left: 8px; }

.panel-subtitle { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.status-badge { flex: 0 0 auto; display: inline-flex !important; width: fit-content; margin: 0 !important; padding: 5px 8px; border-radius: 999px; font-size: 10px !important; font-weight: 800; white-space: nowrap; }
.status-badge.pending { background: rgba(239,143,97,.14); color: #f4a47b !important; }
.status-badge.approved { background: rgba(136,184,155,.14); color: #a9d5b7 !important; }
.status-badge.rejected { background: rgba(224,90,71,.14); color: #ff9b8c !important; }
.title-line { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.title-line h2 { margin: 0; }
.approval-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.permission-caption { padding: 12px 16px 6px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.permission-item.disabled { opacity: .52; }
.empty.compact { margin: 8px; padding: 26px 16px; font-size: 13px; }

.publish-option { display: flex; align-items: flex-start; gap: 11px; margin: 4px 0 20px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); cursor: pointer; }
.publish-option input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--ok); }
.publish-option strong, .publish-option small { display: block; }
.publish-option strong { font-size: 14px; }
.publish-option small { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.modal-copy { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.account-form .field { text-align: left; }
.account-panel { max-width: 760px; }
.account-settings-form { padding: clamp(22px, 5vw, 34px); }
.current-account { display: grid; gap: 6px; margin-bottom: 24px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); }
.current-account span { color: var(--muted); font-size: 12px; }
.current-account strong { overflow-wrap: anywhere; font-size: 16px; }
.settings-note { margin: 18px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }

@keyframes pulse { from { transform: scale(.96); opacity: .72; } to { transform: scale(1.04); opacity: 1; } }

@media (max-width: 600px) {
  .approval-actions { width: 100%; }
  .approval-actions .button { flex: 1; }
  .status-card .button { width: 100%; }
  .status-card .button + .button { margin: 8px 0 0; }
}
