* { box-sizing: border-box; }

:root {
  --purple: #e07856;        /* 메인: 따뜻한 테라코타/코랄 */
  --purple-light: #fbe9df;  /* 연한 살구 */
  --bg: #fdf6ef;            /* 크림 배경 */
  --ink: #4a3b33;           /* 따뜻한 갈색 글자 */
  --muted: #9b8577;         /* 흐린 갈색 */
  --line: #f0e2d6;          /* 연한 베이지 선 */
  --green: #5a9e6f;         /* 부드러운 초록 */
  --red: #d9674b;           /* 따뜻한 빨강 */
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 40px;
}

/* ===== 로그인 화면 ===== */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px;
  background: linear-gradient(135deg, #f0946f, #e07856);
}
.login-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 20px;
  padding: 32px 24px; box-shadow: 0 12px 40px rgba(0,0,0,0.2); text-align: center;
}
.login-card h1 { margin: 0 0 6px; color: var(--purple); font-size: 24px; }
.login-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.switch { font-size: 14px; color: var(--muted); margin-top: 16px; }
.switch a { color: var(--purple); font-weight: 600; text-decoration: none; }
.auth-msg { color: var(--red); font-size: 14px; min-height: 18px; margin: 10px 0 0; }

/* ===== 상단 바 ===== */
.topbar {
  background: linear-gradient(135deg, #f0946f, #e07856);
  color: #fff; padding: 18px 16px 14px;
}
.topbar-row { display: flex; justify-content: space-between; align-items: center; max-width: 560px; margin: 0 auto; }
.topbar h1 { margin: 0; font-size: 20px; }
.topbar .sub { margin: 2px 0 0; font-size: 13px; opacity: 0.9; }
.logout { background: rgba(255,255,255,0.2); color: #fff; padding: 8px 12px; font-size: 13px; }

/* ===== 탭 ===== */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; background: #fff;
  position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px rgba(180,110,70,0.06);
  -webkit-overflow-scrolling: touch; justify-content: center;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto; padding: 8px 14px; border: 0; border-radius: 999px;
  background: var(--purple-light); color: var(--purple); font: inherit; font-size: 14px;
  white-space: nowrap; cursor: pointer;
}
.tabs button.active { background: var(--purple); color: #fff; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

.tab-panel { display: none; animation: fade 0.2s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h2 { color: var(--purple); font-size: 19px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }

/* ===== 폼 공통 ===== */
form { margin-bottom: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.col { display: flex; flex-direction: column; gap: 8px; }

input, select, textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; min-width: 0; flex: 1;
}
textarea { resize: vertical; min-height: 60px; }

button {
  padding: 10px 16px; border: 0; border-radius: 10px; background: var(--purple);
  color: #fff; font: inherit; font-weight: 600; cursor: pointer; flex: 0 0 auto;
}
button:active { transform: scale(0.97); }
button.ghost { background: var(--purple-light); color: var(--purple); }
button:disabled { opacity: 0.5; cursor: default; }

/* ===== 리스트 공통 ===== */
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.item { background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 2px 8px rgba(180,110,70,0.07); }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.item .actions { display: flex; gap: 6px; flex-shrink: 0; }
.mini { padding: 5px 10px; font-size: 13px; background: var(--purple-light); color: var(--purple); }
.mini.del { background: #fdecec; color: var(--red); }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--purple-light); color: var(--purple); }
.badge.dday { background: #fdecec; color: var(--red); font-weight: 700; }
.badge.dday.safe { background: #e4f7ee; color: var(--green); }
.done .title { text-decoration: line-through; color: var(--muted); }

/* ===== 캘린더 ===== */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 12px; }
.cal-head h2 { margin: 0; min-width: 140px; text-align: center; }
.cal-head button { padding: 6px 12px; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal-dow.sun { color: var(--red); }
.cal-dow.sat { color: #5a8d9e; }
.cal-cell {
  aspect-ratio: 1; border: 1px solid transparent; border-radius: 10px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 6px; font-size: 14px; cursor: pointer; position: relative;
}
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell:not(.empty):hover { background: var(--purple-light); }
.cal-cell.today { border-color: var(--purple); font-weight: 700; color: var(--purple); }
.cal-cell.selected { background: var(--purple); color: #fff; }
.cal-cell .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--purple); margin-top: 3px; }
.cal-cell.selected .dot { background: #fff; }
.cal-cell .dot.done { background: var(--green); }

.day-detail { margin-top: 20px; }
#day-title { color: var(--purple); font-size: 16px; }

/* ===== 단어 학습 ===== */
#word-study { margin-bottom: 16px; }
.quiz-bar { margin-bottom: 14px; }
.flashcard {
  background: #fff; border-radius: 16px; padding: 40px 16px; text-align: center;
  box-shadow: 0 4px 16px rgba(180,110,70,0.12); cursor: pointer; user-select: none;
}
.flashcard .front { font-size: 26px; font-weight: 700; }
.flashcard .back { font-size: 20px; color: var(--purple); margin-top: 10px; }
.card-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.quiz-box { background: #fff; border-radius: 16px; padding: 20px 16px; box-shadow: 0 4px 16px rgba(180,110,70,0.12); text-align: center; }
.quiz-q { font-size: 22px; font-weight: 700; margin-bottom: 14px; }
.quiz-choices { display: flex; flex-direction: column; gap: 8px; }
.quiz-choices button { width: 100%; background: var(--purple-light); color: var(--ink); }
.quiz-choices button.correct { background: #e4f7ee; color: var(--green); }
.quiz-choices button.wrong { background: #fdecec; color: var(--red); }
.quiz-score { margin-top: 12px; font-weight: 600; }

/* ===== 타이머 ===== */
.timer-box { background: #fff; border-radius: 16px; padding: 20px 16px; box-shadow: 0 4px 16px rgba(180,110,70,0.1); text-align: center; }
.timer { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--purple); margin: 14px 0; letter-spacing: 1px; }
.today { text-align: center; font-size: 14px; color: var(--muted); }
.today b { color: var(--purple); }

/* ===== 홈 통계 대시보드 ===== */
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px;
}
.stat-card {
  background: #fff; border-radius: 14px; padding: 16px 12px; text-align: center;
  box-shadow: 0 2px 8px rgba(180,110,70,0.08);
}
.stat-num { font-size: 26px; font-weight: 700; color: var(--purple); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.week-chart {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 6px; height: 140px; background: #fff; border-radius: 14px;
  padding: 10px 10px 6px; box-shadow: 0 2px 8px rgba(180,110,70,0.08);
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-val { font-size: 10px; color: var(--muted); margin-bottom: 2px; min-height: 12px; }
.bar {
  width: 70%; max-width: 26px; background: linear-gradient(180deg, #f0946f, var(--purple));
  border-radius: 6px 6px 0 0; transition: height 0.4s;
}
.bar-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

.quiz-best {
  background: #fff; border-radius: 14px; padding: 16px; text-align: center;
  font-size: 16px; color: var(--ink); box-shadow: 0 2px 8px rgba(180,110,70,0.08);
}
.quiz-best b { color: var(--purple); font-size: 20px; }

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