/* ================= 기본 리셋 ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Pretendard','Apple SD Gothic Neo','Malgun Gothic',sans-serif;
  background: #f3ede0;
  color: #222;
  -webkit-text-size-adjust: 100%;
}

/* ================= 탑바 ================= */
.topbar {
  background: #fff;
  border-bottom: 1px solid #d9d0bd;
  padding: 14px 18px 0;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 1.05rem; font-weight: 700; color: #2d6ab2; margin-bottom: 10px; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; padding: 10px 16px; font-size: 0.95rem;
  color: #666; cursor: pointer; border-bottom: 3px solid transparent;
  font-family: inherit;
}
.tab.active { color: #2d6ab2; border-bottom-color: #2d6ab2; font-weight: 700; }

/* ================= 본문 ================= */
main { max-width: 900px; margin: 0 auto; padding: 16px 14px 80px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ================= 컨트롤 ================= */
.controls {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  background: #fff; padding: 12px; border-radius: 10px; margin-bottom: 14px;
  border: 1px solid #e1d9c7;
}
.controls label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.9rem; color: #555;
}
.controls select, .controls input[type=number] {
  padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px;
  font-size: 0.95rem; font-family: inherit; background: #fff;
}
.controls input[type=number] { width: 68px; }
.controls button {
  padding: 7px 14px; border-radius: 6px; border: 1px solid #2d6ab2;
  background: #fff; color: #2d6ab2; font-size: 0.9rem; cursor: pointer;
  font-family: inherit; font-weight: 600;
}
.controls button.primary { background: #2d6ab2; color: #fff; }
.controls button.ghost { border-color: #bbb; color: #555; }

/* ================= 학습지 영역 ================= */
:root {
  --line-h: 34px;
  --line-color: #c9d6e8;
  --paper: #fffbf0;
  --margin-line: #e08a8a;
}
.worksheet {
  background: var(--paper);
  background-image: linear-gradient(to bottom, transparent calc(var(--line-h) - 1px), var(--line-color) calc(var(--line-h) - 1px), var(--line-color) var(--line-h));
  background-size: 100% var(--line-h);
  background-position: 0 0;
  border: 1px solid #d9d0bd;
  border-radius: 8px;
  padding: 0 14px 0 46px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  overflow: hidden;
}
.worksheet::before {
  content: ''; position: absolute; left: 36px; top: 0; bottom: 0;
  width: 1px; background: var(--margin-line); opacity: 0.6;
}
.ws-section-header {
  font-size: 0.88rem; color: #2d6ab2; font-weight: 700;
  line-height: var(--line-h); height: var(--line-h);
  padding-top: 2px;
  border-bottom: 1px dashed #c9d6e8;
  background: transparent;
}
.ws-sentence {
  line-height: var(--line-h);
  padding: 0;
  color: #222;
  font-size: 1rem;
  word-break: keep-all;
  overflow-wrap: break-word;
}
/* 다른 섹션 구분선 */
.ws-divider {
  line-height: var(--line-h); height: var(--line-h);
  text-align: center; color: #b99b6a; letter-spacing: 8px;
  font-size: 0.9rem;
}

/* 빈칸 입력 */
.blank {
  display: inline-block;
  border: none; border-bottom: 2px solid #2d6ab2;
  background: #fff7d6;
  font: inherit; font-weight: 600;
  padding: 0 6px;
  width: 5.5em; min-width: 3em;
  text-align: center;
  color: #2d6ab2;
  outline: none;
  margin: 0 2px;
  border-radius: 3px 3px 0 0;
}
.blank:focus { background: #ffefb0; }
.blank.correct {
  background: #dff5dd; color: #1e7e34; border-bottom-color: #1e7e34;
}
.blank.wrong {
  background: #fcdede; color: #c0392b; border-bottom-color: #c0392b;
  animation: shake 0.25s;
}
.blank.revealed {
  background: #e6e6e6; color: #333; border-bottom-color: #666;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ================= 피드백/플로터 ================= */
.feedback {
  margin-top: 12px; min-height: 24px;
  font-size: 0.95rem; font-weight: 600;
}
.feedback.ok { color: #1e7e34; }
.feedback.bad { color: #c0392b; }
.feedback .summary {
  padding: 10px 14px; border-radius: 8px; background: #fff;
  border: 1px solid #ddd; display: inline-block;
}

/* ================= 타임어택 HUD ================= */
.ta-hud {
  display: flex; gap: 14px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e1d9c7; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 12px;
  font-size: 0.92rem;
}
.ta-hud b { color: #2d6ab2; font-size: 1.1rem; margin-left: 4px; }

/* ================= 타임어택 복기 ================= */
.review { margin-top: 16px; }
.review h2 { font-size: 1rem; margin-bottom: 8px; color: #2d6ab2; }
.review h2 small { color: #888; font-weight: 400; font-size: 0.8rem; margin-left: 6px; }
.review-item {
  background: #fff; border: 1px solid #ddd; border-left: 4px solid #bbb;
  border-radius: 6px; padding: 10px 12px; margin-bottom: 8px;
  font-size: 0.95rem; line-height: 1.5;
}
.review-item.correct { border-left-color: #1e7e34; }
.review-item.wrong { border-left-color: #c0392b; }
.review-item .sec { font-size: 0.8rem; color: #777; margin-bottom: 4px; }
.review-item .user { color: #c0392b; text-decoration: line-through; margin-left: 6px; font-size: 0.85rem; }
.review-item .ans { color: #1e7e34; font-weight: 700; }

.hidden { display: none; }

/* ================= 반응형 ================= */
@media (min-width: 640px) {
  :root { --line-h: 38px; }
  .topbar h1 { font-size: 1.2rem; }
  .ws-sentence { font-size: 1.05rem; }
  .blank { width: 6em; }
  main { padding: 20px 18px 80px; }
}
@media (min-width: 960px) {
  :root { --line-h: 42px; }
  .ws-sentence { font-size: 1.1rem; }
  .topbar { padding-left: 24px; padding-right: 24px; }
}
