:root {
  --primary: #7c3aed;
  --primary-light: #ede9fe;
  --bg: #f5f3ff;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* ===== 당겨서 새로고침 표시기 ===== */
#ptr-indicator {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  transform: translateX(-50%) translateY(-40px);
  z-index: 999;
  width: 36px;
  height: 36px;
  margin-top: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}
#ptr-indicator .ptr-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
}
#ptr-indicator.ptr-ready .ptr-spinner {
  border-color: var(--primary);
}
#ptr-indicator.ptr-loading .ptr-spinner {
  animation: ptr-spin 0.7s linear infinite;
}
@keyframes ptr-spin {
  to { transform: rotate(360deg); }
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-bottom: 76px;
  overflow-x: hidden;
}

header.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: white;
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 2px 10px rgba(124,58,237,0.25);
}

header.topbar .brand {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 2px;
}

header.topbar h1 {
  margin: 0;
  font-size: 20px;
}

main {
  flex: 1;
  padding: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--primary);
}

.stat-row {
  display: flex;
  gap: 10px;
}

.stat-box {
  flex: 1;
  background: var(--primary-light);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat-box .num {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.stat-box .label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.class-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f1f4;
}

.class-item:last-child { border-bottom: none; }

.class-item .info .name { font-weight: 600; font-size: 14px; }
.class-item .info .time { font-size: 12px; color: var(--muted); }

.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.pill.warn { background: #fef3c7; color: var(--amber); }
.pill.danger { background: #fee2e2; color: var(--red); }
.pill.ok { background: #dcfce7; color: var(--green); }

.student-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #f1f1f4;
}

.student-row:last-child { border-bottom: none; }

.student-row .name { font-weight: 600; font-size: 14px; }
.student-row .meta { font-size: 12px; color: var(--muted); }

.attend-btns { display: flex; gap: 6px; }

.attend-btns button {
  border: none;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #f3f4f6;
  color: var(--muted);
}

.attend-btns button.active-present { background: var(--green); color: white; }
.attend-btns button.active-absent { background: var(--red); color: white; }
.attend-btns button.active-makeup { background: var(--amber); color: white; }

select, input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 16px;
  margin-bottom: 10px;
  background: white;
  color: var(--text);
  font-family: inherit;
}

input[type="checkbox"] {
  width: auto;
  margin-bottom: 0;
}

label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  display: block;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.progress-bar {
  height: 8px;
  background: #f1f1f4;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

nav.bottomnav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: white;
  border-top: 1px solid #ececf1;
  display: flex;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

nav.bottomnav button {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 2px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

nav.bottomnav button .icon { font-size: 19px; }
nav.bottomnav button.active { color: var(--primary); font-weight: 700; }

.install-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
  display: none;
}

.install-banner.show { display: block; }

.empty-msg {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 16px 0;
}

.band-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}

/* ===== 캘린더 ===== */
.btn-nav {
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-weekdays {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 4px;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 2px;
  min-height: 40px;
}

.cal-cell.empty { cursor: default; }

.cal-cell:not(.empty):hover { background: var(--primary-light); }

.cal-cell.today .cal-daynum {
  color: var(--primary);
  font-weight: 800;
}

.cal-cell.selected {
  background: var(--primary);
}

.cal-cell.selected .cal-daynum { color: white; }

.cal-daynum { font-size: 12px; font-weight: 600; }

.cal-dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; max-width: 28px; }

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 55, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}

.modal-card {
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}

@media (min-width: 520px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: 18px; max-height: 70vh; }
}

.cal-class-block {
  padding: 10px 0;
  border-bottom: 1px solid #f1f1f4;
}

.cal-class-block:last-child { border-bottom: none; }

.cal-roster {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ===== 출석 행 상태 색상 ===== */
.student-row.row-present {
  background: #f0fdf4;
  border-left: 4px solid var(--green);
  padding-left: 10px;
  border-radius: 8px;
  border-bottom: 1px solid #f1f1f4;
}

.student-row.row-absent {
  background: #fef2f2;
  border-left: 4px solid var(--red);
  padding-left: 10px;
  border-radius: 8px;
  border-bottom: 1px solid #f1f1f4;
}

.student-row.row-paused {
  opacity: 0.55;
  filter: grayscale(0.6);
}

.class-pick-btn {
  border: 1px solid var(--primary-light);
  background: white;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.class-pick-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* 가장 임박한 수업 반: 발광 효과 */
@keyframes classPickGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124,58,237,0.55), 0 0 4px 0 rgba(124,58,237,0.35); }
  50% { box-shadow: 0 0 0 5px rgba(124,58,237,0.15), 0 0 12px 2px rgba(124,58,237,0.55); }
}

.class-pick-btn.class-pick-glow {
  animation: classPickGlow 1.6s ease-in-out infinite;
  border-color: var(--primary);
}

/* 이미 시간이 지난 오늘의 수업: 반투명 처리 */
.class-pick-btn.class-pick-passed {
  opacity: 0.4;
}

/* 홈 화면 카드 강조용 플래시 효과 */
@keyframes flashHighlight {
  0% { box-shadow: 0 0 0 0 rgba(124,58,237,0.7); }
  50% { box-shadow: 0 0 0 8px rgba(124,58,237,0); }
  100% { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
}

.card.flash-highlight {
  animation: flashHighlight 1s ease-out 2;
}

/* ===== 보강 예약 ===== */
.link-btn {
  border: none;
  background: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
}

.makeup-info {
  margin-top: 8px;
  font-size: 12px;
  color: var(--amber);
  background: #fffbeb;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.makeup-form {
  margin-top: 10px;
  background: #faf5ff;
  border-radius: 10px;
  padding: 10px;
}

.makeup-form label { margin-top: 0; }

/* ===== 위험한 작업(삭제 등) ===== */
.danger-zone {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px dashed #fecaca;
}

.danger-zone .danger-label {
  font-size: 12px;
  color: var(--red);
  font-weight: 700;
  margin-bottom: 8px;
}

.btn-danger {
  width: 100%;
  background: #fff;
  color: var(--red);
  border: 1px solid #fca5a5;
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-danger:active {
  background: #fef2f2;
}

/* ===== 회원용 확인 페이지 ===== */
#member-app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
