/* mobile-index.css — index.html 모바일(≤640px) 전용 화면.
   테마 CSS(pink/purple/blue/green/index.css) 뒤에 걸어서 좁은 화면에서만 덮어쓴다.
   넓은 화면에서는 아무것도 바꾸지 않는다. */
@media (max-width: 640px) {
  html { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  /* ── 배너·바깥 여백 ── */
  .header-banner { height: 96px; }
  .container { margin: -24px auto 24px; padding: 0 12px; }

  /* ── 제목 칸: 로고 + 이름 한 줄, 그 아래 두 개 버튼 한 줄 ── */
  .title-section {
    max-height: none !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
  }
  .title-section img { height: 40px !important; }
  .title-section h1 { font-size: 18px !important; flex: 1 1 auto; letter-spacing: -0.2px; }
  .title-section > button.move-btn {
    float: none !important;
    font-size: 11px !important;
    padding: 6px 10px !important;
    border-radius: 999px;
    order: 1;
  }
  /* 주간 리포트와 생기부 DB는 둘째 줄에 반반 */
  .title-section > div { flex: 1 1 calc(50% - 5px); min-width: 0; order: 2; }
  .title-section > div > button { width: 100%; justify-content: center; min-height: 40px; font-size: 13px !important; }
  .title-section > a.shortcut-card {
    flex: 1 1 calc(50% - 5px) !important;
    max-width: none !important;
    margin-left: 0 !important;
    order: 3;
    min-height: 40px;
    padding: 6px 12px;
  }
  .title-section > a.shortcut-card .shortcut-icon { font-size: 18px; }
  .title-section > a.shortcut-card .shortcut-sub { display: none; }

  /* ── 카드 공통: 열 구분을 없애고 한 줄로 세운다. 테마 점은 맨 아래로 ── */
  .container { display: flex; flex-direction: column; gap: 12px; }
  .title-section { margin-bottom: 0; }
  .main-layout, .bottom-layout, .left-col, .mid-col, .right-col { display: contents; }
  .left-col > .block { margin-bottom: 0 !important; }
  .theme-selector { order: 99; margin: 6px 0 0; }
  .block { min-height: 0 !important; padding: 14px; border-radius: 14px; }
  .block h3 { font-size: 15px !important; }
  .move-btn { font-size: 12px !important; padding: 6px 12px !important; border-radius: 999px; min-height: 30px; display: inline-flex; align-items: center; }

  /* 손가락 크기 */
  select, input[type="text"] { font-size: 16px !important; padding: 8px 10px !important; border-radius: 8px !important; min-height: 40px; }
  #checkSubject { min-height: 30px; padding: 4px 10px !important; font-size: 12px !important; }

  /* ── 달력 ── */
  .calendar-header { font-size: 15px; margin-bottom: 10px; }
  .calendar-header span:first-child, .calendar-header span:last-child { padding: 6px 12px; }
  .calendar-grid { font-size: 13px; gap: 2px; }
  .calendar-grid > div { padding: 7px 0; min-height: 34px; justify-content: center; }
  .calendar-grid .exam-dot { min-height: 0; padding: 0; width: 6px; height: 6px; margin-top: 2px; }
  .today { border-radius: 10px; }

  /* ── 타이머 ── */
  .time-display { font-size: 48px !important; margin: 10px 0 !important; letter-spacing: 1px; }
  .mode-btn { font-size: 12px; padding: 5px 10px; }
  .timer-btns { display: flex; gap: 8px; padding-bottom: 0; }
  .timer-btns button { flex: 1; padding: 13px 0; font-size: 17px; }
  .theme-selector { justify-content: center; gap: 18px; padding-left: 0; }
  .theme-dot { width: 26px; height: 26px; }

  /* ── 타이머 상자: 세로로 여유 있게 ── */
  .left-col > .block:not(.pink-block) { min-height: 250px !important; padding: 18px 16px 20px; justify-content: space-between; }
  .left-col > .block:not(.pink-block) .time-display { margin: 18px 0 !important; }

  /* ── 성취 DB: 글자 키움 ── */
  [data-odin-db="achieve"] > div:nth-of-type(2) { padding: 18px 16px !important; gap: 16px !important; }
  [data-odin-db="achieve"] > div:nth-of-type(2) > div:first-child > div:first-child { font-size: 14px !important; color: #666 !important; }
  [data-odin-db="achieve"] > div:nth-of-type(2) > div:first-child { display: flex; flex-direction: column; align-items: center; text-align: center !important; width: 100%; }
  #achieve-time { font-size: 40px !important; display: block; width: 100%; text-align: center !important; font-variant-numeric: tabular-nums; }
  [data-odin-db="achieve"] > div:nth-of-type(2) > div:last-child > div:first-child { font-size: 14px !important; margin-bottom: 8px !important; color: #555; }
  #achieve-percent { font-size: 16px !important; }
  [data-odin-db="achieve"] > div:nth-of-type(2) > div:last-child > div:last-child { height: 12px !important; border-radius: 6px !important; }

  /* ── 목표 DB: 학교 이름 크게, 옆에 학과 ── */
  .goal-prev-row { align-items: center !important; gap: 10px !important; padding: 10px 12px !important; }
  .goal-prev-row > span { font-size: 11px !important; flex-shrink: 0; }
  .goal-prev-row > div { display: flex !important; flex-direction: row !important; align-items: baseline; flex-wrap: wrap; gap: 0 8px; min-width: 0; }
  .goal-prev-row [id^="goalSchool"] { font-size: 16px !important; font-weight: 800 !important; color: #222 !important; }
  .goal-prev-row [id^="goalMajor"] { font-size: 13px !important; color: #666 !important; font-weight: 600 !important; margin: 0 !important; }

  /* ── 바로가기 ── */
  .shortcut-grid { gap: 10px; margin-top: 0; }
  .shortcut-card { padding: 12px 14px; min-height: 58px; }
  .shortcut-title { font-size: 16px; }
  .shortcut-grid .shortcut-sub { display: none; }

  /* ── Tracker: 선택 줄이 넘치지 않게, 표는 손가락 높이로 ── */
  .right-col > .block { height: auto !important; }
  .right-col > .block > div:nth-of-type(2) { flex-wrap: nowrap; gap: 4px !important; }
  .right-col > .block > div:nth-of-type(2) select { flex: 1 1 0; min-width: 0; padding: 8px 4px !important; font-size: 14px !important; text-align: center; }
  .right-col > .block > div:nth-of-type(3) { display: flex; gap: 6px; }
  .right-col > .block > div:nth-of-type(3) select { flex: 1; }
  .right-col > .block > button { min-height: 42px; font-size: 14px; }
  .tracker-table { margin-top: 8px; }
  .tracker-table th { font-size: 12px; color: #999; width: 30px; padding: 4px 0; }
  .tracker-table thead th { font-size: 11px; }
  .tracker-table td { height: 26px; }
  .tracker-table .tracker-label { font-size: 13px !important; font-weight: 800 !important; }

  /* ── 체크 DB: 두 칸을 위아래로 세우고, 원그래프 왼쪽·글 오른쪽 ── */
  [data-odin-db="check"] .block > div:nth-of-type(2) { flex-direction: column; gap: 10px !important; }
  [data-odin-db="check"] .block > div:nth-of-type(2) > div {
    display: grid !important;
    grid-template-columns: 112px 1fr;
    grid-template-areas: "chart label" "chart value";
    align-items: center;
    column-gap: 14px; row-gap: 2px;
    padding: 12px 14px !important;
    text-align: left;
  }
  [data-odin-db="check"] .block > div:nth-of-type(2) > div > div:first-child { grid-area: label; font-size: 12px !important; color: #888; align-self: end; }
  #main-top-error, #main-top-part { grid-area: value; font-size: 20px !important; line-height: 1.2; align-self: start; }
  [data-odin-db="check"] .block > div:nth-of-type(2) > div > div:last-child { grid-area: chart; width: 112px !important; height: 112px !important; }
  /* 아직 그래프가 안 그려졌으면(기록 없음) 빈 그래프 칸은 숨긴다 */
  [data-odin-db="check"] .block > div:nth-of-type(2) > div:has(> div:last-child > canvas:not([style])) {
    grid-template-columns: 1fr; grid-template-areas: "label" "value";
  }
  [data-odin-db="check"] .block > div:nth-of-type(2) > div:has(> div:last-child > canvas:not([style])) > div:last-child { display: none; }
  canvas { max-width: 100% !important; }

  /* ── 시험 DB ── */
  /* ── 시험 DB: 내신·모고를 위아래 두 줄로. 왼쪽에 큰 등급, 오른쪽에 목표·차이·설명 ── */
  #naesin-hero-card { grid-template-columns: 1fr !important; gap: 10px !important; }
  #naesin-hero-card > div {
    display: grid !important;
    grid-template-columns: auto 1fr;
    grid-template-areas: "label label" "num goal" "num badge" "num msg";
    column-gap: 18px; row-gap: 5px;
    align-items: center; justify-items: start;
    text-align: left !important;
    padding: 14px 16px !important;
  }
  #naesin-hero-card > div > div:nth-child(1) { grid-area: label; font-size: 13px !important; letter-spacing: 0 !important; }
  #naesin-hero-card > div > div:nth-child(2) { grid-area: num; align-self: center; }
  #naesin-total, #mogo-avg { font-size: 46px !important; letter-spacing: -1px; }
  #naesin-hero-card > div > div:nth-child(2) > span:last-child { font-size: 13px !important; }
  #naesin-hero-card > div > div:nth-child(3) { grid-area: goal; font-size: 15px !important; color: #555 !important; }
  #naesin-hero-card > div > div:nth-child(3) > span { font-size: 17px !important; }
  #naesin-gap-badge, #mogo-gap-badge { grid-area: badge; font-size: 12px !important; padding: 4px 10px !important; }
  #naesin-msg, #mogo-msg { grid-area: msg; font-size: 12px !important; color: #999 !important; line-height: 1.35 !important; }
  #naesin-empty { padding: 8px 0; }

  /* ── 오른쪽 떠 있는 버튼: 작게, 겹치지 않게 ── */
  html body #magFab, html body #userFab, html body #helpFab, html body #scrapFab {
    width: 40px !important; height: 40px !important;
    right: 8px !important;
    font-size: 17px !important;
    opacity: .92 !important;
    box-shadow: 0 3px 10px rgba(0,0,0,.12) !important;
  }
  html body #userFab  { bottom: calc(12px + env(safe-area-inset-bottom)) !important; }
  html body #magFab   { bottom: calc(60px + env(safe-area-inset-bottom)) !important; }
  html body #helpFab  { bottom: calc(108px + env(safe-area-inset-bottom)) !important; }
  html body #scrapFab { bottom: calc(156px + env(safe-area-inset-bottom)) !important; }

  /* ── 체험 배지: 배너 위 작게 ── */
  html body .odin-trial-badge { top: calc(10px + env(safe-area-inset-top)) !important; right: 10px !important; padding: 5px 11px !important; font-size: 12px !important; }

  /* ── 첫 설정 팝업이 화면보다 넓게 그려지던 것 ── */
  #odin-setup-overlay { width: 100vw !important; max-width: 100vw !important; }
  #odin-setup-overlay > * { max-width: calc(100vw - 24px) !important; }

  footer { padding: 0 12px; font-size: 10px; line-height: 1.6; }
}
