:root {
  --bg: #f4fbfa;
  --panel: #ffffff;
  --line: #d9eeea;
  --text: #14323a;
  --sub: #5c7277;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --secondary: #eef7f6;
  --good: #0f9d58;
  --bad: #d93025;
  --shadow: 0 10px 28px rgba(7, 39, 46, 0.08);
  --yellow: #f8d448;
  --blackish: #2c2c3a;
  --blue: #7386d5;
  --gold: #d4a63a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #f2fbfb 0%, #edf7ff 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}
button { font: inherit; }
.app { max-width: 980px; margin: 0 auto; padding: 20px 14px 40px; }
.header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.mini { margin: 0 0 4px; color: var(--primary); font-weight: 700; font-size: 12px; letter-spacing: 0.06em; }
h1 { margin: 0; font-size: 28px; }
.sub { margin: 6px 0 0; color: var(--sub); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.section-title { margin: 0 0 12px; font-size: 20px; }
.no-margin { margin: 0; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mode-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mode-btn,
.primary,
.secondary,
.ghost,
.choice-btn,
.mark-btn { border-radius: 14px; border: none; padding: 14px 16px; cursor: pointer; font-weight: 700; }
.mode-btn,
.primary { background: var(--primary); color: white; }
.mode-btn:hover,
.primary:hover { background: var(--primary-strong); }
.mode-btn.retry { background: var(--blackish); }
.mode-btn.retry:hover { background: #181820; }
.mode-btn.weekend { background: var(--blue); }
.mode-btn.weekend:hover { background: #5c70c3; }
.mode-btn.month { background: var(--gold); }
.mode-btn.month:hover { background: #bd9330; }
.mode-btn.with-icon { display: flex; align-items: center; gap: 10px; justify-content: center; }
.btn-icon { width: 34px; height: 34px; object-fit: contain; flex: 0 0 auto; }
.secondary, .choice-btn { background: var(--secondary); color: var(--text); border: 1px solid var(--line); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--sub); }
.small { padding: 10px 12px; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: #f8fbfb; border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-align: center; }
.stat span { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.stat strong { font-size: 22px; }
.top-note { margin-top: 12px; }
.calendar-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); }
.legend-img { width: 36px; height: 36px; object-fit: contain; }
.week-header,
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week-header { margin-bottom: 6px; color: var(--sub); font-size: 13px; text-align: center; }
.calendar-cell { min-height: 98px; border: 1px solid var(--line); border-radius: 14px; background: #fbfefe; padding: 8px; }
.calendar-cell.other { opacity: 0.32; }
.calendar-cell.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.day-number { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.icon-row { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-icon-img { width: 28px; height: 28px; object-fit: contain; }
.question-topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.current-mode { color: var(--primary); font-weight: 700; font-size: 14px; }
.progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress-bar { flex: 1; height: 10px; background: #e7f4f1; border-radius: 999px; overflow: hidden; }
#progressFill { width: 0%; height: 100%; background: linear-gradient(90deg, #14b8a6, #0f766e); }
#progressText { color: var(--sub); font-size: 14px; }
.question-card.empty { display: flex; min-height: 280px; align-items: center; justify-content: center; }
.empty-text { color: var(--sub); }
.question-top { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; background: #edf8f7; color: var(--primary); border: 1px solid var(--line); padding: 6px 10px; font-size: 12px; font-weight: 700; }
.question-title { margin: 0 0 12px; font-size: 24px; line-height: 1.45; }
.question-image { width: 100%; max-height: 380px; object-fit: contain; background: #fbfefe; border: 1px solid var(--line); border-radius: 16px; padding: 10px; margin-bottom: 14px; }
.choices { display: grid; grid-template-columns: 1fr; gap: 10px; }
.choice-btn { text-align: left; }
.choice-btn.correct-choice { background: #eaf8ee; border-color: #c9ebd3; }
.choice-btn.wrong-choice { background: #fdeeee; border-color: #f5c6c2; }
.answer-box { margin-top: 16px; border-radius: 16px; padding: 14px; border: 1px solid var(--line); background: #f8fbfb; }
.answer-box.correct { border-color: #c9ebd3; background: #f1fbf4; }
.answer-box.incorrect { border-color: #f5c6c2; background: #fff5f5; }
.answer-label { font-size: 12px; font-weight: 700; color: var(--sub); margin-bottom: 6px; }
.answer-main { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.answer-exp { line-height: 1.7; white-space: pre-wrap; }
.mark-row { display: flex; gap: 10px; margin-top: 14px; }
.mark-btn.good { background: #eaf8ee; color: var(--good); border: 1px solid #c9ebd3; }
.mark-btn.bad { background: #fdeeee; color: var(--bad); border: 1px solid #f5c6c2; }
.action-area { display: flex; gap: 10px; margin-top: 14px; }
.hidden { display: none !important; }
.note { color: var(--sub); font-size: 14px; line-height: 1.7; margin-top: 10px; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-head, .question-topbar { flex-direction: column; align-items: stretch; }
  .question-title { font-size: 21px; }
  h1 { font-size: 24px; }
}


.mode-btn-text {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}
.mode-status {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.86;
}
.mode-btn.timed-mode.is-locked,
.mode-btn.timed-mode:disabled {
  opacity: 0.34;
  filter: grayscale(0.65);
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}
.mode-btn.timed-mode.is-locked .btn-icon,
.mode-btn.timed-mode:disabled .btn-icon {
  opacity: 0.65;
}

.backup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.backup-note { margin: 6px 0 0; }
.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.backup-btn {
  background: #f7fbfb;
  color: var(--text);
  white-space: nowrap;
}
.backup-message {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}
@media (max-width: 760px) {
  .backup-head { flex-direction: column; align-items: stretch; }
  .backup-actions { justify-content: stretch; }
  .backup-btn { flex: 1 1 140px; }
}
