/* ==========================================================================
   資二丙班級資訊站 - Mobile First Design System & Stylesheet (style.css)
   ========================================================================== */

/* 1. CSS Custom Properties / Design Tokens */
:root {
  /* Brand Color Palette */
  --primary-color: #2563eb;       /* Royal Blue */
  --primary-dark: #1d4ed8;        /* Deep Blue Header */
  --primary-light: #eff6ff;       /* Light Blue Tint */
  --primary-border: #bfdbfe;      /* Subtle Blue Border */

  --bg-main: #f8fafc;             /* Slate 50 Main Background */
  --bg-card: #ffffff;             /* Pure White Card */
  --bg-card-hover: #f1f5f9;       /* Hover state */

  --text-main: #1e293b;           /* Slate 800 Primary Text */
  --text-muted: #64748b;          /* Slate 500 Subtitle/Desc */
  --text-light: #94a3b8;          /* Slate 400 Light Text */

  --danger-color: #ef4444;        /* Urgent / Important Red */
  --danger-bg: #fef2f2;
  --success-color: #10b981;       /* Active / Open Green */
  --success-bg: #ecfdf5;
  --warning-color: #f59e0b;       /* Warning Orange */
  --warning-bg: #fffbeb;

  /* Layout & Spacing */
  --max-width: 480px;             /* Mobile frame optimal max-width */
  --border-radius-lg: 14px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
  --border-radius-pill: 9999px;

  /* Elevation & Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 3px 12px -1px rgba(37, 99, 235, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 6px 20px -3px rgba(37, 99, 235, 0.12);

  /* Typography */
  --font-family: 'Noto Sans TC', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-size-base: 16px;         /* 16px minimum for mobile comfort */
}

/* 2. Global Resets & Base Setup */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  background-color: #cbd5e1;     /* Outer backdrop for desktop preview */
}

body {
  font-family: var(--font-family);
  color: var(--text-main);
  background-color: var(--bg-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* 3. Main App Container (Mobile Shell) */
.app-container {
  width: 100%;
  max-width: var(--max-width);
  min-height: 100vh;
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.12);
  position: relative;
  overflow-x: hidden;
}

/* 4. Global App Header (Compact Mobile Height) */
.app-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
  color: #ffffff;
  padding: 0.85rem 1rem 0.95rem;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: all 0.2s ease;
}

/* Home Header Content */
.header-home-mode {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.header-title-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.header-logo-icon {
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.class-badge-pill {
  background-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--border-radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.site-subtitle {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
  padding-left: 1.75rem; /* Align with title text */
}

/* Subpage Header Content (Sticky Navigation) */
.header-subpage-mode {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--border-radius-md);
  padding: 0.4rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: background-color 0.2s ease, transform 0.1s ease;
  flex-shrink: 0;
}

.btn-back-home:active {
  background-color: rgba(255, 255, 255, 0.35);
  transform: scale(0.97);
}

.subpage-title {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Helper Class to Toggle Elements */
.hidden {
  display: none !important;
}

/* 5. Main Content & Page Views */
.app-main {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

.page-view {
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 6. Home Feature Grid (2 columns x 3 rows) */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.feature-card {
  background-color: var(--bg-card);
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius-lg);
  padding: 0.9rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  position: relative;
  min-height: 105px; /* Compact height for quick mobile viewing */
  width: 100%;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.feature-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-lg);
}

.feature-card:active {
  transform: scale(0.96);
  background-color: var(--bg-card-hover);
}

.card-badge-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0.4rem;
}

.card-icon {
  font-size: 1.5rem; /* Uniform emoji size */
  line-height: 1;
}

.card-text-group {
  flex: 1;
  width: 100%;
}

.card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.15rem;
  line-height: 1.25;
}

.card-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.card-arrow {
  position: absolute;
  bottom: 0.65rem;
  right: 0.65rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
}

/* Quick Access Section (移至六格下方之小功能按鈕) */
.quick-access-section {
  background-color: #f1f5f9;
  border-radius: var(--border-radius-lg);
  padding: 0.75rem 0.85rem;
  margin-bottom: 1rem;
}

.quick-access-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.5rem;
}

.quick-access-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.quick-btn {
  background-color: var(--bg-card);
  border: 1px solid #cbd5e1;
  border-radius: var(--border-radius-md);
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  min-height: 44px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.quick-btn:active {
  transform: scale(0.97);
  background-color: var(--bg-card-hover);
}

.quick-btn-icon {
  font-size: 1.1rem;
}

/* Home Quick Teacher Notice */
.home-quick-info {
  background-color: var(--bg-card);
  border-left: 4px solid var(--primary-color);
  border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  border-left-width: 4px;
}

.quick-info-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.quick-icon { font-size: 1rem; }
.quick-title { font-weight: 700; font-size: 0.88rem; color: var(--primary-dark); }
.quick-text { font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; }

/* 7. Subpage View Components */
.view-intro-bar {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.55rem 0.8rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
}

/* ================= 最新公告 Accordion Announcements ================= */
.announcements-container {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

#view-announcements .ann-history-group {
  margin-top: 0.85rem;
}

#view-announcements .ann-history-toggle {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: var(--border-radius-md);
  background-color: #f1f5f9;
  color: #64748b;
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

#view-announcements .ann-history-toggle:active {
  background-color: #e2e8f0;
}

#view-announcements .ann-history-toggle:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 2px;
}

#view-announcements .ann-history-chevron {
  flex-shrink: 0;
  color: var(--primary-dark);
  line-height: 1;
}

#view-announcements .ann-history-list {
  margin-top: 0.35rem;
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

#view-announcements .ann-history-list[hidden] {
  display: none;
}

#view-announcements .ann-history-row {
  min-width: 0;
  padding: 0.55rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background-color: var(--bg-card);
  color: var(--text-main);
}

#view-announcements .ann-history-row + .ann-history-row {
  border-top: 1px solid #e2e8f0;
}

#view-announcements .ann-history-date {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

#view-announcements .ann-history-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 600;
}

.announcement-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-md);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.announcement-card.is-important {
  border-left: 4px solid var(--danger-color);
}

.announcement-card.is-expanded {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
}

/* Compact Summary Header (Entire Bar Clickable) */
.ann-summary-header {
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 52px;
  background-color: var(--bg-card);
  transition: background-color 0.15s ease;
}

.ann-summary-header:active {
  background-color: var(--bg-card-hover);
}

.ann-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ann-date {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.ann-action-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tag-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--border-radius-pill);
  line-height: 1.3;
}

.tag-important { background-color: var(--danger-color); color: #ffffff; }
.tag-signature { background-color: #f59e0b; color: #ffffff; }
.tag-payment { background-color: #10b981; color: #ffffff; }
.tag-deadline { background-color: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.tag-category { background-color: var(--primary-light); color: var(--primary-dark); }

.ann-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.ann-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  flex: 1;
}

.ann-toggle-chevron {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform 0.25s ease, color 0.2s ease;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.announcement-card.is-expanded .ann-toggle-chevron {
  transform: rotate(180deg);
  color: var(--primary-color);
}

/* Expanded Content Body */
.ann-expanded-body {
  display: none;
  padding: 0.75rem 0.85rem 0.85rem 0.85rem;
  border-top: 1px dashed #e2e8f0;
  background-color: #fafafa;
}

.announcement-card.is-expanded .ann-expanded-body {
  display: block;
  animation: fadeIn 0.2s ease;
}

.ann-full-content {
  font-size: 0.88rem;
  color: var(--text-main);
  white-space: pre-line;
  line-height: 1.55;
  margin-bottom: 0.65rem;
}

.ann-deadline-info {
  font-size: 0.82rem;
  font-weight: 700;
  color: #991b1b;
  background-color: #fee2e2;
  padding: 0.4rem 0.6rem;
  border-radius: var(--border-radius-sm);
  margin-bottom: 0.65rem;
  display: inline-block;
}

.ann-external-link {
  margin-bottom: 0.65rem;
}

.btn-inline-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #ffffff;
  background-color: var(--primary-color);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--border-radius-md);
}

.ann-collapse-footer {
  display: flex;
  justify-content: center;
  padding-top: 0.4rem;
  border-top: 1px solid #f1f5f9;
}

.btn-collapse-ann {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.3rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.btn-collapse-ann:hover {
  color: var(--primary-color);
}

/* ================= 宣導事項 & 重要規定 ================= */
.guidelines-container, .rules-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.guide-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.guide-card-header {
  padding: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  min-height: 48px;
}

.guide-card-header:active {
  background-color: var(--bg-card-hover);
}

.guide-header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.guide-icon { font-size: 1.35rem; line-height: 1; }

.guide-title-box {
  display: flex;
  flex-direction: column;
}

.guide-title { font-size: 0.98rem; font-weight: 700; color: var(--text-main); }
.guide-summary { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }

.guide-toggle-icon {
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.guide-card.expanded .guide-toggle-icon {
  transform: rotate(180deg);
  color: var(--primary-color);
}

.guide-card-body {
  padding: 0 0.85rem 0.85rem 0.85rem;
  border-top: 1px dashed #e2e8f0;
  background-color: #fafafa;
  display: none;
}

.guide-card.expanded .guide-card-body {
  display: block;
  animation: fadeIn 0.2s ease;
}

.guide-detail-list {
  list-style: none;
  padding: 0.5rem 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.guide-detail-list li {
  font-size: 0.88rem;
  color: var(--text-main);
  position: relative;
  padding-left: 1.1rem;
  line-height: 1.45;
}

.guide-detail-list li::before {
  content: "•";
  color: var(--primary-color);
  font-weight: bold;
  font-size: 1.1rem;
  position: absolute;
  left: 0.2rem;
  top: -0.1rem;
}

#view-rules .rule-link-card {
  min-width: 0;
  min-height: 80px;
  padding: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text-main);
  background-color: var(--bg-card);
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

#view-rules .rule-link-card:active {
  background-color: var(--bg-card-hover);
}

#view-rules .rule-link-card:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 2px;
}

#view-rules .rule-link-icon {
  flex-shrink: 0;
  font-size: 1.35rem;
  line-height: 1;
}

#view-rules .rule-link-content {
  min-width: 0;
  flex: 1;
}

#view-rules .rule-link-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
}

#view-rules .rule-link-summary {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
}

#view-rules .rule-link-items {
  min-width: 0;
  margin-top: 0.25rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

#view-rules .rule-link-action {
  flex-shrink: 0;
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ================= 報名專區 Registrations ================= */
.registrations-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.reg-group-title {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.urgent-title { color: #dc2626; }
.open-title { color: #059669; }
.closed-title { color: #64748b; }

.reg-cards-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.reg-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 0.9rem;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.reg-card.status-urgent { border-left: 4px solid var(--danger-color); }
.reg-card.status-open { border-left: 4px solid var(--success-color); }
.reg-card.status-closed { border-left: 4px solid #cbd5e1; opacity: 0.75; }

.reg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.reg-category-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: var(--border-radius-pill);
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

.reg-status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: var(--border-radius-pill);
}

.status-urgent .reg-status-badge { background-color: var(--danger-color); color: #fff; }
.status-open .reg-status-badge { background-color: var(--success-color); color: #fff; }
.status-closed .reg-status-badge { background-color: #94a3b8; color: #fff; }

.reg-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.reg-meta-row {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.reg-summary {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.45;
  margin-top: 0.2rem;
}

.reg-action-link {
  margin-top: 0.4rem;
  align-self: flex-start;
}

.btn-reg-apply {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background-color: var(--primary-color);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: var(--border-radius-md);
  min-height: 40px;
}

#view-registrations .reg-history-toggle {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: var(--border-radius-md);
  background-color: #f1f5f9;
  color: #64748b;
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

#view-registrations .reg-history-toggle:active {
  background-color: #e2e8f0;
}

#view-registrations .reg-history-toggle:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 2px;
}

#view-registrations .reg-history-chevron {
  flex-shrink: 0;
  color: var(--primary-dark);
  line-height: 1;
}

#view-registrations .reg-history-list {
  margin-top: 0.35rem;
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

#view-registrations .reg-history-list[hidden] {
  display: none;
}

#view-registrations .reg-history-row {
  min-width: 0;
  padding: 0.55rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background-color: var(--bg-card);
  color: var(--text-main);
}

#view-registrations .reg-history-row + .reg-history-row {
  border-top: 1px solid #e2e8f0;
}

#view-registrations .reg-history-date {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

#view-registrations .reg-history-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 600;
}

/* ================= 課表查詢 Timetable Dual Mode ================= */
.timetable-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.timetable-mode-switcher {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
  background-color: #e2e8f0;
  padding: 0.25rem;
  border-radius: var(--border-radius-lg);
}

.timetable-mode-btn {
  border: none;
  background: none;
  padding: 0.5rem 0;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s ease;
}

.timetable-mode-btn.active {
  background-color: var(--primary-color);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.mode-desc-box {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.45rem 0.75rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.day-tabs-bar {
  display: flex;
  background-color: #f1f5f9;
  padding: 0.2rem;
  border-radius: var(--border-radius-lg);
  gap: 0.2rem;
  border: 1px solid #e2e8f0;
}

.day-tab {
  flex: 1;
  border: none;
  background: none;
  padding: 0.5rem 0;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  min-height: 42px;
  transition: all 0.2s ease;
}

.day-tab.active {
  background-color: var(--bg-card);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.timetable-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.1rem 0.2rem;
}

.day-title { font-size: 1.05rem; font-weight: 800; color: var(--text-main); }

.day-badge {
  background-color: var(--success-bg);
  color: var(--success-color);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--border-radius-pill);
}

.timetable-lessons-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.lesson-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
}

.lesson-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.period-badge {
  width: 34px;
  height: 34px;
  background-color: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lesson-info {
  display: flex;
  flex-direction: column;
}

.subject-name { font-size: 0.98rem; font-weight: 700; color: var(--text-main); }
.time-range { font-size: 0.74rem; color: var(--text-muted); }

.lesson-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.teacher-name { font-size: 0.82rem; font-weight: 600; color: var(--text-main); }

.division-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}

.division-junior { background-color: #e0f2fe; color: #0369a1; }
.division-senior { background-color: #fef3c7; color: #b45309; }
.division-free { background-color: #f1f5f9; color: #64748b; }

.room-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  background-color: #f1f5f9;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.lesson-card.break-card {
  background-color: #f8fafc;
  border-style: dashed;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem;
}

.break-text { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }

/* ================= 重要日程 Events ================= */
.events-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.next-event-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #ffffff;
  border-radius: var(--border-radius-lg);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.next-event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.next-badge {
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--border-radius-pill);
  display: inline-block;
}

.next-event-title { font-size: 1.1rem; font-weight: 800; line-height: 1.3; }
.next-event-date { font-size: 0.92rem; font-weight: 700; color: #fde047; }
.next-event-note { font-size: 0.8rem; color: rgba(255, 255, 255, 0.88); line-height: 1.4; }

/* Filter Chips Bar (Horizontally scrollable on 390px mobile screens) */
.events-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.2rem 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.events-filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  border: 1px solid #cbd5e1;
  background-color: var(--bg-card);
  color: var(--text-main);
  padding: 0.35rem 0.8rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--border-radius-pill);
  cursor: pointer;
  min-height: 38px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  user-select: none;
}

.filter-chip.active {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

/* Monthly Accordion Groups */
#view-events .events-month-groups {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

#view-events .event-month-group {
  min-width: 0;
}

#view-events .event-month-header {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: var(--border-radius-md);
  background-color: #f1f5f9;
  color: var(--text-main);
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

#view-events .event-month-header:active {
  background-color: #e2e8f0;
}

#view-events .event-month-header:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 2px;
}

#view-events .event-month-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.55rem;
  font-size: 0.9rem;
  font-weight: 700;
}

#view-events .event-month-count {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

#view-events .event-month-chevron {
  flex-shrink: 0;
  color: var(--primary-dark);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

#view-events .event-month-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.45rem;
}

#view-events .event-month-panel[hidden] {
  display: none;
}

#view-events .events-empty-state {
  text-align: center;
  padding: 1rem;
}

/* ================= Compact Density Hierarchy Styles ================= */

/* Day Group Box for Same-Day Event Merging */
.day-group-box {
  background-color: var(--bg-card);
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--shadow-sm);
}

.day-group-date-header {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary-dark);
  padding-bottom: 0.2rem;
  border-bottom: 1px solid #f1f5f9;
}

.day-group-items {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Level A: 重大日程 (段考 / 作業抽查 / 測驗與檢定) -> Compact Card with Accent Border */
.event-item-level-a {
  background-color: #ffffff;
  border-radius: var(--border-radius-sm);
  padding: 0.55rem 0.65rem;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.event-item-level-a.cat-exam {
  border-left: 4px solid var(--primary-color);
  background: linear-gradient(to right, #eff6ff 0%, #ffffff 20%);
}

.event-item-level-a.cat-homework {
  border-left: 4px solid #9333ea;
  background: linear-gradient(to right, #faf5ff 0%, #ffffff 20%);
}

.event-item-level-a.cat-assessment {
  border-left: 4px solid #d97706;
  background: linear-gradient(to right, #fffbeb 0%, #ffffff 20%);
}

.item-level-a-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.item-level-a-date {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.item-level-a-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Level C: 例行日程 (社團活動) -> Streamlined Single-Line Row */
.event-item-level-c {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--border-radius-sm);
  padding: 0.4rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  min-height: 36px;
}

.item-level-c-text {
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#view-events .item-level-c-text {
  min-width: 0;
  flex-wrap: wrap;
}

.tag-badge-sm {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--border-radius-pill);
}

.tag-cat-exam { background-color: #dbeafe; color: #1e40af; }
.tag-cat-homework { background-color: #f3e8ff; color: #6b21a8; }
.tag-cat-club { background-color: #ccfbf1; color: #0f766e; }
.tag-cat-assessment { background-color: #fef3c7; color: #b45309; }

/* Official School Calendar Bottom Box */
.official-calendar-card {
  background-color: var(--bg-card);
  border: 1px solid #cbd5e1;
  border-radius: var(--border-radius-lg);
  padding: 0.9rem;
  text-align: center;
  margin-top: 0.4rem;
  box-shadow: var(--shadow-sm);
}

.calendar-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.15rem;
}

.calendar-card-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.btn-calendar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  background-color: var(--primary-color);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-calendar-link:active {
  transform: scale(0.97);
  opacity: 0.95;
}
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease;
}

.btn-secondary-link:active {
  background-color: var(--primary-light);
}

/* ================= 請假說明 Leave ================= */
.leave-card-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.leave-section-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 1.1rem;
  box-shadow: var(--shadow-md);
  border: 1px solid #e2e8f0;
}

.leave-section-card.warning-accent {
  border-top: 4px solid var(--warning-color);
}

.section-card-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #f1f5f9;
}

.section-icon { font-size: 1.2rem; }
.section-title { font-size: 1rem; font-weight: 700; color: var(--text-main); }

.leave-data-grid {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.data-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.data-label { font-size: 0.82rem; font-weight: 700; color: var(--primary-dark); }

.data-val {
  font-size: 0.88rem;
  color: var(--text-main);
  background-color: #f8fafc;
  padding: 0.45rem 0.65rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid #e2e8f0;
}

.options-tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.option-pill {
  font-size: 0.78rem;
  padding: 0.28rem 0.6rem;
  background-color: #f1f5f9;
  color: var(--text-main);
  border-radius: var(--border-radius-sm);
  border: 1px solid #cbd5e1;
}

.option-pill.highlight {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-dark);
  font-weight: 600;
}

.option-pill.type-pill {
  background-color: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
  font-weight: 600;
}

.reminders-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.reminders-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.86rem;
  line-height: 1.45;
}

.bullet-icon { font-size: 0.8rem; flex-shrink: 0; margin-top: 0.1rem; }

.leave-action-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.btn-primary-action {
  width: 100%;
  min-height: 48px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-lg);
}

.btn-primary-action:active {
  transform: scale(0.97);
}

.action-hint { font-size: 0.78rem; color: var(--text-muted); }

/* ================= 常見問題 FAQ ================= */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.faq-item {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-md);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.faq-question-btn {
  width: 100%;
  padding: 0.85rem;
  min-height: 48px;
  background: none;
  border: none;
  text-align: left;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  gap: 0.4rem;
}

.faq-chevron {
  color: var(--text-muted);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.faq-item.active .faq-chevron {
  transform: rotate(180deg);
  color: var(--primary-color);
}

.faq-answer-panel {
  padding: 0 0.85rem 0.85rem 0.85rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  display: none;
  border-top: 1px solid #f1f5f9;
  background-color: #fafafa;
}

.faq-item.active .faq-answer-panel {
  display: block;
  animation: fadeIn 0.2s ease;
}

.faq-contact-box {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.85rem;
  background-color: #f1f5f9;
  border-radius: var(--border-radius-md);
}

/* 8. Global App Footer (Compact) */
.app-footer {
  margin-top: auto;
  background-color: #0f172a;
  color: #94a3b8;
  text-align: center;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  border-top: 1px solid #1e293b;
}

.footer-title {
  color: #ffffff;
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 0.15rem;
}

.footer-copy {
  font-size: 0.72rem;
  color: #64748b;
}

/* 9. Responsive Adjustments for Desktop Container */
@media (min-width: 640px) {
  body {
    padding: 1.5rem 0;
  }

  .app-container {
    border-radius: 20px;
    height: 844px;
    min-height: auto;
    overflow-y: auto;
  }

  .app-header {
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
  }
}
