/* ==========================================================================
   구리고등학교 스마트 시간표 & 급식 포털 - CSS 스타일시트
   컴시간알리미, 나이스 급식 & T-Rex 공룡 달리기 게임 테마
   ========================================================================== */

:root {
  /* Brand Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg-main: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --surface-border: #e2e8f0;

  /* Tag Colors */
  --comci-color: #f59e0b;
  --comci-bg: #fef3c7;
  --neis-color: #10b981;
  --neis-bg: #d1fae5;
  --dino-color: #8b5cf6;
  --dino-bg: #ede9fe;

  /* Typography */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --live-color: #10b981;

  /* Shadows & Radius */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  /* Transitions */
  --trans: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Subject Color Palette (Light Theme) */
  --color-blue-bg: #e0f2fe;    --color-blue-text: #0369a1;    --color-blue-border: #0284c7;
  --color-red-bg: #fee2e2;     --color-red-text: #b91c1c;     --color-red-border: #dc2626;
  --color-orange-bg: #ffedd5;  --color-orange-text: #c2410c;  --color-orange-border: #ea580c;
  --color-emerald-bg: #d1fae5; --color-emerald-text: #047857; --color-emerald-border: #059669;
  --color-amber-bg: #fef3c7;   --color-amber-text: #b45309;   --color-amber-border: #d97706;
  --color-teal-bg: #ccfbf1;    --color-teal-text: #0f766e;    --color-teal-border: #0d9488;
  --color-purple-bg: #f3e8ff;  --color-purple-text: #7e22ce;  --color-purple-border: #9333ea;
  --color-indigo-bg: #e0e7ff;  --color-indigo-text: #4338ca;  --color-indigo-border: #4f46e5;
  --color-pink-bg: #fce7f3;    --color-pink-text: #be185d;    --color-pink-border: #db2777;
  --color-slate-bg: #f1f5f9;   --color-slate-text: #334155;   --color-slate-border: #64748b;
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-light: #1e293b;
  --bg-main: #0b1120;
  --surface: #1e293b;
  --surface-alt: #0f172a;
  --surface-border: #334155;

  --comci-color: #fbbf24;
  --comci-bg: #78350f;
  --neis-color: #34d399;
  --neis-bg: #064e3b;
  --dino-color: #c084fc;
  --dino-bg: #581c87;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);

  /* Subject Colors Dark */
  --color-blue-bg: #0c4a6e;    --color-blue-text: #bae6fd;    --color-blue-border: #38bdf8;
  --color-red-bg: #7f1d1d;     --color-red-text: #fecaca;     --color-red-border: #f87171;
  --color-orange-bg: #7c2d12;  --color-orange-text: #fed7aa;  --color-orange-border: #fb923c;
  --color-emerald-bg: #064e3b; --color-emerald-text: #a7f3d0; --color-emerald-border: #34d399;
  --color-amber-bg: #78350f;   --color-amber-text: #fde68a;   --color-amber-border: #fbbf24;
  --color-teal-bg: #134e4a;    --color-teal-text: #99f6e4;    --color-teal-border: #2dd4bf;
  --color-purple-bg: #581c87;  --color-purple-text: #e9d5ff;  --color-purple-border: #c084fc;
  --color-indigo-bg: #312e81;  --color-indigo-text: #c7d2fe;  --color-indigo-border: #818cf8;
  --color-pink-bg: #831843;    --color-pink-text: #fbcfe8;    --color-pink-border: #f472b6;
  --color-slate-bg: #334155;   --color-slate-text: #e2e8f0;   --color-slate-border: #94a3b8;
}

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

body {
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color var(--trans), color var(--trans);
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 20px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
}

/* Offline Notification Banner */
.offline-banner {
  display: none;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: slide-down 0.3s ease;
}

.offline-banner.active {
  display: block;
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.offline-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.offline-icon { font-size: 1.5rem; }
.offline-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.offline-text strong { font-size: 0.96rem; font-weight: 800; }
.offline-text span { font-size: 0.84rem; opacity: 0.92; }

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.school-emblem {
  font-size: 2.2rem;
  line-height: 1;
}

.logo-titles {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.school-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.school-region {
  font-size: 0.74rem;
  font-weight: 700;
  background-color: var(--primary);
  color: white;
  padding: 1px 8px;
  border-radius: var(--radius-full);
}

.school-type {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sync-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: var(--radius-full);
}

.comci-badge { background-color: var(--comci-bg); color: var(--comci-color); }
.neis-badge { background-color: var(--neis-bg); color: var(--neis-color); }
.dino-badge { background-color: var(--dino-bg); color: var(--dino-color); }

.logo-text {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live-clock-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  font-variant-numeric: tabular-nums;
}

.sync-icon.rotating {
  display: inline-block;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Selector Card */
.selector-card {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.selector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.selector-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.selector-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

.grade-tabs {
  display: flex;
  background-color: var(--surface-alt);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  gap: 4px;
}

.grade-tab {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--trans);
}

.grade-tab.active {
  background-color: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.form-select {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  background-color: var(--surface-alt);
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  transition: border-color var(--trans);
}

.form-select:focus {
  border-color: var(--primary);
}

.week-nav-group {
  margin-left: auto;
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--surface-alt);
  padding: 3px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
}

.week-nav-btn {
  background: transparent;
  border: none;
  padding: 4px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.week-nav-btn:hover {
  background-color: var(--surface);
}

.week-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 0 4px;
  min-width: 90px;
  text-align: center;
}

/* API Sync Status Bar */
.api-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding-top: 6px;
  border-top: 1px dashed var(--surface-border);
  flex-wrap: wrap;
}

.sync-status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sync-divider {
  color: var(--surface-border);
}

.api-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
}

.dot-comci { background-color: var(--comci-color); }
.dot-neis { background-color: var(--neis-color); }

.online-indicator-text {
  font-weight: 700;
  color: var(--success);
}

.online-indicator-text.offline {
  color: var(--danger);
}

/* Live Status Banner */
.live-status-bar {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-alt) 100%);
  border: 1px solid var(--surface-border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  background-color: var(--live-color);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-ring 1.8s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-badge {
  font-size: 0.8rem;
  font-weight: 700;
  background-color: var(--primary);
  color: white;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.status-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-content strong {
  font-size: 1.05rem;
  color: var(--text-main);
}

.status-content span {
  font-size: 0.87rem;
  color: var(--text-muted);
}

.status-time {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.tab-group {
  display: flex;
  background-color: var(--surface-alt);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  gap: 4px;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--trans);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn.active {
  background-color: var(--surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.tab-btn.tab-dino.active {
  background: linear-gradient(135deg, var(--dino-color) 0%, #6366f1 100%);
  color: white;
}

.quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.day-filter {
  display: none;
  background-color: var(--surface-alt);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
  gap: 2px;
}

.day-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}

.day-btn.active {
  background-color: var(--primary);
  color: white;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--trans);
  text-decoration: none;
}

.btn-sm { padding: 6px 12px; font-size: 0.84rem; }
.btn-xs { padding: 3px 9px; font-size: 0.78rem; border-radius: 4px; }
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-warning { background-color: var(--comci-color); color: white; }
.btn-warning:hover { filter: brightness(0.95); }
.btn-secondary { background-color: var(--surface); color: var(--text-main); border: 1px solid var(--surface-border); }
.btn-secondary:hover { background-color: var(--surface-alt); }
.btn-outline { background-color: transparent; color: var(--text-muted); border: 1px solid var(--surface-border); }
.btn-outline:hover { background-color: var(--surface-alt); color: var(--text-main); }
.btn-danger-outline { background-color: transparent; color: var(--danger); border: 1px solid var(--danger); }

.btn-icon {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.05rem;
}

.btn-text-link {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

/* View Panels */
.main-content { flex: 1; }
.view-panel { display: none; }
.view-panel.active { display: block; }

/* Weekly Timetable Table */
.timetable-card {
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.timetable-header-info {
  padding: 14px 20px;
  background-color: var(--surface-alt);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.current-view-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.05rem;
}

.date-range-badge {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.source-tags-group { display: flex; gap: 6px; }
.source-tag { font-size: 0.78rem; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-full); }
.tag-applied {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(245, 158, 11, 0.2) 100%);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.table-responsive { width: 100%; overflow-x: auto; }
.timetable { width: 100%; border-collapse: collapse; text-align: center; table-layout: fixed; }

.timetable th {
  padding: 12px 10px;
  background-color: var(--surface-alt);
  border-bottom: 2px solid var(--surface-border);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
}

.timetable th.col-period { width: 110px; font-size: 0.82rem; color: var(--text-muted); }
.th-day-title { font-weight: 800; }
.th-day-date { font-size: 0.75rem; font-weight: 500; color: var(--text-light); margin-top: 2px; }

.timetable th.col-day.today-col-head {
  background-color: var(--primary-light);
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.timetable td {
  padding: 6px;
  border: 1px solid var(--surface-border);
  vertical-align: middle;
  height: 88px;
}

.timetable td.period-label-cell {
  background-color: var(--surface-alt);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px;
}

.period-num { font-size: 1.05rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 2px; }
.period-time-range { font-size: 0.75rem; color: var(--text-light); display: block; font-variant-numeric: tabular-nums; }

.timetable tr.break-row td {
  height: 44px;
  background-color: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.85rem;
}

.subject-slot {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  cursor: pointer;
  transition: transform var(--trans), box-shadow var(--trans);
}

.subject-slot:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); filter: brightness(0.97); }
.subject-slot.empty-slot { background-color: transparent; border: 1.5px dashed var(--surface-border); color: var(--text-light); }
.empty-plus { font-size: 1.1rem; opacity: 0.6; }
.subject-name { font-size: 0.95rem; font-weight: 800; line-height: 1.25; margin-bottom: 2px; word-break: break-word; }

.subject-details {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  opacity: 0.88;
  line-height: 1.2;
}

.subject-room, .subject-teacher { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timetable td.current-active-cell .subject-slot {
  box-shadow: 0 0 0 2.5px var(--live-color);
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 2px var(--live-color); }
  50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.4); }
  100% { box-shadow: 0 0 0 2px var(--live-color); }
}

.timetable-footer-info {
  padding: 12px 20px;
  background-color: var(--surface-alt);
  border-top: 1px solid var(--surface-border);
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Subject Colors */
.color-blue { background-color: var(--color-blue-bg); color: var(--color-blue-text); border-left: 4px solid var(--color-blue-border); }
.color-red { background-color: var(--color-red-bg); color: var(--color-red-text); border-left: 4px solid var(--color-red-border); }
.color-orange { background-color: var(--color-orange-bg); color: var(--color-orange-text); border-left: 4px solid var(--color-orange-border); }
.color-emerald { background-color: var(--color-emerald-bg); color: var(--color-emerald-text); border-left: 4px solid var(--color-emerald-border); }
.color-amber { background-color: var(--color-amber-bg); color: var(--color-amber-text); border-left: 4px solid var(--color-amber-border); }
.color-teal { background-color: var(--color-teal-bg); color: var(--color-teal-text); border-left: 4px solid var(--color-teal-border); }
.color-purple { background-color: var(--color-purple-bg); color: var(--color-purple-text); border-left: 4px solid var(--color-purple-border); }
.color-indigo { background-color: var(--color-indigo-bg); color: var(--color-indigo-text); border-left: 4px solid var(--color-indigo-border); }
.color-pink { background-color: var(--color-pink-bg); color: var(--color-pink-text); border-left: 4px solid var(--color-pink-border); }
.color-slate { background-color: var(--color-slate-bg); color: var(--color-slate-text); border-left: 4px solid var(--color-slate-border); }

/* Today's Dashboard Grid */
.today-dashboard-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: start;
}

.today-classes-col, .today-meal-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.today-header-card {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.today-badge, .meal-badge, .dino-badge-tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 4px;
}

.today-badge { background-color: var(--primary-light); color: var(--primary); }
.dino-badge-tag { background-color: var(--dino-bg); color: var(--dino-color); font-family: monospace; font-weight: 900; }

.today-title-area h2 { font-size: 1.35rem; font-weight: 800; }
.today-class-subtitle { font-size: 0.86rem; color: var(--text-muted); }
.today-summary strong { color: var(--primary); font-size: 1.2rem; }

.today-timeline { display: flex; flex-direction: column; gap: 10px; }

.today-card {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: all var(--trans);
}

.today-card:hover { transform: translateX(3px); box-shadow: var(--shadow-md); }
.today-card.status-ongoing {
  border-left: 6px solid var(--live-color);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08) 0%, var(--surface) 100%);
}
.today-card.status-completed { opacity: 0.55; }

.today-card-period { display: flex; flex-direction: column; align-items: center; min-width: 44px; }
.today-period-num { font-size: 1.15rem; font-weight: 800; }
.today-card-body { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.today-card-top { display: flex; align-items: center; gap: 8px; }
.today-subject-name { font-size: 1.05rem; font-weight: 800; }
.today-card-meta { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-muted); }
.today-card-time { font-size: 0.82rem; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.badge-tag { font-size: 0.72rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; }
.badge-ongoing { background-color: var(--live-color); color: white; }
.badge-completed { background-color: var(--surface-alt); color: var(--text-muted); }
.badge-upcoming { background-color: var(--primary-light); color: var(--primary); }

/* Quick Meal Card */
.quick-meal-card {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quick-meal-header { display: flex; justify-content: space-between; align-items: center; }
.meal-mini-badge { font-size: 0.72rem; font-weight: 700; background-color: var(--neis-bg); color: var(--neis-color); padding: 2px 7px; border-radius: var(--radius-full); }
.quick-meal-title-box h3 { font-size: 1.15rem; font-weight: 800; margin-top: 4px; }
.quick-meal-cal { font-size: 0.92rem; font-weight: 800; color: var(--primary); background-color: var(--surface-alt); padding: 4px 10px; border-radius: var(--radius-sm); }
.quick-meal-list { display: flex; flex-direction: column; gap: 8px; }
.quick-meal-item { font-size: 0.96rem; font-weight: 700; padding: 8px 12px; background-color: var(--surface-alt); border-radius: var(--radius-sm); color: var(--text-main); }
.quick-meal-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: var(--text-muted); padding-top: 8px; border-top: 1px dashed var(--surface-border); }

/* Helper Card */
.comci-helper-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, var(--surface) 100%);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comci-helper-card h4 { font-size: 0.95rem; font-weight: 800; color: var(--comci-color); }
.comci-helper-card p { font-size: 0.84rem; color: var(--text-muted); line-height: 1.45; }
.comci-helper-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* Meal Full View */
.meal-container, .comci-container, .dino-game-container {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 840px;
  margin: 0 auto;
}

.meal-header-card, .comci-header-card, .dino-header-card {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.meal-title-area h2, .comci-title-area h2, .dino-title-area h2 { font-size: 1.4rem; font-weight: 800; }
.meal-school-name, .comci-title-area p, .dino-title-area p { font-size: 0.88rem; color: var(--text-muted); margin-top: 2px; }

.meal-calorie-badge {
  background-color: var(--surface-alt);
  border: 1px solid var(--surface-border);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
}

.meal-content-card, .comci-content-card {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.meal-icon-hero { font-size: 3rem; text-align: center; }
.meal-menu-list { display: flex; flex-direction: column; gap: 10px; max-width: 500px; margin: 0 auto; width: 100%; }

.meal-dish-item {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 10px 16px;
  background-color: var(--surface-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
}

.meal-ntr-info { font-size: 0.8rem; color: var(--text-light); line-height: 1.6; text-align: center; }

/* Comci Integration Steps & Frame */
.comci-integration-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.comci-step-box { display: flex; gap: 12px; padding: 14px; background-color: var(--surface-alt); border-radius: var(--radius-md); border: 1px solid var(--surface-border); }
.step-num { width: 28px; height: 28px; border-radius: 50%; background-color: var(--comci-color); color: white; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; flex-shrink: 0; }
.comci-step-box strong { font-size: 0.92rem; color: var(--text-main); }
.comci-step-box p { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.comci-frame-wrapper { border: 1px solid var(--surface-border); border-radius: var(--radius-md); overflow: hidden; background-color: var(--surface-alt); }
.comci-frame-header { padding: 10px 16px; background-color: var(--surface); border-bottom: 1px solid var(--surface-border); display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; font-weight: 700; }
.comci-link { color: var(--primary); text-decoration: none; }
.comci-frame-container { position: relative; min-height: 380px; display: flex; align-items: center; justify-content: center; }
.comci-iframe { width: 100%; height: 480px; border: none; }
.comci-fallback-overlay { padding: 32px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.comci-fallback-box { max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.comci-hero-icon { font-size: 2.8rem; }
.comci-fallback-box h3 { font-size: 1.2rem; font-weight: 800; }
.comci-fallback-box p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

/* ==========================================================================
   Chrome T-Rex Dinosaur Game Styles
   ========================================================================== */
.dino-scores-box {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'Press Start 2P', monospace, sans-serif;
  background-color: var(--surface-alt);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
}

/* Main Dino Difficulty Bar */
.dino-diff-bar {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.diff-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.diff-bar-left strong {
  color: var(--danger);
  font-size: 0.92rem;
}

.diff-btn-group {
  display: flex;
  background-color: var(--surface-alt);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 4px;
}

.btn-main-diff {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 0.84rem;
  font-weight: 800;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--trans);
}

.btn-main-diff.active[data-diff="normal"] { background-color: var(--success); color: white; }
.btn-main-diff.active[data-diff="hard"] { background-color: var(--warning); color: white; }
.btn-main-diff.active[data-diff="hell"] { background-color: var(--danger); color: white; box-shadow: 0 0 8px rgba(239, 68, 68, 0.4); }

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.current-score-item .score-val {
  color: var(--primary);
  font-weight: 900;
}

.score-label {
  font-size: 0.72rem;
  opacity: 0.7;
}

.dino-canvas-card {
  background-color: var(--surface);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.canvas-responsive-wrapper {
  width: 100%;
  max-width: 800px;
  display: flex;
  justify-content: center;
}

#dino-canvas {
  width: 100%;
  height: auto;
  max-width: 800px;
  aspect-ratio: 800 / 240;
  background-color: #fafafa;
  border-radius: var(--radius-sm);
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  display: block;
}

[data-theme="dark"] #dino-canvas {
  background-color: #111827;
}

/* Dino Overlay (Start & Game Over) */
.dino-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--trans);
  z-index: 10;
}

.dino-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.dino-overlay-content {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 24px 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 380px;
}

.dino-hero-emoji { font-size: 2.8rem; }
.dino-overlay-content h3 { font-size: 1.25rem; font-weight: 800; }
.dino-overlay-content p { font-size: 0.85rem; color: var(--text-muted); }

/* Controls Panel */
.dino-controls-panel {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.dino-key-guides {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.key-guide-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.key-badge {
  background-color: var(--surface-alt);
  border: 1px solid var(--surface-border);
  box-shadow: 0 2px 0 var(--surface-border);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text-main);
}

/* Mobile Touch Controls */
.mobile-dino-controls {
  display: none;
  gap: 12px;
  width: 100%;
}

.touch-control-btn {
  flex: 1;
  padding: 14px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
}

.touch-control-btn:active {
  transform: scale(0.96);
}

.btn-jump {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-duck {
  background-color: var(--surface-alt);
  color: var(--text-main);
  border: 1.5px solid var(--surface-border);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans);
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-card {
  background-color: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform var(--trans);
}

.modal-card-lg { max-width: 580px; }
.modal-overlay.active .modal-card { transform: scale(1); }

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1.12rem; font-weight: 800; }
.modal-close { background: transparent; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-desc { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-group label { font-size: 0.85rem; font-weight: 700; color: var(--text-main); }
.form-group label .req { color: var(--danger); }

.form-input, .form-textarea {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
  background-color: var(--bg-main);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--trans);
}

.form-textarea {
  resize: vertical;
  line-height: 1.5;
  font-family: monospace, sans-serif;
  font-size: 0.88rem;
}

.form-input:focus, .form-textarea:focus { border-color: var(--primary); }
.paste-preset-actions { display: flex; justify-content: flex-end; }
.color-palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.color-swatch { height: 34px; border-radius: var(--radius-sm); border: 2px solid transparent; cursor: pointer; }
.color-swatch.active { border-color: var(--text-main); box-shadow: 0 0 0 2px var(--surface); }

.modal-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; gap: 10px; }
.right-actions { display: flex; gap: 8px; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; pointer-events: none; }
.toast {
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-lg);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.3s ease forwards;
  pointer-events: auto;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Footer */
.app-footer { margin-top: auto; padding-top: 24px; border-top: 1px solid var(--surface-border); text-align: center; font-size: 0.85rem; color: var(--text-muted); }
.footer-sub { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }

/* Print */
@media print {
  body { background-color: white !important; color: black !important; }
  .offline-banner, .app-header .header-right, .selector-card, .live-status-bar, .controls-bar, .timetable-footer-info, .app-footer, .modal-overlay, .toast-container { display: none !important; }
  .app-container { max-width: 100% !important; padding: 0 !important; }
  .timetable-card { box-shadow: none !important; border: 1px solid #000 !important; }
  .timetable th { background-color: #f1f5f9 !important; color: black !important; }
  .timetable td { border: 1px solid #94a3b8 !important; }
}

/* Responsive */
@media (max-width: 860px) {
  .today-dashboard-grid { grid-template-columns: 1fr; }
  .selector-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .week-nav-group { margin-left: 0; width: 100%; justify-content: space-between; }
  .day-filter { display: flex; }
  .timetable th.col-period { width: 75px; }
  .timetable td { height: 75px; padding: 3px; }
  .subject-name { font-size: 0.85rem; }
  .status-time { display: none; }
  .mobile-dino-controls { display: flex; }
  .dino-scores-box { width: 100%; justify-content: space-between; }
}