:root {
  --primary: #1976D2;
  --primary-light: #E3F2FD;
  --bg: #F5F5F5;
  --card-bg: #FFFFFF;
  --text: #212121;
  --text-secondary: #757575;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --border: #E0E0E0;
}
[data-theme="dark"] {
  --primary: #90CAF9;
  --primary-light: #1A3A5C;
  --bg: #121212;
  --card-bg: #1E1E1E;
  --text: #E0E0E0;
  --text-secondary: #9E9E9E;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --border: #333333;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.header {
  padding: 20px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 { font-size: 18px; font-weight: 700; white-space: nowrap; }
.header-btns { display: flex; gap: 8px; }
.header-icon {
  background: none;
  border: none;
  cursor: pointer;
  width: 44px; height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
  -webkit-appearance: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.notice-bar {
  margin: 0 16px 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-line;
}
.notice-bar.info    { background: #E3F2FD; color: #1565C0; }
.notice-bar.warn    { background: #FFF3E0; color: #E65100; }
.notice-bar.success { background: #E8F5E9; color: #2E7D32; }
.notice-bar.error   { background: #FFEBEE; color: #C62828; }
[data-theme="dark"] .notice-bar.info    { background: #0D2B40; color: #90CAF9; }
[data-theme="dark"] .notice-bar.warn    { background: #3E2000; color: #FFB74D; }
[data-theme="dark"] .notice-bar.success { background: #0D2810; color: #81C784; }
[data-theme="dark"] .notice-bar.error   { background: #3E0000; color: #EF9A9A; }

.section {
  background: var(--card-bg);
  border-radius: 12px;
  margin: 12px 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.section-title {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 12px 16px 4px;
  letter-spacing: 0.5px;
}

.tabs {
  display: flex;
  padding: 12px 16px;
  gap: 12px;
}
.tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-secondary);
  transition: all 0.2s;
  border: none;
  -webkit-appearance: none;
}
.tab.active {
  background: var(--primary);
  color: white;
}

.building-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px 16px;
}
.bld-cell {
  padding: 12px 4px;
  text-align: center;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  transition: all 0.15s;
  -webkit-appearance: none;
  user-select: none;
}
.bld-cell.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.bld-cell:active { transform: scale(0.95); }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px 16px;
}
.slot-cell {
  padding: 10px 4px;
  text-align: center;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  transition: all 0.15s;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  user-select: none;
}
.slot-cell .slot-num { font-weight: 600; font-size: 12px; }
.slot-cell .slot-time { font-size: 11px; opacity: 0.8; }
.slot-cell.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.slot-cell:active { transform: scale(0.95); }
.slot-cell.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}
.slot-cell.toggle-all {
  background: var(--card-bg);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  justify-content: center;
}

.count {
  padding: 16px 20px 4px;
  font-size: 14px;
  color: var(--text-secondary);
}
.room-list {
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.room-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.room-card:active { transform: scale(0.98); }
.room-info { display: flex; flex-direction: column; gap: 4px; }
.room-name { font-size: 18px; font-weight: 600; }
.room-building { font-size: 13px; color: var(--text-secondary); }
.room-capacity {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.footer-update {
  font-size: 12px;
  opacity: 0.7;
}
.footer-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
}
.github-link {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.github-link:hover { color: var(--text); }

.loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.error {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-hint {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}
.error p { margin-bottom: 16px; }
.retry-btn {
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}

/* Bus Schedule */
.day-picker {
  display: flex;
  gap: 6px;
}
.day-cell {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.day-cell small { font-size: 10px; font-weight: 400; }
.day-cell.selected { background: var(--primary); color: white; border-color: var(--primary); }
.day-cell.today:not(.selected) { border-color: var(--primary); color: var(--primary); }

.bus-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}
.bus-date-label { font-size: 14px; color: var(--text-secondary); }
.bus-date-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-appearance: none;
}
.bus-date-weekday { font-size: 15px; font-weight: 500; }
.bus-route-title { font-size: 17px; font-weight: 600; padding: 0 4px 4px; }
.bus-route-departure { font-size: 12px; color: var(--text-secondary); padding: 0 4px 4px; }
.bus-card-list { display: flex; flex-direction: column; gap: 8px; }
.bus-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.bus-card-time { font-size: 20px; font-weight: 700; color: var(--primary); min-width: 64px; }
.bus-card-icons { display: flex; gap: 4px; align-items: center; }
.bus-icon { display: block; }
.bus-card-vehicle { font-size: 15px; color: var(--text-secondary); }
.bus-card.departed { opacity: 0.55; }
.bus-card.departed .bus-card-time { color: var(--text-secondary); opacity: 0.7; }
.bus-card.departed .bus-card-icons { filter: grayscale(1); }
.bus-departed-msg { font-size: 13px; color: var(--text-secondary); flex: 1; text-align: center; }
.bus-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
}
.bus-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 480px; }
.bus-table th, .bus-table td { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--border); }
.bus-table th { background: var(--primary); color: white; font-weight: 500; font-size: 11px; }
.bus-table th:first-child { border-radius: var(--radius) 0 0 0; }
.bus-table th:last-child { border-radius: 0 var(--radius) 0 0; }
.bus-table td:first-child { font-weight: 600; color: var(--primary); white-space: nowrap; }
.bus-table td.empty { color: #CCC; }
.bus-table .today-col { background: var(--primary-light); }
.bus-note { padding: 12px 20px; font-size: 12px; color: var(--text-secondary); }
.bus-notice {
  margin: 0 16px 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  background: #E3F2FD;
  color: #1565C0;
}
[data-theme="dark"] .bus-notice {
  background: #0D2B40;
  color: #90CAF9;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet {
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px 20px 32px;
  animation: slideUp 0.25s;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-room-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.modal-room-bld { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }
.modal-section { margin-bottom: 14px; }
.modal-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.modal-value { font-size: 15px; }
.modal-slots { display: flex; flex-wrap: wrap; gap: 6px; }
.modal-slot-tag {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 13px;
  background: #E8F5E9;
  color: #2E7D32;
}
[data-theme="dark"] .modal-slot-tag {
  background: #1B3A1B;
  color: #81C784;
}
.modal-close {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--bg);
  font-size: 15px;
  cursor: pointer;
  color: var(--text-secondary);
}

/* Feedback */
.feedback-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  margin-top: 16px;
}
.feedback-input:focus { outline: none; border-color: var(--primary); }
.faq-toggle {
  margin: 8px 0 4px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
  color: var(--primary);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.faq-panel {
  margin-bottom: 8px;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.faq-section { margin-bottom: 10px; }
.faq-section:last-child { margin-bottom: 0; }
.faq-q { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.faq-a { color: var(--text-secondary); }
.search-result-card { margin-top: 8px; }
.search-select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-appearance: none;
}

/* Settings Modal */
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.settings-label { font-size: 15px; }
.toggle-switch {
  width: 48px; height: 28px;
  border-radius: 14px;
  border: none;
  background: #CCC;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  -webkit-appearance: none;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
}
.toggle-switch.on {
  background: var(--primary);
}
.toggle-switch.on::after {
  transform: translateX(20px);
}
