:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  --accent: #f97316;
  --ink: #182033;
  --muted: #697386;
  --line: #e7eaf0;
  --surface: #ffffff;
  --background: #f6f7fb;
  --success: #10b981;
  --shadow: 0 12px 32px rgba(26, 36, 64, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: "Noto Sans KR", "Noto Sans JP", sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 28px 20px;
  display: flex; flex-direction: column; background: #17182c; color: white; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; margin: 0 10px 34px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; background: var(--primary); border-radius: 13px; font-size: 21px; font-weight: 700; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; }
.brand small { color: #aeb2c8; letter-spacing: .12em; }
.nav { display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 13px; padding: 12px 14px; color: #bfc3d5; border-radius: 12px; font-size: 14px; transition: .2s; }
.nav-link:hover, .nav-link.active { color: white; background: rgba(255,255,255,.1); }
.nav-icon { width: 23px; text-align: center; font-size: 17px; }
.sidebar-note { margin-top: auto; padding: 17px; background: rgba(79,70,229,.24); border: 1px solid rgba(255,255,255,.08); border-radius: 15px; }
.sidebar-note span { font-family: "Noto Sans JP"; font-weight: 700; }
.sidebar-note p { margin: 5px 0 0; color: #bfc3d5; font-size: 12px; }

.main-wrap { min-width: 0; }
.topbar { height: 94px; padding: 0 clamp(20px, 4vw, 54px); display: flex; align-items: center; gap: 16px; background: rgba(246,247,251,.9); backdrop-filter: blur(12px); }
.topbar h1 { margin: 2px 0 0; font-size: clamp(22px, 3vw, 30px); line-height: 1.2; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; }
.profile { margin-left: auto; width: 42px; height: 42px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, var(--primary), #8b5cf6); border-radius: 50%; font-weight: 700; box-shadow: var(--shadow); }
.icon-button { border: 0; background: transparent; cursor: pointer; }
.menu-toggle { display: none; font-size: 23px; }
main { padding: 6px clamp(20px, 4vw, 54px) 54px; max-width: 1500px; margin: auto; }

.hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .8fr); gap: 20px; }
.card { background: var(--surface); border: 1px solid rgba(231,234,240,.8); border-radius: var(--radius); box-shadow: var(--shadow); }
.welcome-card { position: relative; overflow: hidden; padding: clamp(26px, 4vw, 42px); color: white; background: linear-gradient(125deg, #4338ca, #6d5ce8); }
.welcome-card::after { content: "語"; position: absolute; right: 4%; bottom: -50px; color: rgba(255,255,255,.08); font: 800 190px "Noto Sans JP"; }
.welcome-card > * { position: relative; z-index: 1; }
.welcome-card .tag { display: inline-block; padding: 6px 10px; background: rgba(255,255,255,.14); border-radius: 999px; font-size: 12px; }
.welcome-card h2 { max-width: 510px; margin: 16px 0 8px; font-size: clamp(24px, 4vw, 38px); line-height: 1.35; }
.welcome-card p { margin: 0 0 24px; color: #e3e2ff; }
.primary-button { display: inline-flex; align-items: center; gap: 8px; padding: 12px 17px; color: var(--primary-dark); background: white; border: 0; border-radius: 12px; font-weight: 700; cursor: pointer; }
.dday-card { padding: 28px; display: flex; flex-direction: column; justify-content: center; }
.card-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.dday { margin: 8px 0; color: var(--primary); font-size: clamp(40px, 6vw, 58px); font-weight: 800; line-height: 1; }
.exam-date { color: var(--muted); font-size: 13px; }

.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 34px 2px 15px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading span { color: var(--muted); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { padding: 21px; }
.stat-top { display: flex; justify-content: space-between; gap: 12px; }
.stat-icon { width: 40px; height: 40px; display: grid; place-items: center; background: var(--primary-soft); border-radius: 12px; }
.stat-value { margin: 15px 0 3px; font-size: 26px; font-weight: 800; }
.stat-sub { color: var(--muted); font-size: 12px; }
.wide { grid-column: span 2; }
.progress-row { display: flex; justify-content: space-between; margin: 14px 0 8px; font-size: 13px; }
.progress { height: 8px; overflow: hidden; background: #eceef4; border-radius: 99px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #8b5cf6); border-radius: inherit; transition: width .4s ease; }
.progress-fill.orange { background: linear-gradient(90deg, var(--accent), #fbbf24); }

.menu-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.menu-card { min-height: 130px; padding: 20px; text-align: left; background: white; border: 1px solid var(--line); border-radius: 17px; cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s; }
.menu-card:hover { transform: translateY(-3px); border-color: #c7d2fe; box-shadow: var(--shadow); }
.menu-card .menu-icon { display: block; margin-bottom: 17px; font-size: 23px; }
.menu-card strong { display: block; margin-bottom: 4px; }
.menu-card small { color: var(--muted); }

.page-card { padding: clamp(22px, 4vw, 34px); }
.page-intro { display: flex; align-items: center; gap: 18px; }
.page-icon { width: 58px; height: 58px; display: grid; place-items: center; flex: 0 0 auto; background: var(--primary-soft); border-radius: 17px; font-size: 27px; }
.page-intro h2 { margin: 0 0 5px; }
.page-intro p { margin: 0; color: var(--muted); }
.placeholder { margin-top: 28px; padding: 32px; text-align: center; color: var(--muted); background: #fafbfe; border: 1px dashed #ccd1dc; border-radius: 16px; }
.word-list { display: grid; gap: 10px; margin-top: 25px; }
.word-item { display: grid; grid-template-columns: 70px 1fr 1fr; align-items: center; gap: 14px; padding: 15px; border-bottom: 1px solid var(--line); }
.level-badge { width: fit-content; padding: 4px 8px; color: var(--primary); background: var(--primary-soft); border-radius: 7px; font-size: 11px; font-weight: 700; }
.jp-word { font: 700 18px "Noto Sans JP"; }
.reading, .meaning { color: var(--muted); font-size: 13px; }
.settings-form { display: grid; max-width: 480px; gap: 9px; margin-top: 28px; }
.settings-form label { font-weight: 600; font-size: 13px; }
.settings-form input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; outline: none; }
.settings-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.save-button { margin-top: 8px; padding: 12px; color: white; background: var(--primary); border: 0; border-radius: 11px; cursor: pointer; font-weight: 700; }
.toast { position: fixed; right: 24px; bottom: 24px; padding: 13px 17px; color: white; background: #202334; border-radius: 12px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translateY(0); }
.overlay { display: none; }

/* 실제 단어 학습 화면 */
.study-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 28px; }
.study-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 26px; }
.study-breakdown span { padding: 13px 15px; color: var(--muted); background: #fafbff; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; }
.study-breakdown b { display: block; margin-top: 3px; color: var(--ink); font-size: 17px; }
.mode-switch { display: inline-flex; padding: 4px; background: #f0f1f6; border-radius: 12px; }
.mode-button { padding: 9px 14px; color: var(--muted); background: transparent; border: 0; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600; }
.mode-button.active { color: var(--primary-dark); background: white; box-shadow: 0 3px 10px rgba(26,36,64,.08); }
.study-count { color: var(--muted); font-size: 13px; font-weight: 700; }
.study-progress { margin: 16px 0 22px; }
.review-panel { margin-top: 22px; }
.quiz-panel { max-width: 720px; margin: auto; padding: clamp(24px, 5vw, 44px); text-align: center; background: #fafbff; border: 1px solid var(--line); border-radius: 18px; }
.quiz-meta { display: flex; justify-content: center; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.task-badge { padding: 4px 8px; border-radius: 7px; font-weight: 700; }
.task-badge.new { color: #047857; background: #ecfdf5; }
.task-badge.review { color: #c2410c; background: #fff7ed; }
.quiz-word { margin: 27px 0 4px; font: 700 clamp(36px, 7vw, 58px) "Noto Sans JP"; }
.quiz-word.korean { font-family: "Noto Sans KR"; }
.quiz-reading { min-height: 24px; color: var(--muted); font-family: "Noto Sans JP", "Noto Sans KR"; }
.answer-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; max-width: 540px; margin: 34px auto 0; text-align: left; }
.answer-form label { grid-column: 1 / -1; font-size: 13px; font-weight: 600; }
.answer-form input { min-width: 0; padding: 13px 15px; background: white; border: 1px solid #ccd1dc; border-radius: 11px; outline: none; }
.answer-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.answer-form input:disabled { color: var(--muted); background: #f2f3f7; }
.check-button { padding: 0 20px; color: white; background: var(--primary); border: 0; border-radius: 11px; cursor: pointer; font-weight: 700; }
.answer-result { max-width: 540px; margin: 17px auto 0; padding: 16px; text-align: left; border-radius: 12px; }
.answer-result.correct { color: #047857; background: #ecfdf5; border: 1px solid #a7f3d0; }
.answer-result.incorrect { color: #b42318; background: #fff1f0; border: 1px solid #fecaca; }
.answer-result > strong, .answer-result small { display: block; }
.answer-result small { margin-top: 9px; opacity: .8; }
.correct-answer { margin-top: 10px; color: var(--ink); }
.correct-answer b { font: 700 20px "Noto Sans JP"; }
.correct-answer span { color: var(--muted); font-size: 13px; }
.study-complete { margin-top: 28px; padding: 48px 20px; text-align: center; background: #fafbff; border-radius: 18px; }
.study-complete > span { font-size: 42px; }
.study-complete h3 { margin: 13px 0 6px; font-size: 23px; }
.study-complete p { margin: 0 0 24px; color: var(--muted); }
.inline-button { display: inline-block; text-decoration: none; }
.list-summary { margin: 25px 0 4px; color: var(--muted); font-size: 13px; }
.wrong-item .meaning small { display: block; margin-top: 5px; color: #dc2626; font-weight: 700; }
.wrong-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 26px; padding: 16px 18px; background: var(--primary-soft); border-radius: 14px; }
.wrong-actions > span { color: var(--primary-dark); font-weight: 700; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 28px; }
.mini-stats div { padding: 22px; background: #fafbff; border: 1px solid var(--line); border-radius: 14px; }
.mini-stats span, .mini-stats strong { display: block; }
.mini-stats span { color: var(--muted); font-size: 12px; }
.mini-stats strong { margin-top: 8px; font-size: 25px; }
.chart-section { margin-top: 30px; padding-top: 28px; border-top: 1px solid var(--line); }
.chart-heading h3 { margin: 0 0 4px; font-size: 18px; }
.chart-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.chart-wrap { margin-top: 20px; overflow-x: auto; }
.accuracy-chart { display: block; width: 100%; min-width: 620px; height: auto; }
.chart-grid { stroke: #e4e7ee; stroke-width: 1; stroke-dasharray: 4 5; }
.chart-axis, .chart-date { fill: var(--muted); font: 11px "Noto Sans KR"; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: white; stroke: var(--primary); stroke-width: 4; }
.chart-value { fill: var(--primary-dark); font: 700 11px "Noto Sans KR"; }
.daily-stat-list { display: grid; gap: 8px; margin-top: 18px; }
.daily-stat-list article { display: grid; grid-template-columns: 70px repeat(3, 1fr) 55px; align-items: center; gap: 10px; padding: 12px 14px; background: #fafbff; border: 1px solid var(--line); border-radius: 11px; font-size: 12px; }
.daily-stat-list article span { color: var(--muted); }
.daily-stat-list article b { color: var(--primary); text-align: right; font-size: 15px; }
.placeholder.compact { margin-top: 18px; padding: 22px; }
.attendance-list { display: grid; gap: 9px; margin-top: 28px; }
.attendance-list div { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; padding: 14px 16px; background: #fafbff; border: 1px solid var(--line); border-radius: 12px; }
.attendance-list div > span { color: var(--success); font-weight: 800; }
.attendance-list small { color: var(--muted); }
.attendance-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 28px; }
.attendance-summary div { padding: 18px 20px; background: #fafbff; border: 1px solid var(--line); border-radius: 14px; }
.attendance-summary span, .attendance-summary strong { display: block; }
.attendance-summary span { color: var(--muted); font-size: 12px; }
.attendance-summary strong { margin-top: 6px; font-size: 22px; }
.calendar-card { max-width: 850px; margin: 18px auto 0; padding: clamp(16px, 3vw, 26px); background: #fafbff; border: 1px solid var(--line); border-radius: 17px; }
.calendar-header { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 12px; margin-bottom: 20px; }
.calendar-header h3 { margin: 0; text-align: center; font-size: 19px; }
.calendar-nav { width: 42px; height: 42px; color: var(--primary); background: white; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; font-size: 20px; }
.calendar-nav:hover:not(:disabled) { border-color: #c7d2fe; background: var(--primary-soft); }
.calendar-nav:disabled { color: #c8ccd5; background: #f4f5f8; cursor: not-allowed; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.calendar-weekdays { margin-bottom: 7px; }
.calendar-weekdays span { padding: 7px 0; color: var(--muted); text-align: center; font-size: 12px; font-weight: 700; }
.calendar-weekdays span:first-child { color: #dc2626; }
.calendar-day { position: relative; min-height: 78px; padding: 9px; background: white; border: 1px solid var(--line); border-radius: 11px; }
.calendar-day.empty { visibility: hidden; }
.calendar-day .day-number { font-size: 13px; font-weight: 700; }
.calendar-day:nth-child(7n + 1) .day-number { color: #dc2626; }
.calendar-day.attended { background: #ecfdf5; border-color: #a7f3d0; }
.calendar-day.today { border: 2px solid var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.calendar-day.missed { color: #9ca3af; background: #f2f3f6; }
.calendar-day.missed::after { content: "미출석"; position: absolute; right: 7px; bottom: 7px; font-size: 9px; }
.attendance-check { position: absolute; right: 8px; top: 7px; width: 22px; height: 22px; display: grid; place-items: center; color: white; background: var(--success); border-radius: 50%; font-size: 12px; font-weight: 800; }
.calendar-day.exam { color: var(--primary-dark); background: #fff7ed; border: 2px solid var(--accent); }
.calendar-day.exam small { position: absolute; left: 8px; bottom: 7px; color: #c2410c; font-size: 9px; font-weight: 800; line-height: 1.25; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.calendar-legend span { display: flex; align-items: center; gap: 5px; }
.calendar-legend i { width: 15px; height: 15px; display: inline-grid; place-items: center; border-radius: 4px; font-style: normal; }
.legend-check { color: white; background: var(--success); }
.legend-today { background: white; border: 2px solid var(--primary); }
.legend-missed { background: #e5e7eb; }
.legend-exam { background: #fff7ed; border: 2px solid var(--accent); }
.form-help { color: var(--muted); }

@media (max-width: 1000px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .menu-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 260px; transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .overlay { position: fixed; inset: 0; display: block; visibility: hidden; opacity: 0; background: rgba(12,14,25,.45); transition: .25s; z-index: 15; }
  .overlay.show { visibility: visible; opacity: 1; }
  .menu-toggle { display: block; }
  .topbar { height: 82px; position: sticky; top: 0; z-index: 10; }
  .hero { grid-template-columns: 1fr; }
  .menu-grid { grid-template-columns: repeat(2, 1fr); }
  .mini-stats { grid-template-columns: repeat(2, 1fr); }
  .daily-stat-list article { grid-template-columns: 55px repeat(2, 1fr); }
  .daily-stat-list article span:nth-of-type(3) { display: none; }
  .calendar-day { min-height: 66px; }
}
@media (max-width: 480px) {
  main { padding-inline: 14px; }
  .topbar { padding-inline: 14px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .menu-grid { gap: 10px; }
  .menu-card { min-height: 116px; padding: 16px; }
  .word-item { grid-template-columns: 54px 1fr; }
  .word-item .meaning { grid-column: 2; }
  .study-toolbar { align-items: stretch; flex-direction: column; }
  .study-breakdown { grid-template-columns: 1fr; }
  .mode-switch { display: grid; grid-template-columns: 1fr 1fr; }
  .review-mode-switch { grid-template-columns: 1fr; }
  .mode-button { padding-inline: 8px; }
  .study-count { text-align: right; }
  .answer-form { grid-template-columns: 1fr; }
  .answer-form label { grid-column: auto; }
  .check-button { min-height: 46px; }
  .mini-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .wrong-actions { align-items: stretch; flex-direction: column; }
  .attendance-summary { grid-template-columns: 1fr; gap: 8px; }
  .attendance-summary div { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; }
  .attendance-summary strong { margin: 0; font-size: 18px; }
  .calendar-card { padding-inline: 10px; }
  .calendar-weekdays, .calendar-grid { gap: 4px; }
  .calendar-day { min-height: 55px; padding: 6px; border-radius: 8px; }
  .calendar-day.missed::after { display: none; }
  .attendance-check { right: 5px; top: 5px; width: 18px; height: 18px; font-size: 10px; }
  .calendar-day.exam small { left: 5px; bottom: 4px; font-size: 7px; }
}
