.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.soft { background: var(--soft); box-shadow: none; }

.toolbar, .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* 카드제작 — 제목 / 폴더 / 플래그 / 타입(티켓 35) */
.create-meta-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}

.create-meta-flag .flag-picker {
  flex-wrap: nowrap;
}

/* 제목 입력칸과 높이·위치를 맞춤(피드백) — select.folder-select의 margin-top:4px는
   사이드바 등 라벨 바로 아래 붙는 다른 자리를 위한 것이라 이 줄에서만 없앤다 */
.create-meta-folder select.folder-select {
  margin-top: 0;
  font-size: 14px;
}

/* 카드 타입(티켓 35) — 커스텀(기본, 아무 동작 없음)·자동(줄 단위 일괄 빈칸, #36·#37) 탭 */
.card-type-tabs {
  display: flex;
  gap: 6px;
  min-height: 38px;
  align-items: center;
}
.card-type-tab {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #475569;
}
.card-type-tab:hover { border-color: #94a3b8; }
.card-type-tab.is-active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}

@media (max-width: 720px) {
  .create-meta-row {
    grid-template-columns: 1fr;
  }
  .create-meta-flag .flag-picker {
    flex-wrap: wrap;
  }
}

/* 이어서 학습 — 사이드바·학습 setup 공통 (js/ui/resume-panel.js) */
.resume-panel-mount:not(.hidden) {
  margin-top: 14px;
}

.resume-panel-mount--study:not(.hidden) {
  margin: 18px 0 20px;
}

.resume-panel {
  padding: 14px 14px 12px;
  border: 1px solid var(--resume-pink-border);
  border-radius: 14px;
  background: linear-gradient(165deg, var(--resume-pink-soft) 0%, #fff 72%);
  box-shadow: 0 4px 14px rgba(157, 61, 107, 0.06);
}

.resume-panel--sidebar {
  margin-bottom: 4px;
}

.resume-panel__eyebrow {
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--resume-pink-text);
  opacity: 0.85;
}

.resume-panel__btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--resume-pink-border);
  border-radius: 11px;
  background: #fff;
  color: var(--resume-pink-text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.resume-panel__btn:hover {
  background: var(--resume-pink-soft);
  border-color: var(--resume-pink);
}

.resume-panel__btn:active {
  background: var(--resume-pink);
  border-color: var(--resume-pink);
  color: #fff;
}

.resume-panel__detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--resume-pink-border);
  line-height: 1.45;
  word-break: break-word;
  color: var(--muted);
}

.sidebar-menu-tools {
  margin-top: 12px;
}

/* 선택 카드 — 전체선택/해제 50:50, 학습시작 오른쪽 */
.selection-select-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.selection-select-row .selection-half {
  flex: 1;
  justify-content: center;
}

.selection-study-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.selection-study-row #startSelectedBtn {
  margin-left: auto;
  flex-shrink: 0;
}

.study-setup-head { margin-bottom: 0; }

/* 학습 카드 이동(이전/다음)은 회독·유사도 등과 성격이 달라 오른쪽 끝으로 분리 */
.study-step-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 이전/다음보다 조금 왼쪽으로 띄운 수정 진입 */
.study-step-nav .study-edit-jump {
  margin-right: 10px;
}

.study-play-bar {
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.study-play-threshold {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 4px;
}

.study-play-threshold > label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1;
}

.study-play-threshold .setup-threshold {
  display: flex;
  align-items: center;
  gap: 8px;
}

.study-play-threshold .setup-threshold input[type="range"] {
  width: 110px;
}

/* ── 학습 세트 구성(setup) ── */
.study-setup-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-top: 12px;
}

.study-setup-bar .setup-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.study-setup-bar .setup-field > label {
  font-size: 12px;
  color: var(--muted, #64748b);
  font-weight: 600;
}

.study-setup-bar select {
  min-width: 140px;
}

.study-setup-bar .setup-threshold {
  display: flex;
  align-items: center;
  gap: 8px;
}

.study-setup-bar .setup-threshold input[type="range"] { width: 130px; }

.study-setup-bar #startStudyBtn { margin-left: auto; align-self: flex-end; }

.study-scope-detail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.study-scope-detail:empty { display: none; }

.study-summary {
  margin-top: 10px;
  font-size: 14px;
  color: var(--ink, #1e293b);
}

.study-summary.warn { color: var(--red, #dc2626); }

/* ── 학습 범위 선택 모달 (폴더 트리 / 카드 목록) ── */
.pick-folder-tree,
.pick-card-list {
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 10px;
  padding: 4px;
}

.pick-folder-node { margin-bottom: 6px; }

.pick-folder-children {
  margin: 4px 0 4px 12px;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pick-folder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  cursor: pointer;
}

.pick-folder-row:hover { background: rgba(37, 99, 235, 0.06); border-color: #93c5fd; }
.pick-folder-row.active { background: var(--green-soft); border-color: var(--green); font-weight: 700; }
.pick-folder-cnt { font-size: 12px; color: var(--muted, #64748b); flex-shrink: 0; }

/* 학습 폴더 선택 — 선택 비우기(티켓 33): 여러 폴더를 골랐을 때 눈에 잘 띄도록 키우고 옅은 배경을 준다.
   .ghost.small은 button.ghost/button.small(타입+클래스, 명시성 0,1,1)로 정의돼 있어 클래스 하나(0,1,0)로는
   안 이긴다 — 클래스 두 개(.pick-clear-btn.ghost, 0,2,0)로 걸어 평상시에도 배경이 실제로 보이게 한다. */
.pick-clear-btn.ghost {
  padding: 9px 14px;
  font-size: 13px;
  background: #eff6ff;
  border-color: #bfdbfe;
}
.pick-clear-btn.ghost:hover { background: #dbeafe; border-color: #93c5fd; }

.pick-card-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}

/* ── 학습 setup 미리보기 카드 목록 ── */
.study-preview { margin-top: 12px; }
.study-preview:empty { display: none; }
.study-preview-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 600;
}
.study-preview-head-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 4px;
}
.study-preview-head-actions .small {
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.2;
}
.study-preview-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.study-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.study-preview-item:last-child { border-bottom: none; }
.study-preview-item:hover { background: #f8fafc; }
.study-preview-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  margin: 0;
}
.study-preview-item input[type="checkbox"] {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
}
.study-preview-title { flex: 1; min-width: 0; font-weight: 600; }
.study-preview-meta { font-size: 12px; color: var(--muted, #64748b); flex-shrink: 0; }
.study-preview-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 4px;
}
.study-preview-actions .small {
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.2;
}

/* ── 카드관리 — 폴더·목록 | 상세 (폴더 쪽 넓게) ── */
.manage-split {
  display: grid;
  grid-template-columns: 5.5fr 4.5fr;
  gap: 14px;
  margin-top: 12px;
}

/* ── 카드관리 폴더 빵부스러기 ── */
.folder-root-title { cursor: pointer; }
.folder-root-title:hover { color: var(--blue, #2563eb); }

.folder-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 13px;
}

.folder-breadcrumb .crumb {
  border: none;
  background: transparent;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--muted, #64748b);
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.folder-breadcrumb .crumb-label { font-size: 13px; }
.folder-breadcrumb .crumb:hover { background: rgba(37, 99, 235, 0.08); color: var(--blue, #2563eb); }
.folder-breadcrumb .crumb:hover .tree-meta { color: var(--muted); }
.folder-breadcrumb .crumb.active .crumb-label { color: var(--ink, #1e293b); font-weight: 700; }
.folder-breadcrumb .crumb-sep { color: #cbd5e1; }

.folder-breadcrumb .folder-study-btn {
  margin-left: 8px;
  flex-shrink: 0;
}

.folder-breadcrumb .folder-study-btn.is-disabled,
.folder-breadcrumb .folder-study-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

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

.col { display: flex; flex-direction: column; gap: 8px; }

h1, h2, h3 { margin: 0 0 6px; }

label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  display: block;
  margin-bottom: 4px;
}

input[type="text"]:not(.blank-field):not(.outline-tree-title),
select,
textarea,
input[type="number"]:not(.outline-tree-line-input) {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

textarea { resize: vertical; line-height: 1.8; font-family: inherit; }
.xl {
  height: 420px;
  min-height: 260px;
  max-height: 1000px;
  overflow-y: auto;
  font-size: 15px;
  resize: vertical;
}
.sm { min-height: 88px; max-height: 320px; overflow-y: auto; resize: vertical; }

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  background: #e5e7eb;
  color: #111827;
}

button.primary { background: var(--blue); color: #fff; }
button.pink { background: var(--pink); color: #fff; }
button.secondary { background: #eef2ff; color: #3730a3; }
button.success { background: #dcfce7; color: #166534; }
button.danger { background: #fee2e2; color: #991b1b; }
button.warn { background: #ffedd5; color: #9a3412; }
button.ghost { background: #fff; border: 1px solid var(--line); }
.study-prompt-panel [data-action="toggle-study-prompt"].ghost {
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--blue);
}
.study-prompt-panel [data-action="toggle-study-prompt"].ghost:hover {
  background: #dbeafe;
  border-color: var(--blue);
}
button.small { padding: 7px 10px; font-size: 12px; }
button.folder-add { background: #ecfccb; color: #3f6212; border: 1px solid #d9f99d; font-weight: 700; }
button.folder-add:hover { background: #d9f99d; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.folder-head-left { display: flex; align-items: center; gap: 8px; }
.sidebar-patch-btn { width: 100%; margin-bottom: 12px; margin-top: 12px; text-align: center; }
.sel-inline { width: auto; flex: 0 0 auto; padding: 7px 10px; font-size: 12px; }

.patch-modal { max-width: 760px; width: 92vw; }
.patch-body { max-height: 70vh; overflow: auto; padding-right: 6px; line-height: 1.65; }
.patch-body h1 { font-size: 20px; margin: 4px 0 12px; }
.patch-body h2 { font-size: 16px; margin: 18px 0 8px; }
.patch-body h3 { font-size: 14px; margin: 12px 0 6px; }
.patch-body p { margin: 6px 0; }
.patch-body ul { margin: 6px 0; padding-left: 20px; }
.patch-body li { margin: 3px 0; }
.patch-body code { background: #f3f4f6; padding: 1px 5px; border-radius: 5px; font-size: 90%; }
.patch-body hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.patch-entry { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.patch-summary { cursor: pointer; padding: 12px 14px; font-weight: 700; list-style: none; user-select: none; }
.patch-summary::-webkit-details-marker { display: none; }
.patch-summary::before { content: '▸ '; color: var(--muted); }
.patch-entry[open] .patch-summary::before { content: '▾ '; }
.patch-summary:hover { background: #f8fafc; }
.patch-content { padding: 0 16px 12px; }
.patch-content h1 { font-size: 18px; margin: 6px 0 10px; }
button.nav-btn.active { outline: 2px solid var(--blue); }
button.nav-btn.pink-nav { background: var(--pink-soft); color: #9d174d; }
button.nav-btn.pink-nav.active { background: var(--pink); color: #fff; }

.muted { color: var(--muted); font-size: 13px; }
.caption { color: var(--muted); font-size: 12px; line-height: 1.5; }

#createSaveStamp {
  margin-right: 6px;
  white-space: nowrap;
}
#createStudyNavBtn {
  flex: none;
  margin-right: 2px;
}
#createStudyNavBtn.create-study-nav--resume {
  border: 1px solid var(--resume-pink-border);
  background: var(--resume-pink-soft);
  color: var(--resume-pink-text);
}
#createStudyNavBtn.create-study-nav--resume:hover {
  background: var(--resume-pink-soft);
  border-color: var(--resume-pink);
}
#createStudyNavBtn.create-study-nav--resume:active {
  background: var(--resume-pink);
  border-color: var(--resume-pink);
  color: #fff;
}
#createStudyNavBtn.create-study-nav--go {
  background: var(--pink-soft);
  color: #9d174d;
  border: 1px solid #f9a8d4;
}
#createStudyNavBtn.create-study-nav--go:hover {
  background: #fbcfe8;
  border-color: var(--pink);
}
#createStudyNavBtn.create-study-nav--go:active {
  background: var(--pink);
  color: #fff;
  border-color: var(--pink);
}
.hidden { display: none !important; }

.list {
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.list-item {
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f7;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.list-item:last-child { border-bottom: 0; }
.list-item.active { background: #eff6ff; }
.list-item.is-manage-focus { background: #dbeafe; outline: 2px solid #3b82f6; outline-offset: -2px; }
.list-item.is-manage-anchor { box-shadow: inset 3px 0 0 #1d4ed8; }
.list-item.dragging { opacity: 0.5; }
.list-item.is-cut { opacity: 0.5; }
.card-cut-hint { font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 카드 끌기 — 글자 선택 대신 드래그 */
#cardList .list-item[draggable="true"] {
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.item-title { font-size: 13px; font-weight: 700; }
.item-sub { font-size: 12px; color: var(--muted); }

.preview {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  white-space: pre-wrap;
  line-height: 2;
  font-size: 16px;
}

.preview-scroll {
  height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
}

.preview-tall {
  min-height: 480px;
  max-height: 900px;
  overflow-y: auto;
}

/* 카드관리 상세 — 본문만 스크롤, 액션 버튼은 하단 고정 */
.manage-detail {
  display: flex;
  flex-direction: column;
  height: 600px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.manage-detail .detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  line-height: 2;
  font-size: 16px;
  white-space: pre-wrap;
}
.manage-detail .detail-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.manage-detail .detail-empty {
  padding: 16px;
  color: #6b7280;
}

.blank-inline {
  display: inline;
  margin: 0 2px;
  padding: 0 2px 4px;
  border-bottom: 3px solid #94a3b8;
  font-weight: 700;
  color: #475569;
  border-radius: 6px 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.blank-inline.blank-shape,
.blank-field-shape {
  letter-spacing: normal;
  color: #64748b;
}

.blank-inline.blank-shape {
  font-weight: 600;
  border-bottom-style: dashed;
  border-bottom-width: 2px;
}

.blank-inline.study { cursor: pointer; border-bottom-color: var(--blue); background: #eff6ff; }
.blank-inline.revealed { color: var(--green); background: var(--green-soft); border-bottom-color: var(--green); }
.blank-inline.wrong-revealed { color: var(--green); background: #ecfccb; }
.blank-inline.current { outline: 3px solid #bfdbfe; }
.empty { color: var(--muted); font-style: italic; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  margin: 2px 4px 2px 0;
}

.flag { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.flag-0 { background: #d1d5db; }
.flag-1 { background: #ef4444; }
.flag-2 { background: #f97316; }
.flag-3 { background: #f59e0b; }
.flag-4 { background: #22c55e; }
.flag-5 { background: #06b6d4; }
.flag-6 { background: #3b82f6; }
.flag-7 { background: #8b5cf6; }

select.folder-select {
  width: 100%;
  font-size: 13px;
  line-height: 1.45;
  margin-top: 4px;
}

/* 카드관리 폴더-목록 사이 정렬 바(티켓 38) — 꽉 채우지 않고 왼쪽에 적당한 크기로, 남은 여백은 비워 둔다 */
.card-sort-bar { gap: 6px; justify-content: flex-start; }
.card-sort-select {
  flex: 0 0 auto;
  width: auto;
  max-width: 60%;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.card-sort-dir.small {
  flex-shrink: 0;
  width: 30px;
  padding: 0;
  font-weight: 700;
}

.filter-result-hint {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
}

.filter-flag-picker { margin-top: 4px; margin-bottom: 4px; }
.filter-flag-picker .flag-pick.filter-flag-all {
  width: auto;
  min-width: 40px;
  height: 28px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
}

.flag-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.flag-pick {
  padding: 0;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.flag-pick .flag { width: 16px; height: 16px; }
.flag-pick .flag-0 { box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px #d1d5db; background: #f3f4f6; }
.flag-pick:hover { border-color: #94a3b8; }
.flag-pick.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px #bfdbfe;
}

/* 카드제작 플래그(티켓 34) — 기본은 선택된 색 하나만, 호버·포커스 시 나머지가 오른쪽으로 펼쳐짐.
   제목/폴더/플래그가 같은 폭(1fr)을 나눠 쓰는 좁은 칸에 8색이 늘 펼쳐져 있던 걸 접어 여유를 만든다. */
#cardFlagPicker.flag-picker {
  position: relative;
  min-height: 38px; /* 제목·폴더 입력칸과 높이·위치를 맞춤(피드백 반영) */
}
@media (min-width: 721px) {
  /* 칩이 하나만 보여도 flex 컨테이너가 그리드 칸(1fr) 전체 폭으로 늘어나 있어서,
     보이지 않는 칩들 위로 마우스가 지나가기만 해도 펼쳐지던 문제(피드백) — 실제 보이는
     칩만큼만 폭을 차지하게 해서 호버 범위를 버튼 위로 좁힌다. 접지 않는 모바일은 그대로 둔다. */
  #cardFlagPicker.flag-picker { width: max-content; max-width: 100%; }
  /* 타입 칸이 생겨 플래그 칸이 좁아지면 펼친 8색이 옆 칸(타입 버튼) 위로 넘친다.
     칸 배치는 그대로 두고, 펼친 동안만 위에 떠 있는 띠처럼 보이게 한다(자리 이동 없음). */
  #cardFlagPicker.flag-picker:has(.active):hover,
  #cardFlagPicker.flag-picker:has(.active):focus-within {
    max-width: none;
    z-index: 5;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 0 0 4px #fff, 0 4px 14px rgba(15, 23, 42, .14);
  }
}
/* .active가 아직 없는 상태(막 연 새 카드 등)에서는 접지 않고 기존처럼 8색을 그대로 보여준다 */
#cardFlagPicker.flag-picker:has(.active) .flag-pick:not(.active) {
  width: 0;
  min-width: 0;
  padding: 0;
  border-width: 0;
  margin-right: -6px;
  overflow: hidden;
  visibility: hidden;
  transition: width .15s ease, margin-right .15s ease, border-width .15s ease;
}
/* 위 :has(.active) 규칙과 명시성을 맞춰야 호버 중에 이 규칙이 이긴다(같은 명시성이면 나중 규칙 우선) */
#cardFlagPicker.flag-picker:has(.active):hover .flag-pick,
#cardFlagPicker.flag-picker:has(.active):focus-within .flag-pick {
  width: 30px;
  min-width: 30px;
  padding: 0;
  border-width: 1px;
  margin-right: 0;
  visibility: visible;
}
@media (max-width: 720px) {
  /* 좁은 화면은 원래도 줄바꿈으로 8색이 다 보이던 화면이라 접지 않고 그대로 둔다 */
  #cardFlagPicker.flag-picker .flag-pick:not(.active),
  #cardFlagPicker.flag-picker:hover .flag-pick,
  #cardFlagPicker.flag-picker:focus-within .flag-pick {
    width: 30px;
    min-width: 30px;
    padding: 0;
    border-width: 1px;
    margin-right: 0;
    visibility: visible;
  }
}

.manage-flag-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 2;
}
.manage-flag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  margin: -4px 0 0 -4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.manage-flag-btn:hover,
.manage-flag-wrap.is-open .manage-flag-btn {
  border-color: var(--line);
  background: #fff;
}
.manage-flag-btn:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 1px;
}
.manage-flag-menu {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.manage-flag-menu[hidden] { display: none; }
/* 목록 행보다 얇게 — 아래 카드 플래그와 겹치지 않게 */
.manage-flag-menu .flag-pick {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}
.manage-flag-menu .flag-pick .flag {
  width: 12px;
  height: 12px;
}
.manage-flag-opt.is-current {
  outline: 2px solid #1d4ed8;
  outline-offset: 0;
}

.export-menu-wrap {
  position: relative;
  display: inline-flex;
  z-index: 3;
}
.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.export-menu[hidden] { display: none; }
.export-menu .ghost.small {
  justify-content: flex-start;
}

/* 칩(chip) 빈칸 에디터 */
.chip-editor {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.9;
  background: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-y: auto;
  outline: none;
}
.chip-editor:empty::before {
  content: attr(data-placeholder);
  color: #9ca3af;
}
.chip-editor:focus { border-color: var(--blue); box-shadow: 0 0 0 2px #eff6ff; }

/* 해설 빈칸(티켓 35·36·37) — 같은 빈칸을 탭마다 다르게 그린다.
   커스텀: ×로 해제하는 칩(기존 방식). 자동: 편집 가능한 음영 span — 형광펜처럼 아무 범위나
   골라 켜고 끄며, 음영이 없는(흰 바탕) 곳만 원문으로 남는다. */
.cz-chip {
  display: inline;
  background: #eff6ff;
  color: #1d4ed8;
  border-bottom: 2px solid var(--blue);
  border-radius: 4px;
  padding: 1px 2px;
  font-weight: 700;
  /* 긴 칩이 칸을 밀지 않도록 줄바꿈만 허용 */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cz-chip-x {
  all: unset;
  cursor: pointer;
  color: #93c5fd;
  font-weight: 700;
  margin-left: 2px;
  padding: 0 2px;
}
.cz-chip-x:hover { color: var(--red); }
.auto-blank-pending {
  background: #d4e2fc;
  border-radius: 2px;
}
/* 빈칸 목록에서 「위치」로 찾아갈 때 잠깐 표시 — 칩·음영 공통 */
.cz-chip-active {
  background: #fde68a;
  border-bottom-color: #d97706;
  color: #92400e;
}
.auto-blank-pending.cz-chip-active {
  background: #fde68a;
  border-bottom-color: transparent;
  color: inherit;
}
/* 빈칸 안의 형광은 음영에 가려 보이게 두지 않는다 — 노란 곳이 "빈칸이 아닌 곳"처럼 읽히지 않게.
   서식 자체(모델)는 그대로다. */
.auto-blank-pending .tm-hl {
  background: transparent !important;
}

/* 호버 정답 엿보기 */
.blank-peek-gauge {
  position: absolute;
  z-index: 999;
  width: 20px;
  height: 20px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.blank-peek-gauge.show {
  opacity: 1;
  transform: scale(1);
}

.blank-peek-gauge.ready {
  opacity: 0;
  transform: scale(1.08);
  transition: opacity 0.1s ease, transform 0.1s ease;
}

.blank-peek-gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.blank-peek-gauge__track {
  fill: none;
  stroke: #dbe4ef;
  stroke-width: 2.5;
}

.blank-peek-gauge__fill {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 50.27;
  stroke-dashoffset: 50.27;
}

.blank-peek {
  position: absolute;
  z-index: 1000;
  padding: 4px 10px;
  background: #111827;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
  max-width: min(34rem, calc(100vw - 24px));
}
.blank-peek.show { opacity: .96; transform: translateY(0); }

/* 회독 자동 +1 알림 — 마지막 채점 빈칸 옆에서 위로 증발 */
.round-toast {
  position: absolute;
  z-index: 1001;
  padding: 4px 12px;
  background: var(--green);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.2px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(22, 163, 74, .35);
  pointer-events: none;
  white-space: nowrap;
  animation: round-toast-rise 1.2s ease-out forwards;
}

@keyframes round-toast-rise {
  0% { opacity: 0; transform: translateY(6px) scale(.9); }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 1; transform: translateY(-4px) scale(1); }
  100% { opacity: 0; transform: translateY(-26px) scale(.96); }
}

@media (prefers-reduced-motion: reduce) {
  .round-toast { animation-duration: 1s; }
}

.slot {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fbfdff;
  margin-bottom: 8px;
}

.blank-chip-wrap {
  display: inline-flex;
  align-items: center;
  margin: 0 6px 6px 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.blank-chip-wrap .blank-chip {
  border: 0;
  border-radius: 0;
  margin: 0;
  cursor: pointer;
}

.blank-chip-wrap .blank-chip:hover { background: #eff6ff; }

.blank-slot-jump {
  border: 0;
  background: none;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.blank-slot-jump:hover { color: #1d4ed8; }

.blank-chip-remove {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1;
  background: #fff;
  color: #991b1b;
  cursor: pointer;
}

.blank-chip-remove:hover { background: #fee2e2; }

.blank-toolbar { margin-top: 8px; }

.blank-slot { margin-bottom: 8px; }

.answer-readonly {
  padding: 6px 10px;
  border: 1px dashed var(--border, #d1d5db);
  border-radius: 8px;
  background: var(--bg-subtle, #f8fafc);
  color: var(--text, #111827);
  font-size: 14px;
  word-break: break-word;
}
.answer-readonly .empty { color: var(--muted, #9ca3af); font-style: italic; }

/* 빈칸별 동의어 — 주 정답 아래에 덧붙이는 보조 입력 */
.alias-input {
  width: 100%;
  margin-top: 4px;
  padding: 5px 10px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}
.alias-input::placeholder { color: var(--muted, #9ca3af); }
.alias-input:focus {
  outline: none;
  border-color: var(--primary, #4f46e5);
}

.blank-chip {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  margin: 0 4px 4px 0;
}

.tree-root { display: flex; flex-direction: column; gap: 4px; min-height: 64px; }
.tree-node { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px 8px; }
.tree-node.active { background: #eff6ff; border-color: #93c5fd; }
.tree-node.drop-target { outline: 2px dashed var(--blue); background: #eff6ff; }
.tree-node.folder-dragging { opacity: 0.5; }
.folder-panel.drop-target-root {
  outline: 2px dashed var(--blue);
  background: rgba(239, 246, 255, 0.55);
}
.folder-breadcrumb .crumb.drop-target {
  background: rgba(37, 99, 235, 0.08);
  color: var(--blue, #2563eb);
  border-radius: 6px;
}
.tree-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tree-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.tree-left[data-action="select-folder"] { cursor: pointer; }
.tree-left[data-drag-folder] { cursor: grab; }
.tree-label { min-width: 0; flex: 1; }
.tree-toggle { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font-size: 11px; cursor: pointer; flex-shrink: 0; }
.tree-title { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-meta { font-size: 11px; color: var(--muted); }
.tree-root,
.folder-breadcrumb { user-select: none; -webkit-user-select: none; }
.tree-children { margin: 4px 0 0 16px; display: flex; flex-direction: column; gap: 4px; }

.study-prompt { white-space: pre-wrap; line-height: 2.1; font-size: 17px; padding-bottom: 16px; }
.study-answer-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fbfdff; margin-bottom: 10px; scroll-margin-top: 12px; }
.study-answer-item.ok { background: var(--green-soft); border-color: #86efac; }
.study-answer-item.bad { background: var(--red-soft); border-color: #fca5a5; }
.study-answer-item.focus { outline: 3px solid #bfdbfe; }
.score-line { font-size: 12px; color: var(--muted); margin-top: 4px; }
.result-box { border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; padding: 10px 12px; font-size: 14px; font-weight: 700; margin: 8px 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  box-shadow: var(--shadow);
}

.modal h3 { margin-bottom: 12px; }

/* 확인·선택 모달 */
.choice-modal { max-width: 420px; text-align: center; }
.choice-modal h3 { margin-bottom: 6px; }
.choice-message { margin-bottom: 14px; white-space: pre-line; }
.choice-items {
  text-align: left;
  max-height: 220px;
  overflow: auto;
  margin: 0 0 14px;
  padding: 8px 12px 8px 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  font-size: 13px;
  line-height: 1.5;
}
.choice-items li { margin: 2px 0; }
.choice-actions { justify-content: center; gap: 8px; }
.choice-actions button { min-width: 96px; }
.choice-actions button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .45);
  outline-offset: 2px;
}

.outline-panel {
  margin: 10px 0 8px;
}

.outline-panel > label {
  display: block;
  margin-bottom: 6px;
}

.outline-summary-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

.outline-summary-panel--empty {
  padding: 14px 12px;
  background: var(--soft, #f8fafc);
  text-align: center;
}

.outline-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 13px;
}

.outline-summary-head-title {
  color: var(--text, #111827);
}

.outline-summary-tree {
  border: 1px solid #eef2f7;
  border-radius: 10px;
  padding: 6px 4px;
  background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
  max-height: none;
  overflow: auto;
}

.outline-summary-tree.is-collapsed {
  max-height: 220px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent);
  mask-image: linear-gradient(to bottom, #000 75%, transparent);
}

.outline-summary-tree.is-expanded {
  max-height: min(420px, 55vh);
  overflow: auto;
  -webkit-mask-image: none;
  mask-image: none;
}

.outline-summary-row {
  font-size: 13px;
}

.outline-summary-toggle {
  display: block;
  width: 100%;
  margin-top: 8px;
  text-align: center;
}

.outline-summary-actions {
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 6px;
}

.outline-summary-pick {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  margin: 0;
  cursor: pointer;
}

.outline-summary-status {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  min-width: 2.2em;
  text-align: center;
}

.outline-summary-status.is-blank {
  color: #166534;
  background: #dcfce7;
  border-radius: 6px;
  padding: 2px 6px;
}

.outline-help { line-height: 1.5; margin-bottom: 12px; }

.modal-wide { max-width: 880px; }

.outline-modal { max-height: 88vh; display: flex; flex-direction: column; }

.outline-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 720px) {
  .outline-split { grid-template-columns: 1fr; }
}

.outline-pane {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.outline-pane-preview {
  background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
  border-color: #c7d9f5;
}

.outline-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.outline-pane-hint {
  margin: 0 0 8px;
  line-height: 1.4;
}

.outline-tree-scroll {
  flex: 1;
  overflow: auto;
  border: 1px solid #eef2f7;
  border-radius: 10px;
  padding: 6px 4px;
  background: rgba(255, 255, 255, 0.7);
  min-height: 160px;
}

.outline-tree-empty {
  padding: 12px 8px;
  text-align: center;
}

.outline-tree-node {
  padding-left: calc(var(--ol-level, 0) * 18px + 4px);
}

.outline-tree-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 8px;
  font-size: 13px;
}

.outline-tree-check {
  flex-shrink: 0;
}

.outline-tree-line-num {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 11px;
  font-weight: 800;
  color: #7c3aed;
  background: #f3e8ff;
  padding: 2px 7px;
  border-radius: 6px;
  min-width: 3.2em;
  text-align: center;
}

.outline-tree-row:hover { background: rgba(37, 99, 235, 0.05); }

.outline-tree-row.is-new { background: #f0fdf4; }
.outline-tree-row.is-removed { opacity: 0.55; text-decoration: line-through; }

.outline-tree-badge {
  flex-shrink: 0;
  font-weight: 800;
  font-size: 12px;
  color: #1d4ed8;
  min-width: 2.2em;
}

.outline-tree-title-read {
  flex: 1;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.outline-tree-title {
  flex: 1 1 0;
  min-width: 3rem;
  width: auto;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111827);
  background: #fff;
}

.outline-tree-line-input {
  flex-shrink: 0;
  width: 3.4em;
  padding: 2px 4px;
  border: 1px solid #e9d5ff;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #7c3aed;
  background: #f3e8ff;
  text-align: center;
  -moz-appearance: textfield;
}

.outline-tree-line-input::-webkit-outer-spin-button,
.outline-tree-line-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.outline-tree-check {
  flex-shrink: 0;
}

.outline-tree-del {
  flex-shrink: 0;
  padding: 2px 8px !important;
  line-height: 1;
}

.outline-pane-tools {
  margin-top: 10px;
  flex-wrap: wrap;
}

.outline-modal-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.candidate-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.candidate-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px; border-bottom: 1px solid #f1f5f9; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 800; margin-top: 4px; }
code { background: #eef2ff; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* 문제·해설 폭 조절 핸들(티켓 39) — 학습·카드제작 공용. js/ui/split-resize.js가 드래그·키보드를 붙인다 */
.split-handle {
  cursor: col-resize;
  position: relative;
  align-self: stretch;
  touch-action: none;
}
/* 핸들 칸은 6px뿐이라 막대 근처를 눌러도 빗나가기 쉽다 — 양옆 간격(14px) 안쪽으로 잡는 영역만 넓힌다 */
.split-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -6px;
  right: -6px;
}
.study-layout > .split-handle {
  overflow: visible;
}
/* 끄는 동안 커서가 칸 밖으로 나가도 모양 유지, 글자 선택 막기. 학습 화면의 칸 폭 전환 애니메이션
   (문제 접기용 0.2초)이 끄는 중에도 걸리면 막대가 커서를 늦게 따라가므로 끄는 동안만 끈다. */
html.is-split-dragging,
html.is-split-dragging * {
  cursor: col-resize !important;
  user-select: none !important;
}
html.is-split-dragging .study-layout,
html.is-split-dragging .create-split {
  transition: none !important;
}
.split-handle::after {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--line);
  transition: background .12s ease, width .12s ease;
}
.split-handle:hover::after,
.split-handle:focus-visible::after,
.split-handle.is-dragging::after {
  width: 3px;
  background: var(--blue);
}
.split-handle:focus-visible {
  outline: none;
}

/* 카드제작 — 문제/해설 분리. 폭은 --create-split-a/-b(둘 다 fr, 티켓 39, ui.createSplitPct로 저장)로
   나눈다. %는 고정 폭(각주 240px·핸들 6px)을 뺀 남는 폭을 정확한 비율로 못 나눠 fr을 그대로 쓴다. */
.create-split {
  display: grid;
  grid-template-columns: minmax(0, var(--create-split-a, 4.5fr)) 6px minmax(0, var(--create-split-b, 5.5fr)) 240px;
  gap: 14px;
  margin-top: 12px;
}
.create-notes-mount:empty {
  display: none;
}
.create-split:has(.create-notes-mount:empty) {
  grid-template-columns: minmax(0, var(--create-split-a, 4.5fr)) 6px minmax(0, var(--create-split-b, 5.5fr));
}
.create-notes-mount {
  min-width: 0;
  display: flex;
}
.create-notes-mount .study-notes-panel {
  flex: 1;
  min-height: 0;
}

/* 각주 사이드바 접기 — 학습모드 각주바와 같은 방식으로 카드제작에서도 접을 수 있게 */
body.create-notes-collapsed .create-split {
  grid-template-columns: minmax(0, var(--create-split-a, 4.5fr)) 6px minmax(0, var(--create-split-b, 5.5fr)) 44px;
}
body.create-notes-collapsed .create-notes-mount .study-notes-panel[data-notes-host="create"] .study-panel-body,
body.create-notes-collapsed .create-notes-mount .study-notes-panel[data-notes-host="create"] .study-notes-tabs,
body.create-notes-collapsed .create-notes-mount .study-notes-panel[data-notes-host="create"] .study-panel-head {
  display: none;
}
body.create-notes-collapsed .create-notes-mount .study-notes-panel[data-notes-host="create"] .study-panel-tab {
  display: block;
  width: 100%;
  height: 100%;
  padding: 14px 0;
  border: 1px solid #c4b5fd;
  border-radius: 16px;
  background: #f5f3ff;
  color: #6d28d9;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  white-space: nowrap;
  writing-mode: vertical-rl;
  cursor: pointer;
}

.create-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.create-panel-foot {
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.create-panel-head {
  font-size: 15px;
  font-weight: 800;
  color: var(--blue);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 4px;
}
.create-panel-head.explanation { color: #7c3aed; }

.create-explanation-workspace,
.create-explanation-aside {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.create-explanation-label-row {
  align-items: center;
}

.create-explanation-label-row .create-explanation-label {
  margin: 0;
}

.create-explanation-focus-open {
  flex-shrink: 0;
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
}

.create-explanation-focus-open:hover {
  background: #ddd6fe;
}

.create-explanation-focus-close,
.create-explanation-focus-save {
  display: none;
}

/* 해설 집중 편집 — 기존 #explanationTemplate 를 화면 전체로 키운다 */
body.create-explanation-focus {
  overflow: hidden;
}

body.create-explanation-focus .create-explanation-panel {
  position: fixed;
  inset: 0 240px 0 0;
  z-index: 400;
  border-radius: 0;
  border: 0;
  margin: 0;
  padding: 14px 16px 16px;
  background: var(--panel, #fff);
  box-sizing: border-box;
}

body.create-explanation-focus .create-notes-mount:not(:empty) {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 240px;
  z-index: 401;
  padding: 12px 10px 12px 0;
  background: var(--panel, #fff);
  box-sizing: border-box;
}

/* 집중 편집 중 각주바를 접으면 해설 폭을 그만큼 돌려준다 */
body.create-explanation-focus.create-notes-collapsed .create-notes-mount:not(:empty) {
  width: 44px;
  padding: 12px 2px 12px 0;
}
body.create-explanation-focus.create-notes-collapsed .create-explanation-panel {
  inset: 0 44px 0 0;
}

body.create-explanation-focus .create-explanation-focus-open {
  display: none;
}

body.create-explanation-focus .create-explanation-focus-close,
body.create-explanation-focus .create-explanation-focus-save {
  display: inline-block;
}

body.create-explanation-focus .create-explanation-aside,
body.create-explanation-focus .create-explanation-label-row {
  display: none;
}

body.create-explanation-focus .create-explanation-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.create-explanation-focus #explanationTemplate.xl {
  flex: 1;
  height: auto;
  min-height: 0;
  max-height: none;
  resize: none;
}

.explanation-prose {
  line-height: 1.65;
  margin-bottom: 14px;
  white-space: pre-wrap;
}



/* 집중학습 설정 바 — 토글 아래 인라인 (모달 아님) */
.focus-study-setup-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  margin: 0 0 8px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fff7f7;
}
.focus-study-setup-bar[hidden] { display: none !important; }
.focus-study-setup-bar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.focus-study-setup-bar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.focus-study-setup-hint {
  margin: 0;
}
body.focus-study-setup #studyExplanation .focus-study-pick {
  cursor: pointer;
}
body.focus-study-setup #studyExplanation .focus-study-pick:not(.is-on) {
  opacity: 0.72;
}

button.focus-study-entry {
  background: #dc2626;
  color: #fff;
  border: 1px solid #b91c1c;
  font-weight: 700;
  flex-shrink: 0;
}

button.focus-study-entry:hover {
  background: #b91c1c;
}

button.focus-study-entry.is-on {
  box-shadow: inset 0 0 0 2px #fff;
  outline: 2px solid #7f1d1d;
}

button.focus-study-start {
  background: #dc2626;
  color: #fff;
  border: 1px solid #b91c1c;
  font-weight: 700;
}

button.focus-study-start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.focus-study-end {
  color: #b91c1c;
  border-color: #fecaca;
}

.focus-study-setup-modal {
  max-width: 480px;
  width: min(480px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}

.focus-study-setup-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.focus-study-setup-toolbar,
.focus-study-setup-fields,
.focus-study-setup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.focus-study-setup-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.focus-study-blank-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 36vh;
  overflow: auto;
}

.focus-study-setup-field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
}

.focus-study-setup-field input {
  width: 4.2rem;
  padding: 4px 6px;
}

/* 빈칸(.blank-wrap)처럼 inline 으로 줄 끝에서 이어져 긴 정답도 모두 보인다. 본문보다 2px 작게, 번호만 굵게 */
.focus-study-pick {
  display: inline;
  margin: 0;
  padding: 1px 8px;
  border-radius: 12px;
  border: 2px solid #94a3b8;
  background: #f8fafc;
  font-size: calc(1em - 2px);
  font-weight: 400;
  cursor: pointer;
  vertical-align: baseline;
  line-height: inherit;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.focus-study-pick-no {
  font-weight: 700;
}

.focus-study-pick:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.focus-study-pick.is-on {
  border-color: #dc2626;
  background: #fef2f2;
  color: #b91c1c;
}

@media (max-width: 900px) {
  .focus-study-setup-modal {
    max-width: 100%;
    width: 100%;
    max-height: 90vh;
  }
  .focus-study-blank-list { max-height: 28vh; }
}

body.focus-study-setup #gradeResult {
  border-color: #fde68a;
  background: #fffbeb;
}

.blank-wrap-locked {
  cursor: default;
  border-bottom-style: solid;
  border-bottom-color: #86efac;
  background: var(--green-soft);
}

.blank-wrap-locked:hover {
  background: var(--green-soft);
}

.blank-field.focus-locked {
  cursor: default;
}

body.focus-study-active #gradeResult {
  border-color: #fecaca;
  background: #fef2f2;
}

.blank-answer-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.blank-answer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.blank-row-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  min-width: 52px;
}

/* 해설 인라인 빈칸 — 입력부 + 남은 ○○○ 마스크 (본문과 함께 줄바꿈) */
.explanation-body {
  position: relative;
  white-space: pre-wrap;
  line-height: 2.2;
  font-size: 16px;
  padding-bottom: 16px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.blank-wrap {
  display: inline;
  white-space: normal;
  vertical-align: baseline;
  cursor: text;
  padding: 0 1px 4px 0;
  border-bottom: 2px dashed #94a3b8;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.blank-wrap:hover {
  background: rgba(37, 99, 235, 0.08);
  border-bottom-color: #93c5fd;
}

.blank-wrap:focus-within {
  background: #eff6ff;
  border-bottom: 2px solid var(--blue);
}

.blank-wrap:has(.blank-field.ok) {
  background: var(--green-soft);
  border-bottom: 2px solid var(--green);
}

.blank-wrap:has(.blank-field.bad) {
  background: var(--red-soft);
  border-bottom: 2px solid var(--red);
}

.blank-wrap:has(.blank-field.ok) .blank-field {
  color: var(--green);
}

.explanation-body .blank-field,
.blank-field {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: inherit;
  font-style: normal;
  font-weight: 600;
  letter-spacing: normal;
  line-height: inherit;
  vertical-align: baseline;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  outline: none;
  cursor: text;
  caret-color: var(--blue);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.blank-field.blank-field-shape {
  color: inherit;
}

.blank-rest {
  display: inline;
  color: #64748b;
  font-weight: 600;
  letter-spacing: normal;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  pointer-events: none;
  user-select: none;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/*
 * 채점 후 정답 표시 — 빈칸 아래 줄에 깐다.
 * 정답을 흐름 속 block 으로 두면 빈칸 뒤에 이어지던 본문("…입니다.")까지 다음 줄로 밀린다.
 * inline-flex 세로 배치는 첫 항목(빈칸)의 baseline 을 바깥에 물려주므로,
 * 정답은 아래로 내려가면서 본문은 빈칸 오른쪽에 그대로 남는다.
 */
/*
 * 정답이 놓일 자리만 흐름에 남기는 폭 0 자리표시자.
 * 정답을 흐름 속 block 으로 두면 빈칸 뒤에 이어지던 본문("…입니다.")까지 다음 줄로 밀리고,
 * 빈칸과 세로 flex 로 묶으면 빈칸이 원자 인라인이 되어 앞 문장과 줄이 끊긴다.
 * 폭이 0 이라 뒤 본문을 밀지 않고, 빈칸 끝에 붙으므로 여러 줄짜리 빈칸에서도 마지막 줄에 따라붙는다.
 * in-flow 줄상자가 없는 inline-block 은 아래 모서리가 baseline 이므로,
 * vertical-align 을 높이만큼 내리면 딱 그만큼만 줄 아래로 자리를 벌린다. 아랫줄과 겹치지 않는다.
 */
.blank-answer-holder {
  display: inline-block;
  width: 0;
  height: 28px;
  vertical-align: -28px;
  user-select: none;
  pointer-events: none;
}

/*
 * 배경은 두지 않는다. 빈칸이 색 배경을 쓰고 있어 둘이 같은 것으로 보인다.
 * 자리표시자가 폭 0 이라 그냥 두면 글자마다 줄이 바뀐다. max-content 로 한 줄을 기본으로 잡고,
 * layoutBlankAnswers 가 실제 남은 폭에 맞춰 left·max-width 를 다시 잡는다.
 */
.blank-answer {
  position: absolute;
  left: 0;
  top: 0;
  width: max-content;
  max-width: min(30rem, 100%);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--green);
  word-break: break-word;
  overflow-wrap: anywhere;
  pointer-events: none;
  visibility: hidden;
}

.blank-answer.is-placed {
  visibility: visible;
}

/* 채점 후 입력칸 안 글자 단위 대조 — 어긋난 글자만 빨강, 맞은 글자는 초록 */
/* 패널용 --green-soft 는 글자 단위 강조로는 너무 옅어 같은 계열을 진하게 깐다.
   좌우 패딩을 두면 「제2조」가 「제 2 조」처럼 벌어져 보이므로 세로만 준다. */
.bd-same,
.bd-diff,
.bd-extra,
.bd-space-extra,
.bd-missing {
  padding: 1px 0;
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.bd-same { color: var(--green); background: rgba(22, 163, 74, 0.16); }
.bd-diff { color: var(--red); background: rgba(220, 38, 38, 0.16); }
.bd-extra {
  color: var(--red);
  background: rgba(220, 38, 38, 0.16);
  text-decoration: line-through;
  text-decoration-thickness: 0.9px;
}
.bd-skip { color: inherit; }
/* 정답 쪽 전용 — 입력하지 않아 빠진 글자. 오타(bd-diff)와 구분되게 밑줄만 더한다 */
.bd-missing {
  color: var(--red);
  background: rgba(220, 38, 38, 0.16);
  text-decoration: underline dotted;
  text-decoration-thickness: 0.9px;
  text-underline-offset: 2px;
}

/* 첨삭: 띄어쓰기 빠짐 = ∧, 잘못 띈 곳 = 찡긋(호). 글자 폭은 차지하지 않는다. */
.bd-space-miss {
  display: inline-block;
  width: 0;
  position: relative;
  overflow: visible;
  vertical-align: baseline;
}

.bd-space-miss::before {
  content: '∧';
  position: absolute;
  left: -0.45em;
  bottom: -0.35em;
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.bd-space-extra {
  position: relative;
  color: inherit;
  background: rgba(220, 38, 38, 0.12);
}

.bd-space-extra::after {
  content: '‿';
  position: absolute;
  left: 50%;
  top: -0.7em;
  transform: translateX(-50%);
  color: var(--red);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

/* 정답 칸 전체를 초록으로 칠하는 위쪽 :has() 규칙(0,4,0)을 이겨야 빨강이 살아남는다 */
.blank-wrap:has(.blank-field.ok) .blank-field .bd-diff,
.blank-wrap:has(.blank-field.ok) .blank-field .bd-extra { color: var(--red); }

/* ── 알파 테스터 관문 (로그인보다 위) ── */
.alpha-gate-overlay {
  z-index: 3200;
}

.alpha-gate-card .auth-lead {
  margin-bottom: 4px;
}

body.alpha-locked {
  overflow: hidden;
}

/* ── 인증 오버레이 ── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.auth-overlay.hidden { display: none !important; }

.auth-card {
  width: min(100%, 440px);
  max-height: min(92vh, 720px);
  overflow: auto;
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.08);
  padding: 28px 28px 24px;
}

.auth-header { margin-bottom: 18px; text-align: center; }

.auth-header h2 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.auth-lead {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.auth-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 14px 10px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.auth-tab:hover { border-color: #93c5fd; transform: translateY(-1px); }

.auth-tab-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.auth-tab-desc {
  font-size: 12px;
  color: var(--muted);
}

.auth-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.auth-tab.active .auth-tab-title,
.auth-tab.active .auth-tab-desc {
  color: #fff;
}

.auth-feedback {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.auth-feedback.hidden { display: none !important; }

.auth-feedback-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.auth-feedback-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.auth-panel-guide {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
}

.auth-panel-guide-accent {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.auth-panel-guide ol {
  margin: 8px 0 0;
  padding-left: 20px;
}

.auth-panel-guide li { margin-bottom: 4px; }

.auth-empty-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
}

.auth-empty-hint.hidden { display: none !important; }

.auth-security-note {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-name-block {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid #bfdbfe;
}

.auth-name-block label {
  margin-top: 0 !important;
}

.auth-saved-accounts {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-card label {
  display: block;
  margin-top: 10px;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.auth-card input,
.auth-card select {
  width: 100%;
  font-size: 15px;
  padding: 10px 12px;
}

.auth-submit { width: 100%; margin-top: 16px; }

.auth-submit-lg {
  padding: 14px 16px !important;
  font-size: 16px !important;
  font-weight: 800 !important;
}

.auth-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.user-badge {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
}
button.user-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
}
button.user-badge:hover,
button.user-badge[aria-expanded="true"] {
  border-color: var(--blue);
  background: #eff6ff;
}
.user-badge-caret {
  color: #334155;
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}
.account-switcher {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.account-switcher-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: auto;
  scrollbar-color: #64748b #e2e8f0;
}
.account-switcher-list::-webkit-scrollbar {
  width: 14px;
}
.account-switcher-list::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 8px;
}
.account-switcher-list::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 8px;
  min-height: 32px;
}
.account-switcher-list::-webkit-scrollbar-thumb:hover {
  background: #475569;
}
.account-switch-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.account-switch-item:hover {
  border-color: var(--blue);
  background: #eff6ff;
}
.account-switch-item.is-current {
  background: var(--soft);
  cursor: default;
}
.account-switch-empty {
  margin: 0 0 4px;
}
.account-switcher-pin label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 650;
}
.account-switcher-pin input {
  width: 100%;
}

.fmt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 8px;
  margin: 0 0 6px;
}
.fmt-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.fmt-group-align {
  flex: 1 0 auto;
  justify-content: center;
  min-width: min-content;
}
.fmt-group-notes {
  margin-left: auto;
}
.fmt-c-b { color: #1d4ed8; }
.fmt-c-r { color: #dc2626; }
.fmt-c-g { color: #15803d; }
.fmt-color-swatch[data-color="k"] { background: #111111; }
.fmt-color-swatch[data-color="b"] { background: #1d4ed8; }
.fmt-color-swatch[data-color="r"] { background: #dc2626; }
.fmt-color-swatch[data-color="g"] { background: #15803d; }
.fmt-color-wrap {
  position: relative;
  display: inline-flex;
}
.fmt-color-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.fmt-color-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid #94a3b8;
  background: #111111;
}
.fmt-color-caret {
  font-size: 10px;
  line-height: 1;
  color: #64748b;
}
.fmt-color-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.fmt-color-menu[hidden] { display: none; }
.fmt-color-opt {
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 2px;
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fmt-color-opt .fmt-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
}
.fmt-color-opt.is-current {
  outline: 2px solid #1d4ed8;
  outline-offset: 1px;
}
.fmt-hl-btn {
  background: #fff !important;
  color: inherit;
  font-weight: 700;
  border: 1px solid #b7c4d6 !important;
}
.fmt-hl-btn:hover {
  background: #eef2f6 !important;
  border-color: #8fa0b5 !important;
}
.fmt-hl-btn:active,
.fmt-hl-btn.is-active {
  background: #dbe3ee !important;
  border-color: #64748b !important;
  box-shadow: none;
}
.fmt-toolbar .fmt-group-text > button.ghost.small,
.fmt-toolbar .fmt-color-trigger,
.fmt-toolbar .fmt-color-apply {
  background: #fff;
  border: 1px solid #b7c4d6;
}
.fmt-toolbar .fmt-group-text > button.ghost.small:hover,
.fmt-toolbar .fmt-color-trigger:hover,
.fmt-toolbar .fmt-color-apply:hover {
  background: #eef2f6;
  border-color: #8fa0b5;
}
.fmt-toolbar .fmt-group-text > button.ghost.small:active,
.fmt-toolbar .fmt-color-trigger:active,
.fmt-toolbar .fmt-color-apply:active,
.fmt-toolbar .fmt-group-text > button.ghost.small.is-active {
  background: #dbe3ee;
  border-color: #64748b;
}
/* 글자색·형광펜: 왼쪽은 마지막에 고른 색을 바로 적용, ▾는 색 고르기 */
.fmt-toolbar .fmt-split-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.fmt-toolbar .fmt-split-caret {
  display: inline-flex;
  align-items: center;
}
.fmt-toolbar .fmt-color-apply {
  min-width: 34px;
}
.fmt-toolbar .fmt-color-apply .fmt-color-swatch {
  width: 16px;
  height: 16px;
}
.fmt-toolbar .fmt-split-caret {
  min-width: 0;
  margin-left: -1px;
  padding-left: 5px;
  padding-right: 5px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.fmt-hl-label {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(250, 204, 21, 0.55);
  color: #422006;
  line-height: 1.3;
}
button.ghost.small.fmt-align-btn,
.fmt-toolbar button.fmt-align-btn {
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 5px;
  flex: 0 0 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #4b5563;
  background: #fff;
  border: 1px solid #b7c4d6;
  border-radius: 4px;
}
.fmt-toolbar button.fmt-align-btn svg,
.fmt-toolbar .fmt-align-icon {
  display: block;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  flex: 0 0 18px;
  flex-shrink: 0;
  overflow: visible;
  fill: currentColor;
}
.fmt-toolbar button.fmt-align-btn:hover {
  background: #eef2f6;
  border-color: #8fa0b5;
}
.fmt-toolbar button.fmt-align-btn:active,
.fmt-toolbar button.fmt-align-btn.is-active {
  background: #dbe3ee;
  border-color: #64748b;
}
.fmt-toolbar [data-action="fmt-bold"].is-active {
  background: #dbe3ee;
  border-color: #64748b;
}
.fmt-fn-btn,
.fmt-clear-btn {
  background: #fff !important;
  border-color: #b7c4d6 !important;
}
.fmt-fn-btn:hover,
.fmt-clear-btn:hover {
  background: #eef2f6 !important;
  border-color: #8fa0b5 !important;
}
.fmt-fn-btn:active,
.fmt-clear-btn:active {
  background: #dbe3ee !important;
  border-color: #64748b !important;
}
.fmt-toolbar [data-action="fmt-bold"]:focus-visible,
.fmt-toolbar .fmt-color-trigger:focus-visible,
.fmt-toolbar .fmt-hl-btn:focus-visible,
.fmt-toolbar .fmt-align-btn:focus-visible,
.fmt-toolbar .fmt-fn-btn:focus-visible,
.fmt-toolbar .fmt-clear-btn:focus-visible,
.fmt-toolbar .fmt-color-opt:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}
.ui-delay-tip {
  position: fixed;
  z-index: 12000;
  max-width: min(280px, calc(100vw - 16px));
  padding: 6px 8px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
  white-space: normal;
}
.tm-bold { font-weight: 700; }
.tm-fn {
  all: unset;
  display: inline;
  box-sizing: border-box;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 0.12em;
  border: 0;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  vertical-align: super;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.tm-fn::before { content: attr(data-fn-index); }
.tm-fn.note-pulse {
  background: #fef08a;
  outline: 2px solid #eab308;
  outline-offset: 2px;
}
.study-notes-panel .study-fn-heading.note-pulse .ghost.small,
.study-notes-panel .study-fn-heading.note-pulse .ghost.small:hover,
.study-notes-panel .study-fn-heading.note-pulse .ghost.small:active {
  background: #fef08a;
  border-color: #eab308;
}
.footnote-hover {
  position: fixed;
  z-index: 12000;
  max-width: min(360px, calc(100vw - 16px));
  max-height: min(50vh, 300px);
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid #b8c3d2;
  border-radius: 8px;
  background: #fffef5;
  color: #172033;
  box-shadow: 0 4px 16px #0f172a26;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: auto;
}
.tm-line {
  display: block;
  box-sizing: border-box;
  min-height: 1.2em;
  width: 100%;
  max-width: 100%;
}
.tm-line.tm-align-left { text-align: left; }
.tm-line.tm-align-center { text-align: center; }
.tm-line.tm-align-right { text-align: right; }
.tm-line.tm-align-justify { text-align: justify; text-align-last: auto; }
.tm-typing {
  display: inline;
  white-space: pre-wrap;
}
.study-notes-panel .ghost.small {
  border-color: #b7c4d6;
}
.study-notes-panel .ghost.small:hover {
  background: #eef2f6;
  border-color: #8fa0b5;
}
.study-notes-panel .ghost.small:active,
.study-notes-panel .ghost.small.active {
  background: #dbe3ee;
  border-color: #64748b;
}
.notes-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 10px 8px;
}
.notes-panel-head h3 {
  margin-right: auto;
}
.notes-field-tabs {
  display: inline-flex;
  gap: 0;
  margin-left: auto;
  border: 1px solid #b7c4d6;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.study-notes-panel[data-notes-host="study"] .notes-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 6px 8px;
}
.study-notes-panel[data-notes-host="study"] .notes-panel-head h3 {
  margin-right: 0;
  grid-column: 1;
  grid-row: 1;
}
.study-notes-panel[data-notes-host="study"] .notes-collapse-btn {
  grid-column: 2;
  grid-row: 1;
}
.study-notes-panel[data-notes-host="study"] .notes-field-tabs {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-left: 0;
  width: max-content;
  max-width: 100%;
}
.notes-field-tabs [data-action="notes-field-tab"] {
  padding: 6px 12px;
  min-height: 32px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  border: 0;
  border-radius: 0;
  background: #fff;
}
.notes-field-tabs [data-action="notes-field-tab"] + [data-action="notes-field-tab"] {
  border-left: 1px solid #b7c4d6;
}
.notes-field-tabs [data-action="notes-field-tab"].active,
.study-notes-panel .notes-field-tabs [data-action="notes-field-tab"].active {
  background: #334155;
  color: #fff;
  font-weight: 800;
  border-color: #1f2937;
}
.study-notes-panel .ghost.small.notes-collapse-btn {
  flex: none;
  min-width: 0;
  padding: 7px 10px;
  font-size: 12px;
  background: #eff6ff;
  border-color: #93c5fd;
  color: var(--blue);
}
.study-notes-panel .ghost.small.notes-collapse-btn:hover,
.study-notes-panel .ghost.small.notes-collapse-btn:active {
  background: #dbeafe;
  border-color: var(--blue);
  color: var(--blue);
}
.study-notes-mount {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
}
.study-notes-mount:empty { display: none; }
.study-notes-mount .study-notes-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.study-notes-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 10px 0;
  align-items: center;
}
.study-notes-tabs [data-tab="notes"] {
  margin-right: auto;
}
.study-notes-tabs [data-tab="memo"] {
  margin-left: auto;
}
.study-notes-tabs [data-action="study-notes-tab"] {
  background: #fff;
  border-color: #b7c4d6;
}
.study-notes-tabs [data-action="study-notes-tab"].active,
.study-notes-panel .study-notes-tabs [data-action="study-notes-tab"].active {
  background: #334155;
  color: #fff;
  font-weight: 800;
  border-color: #1f2937;
}
.study-notes-panel .study-panel-body {
  padding: 8px 10px 10px;
  overflow: auto;
}
.study-notes-list {
  padding: 0;
  overflow: auto;
}
.notes-fn-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.notes-fn-all {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.study-fn-item { margin-bottom: 8px; }
.study-notes-panel[data-notes-host="create"] .study-fn-item {
  margin-bottom: 6px;
}
.study-fn-heading {
  display: flex;
  align-items: stretch;
}
.study-fn-jump {
  flex: 1;
  min-width: 0;
  text-align: left;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.study-fn-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
  padding: 4px;
  margin-left: -1px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.notes-chevron {
  flex: none;
  display: block;
}
.study-fn-body {
  margin-top: 6px;
  padding: 8px;
  border-radius: 8px;
  background: #f8fafc;
  white-space: pre-wrap;
  font-size: 13px;
}
.study-notes-panel[data-notes-host="create"] .study-fn-body {
  white-space: normal;
  margin-top: 4px;
  padding: 6px 8px;
}
.study-notes-panel[data-notes-host="create"] .notes-fn-edit {
  min-height: 64px;
  margin: 0;
}
.study-notes-panel[data-notes-host="create"] .notes-fn-actions {
  margin-top: 4px;
  margin-bottom: 0;
  padding: 0;
  gap: 6px;
}
.notes-fn-edit {
  width: 100%;
  min-height: 72px;
  resize: vertical;
}
#studyPrompt,
#studyExplanation {
  font-size: calc(17px * var(--study-font-scale, 1));
}
#studyExplanation .blank-field,
#studyExplanation .blank-rest,
#studyExplanation .blank-answer {
  font-size: 16px;
}

body.auth-locked .app,
body.auth-locked .topbar,
body.auth-locked .sidebar-toggle {
  pointer-events: none;
  user-select: none;
  filter: blur(3px) saturate(0.85);
}

@media (max-width: 1100px) {
  .create-split { grid-template-columns: 1fr; }
  body.create-explanation-focus .create-explanation-panel {
    inset: 0 0 42vh 0;
    width: auto;
    overflow: auto;
  }
  body.create-explanation-focus .create-notes-mount:not(:empty) {
    position: fixed;
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: auto;
    height: 42vh;
    max-height: 42vh;
    padding: 8px 10px;
    overflow: auto;
    border-top: 1px solid var(--line);
  }

  /* 좁은 화면에서도 접으면 세로 탭 대신 가로 막대로 — 집중 편집 오버레이와 일반 카드제작 모두 */
  body.create-notes-collapsed .create-notes-mount .study-notes-panel[data-notes-host="create"] {
    height: 44px;
    flex: none;
    max-height: 44px;
  }
  body.create-notes-collapsed .create-notes-mount .study-notes-panel[data-notes-host="create"] .study-panel-tab {
    padding: 0 14px;
    writing-mode: horizontal-tb;
  }
  body.create-explanation-focus.create-notes-collapsed .create-explanation-panel {
    inset: 0 0 44px 0;
  }
  body.create-explanation-focus.create-notes-collapsed .create-notes-mount:not(:empty) {
    height: 44px;
    max-height: 44px;
    padding: 0 10px;
  }
}


/* ── 사이드바 설정 ── */
.sidebar-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.sidebar-panel-head h3 { margin: 0; }
.sidebar-settings-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
/* 설정 창 — 왼쪽 분류 탭, 오른쪽 그 분류의 설정 카드들 */
.modal.settings-modal {
  max-width: 680px; width: min(680px, 94vw); padding: 0; overflow: hidden;
  display: flex; flex-direction: column; max-height: 86vh;
}
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--line);
}
.settings-head h3 { margin: 0; font-size: 18px; }
.settings-close {
  width: 32px; height: 32px; padding: 0; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 22px; line-height: 32px; cursor: pointer;
}
.settings-close:hover, .settings-close:focus-visible { background: var(--soft); color: #111827; }
.settings-layout { display: flex; height: min(500px, 68vh); overflow: hidden; }
.settings-nav {
  flex: none; width: 150px; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px;
  background: #f6f8fb; border-right: 1px solid var(--line);
}
.settings-tab {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border: none; border-radius: 10px; background: transparent; color: #344054;
  font-size: 14px; font-weight: 700; text-align: left; cursor: pointer;
}
.settings-tab:hover { background: #eaf0f8; }
.settings-tab.is-active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1); }
.settings-tab-icon { font-size: 16px; width: 20px; text-align: center; }
.settings-panels { flex: 1; min-width: 0; overflow: auto; padding: 18px 22px 22px; }
.settings-panel { display: flex; flex-direction: column; gap: 12px; }
.settings-panel.hidden { display: none; }
.settings-panel-head h4 { margin: 0 0 2px; font-size: 16px; }
.settings-panel-head p { margin: 0; font-size: 13px; color: var(--muted); }
.settings-item {
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.settings-item.hidden { display: none; }
.settings-item-title { display: block; font-size: 14px; font-weight: 700; color: #111827; margin: 0; }
.settings-item-desc { margin: 3px 0 10px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.settings-item-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-item-row .settings-item-desc { margin-bottom: 0; }
.settings-value { flex: none; font-weight: 700; font-size: 14px; color: #344054; padding: 4px 10px; border-radius: 8px; background: var(--soft); border: 1px solid var(--line); }
.settings-item-control { display: flex; align-items: center; gap: 10px; }
.settings-item-control input[type="range"] { flex: 1; max-width: 280px; }
.settings-inline { display: flex; gap: 8px; align-items: center; }
.settings-inline input { flex: 1; min-width: 0; max-width: 320px; }
.settings-inline button { flex: none; }
.settings-item.is-highlighted { animation: settings-flash 1.4s ease-out; }
@keyframes settings-flash {
  0% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.35); border-color: var(--primary); }
  100% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0); }
}
@media (max-width: 600px) {
  .settings-layout { flex-direction: column; height: auto; min-height: 0; overflow: auto; }
  .settings-nav { width: auto; flex-direction: row; border-right: none; border-bottom: 1px solid var(--line); padding: 8px; }
  .settings-tab { justify-content: center; }
  .settings-panels { overflow: visible; padding: 14px; }
}

/* 입력 칸 바로 아래 한 줄 안내 — 위 칸과 띄우고, 상자 대신 글자색으로만 */
.field-feedback {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}
.field-feedback.hidden { display: none !important; }
.field-feedback-error { color: #b91c1c; }
.field-feedback-success { color: #15803d; }

/* 사이드바 닉네임 옆 작은 펜 — 누르면 설정의 닉네임 칸으로 */
.user-name-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.user-name-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name-edit {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
}
.user-name-edit:hover, .user-name-edit:focus-visible { background: var(--soft); color: var(--primary); }

/* 형광 색 메뉴 */
.fmt-hl-wrap { position: relative; display: inline-flex; }
.fmt-hl-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100vw - 32px);
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line, #dbe3ee);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  white-space: nowrap;
}
.fmt-hl-menu[hidden] { display: none !important; }
.fmt-hl-opt {
  box-sizing: border-box;
  width: auto;
  min-width: 0;
  height: auto;
  padding: 2px 4px;
  border: 1px solid var(--line, #c5d0df);
  border-radius: 4px;
  cursor: pointer;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.fmt-hl-opt.is-current, .fmt-hl-opt:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}
.fmt-hl-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid #94a3b8;
  vertical-align: middle;
}
.fmt-hl-swatch[data-hl="y"] { background: rgba(250, 204, 21, 0.85); }
.fmt-hl-swatch[data-hl="lemon"] { background: rgba(255, 245, 0, 0.85); }
.fmt-hl-swatch[data-hl="g"] { background: rgba(74, 222, 128, 0.8); }
.fmt-hl-swatch[data-hl="r"] { background: rgba(248, 113, 113, 0.9); }
.fmt-hl-swatch[data-hl="b"] { background: rgba(96, 165, 250, 0.95); }
.fmt-hl-swatch[data-hl="h"] { background: rgba(148, 163, 184, 0.95); }
.fmt-hl-swatch[data-hl="k"] { background: rgba(30, 41, 59, 0.9); }

.fmt-hl-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.fmt-hl-caret {
  font-size: 10px;
  line-height: 1;
  color: #64748b;
}
.fmt-hl-sample {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  line-height: 1.35;
  color: #111;
  white-space: nowrap;
}
.fmt-hl-sample[data-hl="y"] { background: rgba(250, 204, 21, 0.85); }
.fmt-hl-sample[data-hl="lemon"] { background: rgba(255, 245, 0, 0.85); }
.fmt-hl-sample[data-hl="g"] { background: rgba(74, 222, 128, 0.75); }
.fmt-hl-sample[data-hl="r"] { background: rgba(248, 113, 113, 0.75); }
.fmt-hl-sample[data-hl="b"] { background: rgba(96, 165, 250, 0.75); }
.fmt-hl-sample[data-hl="h"] { background: rgba(148, 163, 184, 0.8); }
.fmt-hl-sample[data-hl="k"] { background: rgba(30, 41, 59, 0.55); color: #f8fafc; }
.fmt-hl-opt {
  min-width: auto;
  width: auto;
  height: auto;
  padding: 4px 8px;
}
.fmt-hl-trigger .fmt-hl-label { margin-left: 4px; }

/* 화면 아래 알림(공용) */
.app-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 3000;
  display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 32px));
  padding: 11px 12px 11px 16px; border-radius: 12px; background: #1f2937; color: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.28); font-size: 14px; line-height: 1.45;
  animation: app-toast-in 0.18s ease-out;
}
.app-toast-success { background: #14532d; }
.app-toast-text { min-width: 0; }
.app-toast-action {
  flex: none; padding: 4px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer;
}
.app-toast-action:hover { background: rgba(255, 255, 255, 0.14); }
.app-toast-close {
  flex: none; width: 24px; height: 24px; padding: 0; border: none; border-radius: 6px;
  background: transparent; color: rgba(255, 255, 255, 0.75); font-size: 18px; line-height: 24px; cursor: pointer;
}
.app-toast-close:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
@keyframes app-toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
