/* ───────── 색 (macOS Finder 느낌) ───────── */
:root {
  --desk: linear-gradient(140deg, #8fb8f0 0%, #b9a8ee 48%, #f2b9cb 100%);
  --win: #ffffff;
  --side: rgba(244, 244, 247, 0.78);
  --side-solid: #f4f4f7;
  --side-border: rgba(0, 0, 0, 0.06);
  --text: #1d1d1f;
  --text2: #6e6e73;
  --text3: #a1a1a6;
  --sel: rgba(0, 0, 0, 0.065);
  --accent: #0a7cff;
  --stripe: #f4f5f7;
  --line: rgba(0, 0, 0, 0.09);
  --pill: #ffffff;
  --pill-shadow: 0 1px 3px rgba(0, 0, 0, 0.09), 0 0 0 0.5px rgba(0, 0, 0, 0.07);
  --folder: #5eb5f7;
  --folder-back: #3a8ee6;
  --file-bg: #ffffff;
  --file-line: #c7c7cc;
  --field: #ffffff;
  --field-line: rgba(0, 0, 0, 0.14);
  --shadow: 0 30px 80px rgba(20, 20, 60, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.16);
  --green: #1f9d48;
  --red: #e5352b;
  --orange: #c26a00;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --desk: linear-gradient(140deg, #1c2a4a 0%, #2b2147 50%, #3b2333 100%);
    --win: #1f1f21;
    --side: rgba(46, 46, 50, 0.8);
    --side-solid: #2a2a2d;
    --side-border: rgba(255, 255, 255, 0.07);
    --text: #f5f5f7;
    --text2: #a8a8ad;
    --text3: #6f6f75;
    --sel: rgba(255, 255, 255, 0.09);
    --accent: #3d9bff;
    --stripe: #262628;
    --line: rgba(255, 255, 255, 0.09);
    --pill: #2c2c2f;
    --pill-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
    --file-bg: #3a3a3d;
    --file-line: #5a5a5f;
    --field: #2c2c2f;
    --field-line: rgba(255, 255, 255, 0.14);
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.12);
    --green: #3fcf6d;
    --red: #ff6961;
    --orange: #ffb340;
    color-scheme: dark;
  }
}

/* ───────── 기본 ───────── */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--desk) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", Pretendard, "Malgun Gothic", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--text3); }
.hint { color: var(--text2); font-size: 12.5px; line-height: 1.6; }
.warn-text { color: var(--red); line-height: 1.6; }
code { background: var(--sel); padding: 2px 6px; border-radius: 5px; font-size: 12px; word-break: break-all; }
.boot { color: #fff; font-weight: 600; }

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

/* ───────── 창 ───────── */
.window {
  position: relative;
  display: flex;
  width: min(1200px, 100%);
  height: 100%;
  max-height: 860px;
  background: var(--win);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.lights { display: flex; gap: 8px; padding: 16px 16px 8px; }
.lights i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.15); }
.lights i:nth-child(2) { background: #febc2e; }
.lights i:nth-child(3) { background: #28c840; }
.lights.small { padding: 0; }
.lights.small i:first-child { cursor: pointer; }

/* ───────── 사이드바 (떠 있는 카드) ───────── */
.sidebar {
  flex: none;
  width: 236px;
  margin: 8px;
  display: flex;
  flex-direction: column;
  background: var(--side);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  backdrop-filter: blur(24px) saturate(1.6);
  border: 0.5px solid var(--side-border);
  border-radius: 15px;
  overflow: hidden;
}
.brand { padding: 4px 18px 6px; font-size: 13px; font-weight: 700; color: var(--text2); letter-spacing: -0.01em; }
.side-scroll { flex: 1; overflow-y: auto; padding: 0 10px 12px; }
.side-h { padding: 14px 8px 4px; font-size: 11.5px; font-weight: 600; color: var(--text3); }
.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.side-item .i { width: 19px; height: 19px; color: var(--accent); }
.side-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item:hover { background: var(--sel); }
.side-item.on { background: var(--sel); color: var(--accent); }
.side-item .dot { width: 11px; height: 11px; margin: 0 4px; border-radius: 50%; flex: none; }
.badge { font-size: 11.5px; color: var(--text3); font-variant-numeric: tabular-nums; }
.badge.alert { background: var(--red); color: #fff; border-radius: 9px; padding: 1px 7px; font-weight: 600; }
.side-foot { padding: 8px 10px 10px; border-top: 0.5px solid var(--line); }
.me { padding: 4px 8px 6px; }
.me-name { font-weight: 600; font-size: 13px; }
.me-mail { font-size: 11.5px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { font-size: 10.5px; font-weight: 600; color: var(--accent); background: var(--sel); padding: 1px 6px; border-radius: 6px; }
.demo-box { margin: 0 0 6px; padding: 8px 10px; border-radius: 10px; background: var(--sel); font-size: 12px; line-height: 1.6; color: var(--text2); }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 600; }

/* ───────── 툴바 ───────── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px 10px 10px; }
.pill {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 4px;
  background: var(--pill);
  border-radius: 999px;
  box-shadow: var(--pill-shadow);
  flex: none;
}
.pill button {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: none;
  cursor: pointer;
}
.pill button:hover:not(:disabled) { background: var(--sel); }
.pill button:disabled { color: var(--text3); cursor: default; }
.pill button.on { background: var(--sel); }
.tb-title { margin: 0 4px; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-spacer { flex: 1; }
.tb-menu { display: none; }
.search input {
  width: 0;
  padding: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 14px;
  transition: width 0.2s ease, padding 0.2s ease;
}
.search input::-webkit-search-cancel-button { display: none; }
.search.open input { width: 170px; padding-right: 10px; }

/* ───────── 목록 보기 ───────── */
.content { flex: 1; overflow: auto; padding: 0 10px 18px; }
.list-head, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px 128px 62px 74px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}
.list-head {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 28px;
  background: var(--win);
  border-bottom: 0.5px solid var(--line);
  font-size: 12px;
  color: var(--text3);
}
.row { min-height: 30px; border-radius: 7px; font-size: 13.5px; }
.row.alt { background: var(--stripe); }
.row:hover, .row:focus-visible { background: var(--sel); outline: none; }
.row.file, .row.folder { cursor: pointer; }
.c-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.c-name .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.file .c-name { padding-left: 20px; }
.row.file.indent .c-name { padding-left: 42px; }
.row.folder .c-name .t { font-weight: 500; }
.sub { display: none; }
.chev { width: 13px; height: 13px; color: var(--text3); flex: none; transition: transform 0.15s; }
.row.folder.open .chev { transform: rotate(90deg); }
.ico { width: 18px; height: 20px; flex: none; }
.row.folder .ico { height: 18px; }
.c-date, .c-dur, .c-extra { font-size: 12.5px; color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-size: 12.5px; color: var(--text2); white-space: nowrap; overflow: hidden; }
.tag i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.new { color: var(--accent); font-weight: 700; font-size: 11px; letter-spacing: 0.02em; }
.seen { color: var(--green); display: inline-flex; align-items: center; gap: 3px; }
.seen .i { width: 14px; height: 14px; }

/* ───────── 아이콘 보기 ───────── */
.grid-sec { display: flex; align-items: center; gap: 6px; padding: 16px 12px 6px; font-size: 13px; font-weight: 600; color: var(--text2); }
.grid-sec small { color: var(--text3); font-weight: 400; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 6px; padding: 4px 6px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px 10px; border-radius: 12px; text-align: center; cursor: pointer; }
.tile:hover, .tile:focus-visible { background: var(--sel); outline: none; }
.ficon-big { width: 54px; height: 62px; flex: none; }
.tile .t { font-size: 12.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .s { font-size: 11.5px; color: var(--text3); }

.empty { height: 100%; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text2); }
.hero { width: 72px; height: 72px; }

/* ───────── 버튼·입력 ───────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 0;
  border-radius: 9px;
  background: var(--sel);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.96); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.big { padding: 11px 20px; font-size: 15px; border-radius: 12px; }
.btn .i { width: 16px; height: 16px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btns.end { justify-content: flex-end; }
.btns.center { justify-content: center; }

input:not([type=checkbox]):not([type=color]), select, textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--field);
  border: 0.5px solid var(--field-line);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
textarea { resize: vertical; }
input[type=color] { width: 36px; height: 32px; padding: 0; border: 0; background: none; cursor: pointer; flex: none; }
.toolbar .search input, .toolbar .search input:focus { width: 0; border: 0; box-shadow: none; background: none; padding: 0; }
.toolbar .search.open input, .toolbar .search.open input:focus { width: 170px; padding: 0 10px 0 0; }

/* ───────── 대화상자 ───────── */
dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--win);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
}
dialog.wide { width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.28); }
.dlg-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  background: var(--win);
  border-bottom: 0.5px solid var(--line);
}
.dlg-head h2 { flex: 1; margin: 0; font-size: 14px; font-weight: 600; text-align: center; }
.x { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--sel); cursor: pointer; }
.x .i { width: 14px; height: 14px; }
.dlg-body { padding: 18px; }

.detail-top { display: flex; gap: 14px; align-items: flex-start; }
.d-main { flex: 1; min-width: 0; }
.d-title { font-size: 16px; font-weight: 600; line-height: 1.4; margin: 2px 0 10px; }
.meta { display: grid; grid-template-columns: 64px 1fr; gap: 8px 12px; margin: 18px 0 0; font-size: 13.5px; }
.meta dt { color: var(--text3); }
.meta dd { margin: 0; }
.memo { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--stripe); font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }
.sec-h { margin: 20px 0 8px; font-size: 12px; font-weight: 600; color: var(--text3); }
.stu-list { list-style: none; margin: 0; padding: 0; }
.stu-list li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 0.5px solid var(--line); font-size: 13.5px; }
.stu-list .n { font-weight: 500; }
.stu-list .mail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.invite { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 9%, transparent); font-size: 13px; line-height: 1.6; }
.invite p { margin: 0; }
.invite .btns { margin-top: 10px; }

/* 등록 폼 */
.form .field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-size: 12.5px; font-weight: 600; color: var(--text2); }
.field label small { font-weight: 400; color: var(--text3); margin-left: 4px; }
.field.inline { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; }
.field.inline label { margin: 0; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row2 { display: flex; gap: 8px; align-items: center; }
.row2 input { flex: 1; min-width: 0; }
.pages span { color: var(--text3); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chk { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--sel); font-size: 13.5px; cursor: pointer; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.yt-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 220px; overflow: auto; padding: 4px; border-radius: 10px; background: var(--stripe); }
.yt-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; font-size: 13px; }
.yt-item:hover { background: var(--sel); }
.yt-item.on { background: var(--accent); color: #fff; }
.yt-item.on .muted { color: rgba(255, 255, 255, 0.8); }
.yt-item .t { font-weight: 500; }
.warn { font-size: 11.5px; font-weight: 600; color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); padding: 2px 8px; border-radius: 6px; }
.ok { font-size: 11.5px; font-weight: 600; color: var(--green); }
.yt-item.on .warn { color: #fff; background: rgba(0, 0, 0, 0.28); }
.yt-item.on .ok { color: #fff; }
#yt-list > p { margin: 8px 0 0; font-size: 12.5px; }

/* 학생·카테고리 관리 */
.stu-table, .cat-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.stu-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 90px auto; gap: 8px; align-items: center; }
.stu-row .mail { font-size: 12.5px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row { display: flex; gap: 8px; align-items: center; }
.cat-row input[name=cname] { flex: 1; min-width: 0; }
.cat-row .sort { width: 64px !important; flex: none; }
.tabs { width: max-content; max-width: 100%; overflow-x: auto; }
.tabs button { padding: 0 12px; font-size: 13px; white-space: nowrap; }

/* ───────── 로그인 카드 ───────── */
.card-win { width: min(420px, 100%); background: var(--win); border-radius: 20px; box-shadow: var(--shadow); padding-bottom: 28px; }
.login { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 12px 28px 0; }
.login h1 { margin: 8px 0 4px; font-size: 21px; }
.login p { margin: 4px 0; }
.login .btn.big { margin: 20px 0 6px; }

/* ───────── 알림 ───────── */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(30, 30, 32, 0.92);
  color: #fff;
  font-size: 13.5px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.scrim { display: none; }

/* ───────── 휴대폰 ───────── */
@media (max-width: 760px) {
  #app { padding: 0; align-items: stretch; }
  .window { border-radius: 0; max-height: none; box-shadow: none; }
  .sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    z-index: 20;
    width: min(290px, 84vw);
    margin: 0;
    border-radius: 0 16px 16px 0;
    background: var(--side-solid);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    padding-top: env(safe-area-inset-top);
  }
  .drawer-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .drawer-open .scrim { display: block; position: absolute; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.3); }
  .tb-menu { display: flex; }
  .hide-sm { display: none; }
  .toolbar { gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 12px 8px; }
  .tb-title { flex: 1; font-size: 16px; }
  .tb-spacer { display: none; }
  .toolbar .search.open input, .toolbar .search.open input:focus { width: 120px; }
  .content { padding: 0 6px 24px; }
  .list-head { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) auto; min-height: 52px; padding: 6px 10px; }
  .row .c-date, .row .c-type, .row.file .c-dur { display: none; }
  .row.folder { min-height: 42px; }
  .row.file .c-name { padding-left: 0; }
  .row.file.indent .c-name { padding-left: 18px; }
  .c-name .t { white-space: normal; display: flex; flex-direction: column; gap: 2px; line-height: 1.35; }
  .sub { display: block; font-size: 12px; color: var(--text3); }
  .ico { width: 24px; height: 28px; }
  .row.folder .ico { width: 22px; height: 22px; }
  .grid2 { grid-template-columns: 1fr; }
  .stu-row { grid-template-columns: 1fr 84px auto; }
  .stu-row .mail { grid-column: 1 / -1; order: 5; margin-top: -2px; }
  .row2 { flex-wrap: wrap; }
  .pages { flex-wrap: nowrap; }
  dialog { max-height: calc(100dvh - 24px); }
}

/* ───────── 영상 정보 창 (한눈에 보기) ───────── */
.d-head { display: flex; align-items: center; gap: 10px; }
.d-head .ico { width: 26px; height: 30px; }
.d-head .d-title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; }
.btn.play { display: flex; width: 100%; margin: 14px 0 16px; padding: 11px; font-size: 15px; border-radius: 12px; }
.btn.play .i { width: 18px; height: 18px; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile-i { padding: 10px 12px; border-radius: 12px; background: var(--stripe); min-width: 0; }
.tile-i.wide { grid-column: span 3; }
.tile-i .k, .memo .k { font-size: 11.5px; font-weight: 600; color: var(--text3); margin-bottom: 3px; }
.tile-i .v { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-i .v .tag { font-size: 14.5px; color: var(--text); }
.tile-i .sep { color: var(--text3); font-weight: 400; margin: 0 2px; }
.none { color: var(--text3); font-weight: 400; }
.memo { margin-top: 8px; }
.private-note { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--stripe); font-size: 13.5px; color: var(--text2); }
.private-note .i { width: 16px; height: 16px; color: var(--text3); }
.d-actions { display: flex; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 0.5px solid var(--line); }
@media (max-width: 760px) {
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-i.wide { grid-column: span 2; }
}

/* ───────── 로그인 카드: 휴대폰에서도 가운데 · 구글 버튼 · 앱 안 브라우저 안내 ───────── */
#app.center-card { align-items: center; justify-content: center; padding: 20px; }
.card-win { max-height: calc(100dvh - 40px); overflow: auto; }
.gbtn { display: flex; justify-content: center; min-height: 44px; margin: 20px 0 6px; }
.gbtn .btn.big { margin: 0; }
.inapp { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--orange) 14%, transparent); color: var(--text); font-size: 13px; line-height: 1.6; }
@media (max-width: 760px) {
  #app.center-card { padding: 20px 16px; }
  .card-win { width: 100%; max-width: 380px; }
}
