:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text-main: #1d1d1f;
  --text-muted: #86868b;
  --border: #e5e5ea;
  --border-light: #f2f2f7;
  --primary: #1d1d1f;
  --primary-hover: #434344;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);
  --cell-height: 110px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}

button {
  cursor: pointer;
  font: inherit;
  border: none;
  background: none;
}

input,
select {
  font: inherit;
}

.btn-primary {
  background: var(--text-main);
  color: #fff;
  border-radius: 12px;
  padding: 14px 24px;
  font-weight: 600;
  font-size: 16px;
  width: 100%;
  transition: transform 0.1s, opacity 0.2s, background 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 500;
  font-size: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.btn-text {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.btn-text:hover {
  color: var(--text-main);
}

.switch-link {
  text-decoration: none;
}

.btn-icon {
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--border-light);
}

/* Views */
.view-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Premium Login Landing */
.login-overlay {
  --login-ink: #0b0f17;
  --login-panel: rgba(255, 255, 255, 0.92);
  --login-muted: #667085;
  --login-accent: #14b8a6;
  --login-accent-strong: #0f766e;
  --login-warm: #f59e0b;
  position: fixed;
  inset: 0;
  background-color: #090b10;
  background-image:
    linear-gradient(118deg, rgba(9, 11, 16, 0.98) 0%, rgba(15, 23, 42, 0.96) 49%, rgba(239, 244, 249, 0.97) 49.2%, rgba(248, 250, 252, 0.98) 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 118px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 118px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow: hidden;
  z-index: 1000;
  transition: opacity 0.4s ease, visibility 0.4s;
}

.teacher-page .login-overlay {
  --login-accent: #38bdf8;
  --login-accent-strong: #0369a1;
  --login-warm: #22c55e;
}

.login-overlay[hidden] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-ambient::before {
  content: "";
  position: absolute;
  inset: 9% 7%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left-color: rgba(20, 184, 166, 0.28);
  border-bottom-color: rgba(245, 158, 11, 0.18);
}

.login-ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(90deg, transparent 0%, rgba(20, 184, 166, 0.13) 49%, transparent 50%),
    linear-gradient(0deg, transparent 0%, rgba(245, 158, 11, 0.1) 49%, transparent 50%);
  background-size: 220px 220px;
  mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.75), transparent 72%);
}

.login-ambient-line {
  position: absolute;
  left: 7%;
  right: 7%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.46), rgba(20, 184, 166, 0.5), transparent);
  opacity: 0.42;
  transform-origin: left center;
}

.login-ambient-line.line-one {
  top: 18%;
}

.login-ambient-line.line-two {
  top: 52%;
}

.login-ambient-line.line-three {
  top: 78%;
}

.login-stage {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  align-items: stretch;
  gap: 36px;
}

.login-showcase {
  min-height: 560px;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 22px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02)),
    linear-gradient(180deg, rgba(15, 23, 42, 0.52), rgba(9, 11, 16, 0.72));
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.teacher-showcase {
  --login-accent: #38bdf8;
  --login-accent-strong: #0369a1;
}

.showcase-top {
  max-width: 520px;
}

.showcase-kicker,
.showcase-footer {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  color: rgba(226, 232, 240, 0.82);
}

.showcase-top h2 {
  margin-top: 18px;
  font-size: 54px;
  line-height: 1;
  letter-spacing: 0;
  font-weight: 900;
}

.showcase-top p {
  margin-top: 16px;
  font-size: 16px;
  color: rgba(226, 232, 240, 0.78);
}

.showcase-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 38px;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04)),
    rgba(15, 23, 42, 0.3);
}

.showcase-cell {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.07);
  min-height: 38px;
}

.showcase-cell.wide {
  grid-column: span 2;
}

.showcase-cell.tall {
  grid-row: span 2;
}

.showcase-cell.tone-a {
  background: linear-gradient(145deg, rgba(20, 184, 166, 0.88), rgba(13, 148, 136, 0.6));
}

.showcase-cell.tone-b {
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.8), rgba(29, 78, 216, 0.56));
}

.showcase-cell.tone-c {
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.82), rgba(217, 119, 6, 0.58));
}

.showcase-cell.tone-d {
  background: linear-gradient(145deg, rgba(244, 63, 94, 0.72), rgba(190, 18, 60, 0.5));
}

.showcase-footer {
  display: flex;
  justify-content: space-between;
  color: rgba(226, 232, 240, 0.68);
}

.login-wrapper {
  align-self: center;
  background: var(--login-panel);
  padding: 44px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 22px;
  box-shadow: 0 36px 90px rgba(15, 23, 42, 0.23), 0 0 0 1px rgba(255, 255, 255, 0.76) inset;
  width: 100%;
  max-width: 420px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.login-wrapper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--login-accent), var(--login-warm), #0f172a);
}

.login-header {
  margin-bottom: 34px;
}

.brand-tag {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--login-accent-strong);
  text-transform: uppercase;
  margin-bottom: 14px;
  display: inline-block;
  padding: 6px 10px;
  background: rgba(20, 184, 166, 0.1);
  border: 1px solid rgba(20, 184, 166, 0.18);
  border-radius: 8px;
}

.login-header h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 10px;
  color: var(--login-ink);
}

.login-header p {
  font-size: 15px;
  color: var(--login-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
}

.input-field {
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
}

.input-field label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #111827;
}

.input-field input {
  width: 100%;
  padding: 16px 17px;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  font-size: 16px;
  outline: none;
  transition: all 0.2s;
}

.input-field input:focus {
  background: #ffffff;
  border-color: rgba(20, 184, 166, 0.82);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.11), 0 12px 28px rgba(15, 23, 42, 0.08);
}

.password-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.password-row input {
  flex: 1;
  min-width: 0;
}

.btn-default-password {
  border: 0;
  border-radius: 999px;
  padding: 11px 14px;
  background: rgba(20, 184, 166, 0.1);
  color: var(--login-accent-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(20, 184, 166, 0.16);
  transition: transform 0.18s ease, background 0.18s ease;
}

.btn-default-password:hover {
  background: rgba(20, 184, 166, 0.16);
  transform: translateY(-1px);
}

.btn-default-password:active {
  transform: scale(0.98);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #475467;
  margin-bottom: 32px;
  cursor: pointer;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--login-accent-strong);
  cursor: pointer;
}

.login-form .btn-primary {
  padding: 16px 24px;
  border-radius: 14px;
  background: linear-gradient(135deg, #080b12, #1f2937 58%, #0f766e);
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.22);
}

.teacher-page .login-form .btn-primary {
  background: linear-gradient(135deg, #080b12, #1f2937 58%, #0369a1);
}

.login-form .btn-primary:hover {
  background: linear-gradient(135deg, #111827, #243244 58%, var(--login-accent-strong));
}

.login-error {
  margin: -8px 0 18px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #be123c;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-line;
}

/* Workspace */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border-light);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden; /* For mobile truncation */
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-info h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 2px;
}

.user-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.student-id-mobile {
  display: none;
}
.student-id-desktop {
  display: inline;
}

.meta-separator {
  display: inline;
}
.meta-part {
  display: inline;
}

.main-content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.week-display h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 2px;
}

.week-display span {
  font-size: 12px;
  color: var(--text-muted);
}

.week-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
}

.week-controls .btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
}

.week-controls .btn-secondary {
  border: none;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  padding: 6px 16px;
}

.teacher-sign-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(31, 138, 76, 0.2);
  border-radius: 12px;
  background: #eef9f2;
  color: #14532d;
}

.teacher-sign-notice[hidden] {
  display: none;
}

.teacher-sign-notice > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.teacher-sign-notice strong {
  font-size: 14px;
  line-height: 1.3;
}

.teacher-sign-notice span {
  font-size: 12px;
  color: #2f6f46;
  line-height: 1.45;
}

.teacher-sign-notice button {
  flex: 0 0 auto;
  border-radius: 8px;
  padding: 8px 12px;
  background: #1f8a4c;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* Custom Week Popover */
.week-selector-wrapper {
  position: relative;
}

.week-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  padding: 16px;
  z-index: 500;
  width: 320px;
  transition: opacity 0.2s, transform 0.2s;
}

.week-popover[hidden] {
  display: none;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.week-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-main);
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}

.week-btn .week-num {
  font-size: 14px;
  font-weight: 600;
}

.week-btn .week-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.week-btn:hover {
  background: var(--border);
}

.week-btn.active {
  background: var(--text-main);
  color: #fff;
  border-color: var(--text-main);
}

.week-btn.active .week-date {
  color: rgba(255, 255, 255, 0.7);
}

/* Structural Schedule Grid (looks good even when empty) */
.schedule-container {
  position: relative;
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  isolation: isolate;
}

.schedule-container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 60px;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 122, 255, 0.28), rgba(20, 184, 166, 0.24), transparent);
  pointer-events: none;
  z-index: 2;
}

.time-column {
  width: 60px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg); /* Subtle differentiation */
}

.grid-head-corner {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.time-cell {
  height: var(--cell-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
}

.time-cell span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 4px;
}

.time-cell:last-child {
  border-bottom: none;
}

.days-wrapper {
  flex-grow: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.days-wrapper::-webkit-scrollbar {
  display: none;
}

.days-grid {
  display: flex;
  min-width: 100%;
}

.day-column {
  flex: 1;
  min-width: 135px; /* Perfect for mobile horizontal scroll */
  border-right: 1px solid var(--border-light);
  transform-origin: center top;
  backface-visibility: hidden;
}

/* Zebra striping for empty grid to look structural */
.day-column:nth-child(even) {
  /* Removed zebra striping as it looks dirty with colored cards */
}

.day-column:last-child {
  border-right: none;
}

.day-head {
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  transform-origin: center top;
  backface-visibility: hidden;
}

.day-column:nth-child(even) .day-head {
  background: var(--surface);
}

.day-head small {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* Today Highlight */
.day-column.is-today {
  background-color: rgba(0, 122, 255, 0.03);
}

.day-column.is-today .day-head {
  color: #007aff;
}

.day-column.is-today .day-head small {
  background: #007aff;
  color: #fff;
  border-radius: 10px;
  padding: 0 6px;
  font-weight: 600;
}

.day-column.is-loading .course-cell {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 247, 250, 0.92));
}

.course-cell {
  height: var(--cell-height);
  padding: 3px 4px;
  border-bottom: 1px dashed var(--border-light);
}

.course-cell:last-child {
  border-bottom: none;
}

.course-card {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: center;
  backface-visibility: hidden;
  will-change: transform, opacity;
  transition: filter 0.18s ease;
}

.course-card:hover {
  filter: saturate(1.04) brightness(1.01);
}

.course-card strong {
  font-size: 13px;
  line-height: 1.3;
  margin-bottom: auto;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card .meta {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.8;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card .teacher {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.86;
  margin-top: 8px;
  line-height: 1.25;
}

.teacher-course-card .class-info {
  margin-top: 6px;
}

.course-sign-badge {
  align-self: flex-start;
  max-width: 100%;
  margin: -2px 0 5px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  white-space: nowrap;
}

.course-sign-badge.signed {
  background: rgba(255, 255, 255, 0.68);
  color: inherit;
  border-color: rgba(255, 255, 255, 0.72);
}

.course-sign-badge.unsigned {
  background: rgba(255, 255, 255, 0.46);
  color: inherit;
  border-color: rgba(255, 255, 255, 0.62);
  opacity: 0.82;
}

.course-sign-badge.loading {
  background: rgba(255, 255, 255, 0.38);
  color: inherit;
  border-color: rgba(255, 255, 255, 0.55);
  opacity: 0.72;
}

.empty-cell {
  width: 100%;
  height: 100%;
  /* No dummy content needed, zebra striping provides structure */
}

.skeleton-card {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #eef1f5 0%, #ffffff 45%, #eef1f5 100%);
  background-size: 220% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
  opacity: 0.95;
}

.auth-float {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 1100;
  pointer-events: none;
}

.auth-float[hidden] {
  display: none;
}

.auth-progress-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 20px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(20, 83, 45, 0.16);
  background: linear-gradient(135deg, #f3fbf6 0%, #ffffff 58%, #eef7ff 100%);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
  pointer-events: auto;
  animation: authFloatIn 0.22s ease-out both;
}

.auth-progress-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.72) 48%, transparent 100%);
  transform: translateX(-100%);
  animation: authSweep 2.4s ease-in-out infinite;
}

.auth-orbit {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 50%;
  border: 3px solid rgba(31, 138, 76, 0.16);
  background: rgba(255, 255, 255, 0.78);
  animation: spin 1.4s linear infinite;
  z-index: 1;
}

.auth-orbit::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: #1f8a4c;
  box-shadow: 0 0 18px rgba(31, 138, 76, 0.35);
}

.auth-orbit-dot {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: #007aff;
  box-shadow: 0 0 14px rgba(0, 122, 255, 0.5);
}

.auth-progress-main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
}

.auth-progress-kicker {
  color: #2f6f46;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 2px;
}

.auth-progress-title {
  color: var(--text-main);
  font-size: 16px;
  font-weight: 750;
  line-height: 1.35;
}

.auth-progress-bar {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(31, 138, 76, 0.12);
  overflow: hidden;
}

.auth-progress-bar-fill {
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f8a4c, #007aff);
  animation: authBar 1.6s ease-in-out infinite;
}

.auth-progress-dots {
  position: relative;
  z-index: 1;
  display: flex;
  align-self: flex-end;
  gap: 5px;
  padding-bottom: 4px;
}

.auth-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(31, 138, 76, 0.4);
  animation: authPulse 1s ease-in-out infinite;
}

.auth-dot.second {
  animation-delay: 0.15s;
}

.auth-dot.third {
  animation-delay: 0.3s;
}

/* Day Overview (List) */
.day-overview {
  margin-top: 32px;
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.day-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.day-header h3 span {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 8px;
}

.teacher-day-hint {
  margin-top: 6px;
  color: #1f8a4c;
  font-size: 13px;
  line-height: 1.45;
}

.day-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-bulk-sign {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  background: #111827;
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.14);
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.btn-bulk-sign:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(17, 24, 39, 0.18);
}

.btn-bulk-sign:active {
  transform: translateY(0) scale(0.98);
}

.btn-bulk-sign:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.date-picker {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  outline: none;
}

.date-picker:focus {
  border-color: var(--text-muted);
}

.day-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-item {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transform-origin: center;
  backface-visibility: hidden;
  will-change: transform, opacity;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.day-item[data-course]:hover {
  border-color: rgba(0, 122, 255, 0.18);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

.day-item-main h4 {
  font-size: 15px;
  margin-bottom: 4px;
}

.day-item-main p {
  font-size: 13px;
  color: var(--text-muted);
}

.day-item-side {
  text-align: right;
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
}

.day-item-side span {
  display: block;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
}

.day-loading {
  justify-content: flex-start;
  gap: 14px;
}

.loading-spinner {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  border: 3px solid var(--border-light);
  border-top-color: var(--text-main);
  animation: spin 0.8s linear infinite;
}

.day-loading-copy h4 {
  font-size: 15px;
  margin-bottom: 2px;
}

.day-loading-copy p {
  color: var(--text-muted);
  font-size: 13px;
}

.day-skeleton {
  min-height: 62px;
  overflow: hidden;
  position: relative;
  background: linear-gradient(90deg, #f4f4f6 0%, #ffffff 45%, #f4f4f6 100%);
  background-size: 220% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}

@keyframes authSweep {
  0% { transform: translateX(-120%); }
  55%, 100% { transform: translateX(120%); }
}

@keyframes authFloatIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes authBar {
  0% { transform: translateX(-110%); }
  50% { transform: translateX(70%); }
  100% { transform: translateX(220%); }
}

@keyframes authPulse {
  0%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.teacher-day-item {
  align-items: stretch;
  gap: 16px;
}

.teacher-day-item .day-item-main {
  min-width: 0;
}

.attendance-line {
  margin-top: 6px;
}

.teacher-action-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  min-width: 96px;
}

.teacher-action-side .period-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
}

.btn-sign {
  min-width: 88px;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--text-main);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s, transform 0.1s, background 0.2s;
}

.btn-sign:hover {
  background: var(--primary-hover);
}

.btn-sign:active {
  transform: scale(0.98);
}

.btn-sign:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.btn-sign.is-signed {
  background: #1f8a4c;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 15px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  white-space: pre-line;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(29, 29, 31, 0.9);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 14px;
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  z-index: 1200;
}

/* Mini program parity */
.status-banner {
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: -8px 0 18px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid rgba(29, 78, 216, 0.16);
  background: #f4f8ff;
  color: #1e3a8a;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.status-banner[hidden] {
  display: none;
}

.status-banner.warning {
  border-color: rgba(194, 65, 12, 0.18);
  background: #fff7ed;
  color: #9a3412;
}

.status-banner-dot {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-banner-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.status-banner-copy strong {
  font-size: 14px;
  line-height: 1.35;
}

.status-banner-copy span {
  font-size: 13px;
  line-height: 1.45;
  opacity: 0.82;
}

.course-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: -8px 0 20px;
}

.course-search-field {
  flex: 1;
  min-width: 260px;
  height: 46px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.96);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.course-search-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid #94a3b8;
  border-radius: 50%;
  position: relative;
}

.course-search-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  right: -6px;
  bottom: -3px;
  border-radius: 999px;
  background: #94a3b8;
  transform: rotate(45deg);
  transform-origin: 0 50%;
}

.course-search-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  outline: none;
  color: #0f172a;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.course-search-clear {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: #e2e8f0;
  position: relative;
}

.course-search-clear::before,
.course-search-clear::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 11px;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: #64748b;
}

.course-search-clear::before {
  transform: rotate(45deg);
}

.course-search-clear::after {
  transform: rotate(-45deg);
}

.course-filter-chip {
  min-height: 38px;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  background: #eff6ff;
  color: #1d4ed8;
}

.course-filter-chip[hidden],
.course-search-clear[hidden] {
  display: none;
}

.course-filter-label {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.course-filter-count {
  flex-shrink: 0;
  font-size: 12px;
  color: #64748b;
  font-weight: 800;
}

.course-filter-clear {
  flex-shrink: 0;
  border: 0;
  padding: 5px 9px;
  border-radius: 7px;
  color: #ffffff;
  background: #2563eb;
  font-size: 12px;
  font-weight: 800;
}

.notice-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}

.teacher-sign-notice .notice-actions button {
  position: relative;
  overflow: hidden;
}

.teacher-sign-notice .notice-actions button:disabled,
.btn-bulk-sign:disabled,
.btn-sign:disabled {
  cursor: wait;
}

.day-head-signable {
  cursor: pointer;
}

.day-head-signable:active {
  background: #eef9f2;
}

.day-head-tag {
  margin-top: 3px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(71, 85, 105, 0.08);
  color: #475569;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.25;
}

.day-head-tag.loading {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}

.day-head-tag.pending {
  background: rgba(234, 88, 12, 0.1);
  color: #9a3412;
}

.day-head-tag.done {
  background: rgba(22, 101, 52, 0.1);
  color: #166534;
}

.day-head-tag.empty {
  background: rgba(100, 116, 139, 0.08);
  color: #64748b;
}

.course-time-badge,
.time-label-inline {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  color: #ffffff;
  background: #ff8a00;
  font-weight: 800;
  white-space: nowrap;
}

.course-time-badge {
  margin-bottom: 5px;
  padding: 2px 7px;
  font-size: 10px;
}

.course-time-badge.next,
.time-label-inline.next {
  background: #007aff;
}

.course-time-badge.past,
.time-label-inline.past {
  background: #64748b;
}

.time-label-inline {
  padding: 3px 8px;
  font-size: 12px;
}

.period-label-inline {
  color: #007aff;
  background: rgba(0, 122, 255, 0.1);
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.day-item h4 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.course-card.is-current-course,
.day-item.is-current-course {
  border-color: rgba(255, 138, 0, 0.7);
}

.course-card.is-next-course,
.day-item.is-next-course {
  border-color: rgba(0, 122, 255, 0.42);
  box-shadow: 0 8px 22px rgba(0, 122, 255, 0.1);
}

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(8px);
}

.sheet-mask[hidden],
.share-sheet[hidden],
.course-detail-sheet[hidden],
.sign-sheet[hidden] {
  display: none;
}

.share-sheet,
.course-detail-sheet,
.sign-sheet {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1210;
  width: min(560px, calc(100vw - 32px));
  max-height: min(82vh, 720px);
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.99);
  box-shadow: 0 34px 90px rgba(15, 23, 42, 0.2);
  transform: translateX(-50%);
}

.sheet-handle {
  width: 56px;
  height: 5px;
  border-radius: 999px;
  background: #e2e8f0;
  margin: 0 auto 14px;
}

.share-sheet h2,
.course-detail-sheet h2,
.sign-sheet h2 {
  margin: 0;
  color: #0f172a;
  font-size: 22px;
  line-height: 1.25;
}

.share-sheet p,
.course-detail-sheet p,
.sign-sheet p {
  margin: 8px 0 0;
  color: #475569;
  line-height: 1.55;
}

.sheet-primary,
.sheet-secondary,
.sheet-cancel,
.course-detail-secondary,
.course-detail-primary,
.sign-sheet-secondary,
.sign-sheet-primary {
  height: 46px;
  border: 0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 850;
}

.sheet-primary,
.course-detail-primary,
.sign-sheet-primary {
  color: #ffffff;
  background: #111827;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
}

.sheet-secondary {
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid rgba(37, 99, 235, 0.14);
}

.sheet-cancel,
.course-detail-secondary,
.sign-sheet-secondary {
  color: #475569;
  background: #f1f5f9;
}

.promo-sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 1450;
  width: min(920px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 280px);
  gap: 24px;
  padding: 28px;
  border-radius: 28px;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 34%),
    radial-gradient(circle at bottom right, rgba(37, 99, 235, 0.12), transparent 36%),
    #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
}

.promo-sheet[hidden] {
  display: none;
}

.promo-sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.95);
  color: #475569;
  font-size: 24px;
  line-height: 1;
}

.promo-sheet-copy {
  min-width: 0;
}

.promo-sheet-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
  font-weight: 900;
}

.promo-sheet h2 {
  margin-top: 18px;
  font-size: 34px;
  line-height: 1.08;
  color: #0f172a;
}

.promo-sheet-lead {
  margin-top: 14px;
  color: #334155;
  font-size: 15px;
  line-height: 1.7;
}

.promo-search-card {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(236, 253, 245, 0.92), rgba(239, 246, 255, 0.94));
  border: 1px solid rgba(16, 185, 129, 0.16);
}

.promo-search-card > div {
  min-width: 0;
}

.promo-search-label {
  display: block;
  color: #047857;
  font-size: 12px;
  font-weight: 900;
}

.promo-search-card strong {
  display: block;
  margin-top: 4px;
  color: #0f172a;
  font-size: 20px;
  line-height: 1.25;
  word-break: break-all;
}

.promo-copy-button {
  flex: 0 0 auto;
  min-width: 96px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: #0f172a;
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
}

.promo-sheet-points {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.promo-sheet-points p {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.96);
  color: #475569;
  font-size: 14px;
  line-height: 1.65;
}

.promo-sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.promo-sheet-actions .sheet-primary,
.promo-sheet-actions .sheet-secondary {
  width: auto;
  min-width: 0;
  flex: 1 1 0;
  margin-top: 0;
}

.promo-sheet-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.promo-qr-card {
  width: 100%;
  padding: 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.promo-qr-card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
}

.promo-sheet-qr p {
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.share-sheet button {
  width: 100%;
  margin-top: 14px;
}

.course-detail-head,
.sign-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.sign-sheet-head {
  justify-content: flex-start;
}

.course-detail-head-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: 170px;
}

.course-detail-kicker,
.sign-sheet-kicker {
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
}

.course-detail-status,
.course-detail-filter {
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.course-detail-status {
  color: #475569;
  background: #f1f5f9;
}

.course-detail-status.signed {
  color: #15803d;
  background: #ecfdf3;
}

.course-detail-status.loading {
  color: #1d4ed8;
  background: #eff6ff;
}

.course-detail-filter {
  color: #1d4ed8;
  background: #eff6ff;
}

.course-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.course-detail-row {
  min-height: 72px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.course-detail-row span {
  display: block;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 850;
}

.course-detail-row strong {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
}

.course-detail-notice,
.sign-sheet-warning,
.sign-current-text,
.sign-verify-note,
.sign-result-text {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  background: #f8fafc;
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
}

.course-detail-notice.signed,
.sign-verify-note,
.sign-result-text {
  color: #166534;
  background: #f0fdf4;
  border-color: rgba(22, 101, 52, 0.12);
}

.course-detail-notice.loading {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: rgba(29, 78, 216, 0.12);
}

.sign-sheet-warning {
  color: #9a3412;
  background: #fff7ed;
  border-color: rgba(180, 83, 9, 0.16);
  font-weight: 700;
}

.course-detail-actions,
.sign-sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.course-detail-secondary,
.sign-sheet-secondary {
  flex: 1;
}

.course-detail-primary,
.sign-sheet-primary {
  flex: 1.4;
}

.sign-sheet-mark {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 20px;
  font-weight: 900;
  background: #111827;
}

.sign-sheet-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.75s linear infinite;
}

.sign-confirm-body,
.sign-running-body {
  margin-top: 16px;
}

.sign-sheet-scope {
  color: #64748b;
  font-size: 13px;
  font-weight: 850;
}

.sign-sheet-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.sign-sheet-metrics div {
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid rgba(226, 232, 240, 0.92);
}

.sign-sheet-metrics span {
  display: block;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 900;
}

.sign-sheet-metrics strong {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 16px;
}

.sign-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #475569;
  font-size: 14px;
  font-weight: 900;
}

.sign-progress-track {
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}

.sign-progress-fill {
  width: 0;
  height: 100%;
  min-width: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1d4ed8 0%, #0f766e 100%);
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.sign-verify-block {
  margin-top: 16px;
}

.sign-progress-track.verify {
  background: #dcfce7;
}

.sign-progress-fill.verify {
  background: linear-gradient(90deg, #16a34a 0%, #0f766e 100%);
}

.sign-tone-warning .sign-sheet-primary {
  background: #c2410c;
}

.sign-tone-success .sign-sheet-primary,
.sign-tone-success .sign-sheet-mark {
  background: #15803d;
}

.sign-tone-danger .sign-sheet-primary,
.sign-tone-danger .sign-sheet-mark {
  background: #be123c;
}

.sign-tone-danger .sign-result-text {
  color: #9f1239;
  background: #fff1f2;
  border-color: rgba(190, 18, 60, 0.14);
}

.share-canvas {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 768px) {
  .course-search {
    margin-top: -2px;
  }

  .course-search-field {
    min-width: 100%;
  }

  .course-filter-chip {
    width: 100%;
    justify-content: space-between;
  }

  .notice-actions {
    width: 100%;
    justify-content: stretch;
  }

  .share-sheet,
  .course-detail-sheet,
  .sign-sheet {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto;
    transform: none;
  }

  .course-detail-grid,
  .sign-sheet-metrics {
    grid-template-columns: 1fr;
  }

  .promo-sheet {
    grid-template-columns: 1fr;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px - env(safe-area-inset-bottom));
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    padding: 22px 18px 18px;
    border-radius: 24px;
    overflow-y: auto;
    gap: 16px;
  }

  .promo-sheet h2 {
    font-size: 28px;
  }

  .promo-sheet-lead,
  .promo-sheet-points p {
    font-size: 14px;
  }

  .promo-search-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .promo-search-card strong {
    font-size: 18px;
  }

  .promo-copy-button {
    width: 100%;
  }

  .promo-sheet-actions {
    flex-direction: column-reverse;
  }

  .promo-sheet-qr {
    gap: 10px;
  }
}

@media (max-width: 768px) {
  .login-overlay {
    padding: 16px;
  }

  .login-wrapper {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    padding: 36px 24px;
  }

  .password-row {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
  }

  .password-row input {
    flex: none;
    width: 100%;
    min-width: 0;
  }

  .btn-default-password {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .btn-primary {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .login-form,
  .input-field {
    width: 100%;
    min-width: 0;
  }

  .input-field input {
    max-width: 100%;
    min-width: 0;
  }
}

@media (max-width: 768px) {
  .toast {
    width: 90%;
    text-align: center;
  }
}

/* Tooltip */
.course-tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: 12px;
  padding: 12px 16px;
  width: 200px;
  pointer-events: none; /* Tooltip doesn't block clicks */
  transition: none; /* Instant display */
  transform: translateY(4px);
  opacity: 0;
}

.course-tooltip:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
}

.course-tooltip h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
  line-height: 1.3;
}

.course-tooltip p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}

.course-tooltip p:last-child {
  margin-bottom: 0;
}

.course-tooltip .icon {
  font-size: 14px;
  line-height: 1.2;
}

.teacher-tooltip {
  width: 230px;
}

.teacher-tooltip p {
  align-items: baseline;
}

.tooltip-label {
  flex: 0 0 34px;
  color: var(--text-main);
  font-weight: 600;
}

/* Mobile Adjustments (Mobile-First Polish) */
@media (max-width: 768px) {
  .student-id-mobile {
    display: inline;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 6px;
  }
  .student-id-desktop {
    display: none;
  }

  .meta-separator {
    display: none;
  }
  .meta-part {
    display: block;
    margin-bottom: 2px;
  }

  .login-overlay {
    padding: 24px;
    align-items: center; /* Center like a card */
    overflow-y: auto;
  }

  .login-wrapper {
    padding: 40px 24px;
    border-radius: 24px;
    box-shadow: 0 20px 40px -12px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.02);
    max-width: 100%;
    min-height: auto;
    display: block;
    background: #ffffff;
  }

  .login-wrapper::before {
    display: none;
  }

  .login-header {
    margin-bottom: 40px;
  }

  .login-header h1 {
    font-size: 32px;
  }

  .login-form {
    display: block;
  }

  .input-field input {
    padding: 16px;
    font-size: 16px;
    border-radius: 12px;
  }

  .password-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .btn-default-password {
    padding: 10px 12px;
    font-size: 12px;
  }

  .checkbox-label {
    margin-bottom: 24px;
  }

  .btn-primary {
    margin-top: 12px;
    padding: 16px;
    font-size: 17px;
    border-radius: 16px;
  }
  
  .top-nav {
    padding: 12px 16px;
  }

  .nav-right {
    flex-shrink: 0;
    gap: 8px;
  }

  .btn-text {
    width: auto;
    min-width: 0;
    white-space: nowrap;
    word-break: keep-all;
    line-height: 1.2;
    padding: 6px 4px;
    text-align: center;
    font-size: 15px;
  }

  .switch-link {
    display: none;
  }

  .main-content {
    padding: 12px; /* Restore safe area margin */
  }

  .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 4px 12px;
    margin-bottom: 0;
  }

  .schedule-container {
    border-radius: 12px;
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  }

  .day-column {
    min-width: 76px; /* Slightly narrower, shows ~4.5 days */
  }

  .time-column {
    width: 36px; /* Slightly wider than before to fit text */
  }

  .grid-head-corner {
    font-size: 10px;
    height: 48px;
  }
  
  .day-head {
    height: 48px;
    font-size: 12px;
  }
  
  .day-head small {
    font-size: 10px;
  }

  .time-cell {
    font-size: 11px;
  }
  
  .time-cell span {
    font-size: 9px;
  }

  .course-card {
    padding: 6px 8px; /* Comfortable padding */
  }
  
  .course-card strong {
    font-size: 12px;
    -webkit-line-clamp: 6; 
    letter-spacing: 0;
    line-height: 1.25;
    word-break: normal;
  }
  
  .course-card .meta {
    display: none; /* Hide meta on mobile */
  }

  .course-card .teacher {
    display: none; /* Keep mobile timetable compact */
  }

  body.teacher-page .course-card .teacher {
    display: block;
    font-size: 10px;
    margin-top: 4px;
    line-height: 1.2;
  }

  .teacher-day-item {
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
  }

  .teacher-action-side {
    min-width: 82px;
  }

  .day-header {
    align-items: flex-start;
    gap: 12px;
  }

  .day-header-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .btn-bulk-sign {
    padding: 8px 12px;
    font-size: 12px;
  }

  .btn-sign {
    min-width: 76px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .week-display h1 {
    font-size: 26px;
    margin-bottom: 4px;
  }
  
  .week-controls {
    width: auto;
    justify-content: flex-end;
    margin-top: 0;
    gap: 4px;
    padding: 3px;
    border-radius: 13px;
    align-self: center;
  }

  .week-controls .btn-icon {
    width: 30px;
    height: 30px;
  }

  .week-controls .btn-secondary {
    min-height: 30px;
    padding: 5px 10px;
    font-size: 13px;
    border-radius: 10px;
  }

  .teacher-sign-notice {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    margin: 0 0 10px;
    padding: 10px 12px;
    gap: 10px;
  }

  .teacher-sign-notice strong {
    font-size: 13px;
  }

  .teacher-sign-notice span {
    font-size: 11px;
  }

  .teacher-sign-notice button {
    padding: 8px 10px;
    font-size: 12px;
  }

  .teacher-sign-notice .notice-actions {
    width: 100%;
    gap: 8px;
    flex-direction: row;
  }

  .teacher-sign-notice > div:first-child {
    flex: none;
  }

  .teacher-sign-notice .notice-actions button {
    flex: 1 1 0;
    min-width: 0;
  }

  .day-header {
    align-items: flex-start;
    gap: 12px;
  }

  .teacher-day-hint {
    font-size: 12px;
  }
  
  .week-selector-wrapper {
    flex-grow: 0;
    display: flex;
    justify-content: center;
    max-width: 110px;
  }
  
  .btn-secondary#weekSelectBtn {
    width: auto;
    min-width: 86px;
  }

  .week-popover {
    width: calc(100vw - 32px);
    max-width: 340px;
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (max-width: 380px) {
  .week-controls .btn-icon {
    width: 28px;
    height: 28px;
  }

  .week-controls .btn-secondary {
    padding: 5px 8px;
    font-size: 12px;
  }

  .btn-secondary#weekSelectBtn {
    min-width: 76px;
  }

  .week-display h1 {
    font-size: 24px;
  }
}

@media (max-width: 768px) {
  .login-overlay {
    padding: 16px;
    overflow-x: hidden;
    background-image:
      linear-gradient(160deg, rgba(9, 11, 16, 0.98) 0%, rgba(15, 23, 42, 0.94) 48%, rgba(239, 244, 249, 0.97) 48.2%, rgba(248, 250, 252, 0.98) 100%),
      repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 96px),
      repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 96px);
  }

  .login-stage {
    width: 100%;
    max-width: 420px;
    display: block;
  }

  .login-showcase {
    display: none;
  }

  .login-wrapper {
    width: 100%;
    max-width: min(420px, calc(100vw - 32px));
    padding: 32px 24px;
    margin: 0 auto;
    border-radius: 20px;
  }

  .login-wrapper::before {
    display: block;
  }

  .brand-tag {
    letter-spacing: 0;
  }

  .login-header h1 {
    font-size: 32px;
    letter-spacing: 0;
  }

  .login-form,
  .input-field,
  .password-row {
    width: 100%;
    min-width: 0;
  }

  .password-row {
    flex-direction: column;
    align-items: stretch;
  }

  .password-row input {
    width: 100%;
    min-width: 0;
  }

  .btn-default-password {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .btn-primary {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}
