/* ==========================================================================
   학교생활 대시보드 - 공통 디자인 시스템
   컨셉: "책상 위의 시간표" — 교실 시간표 카드와 다이어리를 모티프로 한
   차분한 인디고 톤 + 급함을 표시하는 코럴, 공부 중 상태를 나타내는 민트.
   ========================================================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  /* ---- Light mode (default) ---- */
  --bg: #F6F7FC;
  --surface: #FFFFFF;
  --surface-alt: #EEF0F9;
  --surface-raised: #FFFFFF;
  --text: #1B1D2A;
  --text-muted: #6B6F85;
  --text-faint: #9498AC;
  --border: #E4E6F0;
  --border-strong: #D2D5E4;

  --primary: #4F53E0;
  --primary-hover: #4045C7;
  --primary-soft: #E7E7FB;
  --primary-soft-text: #4045C7;

  --accent-warm: #FF7A50;
  --accent-warm-soft: #FFE7DE;
  --accent-mint: #21B58E;
  --accent-mint-soft: #DEF6EE;
  --accent-yellow: #F5B440;
  --accent-yellow-soft: #FDF0DA;

  --danger: #E14F4F;
  --danger-soft: #FBE4E4;

  --shadow-sm: 0 1px 2px rgba(23, 24, 40, 0.04), 0 1px 1px rgba(23,24,40,0.03);
  --shadow-md: 0 6px 20px rgba(23, 24, 40, 0.07);
  --shadow-lg: 0 16px 40px rgba(23, 24, 40, 0.12);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --font-ui: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --sidebar-w: 236px;
  --header-h: 64px;

  --subject-1: #4F53E0; /* 인디고 */
  --subject-2: #1FAE7E; /* 그린 */
  --subject-3: #E0A100; /* 앰버 */
  --subject-4: #E0554F; /* 코럴레드 */
  --subject-5: #1D9BD9; /* 시안블루 */
  --subject-6: #A855D9; /* 퍼플 */
  --subject-7: #C9660A; /* 브라운오렌지 */
  --subject-8: #2F8FA8; /* 틸 */
}

[data-theme="dark"] {
  --bg: #13141E;
  --surface: #1B1D2B;
  --surface-alt: #23253676;
  --surface-alt: #232536;
  --surface-raised: #262840;
  --text: #ECEDF6;
  --text-muted: #9A9DB4;
  --text-faint: #6E7089;
  --border: #2C2E42;
  --border-strong: #383B54;

  --primary: #8285FF;
  --primary-hover: #9799FF;
  --primary-soft: #2B2C4E;
  --primary-soft-text: #B3B5FF;

  --accent-warm: #FF9270;
  --accent-warm-soft: #3A2A2C;
  --accent-mint: #3FD9AE;
  --accent-mint-soft: #1D3A34;
  --accent-yellow: #F6C568;
  --accent-yellow-soft: #3A3323;

  --danger: #F17070;
  --danger-soft: #3A2429;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.24);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.32);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-pill); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------- Layout ---------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
}
.sidebar-brand .mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--subject-5));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px;
  flex-shrink: 0;
}
.sidebar-brand .name { font-size: 15px; font-weight: 800; line-height: 1.2; }
.sidebar-brand .sub { font-size: 11px; color: var(--text-faint); font-weight: 500; }

.nav-group { margin-top: 14px; }
.nav-label {
  font-size: 11px; font-weight: 700; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 6px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px; font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-soft-text); }

/* ---- 사이드바 하단: 지금 공부 중인 상태 위젯 (모든 페이지 공통) ---- */
.sidebar-session-widget {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 12px 0; padding: 10px 12px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-yellow) 16%, var(--surface)), var(--surface-alt));
  border: 1px solid color-mix(in srgb, var(--accent-yellow) 40%, var(--border));
  text-decoration: none; color: var(--text);
  transition: background .15s ease;
}
.sidebar-session-widget:hover { background: var(--surface-alt); }
.sidebar-session-widget.paused {
  background: var(--surface-alt);
  border-color: color-mix(in srgb, var(--accent-warm) 40%, var(--border));
}
.sidebar-session-icon { font-size: 18px; flex-shrink: 0; }
.sidebar-session-text { min-width: 0; flex: 1; }
.sidebar-session-title {
  font-size: 11.5px; font-weight: 800; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-session-time {
  font-family: var(--font-mono); font-size: 14px; font-weight: 800; color: var(--text);
  margin-top: 1px;
}
.sidebar-session-widget.paused .sidebar-session-time { color: var(--accent-warm); }
.sidebar-session-widget:not(.paused) .sidebar-session-time { color: color-mix(in srgb, var(--accent-yellow) 70%, var(--text)); }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

/* Header */
.main-col { display: flex; flex-direction: column; min-height: 100vh; }
.header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-title { font-size: 17px; font-weight: 800; }
.header-title .date { font-size: 12px; color: var(--text-faint); font-weight: 600; margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  color: var(--text-muted);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot {
  position: absolute; top: 3px; right: 3px;
  min-width: 16px; height: 16px; padding: 0 3px; border-radius: var(--radius-pill);
  background: var(--accent-warm); color: #fff;
  border: 2px solid var(--surface);
  display: none; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; line-height: 1;
}

.avatar-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--subject-5), var(--primary));
  border: none; color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 0;
}
.avatar-btn img { display: block; width: 100%; height: 100%; object-fit: cover; }

.content { padding: 26px 28px 60px; flex: 1; }

/* ---------------------------------- Cards / Grid ---------------------------------- */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.card-title .icon { width: 17px; height: 17px; color: var(--primary); }
.card-link { font-size: 12px; font-weight: 700; color: var(--text-faint); }
.card-link:hover { color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 700; border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface-alt); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-strong); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-alt); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 700;
  background: var(--surface-alt); color: var(--text-muted);
}

/* ---------------------------------- Form elements ---------------------------------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.input, select.input, textarea.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: none;
}
.input::placeholder { color: var(--text-faint); }
.field-hint { font-size: 11.5px; color: var(--text-faint); }
.field-error { font-size: 11.5px; color: var(--danger); font-weight: 600; min-height: 14px; }

/* ---------------------------------- Notification dropdown ---------------------------------- */
.dropdown-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 340px; height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 8px; z-index: 60;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.dropdown-panel.open { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-panel-title { font-size: 12.5px; font-weight: 800; color: var(--text-muted); padding: 8px 10px 6px; }
.notif-group-label {
  font-size: 11px; font-weight: 800; color: var(--text-faint); text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 10px 4px;
}
.notif-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: var(--radius-sm); }
.notif-item:hover { background: var(--surface-alt); }
.notif-item:hover .notif-delete-btn { opacity: 1; }
.notif-dot-marker { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.notif-item.read .notif-dot-marker { background: var(--border-strong); }
.notif-body { flex: 1; min-width: 0; }
.notif-body .t { font-size: 13px; font-weight: 700; }
.notif-body .d { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.notif-delete-btn {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); border: none; background: transparent;
  opacity: 0; transition: opacity .12s ease;
}
.notif-delete-btn svg { width: 13px; height: 13px; }
.notif-delete-btn:hover { background: var(--surface); color: var(--danger); }
.notif-empty { padding: 30px 10px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ---------------------------------- Auth pages ---------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.auth-visual {
  position: relative;
  background: linear-gradient(155deg, #4F53E0 0%, #6E8BFF 55%, #34B3D9 100%);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px;
  color: #fff;
  overflow: hidden;
}
.auth-visual::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.10) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 30% 30%, black, transparent 70%);
}
.auth-visual .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; position: relative; }
.auth-visual .brand .mark { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,.22); display:flex;align-items:center;justify-content:center; font-weight:800; }
.auth-visual .quote { position: relative; font-size: 26px; font-weight: 800; line-height: 1.4; max-width: 420px; }
.auth-visual .quote span { opacity: .8; font-weight: 600; font-size: 15px; display:block; margin-top: 14px; }
.auth-visual .timetable-peek {
  position: relative;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-lg);
  padding: 16px;
  backdrop-filter: blur(6px);
}
.auth-visual .tt-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 12.5px; font-weight: 700; }
.auth-visual .tt-row .tag { width: 6px; height: 20px; border-radius: 4px; }
.auth-visual .tt-row .time { opacity: .75; width: 44px; font-family: var(--font-mono); font-weight: 600; }

.auth-form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 48px 24px;
}
.auth-form {
  width: 100%; max-width: 380px;
}
.auth-form h1 { font-size: 24px; margin-bottom: 6px; }
.auth-form .lead { font-size: 13.5px; color: var(--text-muted); margin-bottom: 28px; }
.fields { display: flex; flex-direction: column; gap: 18px; margin-bottom: 18px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.auth-switch { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 20px; }
.auth-switch a { color: var(--primary); font-weight: 700; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--text-faint); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.form-alert {
  display: none;
  padding: 10px 13px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger);
  font-size: 12.5px; font-weight: 700; margin-bottom: 14px;
}
.form-alert.show { display: block; }

@media (max-width: 880px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}

/* ---------------------------------- Responsive shell ---------------------------------- */
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 80; transform: translateX(-100%); transition: transform .2s ease; width: 260px; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .menu-btn { display: flex !important; }
  .content { padding: 18px 16px 40px; }
  .header { padding: 0 16px; }
}
.menu-btn { display: none; }

/* ---------------------------------- Timetable widget (격자형) ---------------------------------- */
:root { --grid-line: color-mix(in srgb, var(--border-strong) 100%, var(--primary) 14%); }

.timetable-table {
  width: 100%; border-collapse: collapse; table-layout: fixed;
  border: 1px solid var(--grid-line);
}
.timetable-table th {
  font-size: 12.5px; font-weight: 800; color: var(--text);
  padding: 8px 0; text-align: center;
  border: 1px solid var(--grid-line);
  background: var(--surface-alt);
}
.tt-period {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 800;
  color: var(--text); text-align: center; padding: 8px 4px;
  width: 48px;
  border: 1px solid var(--grid-line);
  background: var(--surface-alt);
}
.tt-cell {
  text-align: center; padding: 0; cursor: pointer;
  border: 1px solid var(--grid-line);
  height: 42px;
  transition: background .12s ease;
}
.tt-cell:hover { background: var(--surface-alt); }
.tt-chip {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 4px;
  font-size: 13px; font-weight: 700; color: var(--text);
}
.tt-empty {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  color: var(--border-strong); font-weight: 700; font-size: 14px;
}
.tt-cell:hover .tt-empty { color: var(--primary); }

/* 오늘 요일: 헤더 글자 위에 작은 새싹 아이콘만 살짝 표시 */
.tt-sprout {
  display: block;
  width: 17px; height: 17px;
  margin: 0 auto 3px;
  color: var(--accent-mint);
}
.tt-sprout svg { width: 100%; height: 100%; }

/* ---------------------------------- D-day widget ---------------------------------- */
.dday-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--border);
}
.dday-row:last-child { border-bottom: none; }
.dday-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dday-info { flex: 1; min-width: 0; }
.dday-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dday-date { font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.dday-num {
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
  color: var(--text-muted); flex-shrink: 0;
}
.dday-row.highlight .dday-num { color: var(--accent-warm); font-size: 16px; }
.dday-row.highlight .dday-title { font-weight: 800; }

.dday-actions {
  display: flex; gap: 2px; margin-left: 6px; flex-shrink: 0;
  opacity: 0; transition: opacity .12s ease;
}
.dday-row:hover .dday-actions,
.dday-row:focus-within .dday-actions { opacity: 1; }
.dday-icon-btn {
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); border: none; background: transparent;
}
.dday-icon-btn svg { width: 13px; height: 13px; }
.dday-icon-btn:hover { background: var(--surface-alt); color: var(--text); }

/* 케밥(⋮) 버튼 - 항상 같은 자리를 차지해서 D-day 숫자 위치가 안 흔들림 */
.dday-kebab-btn {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); border: none; background: transparent;
  margin-left: 4px;
}
.dday-kebab-btn svg { width: 15px; height: 15px; }
.dday-kebab-btn:hover { background: var(--surface-alt); color: var(--text); }
.dday-kebab-btn.kebab-lg { width: 39px; height: 39px; border-radius: 10px; }
.dday-kebab-btn.kebab-lg svg { width: 22px; height: 22px; }

.kebab-menu {
  position: fixed; z-index: 100;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 130px;
  display: flex; flex-direction: column; gap: 1px;
}
.kebab-menu button {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 9px; border-radius: 7px; border: none; background: transparent;
  font-size: 13px; font-weight: 600; color: var(--text); text-align: left;
}
.kebab-menu button svg { width: 14px; height: 14px; flex-shrink: 0; }
.kebab-menu button:hover { background: var(--surface-alt); }
.kebab-menu button.danger { color: var(--danger); }

.dday-hidden-note {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 9px 4px; margin-bottom: 4px;
  font-size: 12px; font-weight: 700; color: var(--text-faint);
  border: none; background: transparent; text-align: left;
  border-bottom: 1px dashed var(--border);
}
.dday-hidden-note svg { width: 13px; height: 13px; }
.dday-hidden-note:hover { color: var(--primary); }

/* ---------------------------------- 모달 (D-day 추가/수정) ---------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10, 11, 20, 0.45);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility .15s;
  padding: 20px;
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal-card {
  width: 100%; max-width: 380px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 22px;
  transform: translateY(8px); transition: transform .15s ease;
}
.modal-backdrop.open .modal-card { transform: translateY(0); }
.modal-card h3 { font-size: 16px; margin-bottom: 16px; }
.save-bar {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px;
}
.modal-card.wide { max-width: 440px; }
@media (max-width: 480px) {
  .modal-backdrop { padding: 8px; align-items: flex-end; }
  .modal-card {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 18px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ---------------------------------- 지필평가 페이지 ---------------------------------- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-head h2 { font-size: 20px; }
.page-head .sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.exam-period-card + .exam-period-card { margin-top: 16px; }
.exam-period-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.exam-period-head h3 { font-size: 15px; font-weight: 800; }
.exam-period-head .count { font-size: 12px; color: var(--text-faint); font-weight: 600; margin-left: 8px; }

.exam-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 4px; border-bottom: 1px solid var(--border);
}
.exam-row:last-child { border-bottom: none; }
.exam-subject-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.exam-row-main { flex: 1; min-width: 0; }
.exam-row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exam-subject-name { font-size: 14px; font-weight: 800; }
.exam-date { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.exam-dday-chip {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--primary-soft-text);
}
.exam-dday-chip.today { background: var(--accent-warm-soft); color: var(--accent-warm); }
.exam-dday-chip.past { background: var(--surface-alt); color: var(--text-faint); }
.exam-range {
  font-size: 12.5px; color: var(--text-muted); margin-top: 5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.exam-range.empty { color: var(--text-faint); font-style: normal; }
.exam-range-btn {
  font-size: 12px; font-weight: 700; color: var(--primary); margin-top: 5px;
  background: none; border: none; padding: 0;
}

.empty-state {
  text-align: center; padding: 50px 20px; color: var(--text-muted);
}
.empty-state .emoji { font-size: 30px; margin-bottom: 10px; }

/* ---------------------------------- Meal widget ---------------------------------- */
.meal-block + .meal-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.meal-name {
  display: inline-block; font-size: 11.5px; font-weight: 800;
  color: var(--primary-soft-text); background: var(--primary-soft);
  padding: 3px 9px; border-radius: var(--radius-pill); margin-bottom: 8px;
}
.meal-menu li {
  font-size: 13px; padding: 3px 0; color: var(--text);
}

@media (min-width: 1600px) {
  .meal-name { font-size: 13.5px; padding: 5px 13px; }
  .meal-menu li { font-size: 15.5px; padding: 6px 0; }
  .meal-block + .meal-block { margin-top: 18px; padding-top: 18px; }
}

/* ---------------------------------- Mini calendar ---------------------------------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-faint); font-weight: 700; padding-bottom: 6px; }
.cal-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; border-radius: var(--radius-sm); color: var(--text-muted);
  position: relative; cursor: pointer; transition: background .12s ease;
}
.cal-cell:hover { background: var(--surface-alt); }
.cal-cell.today { background: var(--primary); color: #fff; font-weight: 800; }
.cal-cell.exam:not(.today) { color: var(--accent-warm); font-weight: 800; }
.cal-cell.has-event:not(.today) { color: var(--primary); font-weight: 800; }
.cal-cell.exam::after {
  content: ''; position: absolute; bottom: 3px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--accent-warm);
}
.cal-cell.has-event::before {
  content: ''; position: absolute; top: 4px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--primary);
}
.cal-cell.today.has-event::before { background: #fff; }
.cal-cell.today.exam::after { background: #fff; }

/* ---------------------------------- 큰 캘린더 (달력 관리 페이지) ---------------------------------- */
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-mode-toggle {
  display: flex; gap: 2px; background: var(--surface-alt);
  padding: 3px; border-radius: var(--radius-pill);
}
.cal-mode-btn {
  padding: 5px 13px; font-size: 12px; font-weight: 700;
  border-radius: var(--radius-pill); border: none; background: transparent;
  color: var(--text-muted);
}
.cal-mode-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.cal-cell-tag.study-tag { background: var(--accent-mint-soft); color: var(--accent-mint); white-space: nowrap; text-overflow: clip; font-size: 9.5px; max-width: none; }
.cal-cell-tag.study-subject-tag { background: var(--accent-yellow-soft); color: var(--accent-yellow); }
.cal-nav-btn {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
}
.cal-nav-btn:hover { background: var(--surface-alt); color: var(--text); }
.cal-nav-btn svg { width: 15px; height: 15px; }

/* ---- 내 학습 현황 (대시보드) ---- */
.my-level-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.level-badge {
  width: 48px; height: 48px; border-radius: 13px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--subject-5), var(--primary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px;
}
.level-progress-wrap { flex: 1; min-width: 0; }
.level-progress-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.level-progress-top span { font-size: 12px; font-weight: 700; color: var(--text-muted); font-family: var(--font-mono); }
.level-progress-bar { height: 8px; border-radius: var(--radius-pill); background: var(--surface-alt); overflow: hidden; }
.level-progress-fill { height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--subject-5), var(--primary)); transition: width .3s ease; }
.today-study-box {
  padding: 12px 14px; border-radius: var(--radius-md); background: var(--surface-alt);
}
.today-study-row {
  display: flex; align-items: center; justify-content: space-between;
}
.today-study-label { font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.level-progress-fill.today-fill { background: linear-gradient(90deg, var(--accent-mint), var(--accent-yellow)); }
.today-study-value { font-family: var(--font-mono); font-size: 16px; font-weight: 800; color: var(--primary); }
.today-goal-wrap { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.today-goal-wrap .level-progress-top span { font-size: 11.5px; }
.today-goal-wrap .level-progress-bar { height: 6px; background: var(--surface); border: 1px solid var(--border); }

.cal-grid-outer { position: relative; overflow: hidden; width: 100%; }
.cal-grid-outer .cal-grid.large { position: absolute; top: 0; left: 0; }


.cal-grid.large {
  gap: 6px;
  grid-template-columns: repeat(7, 82px);
  width: max-content;
}
.cal-grid.large .cal-dow { font-size: 11.5px; padding-bottom: 8px; }
.cal-grid.large .cal-cell {
  aspect-ratio: unset; width: 82px; height: 72px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  align-items: flex-start; justify-content: flex-start;
  flex-direction: column; padding: 6px; gap: 3px;
  font-size: 12px; cursor: pointer; overflow: hidden;
}
.cal-grid.large .cal-cell:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.cal-grid.large .cal-cell.today { background: var(--primary-soft); color: var(--primary-soft-text); border-color: var(--primary); }
.cal-grid.large .cal-cell.today span.num { color: var(--primary-soft-text); }
.cal-grid.large .cal-cell.empty { visibility: hidden; cursor: default; }
.cal-grid.large .cal-cell::after { display: none; }
.cal-cell .num { font-weight: 700; }
.cal-cell-dots { display: flex; gap: 3px; flex-wrap: wrap; width: 100%; min-width: 0; }
.cal-cell-dot { width: 6px; height: 6px; border-radius: 50%; }
.cal-cell-tag {
  font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 5px;
  background: var(--primary-soft); color: var(--primary-soft-text);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.cal-cell-tag.exam-tag { background: var(--accent-warm-soft); color: var(--accent-warm); }
.cal-cell-tag.assign-tag { background: color-mix(in srgb, var(--subject-6) 16%, transparent); color: var(--subject-6); }

.cal-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 2px 2px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.cal-legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; color: var(--text-muted);
}
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---------------------------------- 독서실 페이지 ---------------------------------- */
.group-code-chip {
  font-family: var(--font-mono); font-weight: 800; font-size: 13px;
  letter-spacing: 2px; color: var(--primary); background: var(--primary-soft);
  padding: 3px 10px; border-radius: var(--radius-sm);
}

.group-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; margin-bottom: 12px;
}
.group-card-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md); flex-shrink: 0;
  background: linear-gradient(135deg, var(--subject-5), var(--primary));
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
}
.group-card-main { flex: 1; min-width: 0; }
.group-card-main h4 { font-size: 14.5px; font-weight: 800; }
.group-card-main .meta { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.group-card-main .meta .studying-now { color: var(--accent-mint); font-weight: 700; }

@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---- 그룹 상세 3단 레이아웃 (세 칸 높이 통일) ---- */
.study-detail-grid {
  display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 18px;
  align-items: stretch;
}
@media (max-width: 1180px) {
  .study-detail-grid { grid-template-columns: 1fr 1fr; }
  .study-detail-right { grid-column: span 2; }
}
@media (max-width: 780px) {
  .study-detail-grid { grid-template-columns: 1fr; }
  .study-detail-right { grid-column: span 1; }
}
.study-detail-left, .study-detail-middle, .study-detail-right {
  display: flex; flex-direction: column; gap: 16px; height: 100%;
}
/* 왼쪽 칸: 멤버 카드가 남는 높이를 채우고, 목록이 넘치면 내부 스크롤 */
.study-detail-left { min-height: 560px; }
.study-detail-left > section:last-child { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.study-detail-left > section:last-child #member-list { flex: 1; min-height: 0; overflow-y: auto; }
/* 오른쪽 칸: 캘린더 카드가 전체 높이를 채우고, 날짜 상세가 남는 공간을 흡수 */
.study-detail-right > section { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.group-cal-day-detail { flex: 1; min-height: 0; overflow-y: auto; }

/* ---- 그룹 채팅 ---- */
.chat-card { display: flex; flex-direction: column; flex: 1; min-height: 480px; }
.chat-messages {
  height: 415px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 4px 2px; margin-bottom: 10px;
}
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 82%; }
.chat-msg.grouped { margin-top: -4px; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg .chat-meta { font-size: 10.5px; color: var(--text-faint); font-weight: 600; margin-bottom: 3px; }
.chat-bubble {
  font-size: 13px; line-height: 1.45; padding: 8px 12px; border-radius: 14px;
  background: var(--surface-alt); color: var(--text);
  word-break: break-word; white-space: pre-wrap;
}
.chat-msg.mine .chat-bubble {
  background: var(--primary); color: #fff; border-bottom-right-radius: 4px;
}
.chat-msg:not(.mine) .chat-bubble { border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row .input { flex: 1; }

.chat-date-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0 4px; color: var(--text-faint); font-size: 11px; font-weight: 700;
}
.chat-date-divider::before, .chat-date-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.chat-bubble-row { display: flex; align-items: center; gap: 5px; }
.chat-msg-kebab {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); border: none; background: transparent;
  opacity: .7; transition: opacity .12s ease, background .12s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.chat-msg-kebab svg { width: 15px; height: 15px; }
.chat-msg-kebab:hover, .chat-msg-kebab:active { opacity: 1; background: var(--surface-alt); color: var(--text); }

.chat-edit-input {
  min-width: 160px; padding: 7px 10px; font-size: 13px;
  border-radius: 14px;
}

/* ---- 내 상태 카드 ---- */
.my-status-card { display: flex; flex-direction: column; gap: 16px; align-items: stretch; }

.enter-toggle-big {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; border-radius: var(--radius-md); border: 1.5px solid transparent;
  font-size: 15px; font-weight: 800; color: var(--text-muted);
  background: var(--surface-alt);
  transition: transform .1s ease, filter .15s ease, background .25s ease, color .25s ease, border-color .25s ease;
}
.enter-toggle-big:hover { filter: brightness(1.04); }
.enter-toggle-big:active { transform: scale(0.98); }
.enter-toggle-big.studying {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-yellow) 22%, var(--surface)), var(--surface));
  border-color: color-mix(in srgb, var(--accent-yellow) 55%, transparent);
  color: color-mix(in srgb, var(--accent-yellow) 75%, var(--text));
}

.status-memo-field { position: relative; }
.status-memo-field label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 7px;
}
.status-memo-field label svg { width: 14px; height: 14px; }
.status-memo-field input { padding-right: 52px; }
.status-memo-count {
  position: absolute; right: 12px; bottom: 11px;
  font-size: 11px; font-weight: 700; color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ---- 멤버 카드: 프로필 사진으로 실시간 상태 표시 ---- */
.member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 7px;
  transition: background .25s ease, border-color .25s ease;
}
.member-row:last-child { margin-bottom: 0; }
.member-row.studying {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-yellow) 14%, var(--surface)), var(--surface));
  border-color: color-mix(in srgb, var(--accent-yellow) 45%, transparent);
}
.member-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--subject-5), var(--primary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px;
  border: 2px solid transparent;
  filter: grayscale(0.85) opacity(0.6);
  transition: filter .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-row.studying .member-avatar {
  filter: none;
  border-color: var(--accent-yellow);
  box-shadow: 0 0 0 2px var(--surface), 0 0 10px 2px color-mix(in srgb, var(--accent-yellow) 55%, transparent);
  animation: avatar-glow-pulse 2.4s ease-in-out infinite;
}
@keyframes avatar-glow-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--surface), 0 0 7px 1px color-mix(in srgb, var(--accent-yellow) 40%, transparent); }
  50% { box-shadow: 0 0 0 2px var(--surface), 0 0 12px 3px color-mix(in srgb, var(--accent-yellow) 70%, transparent); }
}
.member-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.member-main-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.member-name { font-size: 13px; font-weight: 800; flex-shrink: 0; }
.member-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.member-status-dot.on { background: var(--accent-yellow); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-yellow) 30%, transparent); }
.member-status-dot.paused { background: var(--accent-warm); }
.member-row.paused { border-color: color-mix(in srgb, var(--accent-warm) 40%, var(--border)); }
.member-memo {
  font-size: 11.5px; color: var(--text-muted);
  white-space: normal; word-break: break-word; line-height: 1.4;
}
.member-timer {
  font-family: var(--font-mono); font-weight: 800; font-size: 12px;
  color: color-mix(in srgb, var(--accent-yellow) 70%, var(--text));
  margin-top: 2px;
}
.member-timer.off { color: var(--text-faint); font-weight: 700; font-size: 11px; }

/* ---- 오늘의 목표 ---- */
.daily-goal-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.daily-goal-row label { font-size: 12px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.daily-goal-row input { width: 90px; flex: none; }
.daily-goal-progress { font-size: 11.5px; font-weight: 700; color: var(--accent-mint); }

/* ---- 멤버 이름 옆 레벨 태그 ---- */
.member-level-tag {
  font-size: 10.5px; font-weight: 800; color: var(--primary-soft-text);
  background: var(--primary-soft); padding: 1.5px 7px; border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.member-rank-icon { width: 21px; text-align: center; font-size: 15px; flex-shrink: 0; }
.member-rank-icon.num { font-size: 11.5px; font-weight: 800; color: var(--text-faint); }

/* ---- 전체 레벨 랭킹 (독서실 목록 페이지) ---- */
.leaderboard-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-rank { width: 26px; text-align: center; font-size: 17px; flex-shrink: 0; font-weight: 800; color: var(--text-faint); }
.leaderboard-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--subject-5), var(--primary));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 14px;
}
.leaderboard-avatar img { width: 100%; height: 100%; object-fit: cover; }
.leaderboard-info { flex: 1; min-width: 0; }
.leaderboard-name { font-size: 13.5px; font-weight: 800; }
.leaderboard-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.leaderboard-level {
  font-size: 12px; font-weight: 800; color: var(--primary-soft-text);
  background: var(--primary-soft); padding: 3px 10px; border-radius: var(--radius-pill); flex-shrink: 0;
}

/* ---- 독서실 목록 페이지: 그룹 목록 / 전체 랭킹 좌우 2단 ---- */
.list-page-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .list-page-grid { grid-template-columns: 1fr; } }
.list-page-left, .list-page-right { display: flex; flex-direction: column; gap: 12px; }
.list-page-left-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.list-page-left-title { font-size: 13px; font-weight: 800; color: var(--text-muted); }

/* ---- 응원 리액션 (버튼 하나 -> 클릭시 팝오버로 이모지 선택) ---- */
.reaction-toggle-btn {
  width: 24px; height: 24px; border-radius: 50%; border: none; background: var(--surface-alt);
  color: var(--text-faint); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  margin-left: auto;
}
.reaction-toggle-btn:hover { background: var(--primary-soft); color: var(--primary); }
.reaction-popover {
  position: fixed; z-index: 120;
  display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-pill); box-shadow: var(--shadow-lg); padding: 5px;
}
.reaction-popover button {
  width: 28px; height: 28px; border-radius: 50%; border: none; background: transparent;
  font-size: 15px; display: flex; align-items: center; justify-content: center;
}
.reaction-popover button:hover { background: var(--surface-alt); transform: scale(1.15); }

/* ---- 멤버 관리 모달 ---- */
.mm-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.mm-row:last-child { border-bottom: none; }
.mm-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--subject-5), var(--primary));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 12.5px;
}
.mm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mm-name { font-size: 13.5px; font-weight: 700; flex-shrink: 0; }
.mm-role-badge {
  font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.mm-role-badge.owner { background: var(--accent-warm-soft); color: var(--accent-warm); }
.mm-role-badge.mod { background: var(--primary-soft); color: var(--primary-soft-text); }
.mm-spacer { flex: 1; }
.mm-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------- 독서 기록 페이지 ---------------------------------- */
.book-rating-input { display: flex; gap: 2px; }
.book-rating-input button {
  border: none; background: transparent; font-size: 22px; color: var(--border-strong);
  padding: 0; line-height: 1;
}
.book-rating-input button.filled { color: var(--accent-yellow); }

.book-card { padding: 16px; margin-bottom: 12px; }
.book-card-top { display: flex; align-items: flex-start; gap: 12px; }
.book-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: linear-gradient(135deg, var(--subject-6), var(--primary));
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.book-card-main { flex: 1; min-width: 0; }
.book-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.book-title { font-size: 15px; font-weight: 800; }
.book-author { font-size: 12.5px; color: var(--text-faint); }
.book-meta-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.book-date { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }
.book-stars { font-size: 12px; color: var(--accent-yellow); letter-spacing: 1px; }
.book-toggle-btn {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); border: none; background: transparent;
  transition: transform .15s ease;
}
.book-toggle-btn.open { transform: rotate(180deg); }
.book-toggle-btn svg { width: 15px; height: 15px; }

.book-detail { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.book-detail.open { display: block; }
.book-detail-label { font-size: 11.5px; font-weight: 800; color: var(--text-muted); margin-bottom: 5px; }
.book-detail-text { font-size: 13px; color: var(--text); line-height: 1.6; white-space: pre-wrap; margin-bottom: 14px; }
.book-detail-text:last-child { margin-bottom: 0; }
.book-detail-text.empty { color: var(--text-faint); }

/* ---------------------------------- 진로 AI 페이지 ---------------------------------- */
.ai-chat-card { display: flex; flex-direction: column; }
.ai-chat-messages {
  height: 460px; overflow-y: auto; min-height: 0;
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 2px; margin-bottom: 12px;
}
.ai-msg { display: flex; gap: 10px; max-width: 88%; }
.ai-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  background: var(--surface-alt);
}
.ai-msg.user .ai-msg-avatar { background: var(--primary-soft); }
.ai-msg-bubble {
  font-size: 13.5px; line-height: 1.6; padding: 10px 14px; border-radius: 14px;
  background: var(--surface-alt); color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.ai-msg.user .ai-msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg:not(.user) .ai-msg-bubble { border-bottom-left-radius: 4px; }
.ai-msg-bubble.typing { display: flex; gap: 4px; align-items: center; padding: 13px 16px; }
.ai-msg-bubble.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: ai-typing-bounce 1.2s infinite ease-in-out; }
.ai-msg-bubble.typing span:nth-child(2) { animation-delay: .15s; }
.ai-msg-bubble.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.ai-suggest-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ai-suggest-chip {
  font-size: 12px; font-weight: 700; padding: 7px 12px; border-radius: var(--radius-pill);
  background: var(--surface-alt); border: 1px solid var(--border); color: var(--text-muted);
}
.ai-suggest-chip:hover { background: var(--primary-soft); color: var(--primary-soft-text); border-color: transparent; }

.ai-input-row { display: flex; gap: 8px; align-items: flex-end; }
.ai-input-row textarea { flex: 1; resize: none; max-height: 120px; }
.ai-input-row .btn { flex-shrink: 0; }

/* ---------------------------------- 로그인/회원가입 화이트다크 토글 ---------------------------------- */
.auth-theme-toggle { position: fixed; top: 20px; right: 20px; z-index: 50; }

.reaction-toast-wrap {
  position: fixed; top: 80px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.reaction-toast {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  border-radius: var(--radius-pill); padding: 9px 16px; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
  animation: toast-in-out 3s ease forwards;
}
@keyframes toast-in-out {
  0% { opacity: 0; transform: translateX(20px); }
  10%, 85% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(20px); }
}

/* ---- 목표 달성 축하 이펙트 ---- */
.celebrate-overlay {
  position: fixed; inset: 0; z-index: 400; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
}
.celebrate-overlay.show { animation: celebrate-fade 2.6s ease forwards; }
@keyframes celebrate-fade { 0% { opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
.celebrate-card {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 28px 36px; text-align: center; border: 1px solid var(--border);
}
.celebrate-card .emoji { font-size: 40px; margin-bottom: 8px; }
.celebrate-card .title { font-size: 16px; font-weight: 800; }
.confetti-piece {
  position: absolute; top: -20px; width: 8px; height: 14px; border-radius: 2px;
  animation: confetti-fall 2.4s ease-in forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* ---- 그룹 공부기록 캘린더 ---- */
.cal-cell.study-record:not(.today) { color: var(--accent-mint); font-weight: 800; }
.cal-cell.study-record::after {
  content: ''; position: absolute; bottom: 3px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--accent-mint);
}
.cal-cell.today.study-record::after { background: #fff; }
.cal-cell.selected-day { outline: 2px solid var(--primary); outline-offset: -2px; }

.group-cal-day-detail { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.group-cal-day-detail .gcd-title { font-size: 12.5px; font-weight: 800; color: var(--text-muted); margin-bottom: 8px; }
.gcd-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.gcd-row .name { font-weight: 700; }
.gcd-row .time { font-family: var(--font-mono); font-weight: 700; color: var(--accent-mint); }
.cal-cell-tag.suneung-tag { background: var(--accent-mint-soft); color: var(--accent-mint); }

/* 일정 상세/추가 모달 안 리스트 */
.day-event-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border-strong);
}
.day-event-item:last-child { border-bottom: none; }
.day-event-item .t { font-size: 13.5px; font-weight: 700; }
.day-event-item .m { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.day-event-item .dday-chip { font-size: 10.5px; font-weight: 700; color: var(--accent-warm); background: var(--accent-warm-soft); padding: 2px 7px; border-radius: var(--radius-pill); margin-top: 4px; display: inline-block; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.study-subject-row {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--surface-alt); border-radius: var(--radius-sm); padding: 8px;
}
.study-subject-row input.subj-name { flex: 0 0 92px; }
.study-subject-row input.subj-range { flex: 1; }
.study-subject-row .remove-subject-btn {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); border: none; background: transparent;
}
.study-subject-row .remove-subject-btn:hover { background: var(--surface); color: var(--danger); }
.study-subject-row .remove-subject-btn svg { width: 14px; height: 14px; }

/* ---- 공부 기록 요약 보기 ---- */
.study-view-time {
  font-family: var(--font-mono); font-size: 26px; font-weight: 800; color: var(--primary);
  margin-bottom: 4px;
}
.study-view-time-breakdown { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.study-modal-auto-hint { font-size: 12px; color: var(--text-muted); background: var(--surface-alt); padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; }
.study-modal-auto-hint:empty { display: none; }
.study-view-subject-item {
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-alt);
  margin-bottom: 8px;
}
.study-view-subject-item .name { font-size: 13.5px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.study-view-subject-item .name .dot { width: 8px; height: 8px; border-radius: 50%; }
.study-view-subject-item .range { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.study-view-memo-label { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-top: 14px; margin-bottom: 6px; }
.study-view-memo { font-size: 13px; color: var(--text); line-height: 1.6; white-space: pre-wrap; }
.day-modal-section-label { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }

/* ---------------------------------- 목표 관리 페이지 ---------------------------------- */
.goals-top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 780px) { .goals-top-grid { grid-template-columns: 1fr; } }

.daily-goal-set-row { display: flex; gap: 8px; }
.daily-goal-set-row .input { flex: 1; }

.timer-display {
  font-family: var(--font-mono); font-size: 40px; font-weight: 800; text-align: center;
  color: var(--text); padding: 16px 0 10px; letter-spacing: 0.02em;
}
.timer-btn-row { display: flex; gap: 10px; justify-content: center; }
.timer-btn-row .btn { min-width: 100px; }
.timer-display.running { color: var(--primary); }
.timer-display.paused { color: var(--accent-warm); }

.goal-item-add-row { display: flex; gap: 8px; }
.goal-item-add-row .input { flex: 1; }

.goal-item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.goal-item-row:last-child { border-bottom: none; }
.goal-item-check {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border-strong); background: transparent;
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.goal-item-check svg { width: 12px; height: 12px; }
.goal-item-row.done .goal-item-check { background: var(--accent-mint); border-color: var(--accent-mint); color: #fff; }
.goal-item-text { flex: 1; font-size: 13.5px; font-weight: 600; }
.goal-item-row.done .goal-item-text { text-decoration: line-through; color: var(--text-faint); }
.goal-item-delete {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); border: none; background: transparent;
}
.goal-item-delete svg { width: 14px; height: 14px; }
.goal-item-delete:hover { background: var(--surface-alt); color: var(--danger); }

/* ---- 대시보드 오늘의 목표 카드: 한 카드 안에서 목록/메모 구역을 정확히 반반으로 분리 ---- */
.goal-card-fixed { display: flex; flex-direction: column; }
.goal-card-split { display: flex; flex-direction: column; flex: 1; min-height: 260px; }
.goal-list-zone { flex: 1 1 50%; min-height: 0; overflow-y: auto; }
.goal-memo-divider { border-top: 1px solid var(--border); margin: 12px 0; flex-shrink: 0; }
.goal-memo-section { flex: 1 1 50%; min-height: 0; display: flex; flex-direction: column; }
.goal-memo-section label {
  display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; flex-shrink: 0;
}
.goal-memo-section textarea { flex: 1; resize: none; }

/* ---------------------------------- 수행평가 페이지 ---------------------------------- */
.assign-file-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-alt); font-size: 12.5px; font-weight: 600;
  margin-bottom: 8px;
}
.assign-file-chip .remove-subject-btn { width: 22px; height: 22px; font-size: 13px; }

.assign-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 4px; border-bottom: 1px solid var(--border);
}
.assign-row:last-child { border-bottom: none; }
.assign-row.done { opacity: 0.55; }
.assign-row.done .assign-title { text-decoration: line-through; }

.assign-check-btn {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  border: 2px solid var(--border-strong); background: transparent;
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.assign-check-btn svg { width: 12px; height: 12px; }
.assign-row.done .assign-check-btn { background: var(--accent-mint); border-color: var(--accent-mint); color: #fff; }

.assign-main { flex: 1; min-width: 0; }
.assign-top-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.assign-subject-chip {
  font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--primary-soft-text);
}
.assign-title { font-size: 14.5px; font-weight: 800; }
.assign-due-chip {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-pill);
  background: var(--accent-warm-soft); color: var(--accent-warm);
}
.assign-due-chip.past { background: var(--surface-alt); color: var(--text-faint); }
.assign-materials { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.assign-materials .label { font-weight: 700; color: var(--text); }
.assign-memo { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; white-space: pre-wrap; }
.assign-file-link {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 6px;
  font-size: 12px; font-weight: 700; color: var(--primary);
}
.assign-file-link svg { width: 13px; height: 13px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------------------------------- 지필평가 재설계 ---------------------------------- */
.exam-duration-badge {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--surface-alt); padding: 3px 9px; border-radius: var(--radius-pill);
  margin-left: 8px;
}
.exam-day-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.exam-day-row:last-child { border-bottom: none; }
.exam-day-label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  color: var(--text-faint); width: 40px; flex-shrink: 0;
}
.exam-day-date { font-size: 12.5px; font-weight: 700; color: var(--text-muted); width: 88px; flex-shrink: 0; }
.exam-day-subjects { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.exam-subject-tag {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--surface-alt); color: var(--text);
}

.day-subject-row { display: flex; align-items: center; gap: 10px; }
.day-subject-row label { width: 78px; flex-shrink: 0; font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.day-subject-row .day-date-hint { font-size: 11px; color: var(--text-faint); width: 74px; flex-shrink: 0; }

.range-section-title { font-size: 14px; font-weight: 800; margin-bottom: 4px; }
.range-section-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.range-period-block + .range-period-block { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.range-period-block h4 { font-size: 13.5px; font-weight: 800; margin-bottom: 10px; }
.range-subject-item + .range-subject-item { margin-top: 12px; }
.range-subject-item .label { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.range-subject-item .label .dot { width: 8px; height: 8px; border-radius: 50%; }
.range-save-hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* ---------------------------------- Greeting banner ---------------------------------- */
.greeting-banner {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.greeting-banner h2 { font-size: 21px; }
.greeting-banner .sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.grid-span-12 { grid-column: span 12; }
.grid-span-8 { grid-column: span 8; }
.grid-span-7 { grid-column: span 7; }
.grid-span-6 { grid-column: span 6; }
.grid-span-5 { grid-column: span 5; }
.grid-span-4 { grid-column: span 4; }
.grid-span-3 { grid-column: span 3; }
@media (max-width: 980px) {
  [class*="grid-span-"] { grid-column: span 12; }
}