:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #eceef1;
  --text: #191f28;
  --text-sub: #6b7684;
  --text-faint: #adb5bd;
  --accent: #3182f6;
  --accent-soft: #e8f1fe;
  --danger: #f04452;
  --danger-soft: #fdecee;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Pretendard", "Noto Sans KR", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(140px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }

/* ---------- 검색 화면 ---------- */

.search-hero { text-align: center; padding: 64px 0 32px; }
.search-hero h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.search-hero .sub { margin-top: 8px; color: var(--text-sub); font-size: 15px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 6px 6px 6px 14px;
  transition: border-color .15s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-icon { width: 20px; height: 20px; color: var(--text-faint); flex: none; }
.search-box input {
  flex: 1; min-width: 0; border: 0; outline: none;
  font: inherit; font-size: 16px; padding: 10px 0; background: transparent;
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-box button {
  flex: none; background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 700;
  padding: 10px 18px; border-radius: 10px;
}
.search-box button:active { opacity: .85; }

.school-list { list-style: none; margin-top: 16px; }
.school-list li + li { margin-top: 8px; }
.school-item {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.school-item:active { background: var(--accent-soft); border-color: var(--accent); }
.school-item .region {
  flex: none; font-size: 12px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  padding: 4px 8px; border-radius: 8px;
}
.school-item .name { font-size: 15.5px; font-weight: 600; word-break: keep-all; }

.status-msg { text-align: center; color: var(--text-sub); font-size: 14px; padding: 20px 0; }
.status-msg:empty { display: none; }

/* ---------- 광고 ---------- */

.ad-slot {
  display: flex;
  justify-content: center;
  width: 100%;
}
#search-ad-slot { margin-top: 28px; }
#timetable-ad-slot { margin-bottom: 16px; }
.ad-shell {
  width: 100%;
  height: 100px;
  min-height: 100px;
  display: grid;
  place-items: center;
  background: var(--card);
}
.ad-shell .kakao_ad_area {
  flex: none;
  width: 100% !important;
  min-width: 0;
  max-width: 100%;
  height: 100px !important;
  min-height: 100px;
}
.ad-shell iframe {
  display: block;
  width: 100% !important;
  height: 100px !important;
  border: 0;
}

/* ---------- 시간표 화면 ---------- */

.tt-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 6px 2px 16px;
}
.school-name {
  display: flex; align-items: center; gap: 4px;
  font-size: 19px; font-weight: 800; letter-spacing: -0.4px;
  min-width: 0;
}
.school-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.school-name svg { width: 16px; height: 16px; color: var(--text-faint); flex: none; }
.school-name:active { opacity: .6; }

.week-select {
  flex: none; max-width: 46%;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-sub);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px;
  -webkit-appearance: none; appearance: none; outline: none;
}

.picker-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
}

.segmented { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; }
.segmented button {
  flex: 1; padding: 9px 0; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--text-sub);
}
.segmented button.active {
  background: var(--card); color: var(--text); font-weight: 800;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.chip-row {
  display: flex; gap: 6px; margin-top: 10px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row button {
  flex: none; min-width: 46px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--text-sub);
  background: var(--card);
}
.chip-row button.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 700;
}

.day-tabs { display: flex; gap: 4px; margin: 14px 0 10px; }
.day-tabs button {
  flex: 1; padding: 8px 0 9px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.day-tabs .d-name { font-size: 14px; font-weight: 700; color: var(--text-sub); }
.day-tabs .d-date { font-size: 11px; color: var(--text-faint); }
.day-tabs button.active { background: var(--text); }
.day-tabs button.active .d-name { color: #fff; }
.day-tabs button.active .d-date { color: rgba(255,255,255,.65); }
.day-tabs button.today:not(.active) .d-name { color: var(--accent); }

.notice {
  background: var(--accent-soft); color: #1b64da;
  border-radius: 12px; padding: 12px 14px;
  font-size: 13px; line-height: 1.5; margin-bottom: 10px;
  word-break: keep-all;
}

/* 수업 목록 */
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 16px;
}
.lesson .no {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.lesson .no b { font-size: 15px; font-weight: 800; line-height: 1.1; }
.lesson .no small { font-size: 9.5px; color: var(--text-faint); }
.lesson .info { flex: 1; min-width: 0; }
.lesson .subject { font-size: 15.5px; font-weight: 700; letter-spacing: -0.2px; }
.lesson .meta { font-size: 13px; color: var(--text-sub); margin-top: 2px; }
.lesson.is-empty { border-style: dashed; background: transparent; }
.lesson.is-empty .subject { color: var(--text-faint); font-weight: 500; }

.lesson.is-changed { border-color: #f8c8cd; background: #fffafa; }
.lesson.is-changed .no { background: var(--danger-soft); }
.lesson.is-changed .no b { color: var(--danger); }
.badge-changed {
  flex: none; font-size: 11px; font-weight: 700;
  color: var(--danger); background: var(--danger-soft);
  padding: 4px 8px; border-radius: 8px;
}

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

/* ---------- 하단 바 ---------- */

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bottom-bar > div, .bottom-bar > button { max-width: 560px; margin-left: auto; margin-right: auto; }
.updated-at { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-bottom: 6px; }
.updated-at:empty { display: none; }
.refresh-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 0;
  background: var(--accent); color: #fff;
  border-radius: 14px; font-size: 16px; font-weight: 700;
  transition: opacity .15s;
}
.refresh-btn:active { opacity: .85; }
.refresh-btn:disabled { opacity: .5; }
.refresh-btn svg { width: 18px; height: 18px; }
.refresh-btn.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 크레딧 ---------- */

.credit {
  text-align: center; font-size: 11.5px; color: var(--text-faint);
  margin-top: 28px;
}
#search-ad-slot + .credit { margin-top: 12px; }
.bottom-bar .credit { margin-top: 7px; }
.credit a { color: var(--text-sub); font-weight: 700; text-decoration: none; }
.credit a:active { color: var(--text); }

/* ---------- 토스트 ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(124px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: rgba(25,31,40,.92); color: #fff;
  font-size: 13.5px; font-weight: 500;
  padding: 11px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 85vw; text-align: center; z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 스켈레톤 로딩 */
.skeleton {
  border-radius: var(--radius); height: 66px;
  background: linear-gradient(90deg, #eef0f3 25%, #f6f8fa 50%, #eef0f3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
