:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --green: #16a34a;
  --red: #dc2626;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03), 0 10px 24px -4px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container { max-width: 880px; margin: 0 auto; padding: 0 16px; }

body { --sidebar-width: 260px; }
body.sidebar-collapsed { --sidebar-width: 76px; }
main.container {
  width: calc(100% - var(--sidebar-width)); max-width: none;
  margin: 0 0 0 var(--sidebar-width);
  padding: 18px max(16px, calc((100vw - var(--sidebar-width) - 880px) / 2)) 24px;
}


.header {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-width); height: 100vh; height: 100dvh;
  background: var(--card); border-right: 1px solid var(--border);
  transition: width 0.18s ease;
}
.header-inner {
  display: flex; flex-direction: column; align-items: stretch; gap: 20px;
  width: 100%; height: 100%; padding: 20px 14px 16px;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-brand .logo { min-width: 0; overflow: hidden; }
.sidebar-label { min-width: 0; }
.mobile-topbar, .sidebar-backdrop { display: none; }
.sidebar-collapse-toggle, .mobile-nav-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 40px;
  width: 40px; height: 40px; padding: 0; border: 1px solid var(--border);
  border-radius: 12px; background: #fff; color: var(--muted); cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.sidebar-collapse-toggle:hover, .mobile-nav-toggle:hover { color: var(--text); background: #f1f5f9; }
.sidebar-collapse-toggle:focus-visible, .mobile-nav-toggle:focus-visible,
.tab:focus-visible, .profile-switch:focus-visible {
  outline: 3px solid #818cf8; outline-offset: 2px;
}
.sidebar-collapse-toggle svg { transition: transform 0.18s ease; }
.mobile-nav-toggle { display: none; }
.sidebar-account { display: grid; gap: 10px; margin-top: auto; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; color: var(--text); }
.logo-icon { color: var(--primary); flex-shrink: 0; }
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon-speaker { stroke-width: 2.2; }
.icon-mic { stroke-width: 2.2; }
.icon-gear { stroke-width: 2; }
.voice-badge {
  font-size: 0.75rem; font-weight: 600; vertical-align: middle;
  font-family: inherit; border: 0; cursor: pointer;
  background: #eef2ff; color: var(--primary);
  border-radius: 999px; padding: 3px 10px; margin-left: 6px;
  max-width: 100%; white-space: normal; overflow-wrap: anywhere;
}
.voice-badge:hover { filter: brightness(0.95); }
.voice-badge[data-state="bad"] { background: #fee2e2; color: var(--red); }
.voice-badge[data-state="busy"] { background: #fef3c7; color: #b45309; }
.profile-switch {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: #fff; color: var(--text); font: inherit; font-size: 0.85rem;
  font-weight: 700; text-align: left; cursor: pointer;
}
.profile-switch[hidden] { display: none; }
.profile-switch:hover { background: #f1f5f9; }
.cloud-status { display: block; color: var(--muted); font-size: 0.78rem; max-width: 100%; overflow-wrap: anywhere; }
.cloud-status[data-state="bad"] { color: var(--red); }
.cloud-status[data-state="busy"] { color: #b45309; }
.cloud-status[data-state="ok"] { color: var(--green); }
.profile-gate-card > .profile-gate-status { margin: 16px 0 10px; color: var(--red); font-size: 0.9rem; }
.profile-gate-status[hidden] { display: none; }
.profile-gate-card > button[hidden] { display: none; }
.profile-gate {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  padding: 20px; background: var(--bg);
}
.profile-gate[hidden] { display: none; }
.profile-gate-card {
  width: min(100%, 420px); padding: 28px; text-align: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-lg);
}
.profile-gate-card h1 { margin: 0 0 8px; font-size: 1.5rem; }
.profile-gate-card > p { margin: 0 0 20px; color: var(--muted); }
.profile-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-option {
  min-height: 64px; border: 1px solid var(--border); border-radius: 14px;
  background: #fff; color: var(--text); font: inherit; font-size: 1.1rem;
  font-weight: 800; cursor: pointer;
}
.profile-option:hover { border-color: var(--primary); color: var(--primary); background: #eef2ff; }
.profile-gate-card .profile-gate-note { margin: 18px 0 0; font-size: 0.82rem; }
kbd {
  background: #f1f5f9; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 7px; font-size: 0.85rem; font-family: inherit;
}
.tabs { display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 100%; }
.tab {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px;
  padding: 10px 12px; border: 1px solid transparent; border-radius: 12px;
  background: transparent; color: var(--text); cursor: pointer;
  font: inherit; font-size: 0.95rem; text-align: left;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.tab svg { flex: 0 0 20px; color: var(--muted); }
.tab:hover { background: #f1f5f9; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab.active svg { color: #fff; }

@media (min-width: 761px) {
  body.sidebar-collapsed .header-inner { padding-right: 10px; padding-left: 10px; }
  body.sidebar-collapsed .sidebar-brand { flex-direction: column; }
  body.sidebar-collapsed .sidebar-brand .logo { justify-content: center; }
  body.sidebar-collapsed .sidebar-collapse-toggle svg { transform: rotate(180deg); }
  body.sidebar-collapsed .sidebar-label { display: none; }
  body.sidebar-collapsed .tabs .tab { justify-content: center; padding-right: 8px; padding-left: 8px; }
  body.sidebar-collapsed .profile-switch { justify-content: center; padding-right: 8px; padding-left: 8px; }
  body.sidebar-collapsed .cloud-status { overflow: hidden; font-size: 0; text-align: center; }
  body.sidebar-collapsed .cloud-status::before {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--muted); content: "";
  }
  body.sidebar-collapsed .cloud-status[data-state="ok"]::before { background: var(--green); }
  body.sidebar-collapsed .cloud-status[data-state="bad"]::before { background: var(--red); }
  body.sidebar-collapsed .cloud-status[data-state="busy"]::before { background: #b45309; }
}

@media (max-width: 760px) {
  body, body.sidebar-collapsed { --sidebar-width: 0px; }
  body.sidebar-open { overflow: hidden; }
  .header {
    position: relative; inset: auto; z-index: auto; width: auto;
    height: calc(56px + env(safe-area-inset-top));
    background: transparent; border: 0; transition: none;
  }
  .mobile-topbar {
    position: fixed; inset: 0 0 auto; z-index: 50;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    background: var(--card); border-bottom: 1px solid var(--border);
  }
  .mobile-brand { min-width: 0; overflow: hidden; font-size: 1.05rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-nav-toggle { display: inline-flex; }
  .header-inner {
    position: fixed; top: calc(56px + env(safe-area-inset-top)); bottom: 0; left: 0; z-index: 40;
    width: min(84vw, 296px); height: calc(100dvh - 56px - env(safe-area-inset-top)); padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--card); border-right: 1px solid var(--border); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform 0.18s ease;
  }
  body.sidebar-open .header-inner { transform: translateX(0); }
  .sidebar-collapse-toggle { display: none; }
  .sidebar-backdrop {
    position: fixed; inset: calc(56px + env(safe-area-inset-top)) 0 0; z-index: 35;
    display: block; width: 100%; padding: 0; border: 0; background: rgba(15, 23, 42, 0.42);
    cursor: pointer; touch-action: manipulation; overscroll-behavior: contain;
  }
  .sidebar-backdrop[hidden] { display: none; }
  main.container { width: 100%; max-width: 880px; margin: 0 auto; padding: 18px 16px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .header, .header-inner, .sidebar-collapse-toggle svg { transition: none; }
}
.toolbar {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin: 18px 0; box-shadow: var(--shadow);
}
.toolbar.sentence-mode .word-only { display: none !important; }
.toolbar-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.toolbar label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 4px; }
select, input[type="text"] {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 1rem;
  background: #fff; min-width: 150px;
}
.progress-wrap { margin-top: 12px; }
.day-row { margin-top: 12px; align-items: center; }
.day-nav { display: flex; gap: 6px; align-items: center; }
.day-nav select { min-width: 110px; }
.count-label { flex-direction: row !important; align-items: center; gap: 8px; }
.count-label input[type="range"] { width: 140px; accent-color: var(--primary); }
.day-summary { color: var(--muted); font-size: 0.9rem; margin: 8px 0 0; }
.form-row { display: flex; gap: 8px; justify-content: center; align-items: center; max-width: 540px; margin: 4px auto 6px; }
.form-row select {
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; color: #334155; font-size: 0.92rem; font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03); transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.form-row select:focus-visible { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.form-note { text-align: center; color: var(--muted); font-size: 0.82rem; font-weight: 500; margin: 0 0 8px; min-height: 1.4em; }
.pronunciation-control { display: flex; align-items: stretch; gap: 10px; max-width: 540px; margin: 14px auto 0; }
#pronounceBtn, .pronounce-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  flex-shrink: 0; min-height: 52px; padding: 0 18px; border-radius: 14px;
  border: 1px solid transparent; font-weight: 700; font-size: 0.92rem;
  touch-action: manipulation; user-select: none; transition: opacity 0.15s ease;
}
#pronounceBtn .pronounce-icon, .pronounce-button .pronounce-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; }
#pronounceBtn kbd, .pronounce-button kbd { background: rgba(255,255,255,0.18); color: inherit; border-color: rgba(255,255,255,0.4); }
#pronounceBtn[data-state], .btn.primary.pronounce-button[data-state] { background: #2563eb; border-color: #1d4ed8; color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,0.22); }
#pronounceBtn[data-state="idle"]:hover, .btn.primary.pronounce-button[data-state="idle"]:hover { background: #1d4ed8; box-shadow: 0 4px 12px rgba(37,99,235,0.32); }
#pronounceBtn[data-state="preparing"], #pronounceBtn[data-state="recording"], .btn.primary.pronounce-button[data-state="preparing"], .btn.primary.pronounce-button[data-state="recording"] { background: #dc2626; border-color: #b91c1c; color: #fff; box-shadow: 0 0 0 4px rgba(220,38,38,0.2); }
#pronounceBtn[data-state="recording"] .pronounce-icon, .pronounce-button[data-state="recording"] .pronounce-icon { animation: recording-pulse 0.8s ease-in-out infinite alternate; }
#pronounceBtn:hover, .pronounce-button:hover { filter: brightness(0.97); }
#pronounceBtn:focus-visible, .pronounce-button:focus-visible { outline: 3px solid #818cf8; outline-offset: 4px; }
#pronounceBtn:disabled, .pronounce-button:disabled { cursor: wait; }
.pronunciation-transcript {
  display: flex; flex: 1; flex-direction: column; justify-content: center;
  gap: 2px; min-width: 0; padding: 8px 14px; border: 1px solid var(--border);
  border-radius: 14px; background: #fff; text-align: left; box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.pronunciation-transcript[data-state="correct"] { background: #dcfce7; border-color: #86efac; }
.pronunciation-transcript[data-state="incorrect"] { background: #fee2e2; border-color: #fca5a5; }
.pronunciation-transcript[data-state="correct"] #pronounceTranscript,
.pronunciation-transcript[data-state="correct"] #sentencePronounceTranscript { color: var(--green); }
.pronunciation-transcript[data-state="incorrect"] #pronounceTranscript,
.pronunciation-transcript[data-state="incorrect"] #sentencePronounceTranscript { color: var(--red); }
.transcript-label { font-size: 0.72rem; font-weight: 700; color: #94a3b8; letter-spacing: 0.04em; text-transform: uppercase; }
#pronounceTranscript, .pronounce-transcript { display: block; font-size: 0.95rem; font-weight: 600; color: #0f172a; overflow-wrap: anywhere; }
#pronounceTranscript[data-state="placeholder"], .pronounce-transcript[data-state="placeholder"] { color: #94a3b8; font-size: 0.85rem; font-weight: 400; }
#pronounceTranscript[data-state="interim"], .pronounce-transcript[data-state="interim"] { color: var(--primary); }
.pronounce-status { text-align: center; font-size: 0.82rem; color: var(--muted); margin: 8px auto 12px; max-width: 540px; overflow-wrap: anywhere; }
@keyframes recording-pulse { from { opacity: 0.55; } to { opacity: 1; } }
.table-nav { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.progress-info { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--muted); }
.progress-bar { height: 10px; background: #eef2ff; border-radius: 999px; overflow: hidden; margin-top: 6px; }
#progressFill { height: 100%; width: 0%; background: var(--primary); transition: width 0.3s; }

.panel { display: none; }
.panel.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }
main.container { overflow-x: clip; }

.card-counter {
  position: absolute; top: 16px; left: 18px; z-index: 4; pointer-events: none;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0; padding: 3px 9px; border-radius: 8px; background: #f1f5f9;
  color: var(--muted); font-weight: 700; font-size: 0.82rem;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.flashcard { position: relative; perspective: 1200px; max-width: 540px; margin: 0 auto; cursor: pointer; }
.flashcard.swiping, .sentence-card.swiping { cursor: grabbing; }
.flashcard-inner {
  position: relative; width: 100%; height: 310px;
  transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard.resetting .flashcard-inner { transition: none; }
.face {
  position: absolute; inset: 0; backface-visibility: hidden;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 24px; text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.flashcard:hover .face { border-color: #cbd5e1; box-shadow: var(--shadow-lg); }
.flashcard:not(.flipped) .face.back,
.flashcard.flipped .face.front { visibility: hidden; }
.face.back { transform: rotateY(180deg); background: #f8fafc; border-color: var(--border); }
.pos { display: inline-flex; align-items: center; color: #4338ca; background: #eef2ff; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; padding: 4px 12px; border-radius: 999px; margin-bottom: 6px; }
.word { font-size: 3rem; font-weight: 800; letter-spacing: -0.03em; color: #0f172a; margin: 10px 0 8px; line-height: 1.15; }
.word.small { font-size: 1.25rem; font-weight: 700; color: #64748b; margin: 0 0 6px; }
.meaning { font-size: 1.9rem; font-weight: 800; color: #0f172a; letter-spacing: -0.02em; margin: 0 0 10px; }
.example { color: #475569; font-size: 0.95rem; line-height: 1.5; font-style: italic; max-width: 90%; margin: 8px 0 0; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.example:empty { display: none; }
.hint { display: inline-flex; align-items: center; gap: 6px; color: #94a3b8; font-size: 0.82rem; font-weight: 500; margin-top: 14px; }
.hint::before { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #cbd5e1; }
.speak {
  position: absolute; top: 16px; right: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: #fff; color: #64748b;
  border-radius: 12px; width: 40px; height: 40px; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04); transition: all 0.15s ease;
}
.speak:hover { background: #f8fafc; color: #0f172a; border-color: #cbd5e1; transform: scale(1.05); }
.speak:active { transform: scale(0.95); }
.speak.inline { position: static; width: auto; height: auto; padding: 6px 14px; border-radius: 999px; font-size: 0.9rem; font-weight: 600; gap: 6px; }
.card-actions { display: flex; gap: 10px; justify-content: center; margin: 18px 0; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px; padding: 11px 20px;
  font-size: 0.98rem; cursor: pointer; font-weight: 700; letter-spacing: -0.01em;
  transition: all 0.15s ease;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #f1f5f9; color: #334155; border-color: var(--border); }
.btn.secondary:hover { background: #e2e8f0; color: #0f172a; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f1f5f9; color: #0f172a; }
.btn.know { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; box-shadow: 0 1px 2px rgba(16,185,129,0.05); }
.btn.know:hover { background: #d1fae5; border-color: #6ee7b7; color: #047857; }
.btn.know:active { transform: scale(0.97); }
.btn.dontknow { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; box-shadow: 0 1px 2px rgba(239,68,68,0.05); }
.btn.dontknow:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.btn.dontknow:active { transform: scale(0.97); }
.tip { text-align: center; color: var(--muted); font-size: 0.9rem; }
.mobile-tip { display: none; }
.mobile-settings-btn { display: none; }
.settings-modal-dialog { display: none; }
body.settings-modal-open { overflow: hidden; }

.sentence-header-row {
  max-width: 540px; margin: 4px auto 14px;
  display: flex; justify-content: center; align-items: center; gap: 10px;
}
.group-nav { display: flex; gap: 8px; align-items: center; width: 100%; max-width: 540px; }
.group-nav .group-select-label { flex: 1; min-width: 0; display: block; }
.group-nav select {
  width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: #ffffff; color: #334155; font-size: 0.92rem; font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03); cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.group-nav select:focus-visible {
  outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.sentence-counter {
  position: absolute; top: 18px; left: 20px; z-index: 4; pointer-events: none;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0; padding: 3px 9px; border-radius: 8px; background: #f1f5f9;
  color: var(--muted); font-weight: 700; font-size: 0.82rem;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.sentence-card {
  position: relative; perspective: 1200px; max-width: 540px; margin: 0 auto 16px;
  cursor: pointer; background: transparent; border: none; box-shadow: none; padding: 0;
}
.sentence-card-inner {
  position: relative; width: 100%; height: 310px;
  transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.sentence-card.flipped .sentence-card-inner { transform: rotateY(180deg); }
.sentence-card.resetting .sentence-card-inner { transition: none; }
.sentence-card:not(.flipped) .face.back,
.sentence-card.flipped .face.front { visibility: hidden; }
.sentence-card .face { border-radius: 22px; }
.sentence-card:hover .face { border-color: #cbd5e1; box-shadow: var(--shadow-lg); }
.sentence-pattern-row {
  display: flex; justify-content: center; align-items: center;
  gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.pattern-badge {
  display: inline-flex; align-items: center; padding: 4px 12px;
  border-radius: 999px; background: #eef2ff; color: #4338ca;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.sentence-answer {
  max-width: 540px; margin: 0 auto 16px; overflow: hidden;
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
}
.sentence-answer summary {
  padding: 14px 18px; color: #334155; font-weight: 800;
  cursor: pointer; user-select: none;
}
.sentence-answer summary:hover { background: #f1f5f9; color: #0f172a; }
.sentence-answer summary:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.28); outline-offset: -3px;
}
.sentence-answer[open] summary { border-bottom: 1px solid var(--border); }
.sentence-answer-body { padding: 18px; }
.sentence-answer-label {
  margin: 14px 0 5px; color: #64748b;
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.04em;
}
.sentence-note {
  color: #475569; font-size: 0.95rem; line-height: 1.7;
  white-space: pre-line; margin: 0; background: #fff;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  overflow-wrap: anywhere;
}
.sentence-note:empty { display: none; }
.sentence-english {
  font-size: clamp(1.6rem, 4.5vw, 2.3rem); font-weight: 800; color: #0f172a;
  letter-spacing: -0.025em; line-height: 1.3; margin: 10px 0 8px;
  overflow-wrap: anywhere; max-width: 92%;
}
.sentence-english.small {
  max-width: none; font-size: 1.15rem; font-weight: 700; color: #64748b; margin: 0 0 8px;
  line-height: 1.35; letter-spacing: -0.01em;
}
.sentence-answer .sentence-korean {
  font-size: clamp(1.35rem, 4vw, 1.8rem); font-weight: 800; color: #0f172a;
  letter-spacing: -0.02em; margin: 0; line-height: 1.4;
  overflow-wrap: anywhere;
}
.sentence-nav-actions {
  display: flex; gap: 12px; justify-content: center; margin: 14px 0 16px;
}
.sentence-nav-actions .btn { min-width: 140px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 1.15rem; }
.quiz-options { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.quiz-top { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 10px; }
.quiz-q { font-size: 1.6rem; font-weight: 800; line-height: 1.35; margin: 10px 0; overflow-wrap: anywhere; }
.choices { display: grid; gap: 10px; margin-top: 12px; }
.choice {
  text-align: left; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 1.05rem;
}
.choice.correct { background: #dcfce7; border-color: var(--green); }
.choice.wrong { background: #fee2e2; border-color: var(--red); }
.choice:disabled { cursor: default; opacity: 0.95; }
.spell-wrap { display: flex; gap: 8px; margin-top: 12px; }
.spell-wrap input { flex: 1; }
.feedback { margin-top: 12px; font-weight: 650; line-height: 1.65; min-height: 1.5em; white-space: pre-line; overflow-wrap: anywhere; }
.feedback.ok { color: var(--green); }
.feedback.no { color: var(--red); }
.quiz-wrong-item {
  display: grid; gap: 4px; margin: 8px 0; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #f8fafc;
}
.quiz-wrong-item span { color: #475569; line-height: 1.5; overflow-wrap: anywhere; }
.hidden { display: none !important; }

.add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form input, .add-form select { flex: 1; min-width: 140px; }
.search { width: 100%; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-size: 0.9rem; }
.badge { background: #eef2ff; color: var(--primary); border-radius: 999px; padding: 2px 10px; font-size: 0.9rem; }
.del-btn { border: none; background: transparent; cursor: pointer; font-size: 1.1rem; }
.status-known { color: var(--green); font-weight: 700; }
.status-new { color: var(--muted); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { text-align: center; }
.stat .num { font-size: 2rem; font-weight: 800; margin: 0; }
.num.green { color: var(--green); }
.num.red { color: var(--red); }
.muted { color: var(--muted); }
.chip-list { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: #fee2e2; border-radius: 999px; padding: 6px 12px; font-size: 0.95rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.file-label { display: inline-block; }

@media (pointer: coarse) {
  .flashcard, .sentence-card {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .sentence-card button, .flashcard button,
  .sentence-card select, .flashcard select,
  .sentence-card input, .flashcard input {
    touch-action: manipulation;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flashcard-inner, .sentence-card-inner { transition: none; }
  #pronounceBtn, .pronounce-button { transition: none; }
  #pronounceBtn .pronounce-icon, .pronounce-button .pronounce-icon { animation: none; }
  .settings-modal { animation: none !important; }
}

@media (max-width: 600px) {
  .word { font-size: 2.3rem; }
  .meaning { font-size: 1.6rem; }
  .flashcard-inner { height: 290px; }
  .pronunciation-control { gap: 8px; }
  #pronounceBtn, .pronounce-button { padding: 10px 14px; font-size: 0.88rem; min-height: 48px; }
  .pronunciation-transcript { padding: 6px 12px; }
  .sentence-card-inner { height: 290px; }
  .sentence-card .face { padding: 24px 20px; border-radius: 20px; }
  .sentence-answer summary { padding: 13px 15px; }
  .sentence-answer-body { padding: 15px; }
  .sentence-note { font-size: 0.91rem; padding: 11px 12px; }
  .container { padding-bottom: 72px; }
  .desktop-tip { display: none; }
  .mobile-tip { display: block; }
  .card-actions kbd, .sentence-nav-actions kbd, .pronounce-button kbd, .speak kbd { display: none; }
  
  /* 모바일에서 몰라요/외웠어요 버튼 */
  .card-actions .btn-emoji { display: none !important; }
  .card-actions .nav-step-btn { display: none !important; }
  .card-actions .btn.know, .card-actions .btn.dontknow { flex: 1; max-width: 175px; padding: 13px 14px; font-size: 1.02rem; border-radius: 14px; }

  /* 모바일에서 단어·문장 페이지의 화살표 버튼 숨기기 */
  #prevFormBtn,
  #nextFormBtn,
  #sentencePrevGroupBtn,
  #sentenceNextGroupBtn,
  .sentence-nav-actions {
    display: none !important;
  }
  .form-row { width: 100%; max-width: 540px; margin: 4px auto 6px; }
  .form-row select { width: 100%; max-width: 100%; }

  .group-nav { width: 100%; }
  .group-nav .group-select-label { flex: 1; min-width: 0; }
  .group-nav select { min-width: 0; width: 100%; }

  /* 모바일에서 상단 툴바를 숨기고 플로팅 톱니바퀴 버튼 노출 */
  .toolbar { display: none !important; margin: 0; }
  .mobile-settings-btn {
    display: flex; position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: calc(22px + env(safe-area-inset-bottom));
    width: 50px; height: 50px; border-radius: 50%; border: 1px solid var(--border);
    background: #ffffff; box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
    align-items: center; justify-content: center; color: #475569;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: all 0.15s ease;
  }
  .mobile-settings-btn:hover { color: #0f172a; border-color: #cbd5e1; }
  .mobile-settings-btn:active { transform: scale(0.92); }

  /* 설정 팝업 모달 */
  .settings-modal-dialog[open] {
    display: flex; position: fixed; inset: 0; z-index: 1000;
    width: 100%; max-width: none; height: 100%; max-height: none;
    margin: 0; padding: 0; border: 0; background: transparent;
    align-items: flex-end; justify-content: center;
    color: var(--text);
  }
  .settings-modal-dialog::backdrop {
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
  }
  .settings-modal {
    background: #fff; width: 100%; min-width: 0;
    max-height: min(85dvh, calc(100dvh - max(16px, env(safe-area-inset-top))));
    border-radius: 20px 20px 0 0; box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
    display: flex; flex-direction: column; overflow: hidden;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .settings-modal-header {
    display: flex; flex: 0 0 auto; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
  }
  .settings-modal-header h3 { margin: 0; font-size: 1.15rem; font-weight: 700; }
  .close-btn {
    border: none; background: #f1f5f9; width: 32px; height: 32px;
    border-radius: 50%; font-size: 1rem; cursor: pointer; color: var(--muted);
  }
  .close-btn:focus-visible { outline: 3px solid #818cf8; outline-offset: 2px; }
  .settings-modal-body {
    min-height: 0; padding: 18px 20px calc(28px + env(safe-area-inset-bottom));
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex; flex-direction: column; gap: 14px;
  }
  .settings-modal-body .toolbar-content { display: flex; flex-direction: column; gap: 14px; width: 100%; min-width: 0; }
  .settings-modal-body .toolbar-row { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .settings-modal-body label { display: flex; flex-direction: column; min-width: 0; font-size: 0.85rem; color: var(--muted); gap: 4px; }
  .settings-modal-body select { width: 100%; min-width: 0; max-width: 100%; }
  .settings-modal-body .day-row { flex-direction: column; align-items: stretch; }
  .settings-modal-body .day-nav { display: flex; width: 100%; min-width: 0; }
  .settings-modal-body .day-nav select { flex: 1; }
  .settings-modal-body .count-label { flex-direction: row; justify-content: space-between; align-items: center; }
  .settings-modal-body .count-label input[type="range"] { flex: 1; min-width: 0; margin-left: 12px; }
  .settings-modal-dialog.sentence-mode .word-only { display: none !important; }
}
