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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.page {
  display: none;
}

.page.active {
  display: flex;
}

/* ===== Search Page ===== */
#search-page {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: #fafbfc;
  padding: 24px 20px;
}

@media (min-width: 600px) {
  #search-page {
    background: #f0f2f5;
  }

  .search-container {
    background: #fff;
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  }
}

.search-container {
  text-align: center;
  width: 100%;
  max-width: 720px;
}

.search-container .logo-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-light {
  display: block;
}

.logo-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .logo-light {
    display: none;
  }
  .logo-dark {
    display: block;
  }
  .search-container .logo-icon {
    background: #1a1a2e;
    border-color: #333;
  }
}

.search-container h1 {
  color: #1a1a2e;
  font-size: 1.6rem;
  margin-bottom: 0.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.subtitle {
  color: #888;
  margin-bottom: 2rem;
  font-size: 0.88rem;
}

.search-box {
  display: flex;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: #1a1a2e;
  box-shadow: 0 4px 20px rgba(26,26,46,0.08);
}

.search-box input {
  flex: 1;
  padding: 15px 18px;
  border: none;
  font-size: 0.95rem;
  outline: none;
  background: transparent;
  color: #1a1a2e;
  min-width: 0;
}

.search-box input::placeholder {
  color: #bbb;
}

.search-box button {
  padding: 15px 24px;
  border: none;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-box button:hover {
  background: #2d2d4a;
}

.search-results {
  margin-top: 10px;
  background: #fff;
  border-radius: 14px;
  max-height: 50vh;
  overflow-y: auto;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  border: 1px solid #eee;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  padding: 14px 18px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.15s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:active {
  background: #f3f4f6;
}

.search-result-item .school-name {
  font-weight: 600;
  font-size: 0.93rem;
  color: #1a1a2e;
}

.search-result-item .school-meta {
  font-size: 0.78rem;
  color: #999;
  margin-top: 3px;
}

.search-result-item .school-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 6px;
  vertical-align: middle;
}

.type-elementary { background: #ecfdf5; color: #059669; }
.type-middle { background: #eff6ff; color: #2563eb; }
.type-high { background: #fef2f2; color: #dc2626; }
.type-other { background: #f5f3ff; color: #7c3aed; }

.loading-msg {
  padding: 24px;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
}

.error-msg {
  padding: 16px 20px;
  color: #c62828;
  font-size: 0.88rem;
  text-align: center;
}

/* ===== Info Page ===== */
#info-page {
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
}

#info-page > * {
  width: 100%;
  max-width: 720px;
}

@media (min-width: 600px) {
  #info-page {
    background: #f0f2f5;
    padding: 0 24px;
  }

  #info-page > header,
  #info-page > .tab-bar,
  #info-page > .tab-content {
    max-width: 720px;
  }

  #info-page > header {
    border-radius: 0 0 14px 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  }

  .panel-content {
    box-shadow: 0 2px 16px rgba(0,0,0,0.07);
  }
}

/* ===== Header ===== */
header {
  background: #fff;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-btn {
  background: none;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  white-space: nowrap;
  color: #555;
  flex-shrink: 0;
}

.back-btn:active {
  background: #f3f4f6;
}

header h2 {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.control-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

.control-group input[type="text"],
.control-group select {
  padding: 7px 8px;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.control-group input[type="text"]:focus,
.control-group select:focus {
  border-color: #1a1a2e;
}

.date-group {
  gap: 4px;
}

.date-group #date-input {
  width: 120px;
  font-family: inherit;
}

.hidden-date {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.calendar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1.5px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
  line-height: 1;
  flex-shrink: 0;
}

.calendar-btn:active {
  background: #f3f4f6;
}

#timetable-refresh-btn {
  padding: 7px 12px;
  border: none;
  background: #1a1a2e;
  color: #fff;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

#timetable-refresh-btn:active {
  background: #2d2d4a;
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.tab-btn {
  flex: 1;
  padding: 13px 0;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  background: transparent;
  transition: background 0.2s;
}

.tab-btn:active {
  background: #f9fafb;
}

.tab-btn.active {
  color: #1a1a2e;
}

.tab-btn.active::after {
  background: #1a1a2e;
}

.tab-content {
  flex: 1;
  padding: 14px 14px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-content {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  padding: 18px 16px;
  overflow-y: auto;
  max-height: calc(100dvh - 180px);
  -webkit-overflow-scrolling: touch;
}

.placeholder {
  color: #aaa;
  text-align: center;
  padding: 40px 0;
  font-size: 0.9rem;
}

/* ===== Meal styles ===== */
.meal-date-label {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 12px;
  text-align: center;
}

.meal-type {
  margin-bottom: 16px;
}

.meal-type-label {
  display: inline-block;
  background: #ecfdf5;
  color: #059669;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.meal-items {
  list-style: none;
}

.meal-items li {
  padding: 7px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid #f5f5f5;
  line-height: 1.4;
}

.meal-items li:last-child {
  border-bottom: none;
}

.meal-calories {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #888;
  text-align: right;
}

.meal-no-data {
  text-align: center;
  color: #aaa;
  padding: 40px 0;
  font-size: 0.9rem;
}

/* ===== Timetable styles ===== */
.timetable-table {
  width: 100%;
  border-collapse: collapse;
}

.timetable-table th {
  background: #eff6ff;
  color: #2563eb;
  padding: 11px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.timetable-table td {
  padding: 11px 8px;
  text-align: center;
  font-size: 0.88rem;
  border-bottom: 1px solid #f0f0f0;
}

.timetable-table tr:last-child td {
  border-bottom: none;
}

.timetable-table tr:nth-child(even) {
  background: #fafbff;
}

.timetable-table .period-num {
  font-weight: 700;
  color: #2563eb;
  width: 50px;
}

.timetable-table .lunch-row td {
  background: #fff8e1;
  color: #f57f17;
  font-weight: 600;
  font-size: 0.82rem;
}

/* ===== Responsive: 480px 미만 ===== */
@media (max-width: 480px) {
  #search-page {
    padding: 20px 16px;
  }

  .search-container h1 {
    font-size: 1.4rem;
  }

  .subtitle {
    margin-bottom: 1.6rem;
    font-size: 0.85rem;
  }

  .search-box {
    flex-direction: column;
    border-radius: 12px;
  }

  .search-box input,
  .search-box button {
    border-radius: 0;
    padding: 14px 16px;
  }

  .search-box input {
    border-bottom: 1px solid #eee;
  }

  header {
    padding: 10px 12px;
    gap: 8px;
  }

  header h2 {
    font-size: 0.92rem;
  }

  .controls {
    gap: 6px;
  }

  .control-group label {
    font-size: 0.75rem;
  }

  .control-group input[type="text"],
  .control-group select {
    padding: 6px 6px;
    font-size: 0.82rem;
  }

  .date-group #date-input {
    width: 105px;
  }

  .tab-content {
    padding: 10px 10px;
  }

  .panel-content {
    padding: 16px 14px;
    border-radius: 12px;
    max-height: calc(100dvh - 200px);
  }

  .meal-items li {
    padding: 6px 0;
    font-size: 0.87rem;
  }

  .timetable-table td,
  .timetable-table th {
    padding: 9px 6px;
    font-size: 0.83rem;
  }
}
