/* 探吉日學生入口 */

:root {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface2: #f0f0f4;
  --border: #e2e2ea;
  --accent: #3a7bd5;
  --accent-dim: rgba(58, 123, 213, 0.1);
  --accent-dim-strong: rgba(58, 123, 213, 0.18);
  --text: #1a1a2e;
  --text2: #6b6b8a;
  --green: #1a7a4a;
  --green-dim: rgba(26, 122, 74, 0.1);
  --red: #d63031;
  --red-dim: rgba(214, 48, 49, 0.1);
  --yellow: #c47d00;
  --yellow-dim: rgba(196, 125, 0, 0.1);
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* 登入畫面 */

#login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 40px 32px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  margin-bottom: 12px;
  font-size: 52px;
}

.login-title {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
}

.login-sub {
  margin-bottom: 12px;
  color: var(--text2);
  font-size: 14px;
  line-height: 1.6;
}

.login-loading {
  margin-bottom: 0;
  color: var(--accent);
  font-weight: 700;
}

.login-error {
  height: 20px;
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

/* 主畫面 */

#main-screen {
  padding: 0 0 28px;
}

.header {
  padding: 24px 20px 18px;
  background: var(--accent);
  color: #fff;
  text-align: center;
}

.header-logo {
  margin-bottom: 6px;
  font-size: 13px;
  opacity: 0.8;
}

.header-name {
  margin-bottom: 4px;
  font-size: 26px;
  font-weight: 700;
}

.content {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.paused-banner {
  padding: 14px 16px;
  border: 1px solid rgba(196, 125, 0, 0.2);
  border-radius: var(--radius);
  background: var(--yellow-dim);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.card {
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.priority-card {
  border: 1.5px solid rgba(58, 123, 213, 0.22);
  box-shadow: 0 8px 24px rgba(58, 123, 213, 0.08);
}

.card-title {
  margin-bottom: 14px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head .card-title {
  margin-bottom: 0;
}

.card-toggle {
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface2);
  color: var(--text2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.card-toggle:hover {
  background: var(--border);
}

.record-icon-button {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
}

.record-icon-button svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.record-icon-button[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.card-summary {
  margin-bottom: 12px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.7;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-divider {
  height: 1px;
  margin: 16px 0;
  background: var(--border);
}

.group-section-title {
  margin-bottom: 12px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.empty-state {
  padding: 24px;
  color: var(--text2);
  font-size: 13px;
  text-align: center;
}

.text-accent {
  color: var(--accent);
}

.text-danger {
  color: var(--red);
}

/* 標籤 */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-small {
  font-size: 11px;
}

.badge-green {
  background: var(--green-dim);
  color: var(--green);
}

.badge-red {
  background: var(--red-dim);
  color: var(--red);
}

.badge-yellow {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.badge-blue {
  background: var(--accent-dim);
  color: var(--accent);
}

/* 公告 */

.announcement {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface2);
}

.announcement-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.announcement-body {
  flex: 1;
  min-width: 0;
}

.announcement-text {
  position: relative;
  max-height: 13em;
  overflow: hidden;
  color: var(--text);
}

.announcement-text.fade::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.4em;
  background: linear-gradient(rgba(240, 242, 247, 0), var(--surface2));
}

.announcement-text.open {
  max-height: none;
}

.announcement-text.open::after {
  display: none;
}

.announcement-more {
  padding: 4px 0 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.announcement-date {
  margin-top: 8px;
  color: var(--text2);
  font-size: 11px;
}

.show-countdown {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface2);
}

.show-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.show-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.show-days {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.show-sub {
  margin-top: 4px;
  color: var(--text2);
  font-size: 12px;
}

.show-sub span,
.show-sub a {
  white-space: nowrap;
}

.show-sub a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

/* 下一堂課 */

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.timeline-dot {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--green-dim);
  color: var(--green);
  font-size: 14px;
}

.timeline-info {
  flex: 1;
}

.timeline-date {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.timeline-detail {
  margin-top: 2px;
  color: var(--text2);
  font-size: 12px;
}

.next-lesson-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.next-lesson-date {
  color: var(--text2);
  font-size: 14px;
  line-height: 1.5;
}

.next-lesson-time {
  margin-top: 4px;
  color: var(--accent);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
}

.next-lesson-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* 繳費提醒 */

.payment-reminder-card {
  --payment-tone: #b7791f;
  margin-top: 2px;
  padding: 13px 14px;
  border: 1px solid rgba(183, 121, 31, 0.24);
  border-radius: 12px;
  background: #fff8e8;
}

.payment-reminder-card .group-section-title {
  margin: 0 0 5px;
  color: var(--payment-tone);
  font-size: 12px;
  font-weight: 800;
}

.payment-reminder-card.due {
  --payment-tone: #c05621;
  border-color: rgba(192, 86, 33, 0.25);
  background: #fff4e8;
}

.payment-reminder-card.overdue {
  --payment-tone: #c53030;
  border-color: rgba(197, 48, 48, 0.24);
  background: #fff0f0;
}

.payment-reminder-message {
  color: #513719;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.55;
}

.payment-reminder-card.due .payment-reminder-message {
  color: #713b1a;
}

.payment-reminder-card.overdue .payment-reminder-message {
  color: #742a2a;
}

/* 學生簽到 */

.self-checkin-card {
  padding: 16px;
  border: 1.5px solid rgba(26, 122, 74, 0.22);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(26, 122, 74, 0.08);
}

.self-checkin-title {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.self-checkin-meta {
  margin-bottom: 12px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.7;
}

.self-sign-pad {
  display: block;
  width: 100%;
  height: 180px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  touch-action: none;
}

.self-checkin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.self-checkin-btn {
  padding: 11px 15px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.self-checkin-submit {
  background: var(--green);
  color: #fff;
}

.self-checkin-clear {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
}

.self-checkin-status {
  min-height: 18px;
  margin-top: 10px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.7;
}

/* 請假／調課 */

.leave-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  align-items: center;
  gap: 12px;
}

.leave-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.leave-guide {
  width: 100%;
  min-width: 0;
}

.leave-options {
  margin-top: 6px;
}

.leave-shared {
  padding: 2px 0 8px;
  color: var(--text2);
  font-size: 12px;
}

.leave-shared b,
.leave-row-meta b {
  color: var(--accent);
  font-weight: 800;
}

.leave-shared b.zero,
.leave-row-meta b.zero {
  color: var(--text2);
}

.leave-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.leave-row:first-child {
  padding-top: 2px;
  border-top: none;
}

.leave-row-copy {
  flex: 1;
  min-width: 0;
}

.leave-row-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
}

.leave-row-meta {
  margin-top: 2px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.4;
}

.note-text {
  margin-top: 2px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  text-align: left;
}

.leave-note {
  margin-top: 4px;
}

.leave-contact {
  margin-top: 9px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.6;
}

.quote {
  color: var(--red);
  font-weight: 800;
  white-space: nowrap;
}

/* 按鈕 */

.primary-btn {
  width: 100%;
  min-height: 44px;
  padding: 11px 15px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn:hover {
  background: #326fc2;
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-btn.danger {
  background: var(--red);
}

.leave-row .primary-btn {
  width: 64px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 9px;
  font-size: 13px;
}

.leave-row .primary-btn:disabled {
  background: var(--surface2);
  color: var(--text2);
  cursor: not-allowed;
  opacity: 1;
}

.secondary-btn,
.modal-close {
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}

.guide-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.guide-button:hover,
.guide-button[aria-expanded="true"] {
  background: var(--accent-dim-strong);
}

/* 我的課程 */

.course-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.course-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.course-guide-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.course-guide-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 7px;
  width: max-content;
  max-width: calc(100vw - 64px);
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(20, 27, 43, 0.16);
}

.material-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.material-button:hover {
  background: var(--border);
}

.course-guide-menu .material-button {
  display: block;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface2);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.5s;
}

.progress-label {
  color: var(--text2);
  font-size: 13px;
  white-space: nowrap;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat-pill {
  min-width: 0;
  padding: 11px 4px;
  border-radius: 10px;
  background: var(--surface2);
  text-align: center;
}

.stat-pill-val {
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}

.stat-pill-val.accent {
  color: var(--accent);
}

.stat-pill-val.warn {
  color: var(--yellow);
}

.stat-pill-val.danger {
  color: var(--red);
}

.stat-pill-label {
  margin-top: 4px;
  color: var(--text2);
  font-size: 10px;
  white-space: nowrap;
}

/* 長期獎勵 */

.reward-soon-tag {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  vertical-align: 1px;
}

.reward-soon {
  filter: grayscale(1);
  opacity: 0.55;
}

.reward-bar {
  position: relative;
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface2);
}

.reward-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #9cc2f2, #3a7bd5);
  transition: width 1.4s ease-in-out;
}

.reward-tick {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
}

.reward-steps {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.reward-steps.perk-only {
  margin-bottom: 10px;
}

.reward-steps li {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding-bottom: 12px;
}

.reward-steps li:last-child {
  padding-bottom: 0;
}

.reward-steps li:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 22px;
  bottom: 2px;
  left: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--border);
}

.reward-steps li.done:not(:last-child)::before {
  background: var(--green);
}

.reward-dot {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.reward-steps li.done .reward-dot {
  border-color: var(--green);
  background: var(--green);
}

.reward-steps li.perk .reward-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.reward-steps li.next .reward-dot {
  border: 3px solid var(--accent);
  animation: reward-pulse 1.8s ease-out infinite;
}

@keyframes reward-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(58, 123, 213, 0.35);
  }

  100% {
    box-shadow: 0 0 0 9px rgba(58, 123, 213, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reward-fill {
    transition: none;
  }

  .reward-steps li.next .reward-dot {
    animation: none;
  }
}

.reward-when {
  color: var(--text2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.reward-gift {
  margin-top: 2px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.reward-steps li.next .reward-gift {
  color: var(--accent);
}

.reward-status {
  margin-top: 3px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.reward-steps li.done .reward-status {
  background: var(--green-dim);
  color: var(--green);
}

.reward-steps li.next .reward-status,
.reward-steps li.perk .reward-status {
  background: rgba(58, 123, 213, 0.12);
  color: var(--accent);
}

.gift-value {
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
}

.site-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  border-radius: 7px;
  background: var(--accent-dim);
  color: var(--accent);
  vertical-align: -5px;
}

.site-link:hover {
  background: var(--accent-dim-strong);
}

.site-link svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 繳費、上課、請假紀錄 */

.payment-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--surface2);
}

.payment-history-main {
  min-width: 0;
}

.payment-history-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.payment-history-date {
  margin-top: 2px;
  color: var(--text2);
  font-size: 12px;
}

.payment-history-amount {
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.sig-toggle-btn {
  margin-top: 6px;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: none;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
}

.sig-wrap {
  margin-top: 8px;
}

.sig-thumb {
  max-width: 100%;
  height: 32px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.absence-row {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface2);
}

.absence-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.absence-row-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.absence-row-meta {
  margin-top: 6px;
  color: var(--text2);
  font-size: 12px;
}

.absence-empty {
  color: var(--text2);
  font-size: 13px;
}

/* 課程檔案 */

#course-files-card .card-head {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

#course-files-card .card-title {
  margin: 0;
}

.course-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.course-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 32px;
  padding: 6px 10px;
  border: none;
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}

.course-link:hover {
  background: var(--accent-dim-strong);
}

.course-link:focus-visible {
  outline: 3px solid #a6c8fa;
  outline-offset: 2px;
}

.recent-files {
  display: flex;
  flex-direction: column;
}

.recent-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.recent-file:first-child {
  padding-top: 2px;
  border-top: none;
}

.recent-file-copy {
  flex: 1;
  min-width: 0;
}

.recent-file-name {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-file-meta {
  margin-top: 2px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.4;
}

.recent-file-download {
  width: 40px;
  height: 40px;
  min-width: 40px;
  text-decoration: none;
}

.logout-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text2);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.logout-btn:hover {
  background: var(--border);
}

/* 彈出視窗 */

.modal-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(20, 27, 43, 0.56);
}

.modal {
  width: min(760px, 100%);
  max-height: min(760px, 90vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background: #f7f8fb;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.25);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.modal-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.modal-body {
  overflow: auto;
  padding: 16px 18px 20px;
  overscroll-behavior: contain;
}

/* 須知 */

.material-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.material-text {
  padding: 16px 17px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.85;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.material-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.material-item img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.material-file {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
}

.material-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #fff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.material-file-copy {
  flex: 1;
  min-width: 0;
}

.material-file-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.material-file-meta {
  margin-top: 2px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.45;
}

.material-file .material-button {
  flex: 0 0 auto;
  width: auto;
  background: #fff;
  text-decoration: none;
}

/* 須知、公告的排版內容 */

.doc-paper {
  padding: 24px;
  border: 1px solid #e6e6ee;
  border-radius: 14px;
  background: #fff;
  color: #1a1a2e;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.85;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.doc-fit-box {
  position: relative;
  overflow: hidden;
}

.doc-fit-box > .doc-paper {
  width: 760px;
  transform-origin: 0 0;
}

.doc-paper > :first-child,
.doc-pane > :first-child,
.doc-mini > :first-child {
  margin-top: 0;
}

.doc-paper > :last-child,
.doc-pane > :last-child,
.doc-mini > :last-child {
  margin-bottom: 0;
}

.doc-heading {
  margin: 18px 0 8px;
  padding-left: 10px;
  border-left: 4px solid #3a7bd5;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.5;
}

.doc-text {
  margin: 8px 0;
  white-space: pre-wrap;
}

.doc-list {
  margin: 6px 0 10px;
  padding-left: 22px;
}

.doc-list li {
  margin: 3px 0;
  white-space: pre-wrap;
}

.doc-list li::marker {
  color: #6b6b8a;
}

.doc-note {
  margin: 10px 0;
  padding: 10px 14px;
  border-left: 4px solid;
  border-radius: 10px;
  white-space: pre-wrap;
}

.doc-tone-red {
  border-color: #b42318;
  background: #fdf0ee;
}

.doc-tone-blue {
  border-color: #1d5fd1;
  background: #eef4fd;
}

.doc-tone-gray {
  border-color: #9a9ab0;
  background: #f3f3f6;
}

.doc-tone-yellow {
  border-color: #d4a017;
  background: #fff8e6;
}

.doc-color-red {
  color: #b42318;
}

.doc-color-blue {
  color: #1d5fd1;
}

.doc-color-gray {
  color: #6b7280;
}

.doc-color-green {
  color: #15803d;
}

.doc-image {
  margin: 12px auto;
  text-align: center;
}

.doc-image img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 380px;
  margin: 0 auto;
  border: 1px solid #ececf2;
  border-radius: 10px;
  object-fit: contain;
  cursor: zoom-in;
}

.doc-image-s {
  max-width: 45%;
}

.doc-image-m {
  max-width: 75%;
}

.doc-image-l {
  max-width: 100%;
}

.doc-image figcaption {
  margin-top: 6px;
  color: #6b6b8a;
  font-size: 12px;
  line-height: 1.5;
}

.doc-image-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 12px;
  margin: 12px 0;
}

.doc-image-row .doc-image {
  flex: 1 1 0;
  max-width: 50%;
  margin: 0;
}

.doc-rule {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid #e6e6ee;
}

.doc-file {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid #e6e6ee;
  border-radius: 10px;
  background: #f7f7fa;
  color: #1a1a2e;
  text-decoration: none;
}

.doc-file-icon {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 8px;
  background: #fff;
  color: #3a7bd5;
  font-size: 11px;
  font-weight: 900;
}

.doc-file-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
}

.doc-file-open {
  flex: 0 0 auto;
  color: #3a7bd5;
  font-size: 12px;
  font-weight: 700;
}

.doc-tabs {
  display: flex;
  gap: 4px;
  margin: 4px 0 14px;
  padding: 4px;
  border-radius: 10px;
  background: #f0f0f4;
}

.doc-tab {
  flex: 1;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6b6b8a;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.doc-tab.on {
  background: #fff;
  color: #1a1a2e;
  box-shadow: 0 1px 3px rgba(20, 20, 60, 0.12);
}

.doc-steps {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid #e6e6ee;
  border-radius: 12px;
  background: #fafafc;
}

.doc-steps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.doc-steps-count {
  color: #6b6b8a;
  font-size: 12px;
  font-weight: 700;
}

.doc-steps-nav {
  display: flex;
  gap: 6px;
}

.doc-steps-nav button {
  padding: 5px 10px;
  border: 1px solid #e2e2ea;
  border-radius: 8px;
  background: #fff;
  color: #1a1a2e;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.doc-steps-nav button:disabled {
  cursor: default;
  opacity: 0.35;
}

.doc-step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
}

.doc-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #3a7bd5;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.doc-step .doc-image {
  margin: 8px auto;
}

.doc-step .doc-image img {
  max-height: 480px;
}

.doc-step-text {
  margin-top: 6px;
  white-space: pre-wrap;
}

.doc-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.doc-dots button {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #d4d4de;
  cursor: pointer;
}

.doc-dots button.on {
  width: 16px;
  background: #3a7bd5;
}

.doc-mini {
  font-size: 14px;
  line-height: 1.75;
}

.doc-mini .doc-heading {
  margin: 10px 0 4px;
  font-size: 15px;
}

.doc-mini .doc-image img {
  max-height: 240px;
}

.image-zoom {
  position: fixed;
  z-index: 100000;
  inset: 0;
  display: flex;
  overflow: auto;
  padding: 44px 0 0;
  background: rgba(10, 10, 20, 0.94);
  -webkit-overflow-scrolling: touch;
}

.image-zoom-wrap {
  position: relative;
  flex: none;
  margin: auto;
}

.image-zoom img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  max-height: none;
  border-radius: 6px;
  background: #fff;
  cursor: zoom-in;
  transform-origin: 0 0;
}

.image-zoom.full img {
  cursor: zoom-out;
}

.image-zoom-bar {
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: rgba(10, 10, 20, 0.92);
}

.image-zoom-close {
  position: absolute;
  top: 6px;
  right: 10px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #1a1a2e;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.image-zoom-tip {
  position: absolute;
  top: 12px;
  left: 14px;
  color: #fff;
  font-size: 12px;
  opacity: 0.85;
}

/* 請假／調課視窗 */

.modal.modal-narrow {
  width: min(520px, 100%);
}

.flow-step {
  margin-bottom: 10px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.flow-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--yellow-dim);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}

.flow-notice.danger {
  background: var(--red-dim);
  color: var(--red);
}

.flow-box {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface2);
}

.flow-box-label {
  margin-top: 3px;
  color: var(--text2);
  font-size: 12px;
}

.flow-box-value {
  font-size: 14px;
  font-weight: 700;
}

.flow-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flow-line {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.flow-subhead {
  margin: 14px 0 8px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
}

.flow-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.flow-actions .primary-btn {
  flex: 1;
}

.flow-error {
  margin-top: 10px;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.link-button {
  margin-left: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.slot-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid rgba(58, 123, 213, 0.35);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.slot-option:hover {
  border-color: var(--accent);
}

.slot-option-text {
  flex: 1;
  min-width: 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}

.mode-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(8, 145, 178, 0.12);
  color: #0e7490;
  font-size: 11px;
  font-weight: 800;
  vertical-align: 1px;
}

.calendar {
  padding: 10px 8px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.calendar-month {
  margin: 0 4px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.calendar-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  margin-top: 3px;
}

.calendar-weekday {
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.calendar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 46px;
  padding: 0;
  border: 1.5px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
}

button.calendar-day {
  cursor: pointer;
}

.calendar-day b {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.calendar-day small {
  min-height: 12px;
  color: var(--text2);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.calendar-day.past {
  color: #c4c7d2;
}

.calendar-day.today {
  border-color: var(--accent);
}

.calendar-day.today small {
  color: var(--accent);
}

.calendar-day.lesson {
  background: var(--accent);
  color: #fff;
}

.calendar-day.lesson small {
  color: rgba(255, 255, 255, 0.9);
}

.calendar-day.available {
  background: rgba(58, 123, 213, 0.12);
  color: var(--accent);
}

.calendar-day.available small {
  color: var(--accent);
}

.calendar-day.locked {
  background: var(--surface2);
  color: var(--text2);
}

.calendar-day.original b {
  color: var(--text2);
  text-decoration: line-through;
}

.calendar-day.selected {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--text);
}

.confirm-overlay {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 27, 43, 0.35);
}

.confirm-dialog {
  width: min(340px, 100%);
  padding: 18px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(20, 27, 43, 0.2);
}

.confirm-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.confirm-text {
  margin: 8px 0 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.flow-done {
  padding: 12px 4px;
  text-align: center;
}

.flow-done strong {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 20px;
}

.flow-done.danger strong {
  color: var(--red);
}

.receipt {
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
}

.receipt-row:first-child {
  border-top: none;
}

.receipt-row span:first-child {
  flex: none;
  color: var(--text2);
}

.receipt-row span:last-child {
  color: var(--text);
  font-weight: 700;
  text-align: right;
}

.flow-done-note {
  margin-top: 10px;
  text-align: center;
}

/* 簽名放大 */

.sig-modal-overlay {
  position: fixed;
  z-index: 999;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
}

.sig-modal {
  width: 100%;
  max-width: 400px;
  padding: 24px;
  border-radius: 16px;
  background: #fff;
  text-align: center;
}

.sig-modal-title {
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 700;
}

.sig-modal img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.sig-modal-close {
  margin-top: 16px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

/* 課程檔案視窗 */

.files-overlay {
  position: fixed;
  z-index: 10010;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #1a24395c;
}

.files-window {
  width: min(780px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  border: 1px solid #e0e5ed;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 65px #16213a29;
  color: #253148;
  font:
    14px/1.65 -apple-system,
    BlinkMacSystemFont,
    "PingFang TC",
    sans-serif;
}

.files-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.files-head h2 {
  font-size: 20px;
  white-space: nowrap;
}

.files-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.files-window button,
.files-download {
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid #d9e0eb;
  border-radius: 9px;
  background: #fff;
  color: #344c75;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.files-window button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.files-tools button {
  padding: 7px 10px;
}

.files-tools .files-refresh {
  width: 38px;
  min-height: 38px;
  padding: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: #e2e7ef;
  border-radius: 10px;
  color: #546780;
}

.files-tools .files-refresh:hover {
  border-color: #bec9d9;
  background: #f3f6fa;
}

.files-refresh svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.files-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0;
}

.files-tabs button {
  flex: 1;
  white-space: nowrap;
}

.files-tabs button[aria-selected="true"] {
  border-color: #88a1d5;
  background: #eaf0ff;
}

.files-group {
  margin-top: 18px;
}

.files-group h3 {
  font-size: 16px;
}

.files-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid #e8edf4;
}

.files-row-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}

.files-meta {
  color: #627087;
  font-size: 12px;
}

.files-empty {
  padding: 28px 0;
  color: #627087;
}

.files-error {
  color: #a33131;
}

/* 窄螢幕 */

@media (max-width: 600px) {
  .files-overlay {
    padding: 8px;
  }

  .files-window {
    max-height: 95vh;
    padding: 16px;
  }

  .files-row {
    align-items: flex-start;
  }

  .files-download {
    flex-shrink: 0;
  }
}

@media (max-width: 560px) {
  .modal-overlay {
    padding: 0;
  }

  .modal {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal-body {
    padding: 12px;
  }

  .material-file {
    flex-direction: column;
    align-items: stretch;
  }

  .material-file .material-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .files-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 380px) {
  .next-lesson-main {
    flex-direction: column;
  }
}
