@font-face { font-family: 'Noto Serif JP Local'; src: url('./fonts/Noto_Serif_JP/NotoSerifJP-VariableFont_wght.ttf') format('truetype'); font-weight: 100 900; }
@font-face { font-family: 'Noto Sans JP Local'; src: url('./fonts/Noto_Sans_JP/NotoSansJP-VariableFont_wght.ttf') format('truetype'); font-weight: 100 900; }
@font-face { font-family: 'M PLUS 1'; src: url('./fonts/M_PLUS_1/MPLUS1-VariableFont_wght.ttf') format('truetype'); font-weight: 100 900; }
@font-face { font-family: 'Kosugi'; src: url('./fonts/Kosugi/Kosugi-Regular.ttf') format('truetype'); font-weight: 400; }
@font-face { font-family: 'Zen Maru Gothic'; src: url('./fonts/Zen_Maru_Gothic/ZenMaruGothic-Regular.ttf') format('truetype'); font-weight: 400; }
@font-face { font-family: 'Zen Maru Gothic'; src: url('./fonts/Zen_Maru_Gothic/ZenMaruGothic-Medium.ttf') format('truetype'); font-weight: 500; }
@font-face { font-family: 'Zen Maru Gothic'; src: url('./fonts/Zen_Maru_Gothic/ZenMaruGothic-Bold.ttf') format('truetype'); font-weight: 700; }

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── 포인트 컬러 ── */
  --accent:      #7C6FF7;
  --accent2:     #A89BFF;
  --accent-soft: rgba(124,111,247,0.13);

  /* ── 텍스트 ── */
  --text:   #1A1A2E;
  --sub:    #5C5478;
  --hint:   #8A82B0;

  /* ── 배경 — 은은한 그라데이션 ── */
  --bg:
    radial-gradient(120% 100% at 18% 0%,   rgba(124,111,247,0.10) 0%, transparent 56%),
    radial-gradient(110% 90%  at 85% 100%, rgba(96,165,250,0.08)  0%, transparent 56%),
    linear-gradient(180deg, #FAF9FE 0%, #EFECF9 100%);
  --surface: rgba(255,255,255,0.55);
  --card:    rgba(255,255,255,0.78);

  /* ── 의미 색상 (앱 내부 피드백) ── */
  --pink:   #C4BBFF;
  --pinkd:  #7C6FF7;
  --mint:   #86efac;
  --mintd:  #4ade80;
  --blue:   #93c5fd;
  --blued:  #60a5fa;

  /* ── 테두리 / 그림자 ── */
  --border: rgba(255,255,255,0.72);
  --sh:     rgba(100,80,200,0.12);
  --shh:    rgba(100,80,200,0.22);

  /* ── Glass 시스템 (solid = 완전 불투명) ── */
  --sg-bg:     #FFFFFF;
  --sg-border: rgba(26,26,46,0.08);
  --sg-shadow: 0 2px 8px rgba(26,26,46,0.05), 0 8px 28px rgba(26,26,46,0.07);
  --lg-tint:   rgba(255,255,255,0.32);

  /* ── Apple-style easing ── */
  --spring: cubic-bezier(.34,1.45,.5,1);
  --swift:  cubic-bezier(.32,.72,0,1);

  /* ── 라운드 반경 ── */
  --r:  22px;
  --rl: 30px;
  --rs: 14px;

  /* ── 폰트 ── */
  --font-jp: 'Noto Serif JP Local', 'Noto Serif JP', serif;
  --font-en: system-ui, sans-serif;
}
[data-theme=dark] {
  --accent:      #A89BFF;
  --accent2:     #C4BBFF;
  --accent-soft: rgba(168,155,255,0.14);

  --text:   #EDE8FF;
  --sub:    #9490C0;
  --hint:   #6060A0;

  --bg:
    radial-gradient(120% 100% at 18% 0%,   rgba(124,111,247,0.16) 0%, transparent 56%),
    radial-gradient(110% 90%  at 85% 100%, rgba(96,165,250,0.10)  0%, transparent 56%),
    linear-gradient(180deg, #0D0B16 0%, #131022 100%);
  --surface: rgba(18,12,40,0.65);
  --card:    rgba(28,20,54,0.82);

  --pink:   #A89BFF;
  --pinkd:  #A89BFF;
  --mint:   #4ade80;
  --mintd:  #86efac;
  --blue:   #60a5fa;
  --blued:  #93c5fd;

  --border: rgba(255,255,255,0.10);
  --sh:     rgba(0,0,0,0.28);
  --shh:    rgba(0,0,0,0.45);

  --sg-bg:     #17132A;
  --sg-border: rgba(255,255,255,0.09);
  --sg-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 10px 32px rgba(0,0,0,0.45);
  --lg-tint:   rgba(10,6,24,0.30);
}

/* ── 솔리드 모드: 내부 서피스까지 완전 불투명 ── */
[data-style="solid"] {
  --surface: #F5F3FB;
  --card:    #FFFFFF;
  --border:  rgba(26,26,46,0.09);
  --sh:      rgba(26,26,46,0.07);
  --shh:     rgba(26,26,46,0.16);
}
[data-theme=dark][data-style="solid"] {
  --surface: #211A3E;
  --card:    #191430;
  --border:  rgba(255,255,255,0.10);
  --sh:      rgba(0,0,0,0.30);
  --shh:     rgba(0,0,0,0.50);
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  transition: background .5s, color .5s, border-color .5s;
}
body.zip-drop-active::after {
  content: 'ZIP 파일을 놓으면 단어장 그룹으로 가져옵니다';
  position: fixed;
  inset: 18px;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px dashed var(--pinkd);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--card) 82%, transparent);
  color: var(--pinkd);
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  text-align: center;
  padding: 24px;
}

/* ══════════════════════════════════
   GLASS COMPONENT SYSTEM
   solid: backdrop-filter blur
   liquid: translucent + inset shadow (CSS-only)
══════════════════════════════════ */

/* ── 카드 공통 ── */
.s-card {
  position: relative;
  border-radius: var(--r);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.s-card:hover { transform: translateY(-2px); }

/* ── SOLID MODE — 완전 불투명, 블러 없음 ── */
[data-style="solid"] .s-card,
[data-style="solid"] .auth-box,
[data-style="solid"] .modal,
[data-style="solid"] .addform,
[data-style="solid"] .scard,
[data-style="solid"] .home-cal-wrap {
  background: var(--sg-bg) !important;
  border-color: var(--sg-border) !important;
  box-shadow: var(--sg-shadow) !important;
}

/* ── LIQUID MODE — 실제 backdrop blur + 렌즈 굴절 림 ── */
[data-style="liquid"] .s-card,
[data-style="liquid"] .auth-box,
[data-style="liquid"] .modal,
[data-style="liquid"] .addform,
[data-style="liquid"] .scard,
[data-style="liquid"] .home-cal-wrap {
  position: relative;
  background: var(--lg-tint) !important;
  backdrop-filter: blur(20px) saturate(1.6) brightness(1.02);
  -webkit-backdrop-filter: blur(20px) saturate(1.6) brightness(1.02);
  border: none !important;
  box-shadow:
    inset 0 1.5px 3px rgba(255,255,255,0.38),
    inset 0 -1px 2px rgba(255,255,255,0.08),
    0 18px 50px rgba(40,30,90,0.16),
    0 6px 16px rgba(0,0,0,0.08) !important;
}
[data-theme="dark"][data-style="liquid"] .s-card,
[data-theme="dark"][data-style="liquid"] .auth-box,
[data-theme="dark"][data-style="liquid"] .modal,
[data-theme="dark"][data-style="liquid"] .addform,
[data-theme="dark"][data-style="liquid"] .scard,
[data-theme="dark"][data-style="liquid"] .home-cal-wrap {
  box-shadow:
    inset 0 1.5px 3px rgba(255,255,255,0.18),
    inset 0 -1px 2px rgba(255,255,255,0.05),
    0 24px 60px rgba(0,0,0,0.55),
    0 8px 20px rgba(0,0,0,0.30) !important;
}

/* 렌즈 굴절 림 — 배경 복제를 displacement로 휘어서 가장자리 띠에만 표시.
   z-index:-1 → 틴트 배경 위, 콘텐츠 아래에 그려진다. */
[data-style="liquid"] .s-card::before,
[data-style="liquid"] .auth-box::before,
[data-style="liquid"] .modal::before,
[data-style="liquid"] .addform::before,
[data-style="liquid"] .scard::before,
[data-style="liquid"] .home-cal-wrap::before,
[data-style="liquid"] header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  padding: 18px;
  background: var(--bg);
  background-attachment: fixed;
  filter: url(#lg-lens) blur(0.5px) saturate(1.4) brightness(1.03);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask:         linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ── 모바일: background-attachment:fixed 미지원 → 렌즈 림만 숨김 (글래스는 유지) ── */
@media (max-width: 768px) {
  [data-style="liquid"] .s-card::before,
  [data-style="liquid"] .auth-box::before,
  [data-style="liquid"] .modal::before,
  [data-style="liquid"] .addform::before,
  [data-style="liquid"] .scard::before,
  [data-style="liquid"] .home-cal-wrap::before,
  [data-style="liquid"] header::before {
    display: none;
  }
}

/* ── SCROLL ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── LAYOUT ── */
.app { 
   width: 100%; 
   max-width: 768px; 
   margin: 0 auto; 
   padding: 0 18px 90px; 
   flex: 1;
}

/* ── HEADER ── */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0;
  position: sticky; top: 0; z-index: 100;
  margin: 10px 0 4px;
  border-radius: 20px;
  overflow: visible;
}
[data-style="solid"] header {
  background: var(--sg-bg);
  border: 1px solid var(--sg-border);
  box-shadow: 0 4px 20px rgba(26,26,46,0.06);
  padding: 14px 16px;
  margin: 10px -16px 4px;
}
[data-style="liquid"] header {
  background: var(--lg-tint);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: inset 0 1.5px 3px rgba(255,255,255,0.38), 0 8px 30px rgba(40,30,90,0.12);
  padding: 14px 16px;
  margin: 10px -16px 4px;
}
[data-theme="dark"][data-style="liquid"] header {
  box-shadow: inset 0 1.5px 3px rgba(255,255,255,0.18), 0 10px 40px rgba(0,0,0,0.50);
}
.logo { font-family: 'Nunito', 'Noto Sans KR', sans-serif; font-size: 20px; font-weight: 800; letter-spacing: -0.3px; cursor:pointer; }
.logo em { color: var(--pinkd); font-style: normal; font-weight: 900; }
.hbtns { display: flex; gap: 8px; align-items:center; }
.user-info { font-size: 13px; color: var(--sub); font-weight: 500; display:none; max-width:120px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.icbtn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--card);
  cursor: pointer; font-size: 17px; display: flex; align-items: center; justify-content: center;
  color: var(--sub); transition: all .2s;
}
.icbtn:hover { background: var(--surface); transform: scale(1.06); }
.textbtn {
  padding: 6px 12px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--card);
  cursor: pointer; font-size: 13px; display: none; align-items: center; justify-content: center;
  color: var(--sub); transition: all .2s; font-family: 'Noto Sans KR', sans-serif; font-weight:500;
}
.textbtn:hover { background: var(--surface); color: var(--pinkd); border-color: var(--pinkd); }
.ver-btn {
  padding: 4px 10px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 11px; font-weight: 700;
  color: var(--hint); font-family: 'Noto Sans KR', sans-serif;
  transition: all .2s; letter-spacing: .02em;
}
.ver-btn:hover { border-color: var(--pinkd); color: var(--pinkd); }

/* ── VIEWS ── */
.view { display: none; }
.view.active { display: block; animation: fade-in 0.3s ease; }
@keyframes fade-in { from { opacity: 0; transform:translateY(10px); } to { opacity: 1; transform:translateY(0); } }

/* ── AUTH VIEW ── */
.auth-box {
  background: var(--card); border-radius: var(--rl);
  padding: 30px 24px; border: 1.5px solid var(--border);
  box-shadow: 0 10px 40px var(--sh); text-align: center; margin-top: 20px;
}
.auth-title { font-family: 'Noto Serif JP', serif; font-size: 24px; font-weight: 700; margin-bottom: 24px; }
.auth-input {
  width: 100%; padding: 14px 16px; border-radius: var(--rs);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font-family: 'Noto Sans KR', sans-serif;
  font-size: 15px; outline: none; transition: all .2s; margin-bottom: 12px;
}
.auth-input:focus { border-color: var(--blued); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent); }
.auth-btn {
  width: 100%; padding: 16px; border-radius: var(--rs); border: none;
  background: linear-gradient(130deg, var(--blued), var(--blue));
  color: #fff; font-family: 'Noto Sans KR', sans-serif;
  font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 20px var(--shh); transition: all .25s; margin-bottom: 16px;
}
.auth-btn:hover { transform: translateY(-2px); filter:brightness(1.05); }
.auth-switch {
  font-size: 13px; color: var(--sub); cursor: pointer; font-weight: 500; text-decoration: underline;
}
.auth-divider {
  display:flex; align-items:center; text-align:center; color:var(--hint); font-size:12px; margin: 24px 0;
}
.auth-divider::before, .auth-divider::after {
  content:''; flex:1; border-bottom:1px solid var(--border);
}
.auth-divider::before { margin-right:10px; }
.auth-divider::after { margin-left:10px; }

.google-btn {
  width: 100%; padding: 14px; border-radius: var(--rs);
  border: 1.5px solid var(--border); background: var(--card);
  color: var(--text); font-family: 'Noto Sans KR', sans-serif;
  font-size: 15px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all .2s;
}
.google-btn:hover { background: var(--surface); border-color: var(--sub); }
.google-btn img { width: 18px; height: 18px; }

/* ── STATS ── */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.scard {
  background: var(--card); border-radius: var(--r);
  padding: 18px 20px; border: 1.5px solid var(--border);
  box-shadow: 0 4px 18px var(--sh); transition: background .5s, border-color .5s;
}
.snum { font-family: 'Nunito', 'Noto Sans KR', sans-serif; font-size: 38px; font-weight: 800; line-height: 1; margin-bottom: 3px; }
.slabel { font-size: 12px; color: var(--sub); font-weight: 500; }
.scard:nth-child(1) .snum { color: var(--pinkd); }
.scard:nth-child(2) .snum { color: var(--mintd); }

/* ── SECTION TITLE ── */
.stitle { font-size: 12px; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: .09em; margin-bottom: 10px; display:flex; justify-content:space-between; align-items:center; }
.stitle-action { color: var(--blued); cursor:pointer; text-transform:none; letter-spacing:0;}
.ocr-title-btn {
  border: 1px solid var(--blued); background: transparent; border-radius: 999px;
  padding: 5px 10px; font-family: 'Noto Sans KR', sans-serif; font-size: 12px; font-weight: 600;
}

/* ── MODE TABS ── */
.tabs {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
  background: var(--surface); border-radius: var(--r); padding: 6px;
  border: 1.5px solid var(--border); margin-bottom: 18px;
}
.tab {
  padding: 13px 8px; border-radius: calc(var(--r) - 6px); border: none;
  background: transparent; cursor: pointer; font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px; font-weight: 500; color: var(--sub);
  transition: all .25s; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab .te { font-size: 20px; }
.tab.on { background: var(--card); color: var(--text); box-shadow: 0 3px 10px var(--sh); }

.mode-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}
.mode-head-hint {
  color: var(--hint);
  font-size: 12px;
  text-align: right;
  line-height: 1.35;
}
.mode-grid {
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 8px;
}
.mode-card {
  min-height: 92px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-areas:
    "icon title pill"
    "icon desc desc";
  align-items: center;
  text-align: left;
  gap: 4px 10px;
  padding: 12px;
  border: 1.5px solid transparent;
}
.mode-card .te {
  grid-area: icon;
  font-size: 24px;
  align-self: start;
  margin-top: 2px;
}
.mode-title {
  grid-area: title;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.mode-desc {
  grid-area: desc;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 500;
}
.mode-pill {
  grid-area: pill;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--hint);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  white-space: nowrap;
}
.mode-card.on {
  background: color-mix(in srgb, var(--accent) 9%, var(--card));
  border-color: var(--accent);
  border-left: 3px solid var(--accent);
  box-shadow: 0 5px 18px var(--sh);
}
.mode-card.on .mode-pill {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.mode-card.on .mode-title { color: var(--accent); }
.mode-summary {
  margin: -6px 0 14px;
  padding: 10px 12px;
  border-radius: var(--rs);
  background: color-mix(in srgb, var(--blue) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--border));
  color: var(--sub);
  font-size: 13px;
  line-height: 1.5;
}

@media (min-width: 680px) {
  .mode-grid { grid-template-columns: 1fr 1fr; }
  .mode-grid .mode-card:first-child { grid-column: 1 / -1; }
}


/* ── BUTTONS ── */
.btnstart {
  width: 100%; padding: 18px; border-radius: var(--rl); border: none;
  background: linear-gradient(130deg, var(--pink), var(--blue));
  color: #fff; font-family: 'Noto Sans KR', sans-serif;
  font-size: 17px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 24px var(--shh); transition: all .25s;
  letter-spacing: .02em; margin-bottom: 10px;
}
.btnstart:hover { transform: translateY(-2px); box-shadow: 0 10px 30px var(--shh); }
.btnstart:active { transform: none; }
.btnstart:disabled { background:var(--border); color:var(--sub); cursor:not-allowed; transform:none; box-shadow:none;}

.btnmgr {
  width: 100%; padding: 13px; border-radius: var(--r);
  border: 1.5px solid var(--border); background: var(--card);
  color: var(--sub); font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .2s; margin-bottom: 26px;
}
.btnmgr:hover { background: var(--surface); color: var(--text); }

.deck-review-chip {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 5px; padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--blued); background: transparent;
  color: var(--blued); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: 'Noto Sans KR', sans-serif;
  transition: all .15s;
}
.deck-review-chip:hover { background: var(--blued); color: #fff; }
.deck-test-chip {
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--sub);
  font-size: 11px;
  font-weight: 600;
}

.btnreview {
  width: 100%; padding: 13px; border-radius: var(--r);
  border: 1.5px solid var(--blued); background: var(--card);
  color: var(--blued); font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .2s; margin-bottom: 10px;
}
.btnreview:hover { background: var(--blued); color: #fff; }

/* ── TYPING MODE ── */
.typing-inp {
  margin-top: 14px; width: 100%; font-size: 18px;
  padding: 10px 14px; border-radius: 10px;
  border: 2px solid var(--border); background: var(--bg);
  color: var(--text); outline: none; box-sizing: border-box;
  font-family: 'Noto Sans KR', sans-serif; transition: border-color .2s;
}
.typing-inp:focus { border-color: var(--blued); }
.typing-inp.correct { border-color: var(--mint); background: rgba(78,205,196,.08); }
.typing-inp.wrong { border-color: #e05050; background: rgba(224,80,80,.08); }
.typing-result { margin-top: 8px; font-size: 15px; min-height: 22px; line-height: 1.5; }
.typing-submit {
  margin-top: 12px; width: 100%; padding: 12px;
  border-radius: 12px; background: var(--blued);
  color: #fff; border: none; font-size: 16px; font-weight: 600;
  cursor: pointer; font-family: 'Noto Sans KR', sans-serif; transition: opacity .15s;
}
.typing-submit:disabled { opacity: .4; cursor: not-allowed; }

/* ── TEST MODE ── */
.test-options {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.test-option {
  width: 100%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.test-option:hover {
  border-color: var(--blued);
  transform: translateY(-1px);
}
.test-option.correct {
  border-color: var(--mint);
  background: rgba(78, 205, 196, .14);
}
.test-option.wrong {
  border-color: #e05050;
  background: rgba(224, 80, 80, .14);
}
.test-option:disabled {
  cursor: default;
}

/* ── FOLDER / WORD LIST ── */
.wlhdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; margin-top:20px;}
.witem {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--card);
  border-radius: var(--rs); border: 1.5px solid var(--border);
  margin-bottom: 8px; transition: background .5s, border-color .5s, transform .2s, box-shadow .2s;
  cursor:pointer;
}
.witem:hover { transform: translateY(-2px); box-shadow: 0 4px 12px var(--sh); border-color:var(--pinkd);}
.folder-icon { font-size:28px; min-width: 40px; text-align:center;}
.folder-title { font-size:16px; font-weight:600; color:var(--text); margin-bottom:4px;}
.folder-sub { font-size:12px; color:var(--sub);}
.folder-arrow { color:var(--border); font-size:20px; font-weight:300;}
.witem:hover .folder-arrow { color:var(--pinkd); }

.wkanji {
  font-family: var(--font-jp); font-size: 24px; font-weight: 700;
  min-width: 52px; max-width: min(44%, 260px); color: var(--text);
  overflow-wrap: anywhere; word-break: break-word; line-height: 1.25;
}
.wmeta { flex: 1; min-width: 0; }
.wreading { font-size: 12px; color: var(--sub); margin-bottom: 2px; }
.wmeaning {
  font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; word-break: break-word;
}
.wbadge { font-size: 15px; flex-shrink: 0; }
.wdrag { cursor: grab; font-size: 18px; color: var(--hint); transition: color .2s; padding: 0 4px; touch-action: none; }
.wdrag:hover { color: var(--pinkd); }
.wactions { display: flex; gap: 6px; flex-shrink: 0; }
.wabtn {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.wabtn:hover { background: var(--border); }


/* ── FOLDER CREATE MODAL ── */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:900; 
  display:none; align-items:center; justify-content:center;
  backdrop-filter: blur(3px);
}
.modal-overlay.active { display:flex; animation: fade-in 0.2s;}
.modal {
  background:var(--card); border-radius:var(--r); padding:24px;
  width:90%; max-width:360px; border:1.5px solid var(--border);
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-title { font-size:18px; font-weight:600; margin-bottom:16px; color:var(--text);}
.modal-actions { display:flex; gap:10px; margin-top:20px;}
.modal-btn {
  flex:1; padding:12px; border-radius:var(--rs); border:1.5px solid var(--border);
  background:var(--surface); cursor:pointer; font-family:'Noto Sans KR', sans-serif;
  font-weight:500; transition:all .2s; color:var(--text);
}
.modal-btn.primary { background:var(--pinkd); color:#fff; border-color:var(--pinkd); font-weight:600;}
.modal-btn:hover { filter:brightness(0.95); }
.folder-import-zone {
  margin-top: 14px;
  padding: 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--rs);
  background: var(--surface);
}
.folder-import-title { font-size: 13px; font-weight: 700; color: var(--sub); margin-bottom: 8px; }
.folder-import-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.folder-import-hint { font-size: 12px; color: var(--hint); line-height: 1.45; margin-top: 8px; }


/* ── STUDY HEADER ── */
.shdr { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.backbtn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--card);
  cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center;
  color: var(--sub); flex-shrink: 0; transition: all .2s;
}
.backbtn:hover { background: var(--surface); }
.global-back-btn {
  position: fixed;
  left: 14px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 850;
  box-shadow: 0 6px 18px var(--sh);
}
.app.sel-mode .global-back-btn {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
}
.pinfo { flex: 1; }
.study-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.ptxt { font-size: 12px; color: var(--sub); margin-bottom: 5px; font-weight: 500; }
.study-headline .ptxt { margin-bottom: 0; }
.study-timer {
  color: var(--blued);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ptrack { height: 8px; background: rgba(0,0,0,0.09); border-radius: 10px; overflow: hidden; }
.pfill { height: 100%; background: linear-gradient(to right, var(--accent), var(--mintd)); border-radius: 10px; transition: width .5s cubic-bezier(.4,0,.2,1); }

/* ── ROUND BADGE ── */
.rbadge {
  display: inline-block; padding: 4px 14px; border-radius: 20px;
  background: color-mix(in srgb, var(--pink) 25%, transparent);
  color: var(--pinkd); font-size: 12px; font-weight: 600; margin-bottom: 8px;
}
.study-status-line {
  margin-bottom: 12px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

/* ── FLASH CARD ── */
.cscene { min-height: 300px; margin-bottom: 14px; }

.flashcard {
  background: linear-gradient(135deg, var(--pinkd), var(--pink));
  border-radius: var(--rl);
  border: none;
  box-shadow: 0 10px 40px var(--sh);
  padding: 38px 30px 28px; text-align: center;
  position: relative; overflow: hidden;
  animation: cEnter .4s cubic-bezier(.34,1.56,.64,1) both;
  transition: background .5s;
  color: #fff;
}
[data-style="liquid"] .flashcard {
  background: linear-gradient(135deg, rgba(96,80,210,0.68), rgba(176,155,255,0.58));
  backdrop-filter: blur(20px);
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.42), 0 10px 40px rgba(60,30,180,0.40);
}
[data-theme="dark"] .flashcard {
  background: linear-gradient(135deg, rgba(40,28,100,0.85), rgba(70,52,150,0.75));
}
[data-theme="dark"][data-style="liquid"] .flashcard {
  background: linear-gradient(135deg, rgba(40,28,100,0.75), rgba(70,52,150,0.65));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), 0 10px 40px rgba(0,0,0,0.55);
}
.flashcard::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 110px; height: 110px;
  background: radial-gradient(circle, var(--pink) 0%, transparent 70%);
  opacity: .18; border-radius: 0 var(--rl) 0 110px; pointer-events: none;
}
.flashcard::after {
  content: ''; position: absolute; bottom: 0; left: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle, var(--blue) 0%, transparent 70%);
  opacity: .18; border-radius: 0 80px 0 var(--rl); pointer-events: none;
}

.round-transition {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.round-transition .round-kicker {
  color: var(--hint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.round-transition .round-title {
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
}
.round-transition .round-sub {
  color: var(--sub);
  font-size: 14px;
  line-height: 1.5;
}
.round-transition .round-policy {
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 12%, var(--surface));
  color: var(--blued);
  font-size: 12px;
  font-weight: 700;
}

@keyframes cEnter {
  from { opacity: 0; transform: translateY(28px) scale(.95); }
  to { opacity: 1; transform: none; }
}
@keyframes swR { to { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes swL { to { opacity: 0; transform: translateY(10px) scale(.96); } }
.swr { animation: swR .32s ease-in both !important; }
.swl { animation: swL .32s ease-in both !important; }

.cidx { font-size: 11px; color: var(--hint); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 14px; }
.ckanji {
  font-family: var(--font-jp); font-size: 68px; font-weight: 700; line-height: 1.15;
  color: var(--text); margin-bottom: 22px; max-width: 100%;
  overflow-wrap: anywhere; word-break: break-word; white-space: normal;
}

/* ── HINT REVEALS ── */
.hreveal {
  overflow: hidden; max-height: 0;
  transition: max-height .4s cubic-bezier(.4,0,.2,1), opacity .3s ease, margin .3s;
  opacity: 0; margin-bottom: 0;
}
.hreveal.open { max-height: 720px; opacity: 1; margin-bottom: 10px; }

/* 플래시카드 텍스트 — 컬러 배경 위 흰색 (scoped) */
.flashcard .ckanji { color: #fff; }
.flashcard .hira-text { color: rgba(255,255,255,0.88); }
.flashcard .mean-text { color: rgba(255,255,255,0.92); }
.flashcard .cidx { color: rgba(255,255,255,0.62); }
.rbadge { background: rgba(255,255,255,0.22); color: rgba(255,255,255,0.95); }
.study-status-line { color: var(--sub); }

.hira-text { font-family: 'Noto Serif JP', serif; font-size: 26px; color: var(--blued); padding: 8px 0; overflow-wrap: anywhere; word-break: break-word; }
.reverse-label { font-size: 11px; font-weight: 700; color: var(--mintd); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; opacity: .7; }
.mean-text { font-size: 20px; color: var(--mintd); font-weight: 600; padding: 8px 0; white-space: pre-line; overflow-wrap: anywhere; word-break: break-word; }

.hbtns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.hbtn {
  padding: 10px 12px; border-radius: var(--rs);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--sub); font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px; font-weight: 500; cursor: pointer; transition: all .2s;
}
.hbtn.revealed { border-color: var(--blued); color: var(--text); background: color-mix(in srgb, var(--blue) 15%, var(--card)); }
.hbtn:hover { transform: scale(1.02); }

/* ── ANSWER BUTTONS ── */
.ansbts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.ansbtn {
  padding: 16px 12px; border-radius: var(--r); border: none;
  cursor: pointer; font-family: 'Nunito', 'Noto Sans KR', sans-serif;
  font-size: 16px; font-weight: 800; letter-spacing: -0.2px;
  transition: transform .18s cubic-bezier(.34,1.4,.64,1), filter .18s, box-shadow .18s;
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px;
  color: #fff; min-height: 60px;
}
.ansbtn .ae { font-size: 18px; flex-shrink: 0; line-height: 1; }
.anslabel { display: none; }
.ansstudy {
  background: linear-gradient(145deg, #f07070, #e85555);
  box-shadow: 0 6px 20px rgba(232,85,85,.28), inset 0 1px 0 rgba(255,255,255,.18);
}
.ansknow {
  background: linear-gradient(145deg, #3ecf8e, #2bb87a);
  box-shadow: 0 6px 20px rgba(43,184,122,.28), inset 0 1px 0 rgba(255,255,255,.18);
}
.ansbtn:hover { transform: translateY(-2px); filter: brightness(1.07); }
.ansbtn:active { transform: scale(.97) translateY(1px); filter: brightness(.94); transition: all .08s; }
.ansbtn:disabled { opacity: .38; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }
.study-help-off .ansbtn { gap: 8px; }

.swhint { display: none; }

.shuffle-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.shuffle-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--rs);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.shuffle-option input { margin-top: 3px; }
.shuffle-option strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}
.shuffle-option small {
  display: block;
  margin-top: 2px;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.45;
}
.test-setup-preview {
  border: 1.5px solid var(--border);
  border-radius: var(--rs);
  background: var(--surface);
  padding: 11px 12px;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.45;
}
.test-preview-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.test-preview-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: baseline;
}
.test-preview-label {
  color: var(--hint);
  font-weight: 700;
}
.test-saved-note {
  display: block;
  margin-top: 5px;
  color: var(--pinkd);
  font-size: 12px;
  font-weight: 700;
}

/* ── MANAGE VIEW ── */
.impzone {
  border: 2px dashed var(--border); border-radius: var(--r);
  padding: 28px 20px; text-align: center; margin-bottom: 18px;
  background: var(--surface); cursor: pointer; transition: all .2s; position: relative;
}
.impzone.dov { border-color: var(--pinkd); background: color-mix(in srgb, var(--pink) 12%, var(--surface)); }
.impzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.impicon { font-size: 34px; margin-bottom: 6px; }
.implabel { font-size: 15px; font-weight: 500; color: var(--sub); margin-bottom: 3px; }
.impsub { font-size: 12px; color: var(--hint); }

.addform {
  background: var(--card); border-radius: var(--r);
  border: 1.5px solid var(--border); padding: 20px; margin-bottom: 20px;
  transition: background .5s, border-color .5s;
}
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.frow.full { grid-template-columns: 1fr; }
.finp {
  width: 100%; padding: 12px 14px; border-radius: var(--rs);
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text); font-family: 'Noto Sans KR', sans-serif;
  font-size: 15px; outline: none; transition: all .2s;
}
.font-jp-field { font-family: var(--font-jp) !important; }
.font-en-field { font-family: var(--font-en) !important; }
.finp:focus { border-color: var(--pinkd); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pink) 22%, transparent); }
.finp::placeholder { color: var(--hint); }

.addbtn {
  width: 100%; padding: 13px; border-radius: var(--rs); border: none;
  background: var(--pinkd); color: #fff; font-family: 'Noto Sans KR', sans-serif;
  font-size: 15px; font-weight: 600; cursor: pointer; transition: all .2s;
}
.addbtn:hover { filter: brightness(1.08); transform: translateY(-1px); }

.ocr-modal { max-width: 720px; max-height: 88vh; display: flex; flex-direction: column; }
.ocr-small { font-size: 12px; color: var(--sub); line-height: 1.5; }
.ocr-status {
  border: 1px solid var(--border); background: var(--surface); color: var(--sub);
  border-radius: var(--rs); padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
}
.ocr-section { margin-bottom: 14px; }
.ocr-raw { min-height: 110px; resize: vertical; line-height: 1.55; }
.ocr-candidate-list { overflow-y: auto; max-height: 38vh; padding-right: 2px; }
.ocr-empty {
  border: 1px dashed var(--border); border-radius: var(--rs); padding: 18px;
  color: var(--hint); text-align: center; font-size: 13px; background: var(--surface);
}
.ocr-row {
  border: 1.5px solid var(--border); border-radius: var(--rs); padding: 12px;
  background: var(--card); margin-bottom: 10px; transition: border-color .2s, background .2s;
}
.ocr-row.warn { border-color: #f5a623; background: color-mix(in srgb, #f5a623 8%, var(--card)); }
.ocr-row.dup { border-color: var(--blued); }
.ocr-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--sub); font-size: 12px; }
.ocr-row-head label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--text); }
.ocr-badge {
  padding: 2px 7px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); color: var(--sub); font-size: 11px;
}
.ocr-row-grid { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.ocr-row-grid.english { grid-template-columns: 1fr 1fr 1.4fr; }
.ocr-field label {
  display: block; margin-bottom: 4px; color: var(--hint); font-size: 11px; font-weight: 600;
}
.ocr-field .finp { margin-bottom: 0; padding: 10px 11px; font-size: 14px; }
.ocr-field textarea.finp { min-height: 42px; resize: vertical; }
@media (max-width: 560px) {
  .ocr-row-grid, .ocr-row-grid.english { grid-template-columns: 1fr; }
  .ocr-modal { max-height: 92vh; }
}

.resetbtn {
  width: 100%; padding: 11px; border-radius: var(--rs);
  border: 1.5px solid var(--border); background: transparent;
  color: var(--hint); font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px; cursor: pointer; transition: all .2s; margin-bottom: 14px;
}
.resetbtn:hover { background: var(--surface); color: var(--sub); }

/* ── COMPLETE VIEW ── */
.compscr { text-align: center; padding: 50px 20px 30px; }
.compemoji { font-size: 80px; margin-bottom: 18px; animation: bounce .8s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes bounce { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }
.comptitle { font-family: 'Nunito', 'Noto Sans KR', sans-serif; font-size: 28px; font-weight: 900; margin-bottom: 8px; }
.compsub { font-size: 15px; color: var(--sub); margin-bottom: 36px; line-height: 1.55; }
.compstats { display: flex; gap: 14px; justify-content: center; margin-bottom: 36px; flex-wrap: wrap; }
.cs { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--r); padding: 18px 24px; min-width: 110px; }
.csnum { font-family: 'Nunito', 'Noto Sans KR', sans-serif; font-size: 38px; font-weight: 900; color: var(--pinkd); margin-bottom: 2px; line-height: 1; }
.cslabel { font-size: 12px; color: var(--sub); font-weight: 500; }
.complete-actions {
  display: grid;
  gap: 10px;
  max-width: 300px;
  margin: 0 auto;
}
.complete-actions .btnstart,
.complete-actions .btnmgr {
  margin-bottom: 0;
}
.wrong-note-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
}
.wrong-note-toolbar-text {
  min-width: 0;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.45;
}
.wrong-note-toolbar-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}
.wrong-note-toolbar .textbtn {
  display: flex;
  flex-shrink: 0;
  color: #fff;
  border-color: var(--pinkd);
  background: var(--pinkd);
}

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text); color: var(--card);
  padding: 11px 22px; border-radius: 40px;
  font-size: 14px; font-weight: 500; z-index: 1000;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 36px 20px; color: var(--hint); }
.empty .ee { font-size: 44px; margin-bottom: 10px; }
.empty p { font-size: 14px; }

/* ── LOADER ── */
.loading-overlay {
  position:fixed; inset:0; background:var(--bg); z-index:1001; 
  display:flex; flex-direction:column; align-items:center; justify-content:center;
}
.spinner {
  width:40px; height:40px; border:4px solid var(--border);
  border-top:4px solid var(--pinkd); border-radius:50%;
  animation:spin 1s linear infinite; margin-bottom:16px;
}
@keyframes spin { 0% { transform:rotate(0deg); } 100% { transform:rotate(360deg); } }
.loading-text { font-size:14px; color:var(--text); font-weight:500; font-family:'Noto Sans KR', sans-serif;}

/* ── DIVIDER ── */
.div { height: 1px; background: var(--border); margin: 14px 0; }

/* ── BREADCRUMB ── */
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--hint); margin-bottom: 8px; flex-wrap: wrap; min-height: 18px; }
.breadcrumb-item { cursor: pointer; color: var(--sub); font-weight: 500; transition: color .15s; }
.breadcrumb-item:hover { color: var(--pinkd); }
.breadcrumb-item.active { color: var(--text); cursor: default; }
.breadcrumb-sep { color: var(--border); user-select: none; }

/* ── FOLDER GRID VIEW ── */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.folder-grid-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 8px 10px; background: var(--card);
  border-radius: var(--r); border: 1.5px solid var(--border);
  cursor: pointer; transition: all .2s; text-align: center; position: relative;
}
.folder-grid-item:hover { transform: translateY(-2px); box-shadow: 0 4px 14px var(--sh); border-color: var(--pinkd); }
.folder-grid-icon { font-size: 38px; margin-bottom: 7px; line-height: 1; }
.folder-grid-name { font-size: 12px; font-weight: 500; color: var(--text); word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.folder-grid-badge { font-size: 10px; color: var(--hint); margin-top: 4px; }

/* ── MOBILE ── */
@media (max-width: 480px) {
  .app { padding: 0 14px 80px; }
  header { padding: 16px 0 12px; }
  .logo { font-size: 18px; }
  .ckanji { font-size: 52px; }
  .flashcard { padding: 28px 20px 22px; }
  .ansbts { gap: 8px; }
  .ansbtn { padding: 14px 10px; font-size: 15px; min-height: 52px; }
  .ansbtn .ae { font-size: 18px; }
  .tabs { gap: 4px; }
  .tab { padding: 10px 4px; font-size: 12px; }
  .tab .te { font-size: 17px; }
  .btnstart { padding: 15px; font-size: 15px; }
  .hbtns2 { gap: 6px; }
  .hbtn { padding: 8px 6px; font-size: 12px; }
  .snum { font-size: 30px; }
  .modal { padding: 18px; }
  .global-back-btn { left: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
  .app.sel-mode .global-back-btn { bottom: calc(env(safe-area-inset-bottom, 0px) + 90px); }
}

@media (min-width: 481px) and (max-width: 768px) {
  .app { padding: 0 20px 90px; }
  .ckanji { font-size: 60px; }
}

/* 터치 디바이스 — 최소 탭 영역 44px 및 iOS 줌 방지 */
@media (hover: none) and (pointer: coarse) {
  .icbtn, .backbtn, .wabtn { min-width: 44px; min-height: 44px; }
  .tab { min-height: 56px; }
  .ansbtn { min-height: 64px; }
  .hbtn { min-height: 44px; }
  .addbtn, .auth-btn, .btnstart, .btnmgr { min-height: 50px; }
  .finp, .auth-input { min-height: 48px; font-size: 16px; }
  select.finp { font-size: 16px; }
}

/* 스와이프 중 카드 드래그 시각 피드백 */
.flashcard.dragging { transition: none !important; cursor: grabbing; }

/* ── 다중 선택 하단 액션바 ── */
.selection-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 800;
  background: var(--card); border-top: 1.5px solid var(--border);
  padding: 10px 14px; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 -4px 20px var(--sh);
  transform: translateY(110%);
  transition: transform .25s cubic-bezier(.34,1.2,.64,1);
}
.selection-bar.active { transform: translateY(0); }
.sel-count { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.sel-btn {
  padding: 7px 13px; border-radius: var(--rs); border: 1.5px solid var(--border);
  background: var(--surface); font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--text); white-space: nowrap; transition: all .15s;
  font-family: 'Noto Sans KR', sans-serif;
}
.sel-btn:hover { filter: brightness(.95); }
.sel-btn.sel-move { color: var(--blued); border-color: var(--blued); }
.sel-btn.sel-del  { color: #e05050; border-color: #e05050; }
.sel-btn.sel-cancel { background: var(--surface); }
.sel-btn.sel-study { color: #f5a623; border-color: #f5a623; }
.imp-filter-btn {
  padding: 7px 12px; border-radius: var(--rs); border: 1.5px solid var(--border);
  background: var(--surface); font-size: 13px; cursor: pointer; color: var(--sub);
  font-family: 'Noto Sans KR', sans-serif; transition: all .15s;
}
.imp-filter-btn.active { background: #f5a623; border-color: #f5a623; color: #fff; font-weight: 600; }

/* ── 선택 모드 아이템 ── */
.witem.sel-item, .folder-grid-item.sel-item {
  position: relative; cursor: pointer;
}
.sel-checkbox {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; transition: all .15s;
}
.witem.sel-selected .sel-checkbox,
.folder-grid-item.sel-selected .sel-checkbox {
  background: var(--pinkd); border-color: var(--pinkd); color: #fff;
}
.witem.sel-selected,
.folder-grid-item.sel-selected {
  border-color: var(--pinkd) !important;
  background: color-mix(in srgb, var(--pink) 12%, var(--card)) !important;
}
/* 그리드 선택 체크박스 오버레이 */
.folder-grid-item.sel-item .sel-checkbox {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
}
/* 선택 모드 시 "선택" 버튼 강조 */
#selectModeBtn.active {
  background: var(--pinkd); color: #fff; border-color: var(--pinkd);
}
/* 선택 모드 시 앱 하단 여백 (액션바 높이) */
.app.sel-mode { padding-bottom: 70px; }

/* ── iOS 사파리 터치 텍스트 선택 / 콜아웃 방지 ── */
.witem, .folder-grid-item {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* 카드 스와이프 영역 스크롤 간섭 방지 */
#cscene {
  touch-action: pan-y; /* JS에서 수평 방향 잠금 후 override됨 */
}

/* ── 컨텍스트 메뉴 ── */
.ctx-menu {
  position: fixed; z-index: 9999;
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--rs); padding: 5px 0;
  box-shadow: 0 8px 32px var(--shh);
  min-width: 164px; display: none;
  animation: fade-in .15s;
}
.ctx-menu.active { display: block; }
.ctx-item {
  padding: 10px 16px; font-size: 14px; cursor: pointer;
  color: var(--text); display: flex; align-items: center; gap: 8px;
  transition: background .12s;
  user-select: none;
}
.ctx-item:hover { background: var(--surface); }
.ctx-item.ctx-danger { color: #e05050; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── 드래그 그룹 드롭 대상 하이라이트 ── */
.folder-drop-target {
  outline: 2.5px dashed var(--pinkd) !important;
  background: color-mix(in srgb, var(--pink) 18%, var(--card)) !important;
  transform: scale(1.02);
  transition: all .15s !important;
}
.sortable-ghost { opacity: .4; }
.sortable-drag { opacity: .95; box-shadow: 0 8px 24px var(--shh); }

/* ── 드래그 중 뒤로가기 드롭존 ── */
.backbtn.drag-back-enabled {
  border-color: var(--pinkd);
  background: color-mix(in srgb, var(--pink) 20%, var(--card));
  animation: pulse-border .8s ease-in-out infinite;
}
.backbtn.drag-back-hover {
  background: var(--pinkd) !important;
  color: #fff !important;
  transform: scale(1.15);
}
.drag-back-zone {
  display: none; align-items: center; gap: 8px;
  padding: 10px 16px; margin-bottom: 8px;
  background: color-mix(in srgb, var(--pink) 15%, var(--card));
  border: 2px dashed var(--pinkd); border-radius: var(--rs);
  font-size: 14px; color: var(--pinkd); font-weight: 600;
  cursor: default; transition: all .2s;
}
.drag-back-zone.active { display: flex; animation: fade-in .2s; }
.drag-back-zone.hover {
  background: color-mix(in srgb, var(--pink) 35%, var(--card));
  transform: scale(1.01);
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pinkd) 40%, transparent); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

/* ── 하이어라키 트리 뷰 ── */
.hier-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--rs);
  cursor: pointer; font-size: 14px; color: var(--text);
  transition: background .12s; user-select: none;
}
.hier-item:hover { background: var(--surface); }
.hier-item.hier-current { background: color-mix(in srgb, var(--pink) 20%, var(--card)); font-weight: 600; }
.hier-item.hier-deck { color: var(--sub); }
.hier-toggle {
  width: 18px; font-size: 11px; color: var(--hint); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s;
}
.hier-toggle.open { transform: rotate(90deg); }
.hier-children { overflow: hidden; }
.hier-children.collapsed { display: none; }

/* ── 태그 칩 ── */
.tag-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: color-mix(in srgb, var(--pinkd) 12%, var(--card));
  color: var(--pinkd); border: 1px solid color-mix(in srgb, var(--pinkd) 25%, transparent);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.tag-chip:hover { background: color-mix(in srgb, var(--pinkd) 22%, var(--card)); }
.tag-chip-active {
  background: var(--pinkd); color: #fff;
  border-color: var(--pinkd);
}
.tag-chip-sm {
  display: inline-block; padding: 1px 7px; border-radius: 20px;
  font-size: 10px; font-weight: 600;
  background: color-mix(in srgb, var(--pinkd) 10%, var(--card));
  color: var(--pinkd); border: 1px solid color-mix(in srgb, var(--pinkd) 20%, transparent);
  pointer-events: none; white-space: nowrap;
}

.lib-word-preview {
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
  overflow-wrap: anywhere; word-break: break-word; line-height: 1.45;
}
.lib-word-head { font-weight: 600; }
.lib-word-reading { color: var(--sub); margin-left: 6px; font-size: 12px; }
.lib-word-meaning { color: var(--hint); margin-left: 6px; }

/* ── 홈 탭 ── */
.home-tab {
  padding: 8px 16px; border-radius: 0; font-size: 14px; font-weight: 500;
  border: none; background: none; cursor: pointer; color: var(--hint);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  font-family: 'Noto Sans KR', sans-serif; transition: all .15s;
}
.home-tab:hover { color: var(--pinkd); }
.home-tab.on { color: var(--pinkd); border-bottom-color: var(--pinkd); font-weight: 600; }

/* ── HOME CALENDAR ── */
.home-cal-wrap {
  background: var(--card); border-radius: var(--r);
  border: 1px solid var(--border); margin-bottom: 14px;
  overflow: hidden;
}
.home-cal-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; cursor: pointer; user-select: none;
  gap: 8px;
}
.home-cal-toggle:hover { background: var(--surface); }
.home-cal-chevron {
  font-size: 18px; color: var(--hint); line-height: 1;
  transition: transform .25s ease;
  display: inline-block;
}
.home-cal-wrap.open .home-cal-chevron { transform: rotate(180deg); }
.home-cal-body {
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease, padding .3s ease;
  padding: 0 14px;
}
.home-cal-wrap.open .home-cal-body {
  max-height: 500px;
  padding: 0 14px 14px;
}
.home-cal-nav { display: flex; align-items: center; gap: 4px; }

.hcal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.hcal-dow {
  text-align: center; font-size: 11px; font-weight: 600;
  padding: 2px 0 5px; color: var(--hint);
}
.hcal-dow.sun { color: #e05050; }
.hcal-dow.sat { color: var(--blued); }
.hcal-cell {
  aspect-ratio: 1; border-radius: 6px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  font-size: 12px; font-weight: 500; color: var(--hint);
  background: var(--surface); cursor: default; position: relative;
  transition: transform .1s;
}
.hcal-cell.has-log { color: #fff; }
.hcal-cell.today {
  box-shadow: 0 0 0 2px var(--blued);
  color: var(--blued); font-weight: 700;
}
.hcal-cell.today.has-log { color: #fff; box-shadow: 0 0 0 2px var(--blued); }
.hcal-cell.sun { color: #e05050; }
.hcal-cell.sat { color: var(--blued); }
.hcal-cell.sun.has-log, .hcal-cell.sat.has-log { color: #fff; }
.hcal-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255,255,255,0.6); flex-shrink: 0;
}

/* ── SETTINGS MODAL ── */
.settings-toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.settings-toggle input { opacity: 0; width: 0; height: 0; }
.settings-toggle-slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 24px; cursor: pointer;
  transition: background .2s;
}
.settings-toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; left: 3px; top: 3px; transition: transform .2s;
}
.settings-toggle input:checked + .settings-toggle-slider { background: var(--pinkd); }
.settings-toggle input:checked + .settings-toggle-slider::before { transform: translateX(20px); }

.settings-font-opt {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--rs); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.settings-font-opt:has(input:checked) { border-color: var(--pinkd); background: color-mix(in srgb, var(--pink) 10%, var(--card)); }
.settings-font-opt input[type=radio] { display: none; }
.settings-font-name { font-size: 13px; font-weight: 600; flex: 1; color: var(--text); }
.settings-font-preview { font-size: 18px; color: var(--sub); }

/* ══════════════════════════════════
   APPLE MOTION — 버튼/UI 인터랙션
   스프링 복귀 + 빠른 프레스 다운
══════════════════════════════════ */
.icbtn, .textbtn, .ver-btn, .backbtn, .wabtn,
.auth-btn, .google-btn, .btnstart, .btnmgr, .btnreview,
.typing-submit, .test-option, .tab, .hbtn, .ansbtn,
.addbtn, .modal-btn, .sel-btn, .home-tab,
.deck-review-chip, .deck-test-chip, .ocr-title-btn,
.imp-filter-btn, .resetbtn {
  transition:
    transform .35s var(--spring),
    box-shadow .35s var(--spring),
    background .2s ease, color .2s ease,
    border-color .2s ease, filter .2s ease, opacity .2s ease;
}

/* 프레스 다운 — 빠르게 눌리고, 떼면 스프링으로 복귀 */
.textbtn:active, .ver-btn:active,
.auth-btn:active, .google-btn:active, .btnstart:active,
.btnmgr:active, .btnreview:active, .typing-submit:active,
.test-option:active, .tab:active, .hbtn:active,
.addbtn:active, .modal-btn:active, .sel-btn:active,
.deck-review-chip:active, .ocr-title-btn:active,
.imp-filter-btn:active, .resetbtn:active {
  transform: scale(.96);
  transition: transform .08s ease;
}
.icbtn:active, .backbtn:active, .wabtn:active {
  transform: scale(.88);
  transition: transform .08s ease;
}
.ansbtn:active {
  transform: scale(.96);
  filter: brightness(.94);
  transition: transform .08s ease, filter .08s ease;
}

/* 호버 — 과한 점프 대신 미세한 리프트 */
.icbtn:hover { transform: scale(1.06); }
.btnstart:hover { transform: translateY(-1px) scale(1.01); }
.ansbtn:hover { transform: translateY(-1px) scale(1.01); filter: brightness(1.07); }
.hbtn:hover { transform: scale(1.02); }
.test-option:hover { transform: translateY(-1px); }

/* 뷰 전환 — Apple 시트 느낌의 페이드업 */
.view.active { animation: fade-in .4s var(--swift); }

/* 모달 팝 — 스케일 + 페이드 스프링 */
.modal-overlay.active .modal { animation: modal-pop .38s var(--spring); }
@keyframes modal-pop {
  from { opacity: 0; transform: scale(.94) translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* 설정 토글 스위치 — 스프링 노브 */
.settings-toggle-slider::before { transition: transform .3s var(--spring); }

/* 모션 최소화 환경 존중 */
@media (prefers-reduced-motion: reduce) {
  .view.active, .modal-overlay.active .modal { animation: none; }
  .icbtn, .textbtn, .ver-btn, .backbtn, .wabtn,
  .auth-btn, .google-btn, .btnstart, .btnmgr, .btnreview,
  .typing-submit, .test-option, .tab, .hbtn, .ansbtn,
  .addbtn, .modal-btn, .sel-btn, .home-tab,
  .deck-review-chip, .deck-test-chip, .ocr-title-btn,
  .imp-filter-btn, .resetbtn {
    transition-duration: .01s;
  }
}
