
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: rgba(29, 41, 57, 0.1);
  --text: #263241;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-light: #6366f1;
  --accent-secondary: #0f766e;
  --danger: #b4233a;

  --shadow-light: rgba(255, 255, 255, 0.9);
  --shadow-dark: rgba(15, 23, 42, 0.08);

  --shadow-raised: 0 14px 34px rgba(15, 23, 42, 0.08);
  --shadow-raised-hover: 0 18px 44px rgba(15, 23, 42, 0.1);
  --shadow-small: 0 6px 16px rgba(15, 23, 42, 0.08);
  --shadow-inset: inset 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-inset-deep: inset 0 1px 3px rgba(15, 23, 42, 0.08);

  --radius-card: 8px;
  --radius-control: 12px;
  --radius-inner: 8px;
}
  html[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-soft: #334155;
  --border: rgba(226, 232, 240, 0.2);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --accent: #a78bfa;
  --accent-light: #c4b5fd;
  --accent-secondary: #5eead4;
  --danger: #ff7a90;

  --shadow-light: rgba(255, 255, 255, 0.04);
  --shadow-dark: rgba(0, 0, 0, 0.32);

  --shadow-raised: 0 14px 34px rgba(0, 0, 0, 0.24);
  --shadow-raised-hover: 0 18px 44px rgba(0, 0, 0, 0.3);
  --shadow-small: 0 6px 16px rgba(0, 0, 0, 0.22);
  --shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-inset-deep: inset 0 1px 3px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 7vw 56px;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body > h1,
body > p,
body > h2,
body > h3,
body > ul,
body > article,
body > table,
body > form:not(.nav-search),
body > section {
  width: min(100%, 1080px);
  max-width: 1080px;
  margin-left: auto;
  margin-right: auto;
}

body > form:not(.nav-search) {
  width: min(100%, 760px);
  max-width: 760px;
}

body > form[data-lesson-reorder-form] {
  width: min(100%, 1080px);
  max-width: 1080px;
  overflow-x: auto;
}

h1,
h2,
h3 {
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  color: var(--text);
  letter-spacing: 0;
}

h1 {
  margin-top: 28px;
  margin-bottom: 42px;
  font-size: clamp(32px, 5vw, 64px);
  font-weight: 800;
}

h2 {
  margin-top: 40px;
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 800;
}

h3 {
  margin-top: 0;
  font-size: 20px;
  font-weight: 700;
}

p {
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  transition: color 300ms ease-out, transform 300ms ease-out;
}

a:hover {
  color: var(--accent-light);
  text-decoration: none;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 110;
  width: calc(100% + 14vw);
  margin: 0 -7vw 42px;
  padding: 12px 7vw;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 270px auto auto;
  align-items: center;
  gap: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  backdrop-filter: blur(14px);
}

html[data-theme="dark"] .app-nav {
  background: rgba(24, 34, 49, 0.76);
}

.public-nav {
  grid-template-columns: auto 1fr auto auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand-link {
  padding: 6px 8px 6px 4px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-weight: 800;
  white-space: nowrap;
}

.brand-link::before {
  content: "";
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: var(--surface) url("/logo.png") center / cover no-repeat;
  box-shadow: var(--shadow-small);
}

.brand-logo {
  display: none;
}

.site-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.public-nav .site-links {
  display: none;
}

.nav-search {
  position: relative;
  width: 270px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  justify-self: end;
  align-self: center;
  line-height: 1;
  transform: translateY(4px);
}

.nav-search-box {
  min-height: 38px;
  padding: 0 10px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-small);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.nav-search:focus-within .nav-search-box {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(124, 93, 250, 0.14);
}

.nav-search-icon {
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.nav-search input {
  width: 100%;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.nav-search input:focus {
  outline: none;
}

.nav-search input::placeholder {
  color: var(--muted);
  opacity: 0.78;
}

.nav-search-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.nav-search input:not(:placeholder-shown) + .nav-search-shortcut {
  display: none;
}

.nav-search-shortcut kbd {
  min-width: 18px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.12);
}

.nav-search-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  z-index: 140;
  max-height: min(68vh, 520px);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-raised-hover);
}

.nav-search-empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.nav-search-result,
.search-result-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
}

.nav-search-result:hover,
.search-result-item:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.nav-search-result-kind,
.search-result-kind {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.nav-search-result strong,
.search-result-item strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
}

.nav-search-result span:last-child,
.search-result-item span:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
}

.search-keyword {
  padding: 0 2px;
  border-radius: 4px;
  background: rgba(250, 204, 21, 0.38);
  color: inherit;
  font-weight: 950;
}

html[data-theme="dark"] .search-keyword {
  background: rgba(251, 191, 36, 0.32);
  color: #fef3c7;
}

.search-page-panel {
  max-width: 920px;
  margin: 0 auto;
}

.search-page-form {
  max-width: none;
  margin: 0 0 22px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.search-page-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.search-result-list {
  display: grid;
  gap: 10px;
}

.search-result-item {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.search-muted {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.site-links a,
.login-nav-button,
.admin-menu summary,
.admin-panel a,
.account-panel a,
.back-link,
p > a[href="/login"] {
  min-height: 38px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  transition:
    background 220ms ease-out,
    border-color 220ms ease-out,
    color 220ms ease-out,
    transform 220ms ease-out;
}

.site-links a:hover,
.login-nav-button:hover,
.admin-menu summary:hover,
.admin-panel a:hover,
.account-panel a:hover,
.back-link:hover,
p > a[href="/login"]:hover {
  color: var(--accent);
  background: var(--surface-soft);
  border-color: var(--border);
  transform: translateY(-1px);
}

.site-links a.active,
.login-nav-button.active,
.admin-menu summary.active,
.account-panel a.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.admin-menu {
  position: relative;
}

.admin-menu::after,
.account-menu::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 18px;
  display: none;
}

.admin-menu[open]::after,
.account-menu[open]::after {
  display: block;
}

.admin-menu summary {
  list-style: none;
  cursor: pointer;
}

.admin-menu summary::-webkit-details-marker {
  display: none;
}

.admin-menu summary::after {
  content: "▾";
  margin-left: 8px;
  font-size: 11px;
}

.admin-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 120;
  width: 220px;
  padding: 16px 10px 10px;
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-raised-hover);
}

.admin-menu[open] .admin-panel {
  display: block;
}

.admin-panel a {
  width: 100%;
  justify-content: flex-start;
}

.account-menu {
  position: relative;
  justify-self: end;
}

.login-nav-button {
  min-width: 52px;
  height: 40px;
  justify-self: end;
}

.login-nav-button.active {
  justify-content: center;
}

.account-placeholder {
  display: none;
  justify-self: end;
}

.account-menu summary {
  list-style: none;
  cursor: pointer;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.avatar {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent);
  border: 1px solid var(--border);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-weight: 800;
  box-shadow: var(--shadow-small);
}

.account-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 120;
  width: 240px;
  padding: 16px 10px 10px;
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-raised-hover);
}

.account-menu[open] .account-panel {
  display: block;
}

.account-meta {
  padding: 10px 12px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.account-meta strong,
.account-meta span {
  display: block;
}

.account-meta span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.account-panel a {
  width: 100%;
  justify-content: flex-start;
}

article,
section,
form:not(.nav-search),
table,
ul {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-raised);
  transition: transform 300ms ease-out, box-shadow 300ms ease-out;
}

article,
section,
form:not(.nav-search) {
  padding: 42px;
}

section:hover,
article:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-raised-hover);
}

ul {
  padding: 26px 30px 26px 54px;
}

li {
  margin: 10px 0;
}

li::marker {
  color: var(--accent);
}

.home-block {
  width: min(100%, 980px);
  margin: 28px auto 0;
  padding: 28px;
}

.home-block h2 {
  margin: 0 0 20px;
  font-size: 24px;
}

.lesson-list {
  width: 100%;
  margin: 0;
  display: grid;
  gap: 12px;
}

.teacher-contact {
  margin-top: 28px;
}

.teacher-contact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.contact-item {
  min-height: 64px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 800;
  box-shadow: var(--shadow-small);
}

.contact-item:hover {
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-raised);
}

.contact-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-contrast);
}

.contact-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.contact-icon-discord svg {
  width: 20px;
  height: 20px;
}

.contact-icon-line svg {
  width: 22px;
  height: 22px;
}

.contact-icon-email svg {
  width: 22px;
  height: 22px;
}

.progress-dashboard {
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.progress-meter {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.progress-meter-main {
  grid-column: span 2;
}

.progress-meter span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.progress-meter strong {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 32px;
  line-height: 1;
}

.progress-bar {
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.progress-bar span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--accent);
}

.lesson-list-item {
  min-height: 72px;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-small);
}

.lesson-list-item:hover {
  color: var(--text);
  background: var(--surface-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-raised);
}

.lesson-list-index {
  color: var(--muted);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-weight: 800;
}

.lesson-list-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lesson-list-title {
  font-size: 18px;
  font-weight: 800;
}

.lesson-list-outline {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.lesson-list-outline code,
.lesson-list-outline kbd {
  font-size: 0.92em;
}

.lesson-list-separator {
  color: var(--accent);
  font-weight: 900;
}

.lesson-list-arrow {
  color: var(--muted);
  font-size: 20px;
}

.lesson-direct-links {
  width: min(100%, 1080px);
  margin: -20px auto 24px;
}

.lesson-direct-link {
  min-height: 74px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background:
    linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(13, 148, 136, 0.08)),
    var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-small);
}

.lesson-direct-link:hover {
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-raised);
}

.lesson-direct-link strong,
.lesson-direct-link small {
  display: block;
}

.lesson-direct-link strong {
  font-size: 17px;
  font-weight: 900;
}

.lesson-direct-link small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.lesson-direct-link-arrow {
  color: var(--accent);
  font-size: 22px;
  font-weight: 900;
}

.public-lesson-item .lesson-list-arrow {
  min-width: max-content;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

table th,
table td {
  border: 0;
  padding: 12px 14px;
  vertical-align: middle;
  text-align: left;
}

table th:first-child,
table td:first-child {
  min-width: 72px;
  white-space: nowrap;
}

table th {
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", sans-serif;
  font-weight: 800;
  background: transparent;
}

.admin-content-table th:nth-child(2),
.admin-content-table td:nth-child(2) {
  min-width: 220px;
  width: 28%;
}

.lesson-admin-table th:nth-child(3),
.lesson-admin-table td:nth-child(3) {
  min-width: 360px;
}

.admin-users-table th {
  font-size: 0;
}

.admin-users-table th::before {
  font-size: 16px;
}

.admin-users-table th:nth-child(1)::before {
  content: "帳號";
}

.admin-users-table th:nth-child(2)::before {
  content: "角色";
}

.admin-users-table th:nth-child(3)::before {
  content: "操作";
}

.role-select-form {
  margin: 0;
}

.role-select-form select {
  min-width: 120px;
  min-height: 38px;
  padding: 7px 34px 7px 12px;
  border-radius: var(--radius-control);
  font-weight: 900;
}

.lesson-admin-table [data-lesson-row] {
  cursor: grab;
}

.lesson-admin-table [data-lesson-row].is-dragging {
  opacity: 0.58;
}

.drag-handle {
  margin-right: 8px;
  color: var(--muted);
  cursor: grab;
  font-weight: 900;
}

.lesson-h2-list {
  margin: 0;
  padding-left: 20px;
}

.lesson-h2-list li + li {
  margin-top: 3px;
}

.exercise-list-table th:first-child,
.exercise-list-table td:first-child {
  width: 64px;
  color: var(--muted);
  font-weight: 800;
}

.exercise-page-intro {
  margin-top: -16px;
}

.exercise-page-intro p {
  margin-bottom: 0;
  color: var(--muted);
}

.exercise-lesson-group {
  width: min(100%, 1080px);
  margin: 0 auto 28px;
}

.exercise-lesson-heading {
  margin-bottom: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.exercise-lesson-heading h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
}

.exercise-lesson-heading .eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
}

.exercise-title-link {
  color: var(--text);
  font-weight: 800;
}

.exercise-title-link:hover {
  color: var(--accent);
}

.table-title-link {
  color: var(--text);
  font-weight: 900;
}

.table-title-link:hover {
  color: var(--accent);
}

.tag-pill {
  min-height: 30px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 14px;
  font-weight: 800;
}

.status-pill {
  min-height: 32px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.status-done {
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.28);
}

.status-review {
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.28);
}

.status-stuck {
  color: var(--danger);
  border-color: rgba(180, 35, 58, 0.28);
}

table td {
  color: var(--text);
  border-top: 1px solid rgba(107, 114, 128, 0.18);
}

.markdown-summary {
  max-height: 128px;
  overflow: hidden;
  color: var(--muted);
}

.markdown-summary .lesson-rich-content,
.markdown-summary p,
.markdown-summary ul,
.markdown-summary ol,
.markdown-summary blockquote {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
}

.markdown-summary h1,
.markdown-summary h2,
.markdown-summary h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

table tr:hover td {
  background: rgba(108, 99, 255, 0.055);
}

label {
  display: inline-block;
  margin-top: 14px;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 700;
}

form div {
  margin-bottom: 22px;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  padding: 12px 16px;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  box-shadow: none;
  font: inherit;
  outline: none;
  transition: box-shadow 300ms ease-out, transform 300ms ease-out;
}

select {
  padding-right: 46px;
}

textarea {
  font-family: "DM Sans", "Noto Sans TC", system-ui, sans-serif;
}

input:focus,
select:focus,
textarea:focus {
  box-shadow:
    0 0 0 3px rgba(79, 70, 229, 0.16),
    var(--shadow-inset-deep);
  border-color: rgba(79, 70, 229, 0.42);
}

button,
input[type="submit"] {
  min-height: 46px;
  padding: 11px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-small);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-weight: 800;
  cursor: pointer;
  transition: transform 300ms ease-out, box-shadow 300ms ease-out, color 300ms ease-out;
}

.highlight-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(139, 92, 246, 0.24);
}

.highlight-button:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
  color: #ffffff;
}

.editor-preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 22px;
  align-items: start;
}

.editor-preview-layout form {
  margin: 0;
}

.markdown-preview-card {
  min-height: 420px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  position: sticky;
  top: 112px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-raised);
}

.markdown-preview-card h2 {
  margin-top: 0;
  font-size: 22px;
}

.markdown-preview-card .lesson-rich-content {
  min-width: 0;
  overflow-wrap: anywhere;
}
  
form button {
  margin-top: 4px;
}

form button[type="submit"]:not(.table-action-button):not(.danger-button) {
  min-height: 46px;
  padding: 11px 20px;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(139, 92, 246, 0.22);
}

form button[type="submit"]:not(.table-action-button):not(.danger-button)::before {
  content: "✓";
  margin-right: 8px;
  font-weight: 900;
}

form button[type="submit"]:not(.table-action-button):not(.danger-button):hover {
  border-color: var(--accent-light);
  background: var(--accent-light);
  color: #ffffff;
  transform: translateY(-1px);
}

form button[type="submit"]:not(.table-action-button):not(.danger-button):active {
  transform: translateY(0);
  box-shadow: var(--shadow-small);
}

.inline-form {
  display: inline-block;
  width: auto;
  max-width: none;
  margin: 0 8px 8px 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.inline-form button {
  min-height: 38px;
  padding: 8px 14px;
  margin: 0;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  width: max-content;
  min-width: max-content;
}

td:has(.table-actions),
th:last-child {
  width: 1%;
  min-width: 156px;
  white-space: nowrap;
  text-align: left;
  vertical-align: middle;
}

.table-actions .inline-form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.table-action-button {
  height: 38px;
  min-height: 38px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  box-shadow: var(--shadow-small);
}

.table-action-button:hover {
  color: var(--accent);
  background: var(--surface-soft);
}

.course-admin-table {
  table-layout: auto;
}

.course-admin-table th:first-child,
.course-admin-table td:first-child {
  width: 58px;
  max-width: 58px;
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
  color: var(--muted);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.course-admin-table th:nth-child(2),
.course-admin-table td:nth-child(2) {
  padding-left: 14px;
}

.lesson-section-admin-table th:nth-child(2),
.lesson-section-admin-table td:nth-child(2) {
  width: auto;
  min-width: 260px;
}

.danger-button {
  color: var(--danger);
}

.danger-button:hover {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

button:hover,
input[type="submit"]:hover {
  transform: translateY(-1px);
  color: var(--accent);
  box-shadow: var(--shadow-small);
}

button:active,
input[type="submit"]:active {
  transform: translateY(0);
  box-shadow: none;
}
.theme-toggle {
  justify-self: end;
  min-height: 40px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  box-shadow: none;
  color: var(--accent);
}

.login-choice-wrap {
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  width: min(100%, 980px);
  margin: 0 auto;
}

.login-choice-card {
  width: 100%;
  padding: 56px;
  text-align: center;
}

.auth-site-title {
  text-align: center;
}

.login-choice-wrap .home-block {
  width: 100%;
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-choice-desc {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  color: var(--muted);
  font-size: 18px;
}

.auth-subtitle {
  max-width: 480px;
  margin: -10px auto 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
  text-align: center;
}

.auth-heading {
  width: min(100%, 760px);
  margin: -10px auto 24px;
  padding: 24px;
  text-align: center;
}

.auth-heading h2 {
  margin: 6px 0 12px;
  font-size: clamp(32px, 5vw, 52px);
}

.auth-heading p:last-child {
  margin: 0;
  color: var(--muted);
}

.auth-switch {
  margin: 0 0 14px;
  text-align: center;
  color: var(--muted);
}

.auth-switch a {
  margin-left: 4px;
}

.signup-success-actions {
  width: min(100%, 420px);
  margin: 36px auto 0;
  display: flex;
  justify-content: center;
}

.signup-success-actions .choice-button {
  width: 100%;
  justify-content: center;
}

.signup-success-contact {
  width: min(100%, 980px);
  margin: 44px auto 0;
}

.signup-step {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.signup-step:hover {
  transform: none;
  box-shadow: none;
}

.not-found-shell {
  width: min(100%, 980px);
  min-height: calc(100vh - 220px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.not-found-panel {
  width: min(100%, 720px);
  padding: clamp(36px, 7vw, 72px);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background:
    linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(13, 148, 136, 0.08)),
    var(--surface);
  box-shadow: var(--shadow-raised);
  text-align: center;
}

.not-found-code {
  width: max-content;
  margin: 0 auto 18px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.14em;
}

.not-found-panel h1 {
  margin: 0 0 16px;
  font-size: clamp(34px, 6vw, 64px);
  text-align: center;
}

.not-found-panel p:not(.not-found-code) {
  max-width: 520px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 18px;
}

.not-found-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 32px;
}

fieldset {
  margin: 0 0 22px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}

legend {
  padding: 0 8px;
  color: var(--text);
  font-weight: 800;
}

fieldset label,
.checkbox-grid label {
  width: fit-content;
  margin: 10px 18px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

input[type="radio"],
input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

.checkbox-grid {
  margin-top: 8px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.page-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: -16px;
  margin-bottom: 24px;
}

.action-button {
  min-height: 44px;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-small);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 800;
  transition:
    transform 220ms ease-out,
    box-shadow 220ms ease-out,
    background 220ms ease-out;
}

.action-button:hover {
  color: #ffffff;
  background: var(--accent-light);
  border-color: var(--accent-light);
  transform: translateY(-1px);
}

p:has(a[href="/admin"]),
p:has(a[href="/admin/users"]),
p:has(a[href="/admin/lessons"]),
p:has(a[href="/admin/exercises"]),
p:has(> a.back-link),
p:has(> a[href="/login"]),
p:has(a[href="/"]) {
  position: fixed;
  left: 24px;
  top: 86px;
  z-index: 180;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0;
  margin: 0;
}

p:has(a[href="/admin"]) > a,
p:has(a[href="/admin/users"]) > a,
p:has(a[href="/admin/lessons"]) > a,
p:has(a[href="/admin/exercises"]) > a,
p:has(> a.back-link) > a,
p:has(> a[href="/login"]) > a,
p:has(a[href="/"]) > a {
  min-height: 38px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow-small);
}

p:has(a[href="/admin"]) > a:hover,
p:has(a[href="/admin/users"]) > a:hover,
p:has(a[href="/admin/lessons"]) > a:hover,
p:has(a[href="/admin/exercises"]) > a:hover,
p:has(> a.back-link) > a:hover,
p:has(> a[href="/login"]) > a:hover,
p:has(a[href="/"]) > a:hover {
  color: var(--accent);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.login-choice-actions {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 36px;
}

.compact-actions {
  gap: 14px;
  margin-top: 30px;
}

.choice-button {
  min-width: 300px;
  min-height: 92px;
  padding: 0 34px;
  border-radius: var(--radius-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 24px;
  font-weight: 800;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-small);
  transition:
    transform 300ms ease-out,
    box-shadow 300ms ease-out,
    color 300ms ease-out,
    background 300ms ease-out;
}

.compact-actions .choice-button {
  min-width: 190px;
  min-height: 56px;
  padding: 0 22px;
  gap: 12px;
  font-size: 17px;
}

.compact-actions .choice-arrow {
  font-size: 22px;
}

.choice-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-small);
}

.choice-button:active {
  transform: translateY(0);
  box-shadow: none;
}

.lesson-entry-grid {
  width: min(100%, 980px);
  margin: 44px auto 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.lesson-entry-card {
  min-height: 160px;
  padding: 34px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.lesson-entry-card:hover {
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-raised);
}

.lesson-content-card {
  background: var(--surface);
}

.lesson-exercise-card {
  background: var(--surface);
}

.lesson-card-kicker {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.lesson-entry-card strong {
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 30px;
  line-height: 1.1;
}

.lesson-entry-card span:last-child {
  color: var(--muted);
  font-size: 16px;
}

.slide-deck {
  width: min(100%, 1080px);
  margin: 0 auto;
}

.slide-deck:has(.lesson-table-slide.active) {
  width: min(100%, 1400px);
}

.slide-stage {
  min-height: 520px;
  display: grid;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  overflow: hidden;
}

.slide-stage:has(.lesson-table-slide.active) {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.lesson-slide {
  min-height: 520px;
  padding: clamp(28px, 5vw, 58px);
  display: none;
  align-content: center;
  background: transparent;
}

.lesson-slide.active {
  display: grid;
}

.lesson-table-slide {
  min-height: 0;
  padding: 0;
  align-content: start;
}

.lesson-table-slide .lesson-rich-content {
  display: block;
}

.lesson-table-slide .lesson-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.lesson-toc-slide {
  background:
    linear-gradient(135deg, rgba(124, 58, 237, 0.11), rgba(13, 148, 136, 0.08)),
    var(--surface);
}

.lesson-toc {
  display: block;
}

.lesson-toc-list {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 12px;
  list-style: none;
}

.lesson-toc-list li {
  min-width: 0;
}

.lesson-toc button {
  width: 100%;
  min-height: 58px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  box-shadow: var(--shadow-small);
  cursor: pointer;
}

.lesson-toc button:hover,
.lesson-toc button:focus-visible {
  color: var(--text);
  background: var(--surface-soft);
  transform: translateY(-1px);
  outline: none;
}

.lesson-toc span {
  color: var(--accent);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 900;
}

.lesson-toc strong {
  min-width: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.lesson-toc-arrow {
  color: var(--muted);
  font-size: 20px;
}

.slide-controls {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.slide-controls [data-slide-count] {
  min-width: 76px;
  min-height: 40px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  color: var(--muted);
  text-align: center;
  font-weight: 900;
  cursor: pointer;
}

.slide-controls [data-slide-count]:hover,
.slide-controls [data-slide-count]:focus-visible {
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

.slide-page-input {
  width: 74px;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: var(--radius-control);
  font: inherit;
  font-weight: 900;
  text-align: center;
}

.slide-next-section {
  min-height: 44px;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-small);
}

.lesson-rich-content {
  display: grid;
  gap: 18px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.85;
}

.lesson-rich-content h1,
.lesson-rich-content h2,
.lesson-rich-content h3,
.lesson-rich-content h4,
.lesson-rich-content h5,
.lesson-rich-content h6,
.lesson-rich-content p,
.lesson-rich-content ul,
.lesson-rich-content ol,
.lesson-rich-content blockquote {
  margin: 0;
}

.lesson-rich-content h1 {
  margin-top: 10px;
  font-size: clamp(34px, 5vw, 56px);
}

.lesson-rich-content h2 {
  margin-top: 10px;
  font-size: clamp(30px, 4vw, 46px);
}

.lesson-rich-content h3 {
  margin-top: 8px;
  font-size: clamp(24px, 3vw, 34px);
}

.lesson-rich-content h4 {
  margin-top: 6px;
  font-size: clamp(20px, 2.4vw, 26px);
}

.lesson-rich-content h5,
.lesson-rich-content h6 {
  margin-top: 4px;
  font-size: 18px;
}

.lesson-rich-content ul,
.lesson-rich-content ol {
  padding: 0 0 0 28px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.lesson-rich-content li > ul,
.lesson-rich-content li > ol {
  margin-top: 4px;
}

.lesson-rich-content li::marker {
  color: var(--accent);
  font-weight: 900;
}

.lesson-rich-content blockquote {
  padding: 18px 20px;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  color: var(--muted);
}

.lesson-rich-content hr {
  width: 100%;
  height: 1px;
  border: 0;
  background: var(--border);
}

.lesson-rich-content strong {
  font-weight: 900;
}

.lesson-rich-content em {
  color: var(--muted);
}

.lesson-rich-content del {
  color: var(--muted);
}

.lesson-rich-content a {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.notes-layout {
  width: min(100%, 1080px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

.notes-form,
.notes-preview {
  width: 100%;
  max-width: none;
}

.teacher-comment-alert {
  width: min(100%, 1080px);
  margin: 0 auto 24px;
  padding: 22px 24px;
  border: 1px solid rgba(217, 119, 6, 0.34);
  border-radius: var(--radius-card);
  background: rgba(217, 119, 6, 0.1);
  box-shadow: var(--shadow-small);
}

.teacher-comment-alert strong {
  display: block;
  margin-bottom: 10px;
  color: #d97706;
  font-size: 18px;
}

.teacher-comment-alert.compact {
  width: 100%;
  margin: 0 0 18px;
}

.notes-table .teacher-comment-alert.compact {
  margin: 12px 0 0;
  padding: 14px 16px;
}

.notes-table .teacher-comment-alert.compact strong {
  font-size: 14px;
}

.note-comment-badge {
  min-height: 32px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(217, 119, 6, 0.34);
  border-radius: 999px;
  background: rgba(217, 119, 6, 0.1);
  color: #d97706;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.lesson-image {
  max-width: 100%;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-small);
}

.lesson-rich-content code {
  padding: 2px 7px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--accent);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  font-weight: 700;
}

.lesson-rich-content kbd,
.markdown-help-panel kbd {
  min-width: 1.8em;
  padding: 2px 7px 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
  font-weight: 800;
  line-height: 1.2;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}

.lesson-code-block {
  margin: 0;
}

.lesson-code-block figcaption {
  width: 100%;
  max-width: 100%;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-control) var(--radius-control) 0 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 800;
}

.code-copy-button {
  width: 32px;
  min-width: 32px;
  min-height: 30px;
  padding: 4px;
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
}

.lesson-code {
  margin: 0;
  padding: 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: #f8fafc;
  box-shadow: none;
}

.lesson-code-block figcaption + .lesson-code {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.lesson-code code {
  padding: 18px 0;
  background: transparent;
  color: #1e293b;
  display: block;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.7;
  white-space: normal;
}

.code-line {
  width: 100%;
  min-width: 0;
  min-height: 1.7em;
  padding: 0 18px 0 56px;
  position: relative;
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code-line::before {
  content: attr(data-line);
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  padding-right: 10px;
  color: #94a3b8;
  text-align: right;
  user-select: none;
}

html[data-theme="dark"] .lesson-code {
  background: #111827;
}

html[data-theme="dark"] .lesson-code code {
  color: #f8fafc;
}

.lesson-code-block:has(+ .lesson-code-result) {
  margin-bottom: 0;
}

.lesson-code-block:has(+ .lesson-code-result) .lesson-code {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.lesson-code-result {
  margin-top: -18px;
}

li > .lesson-code-result {
  margin-top: 0;
}

.lesson-code-result pre {
  margin: 0;
  padding: 14px 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius-control) var(--radius-control);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-small);
}

.lesson-code-result code {
  padding: 0;
  background: transparent;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hljs {
  background: transparent;
  color: inherit;
}

.syntax-keyword,
.language-python .py-keyword {
  color: #8b5cf6;
  font-weight: 800;
}

.syntax-builtin,
.language-python .py-builtin {
  color: #1d4ed8;
  font-weight: 800;
}

.syntax-string,
.language-python .py-string {
  color: #047857;
}

.syntax-number,
.language-python .py-number {
  color: #b45309;
}

.syntax-flag {
  color: #0e7490;
  font-weight: 800;
}

html[data-theme="dark"] .syntax-keyword,
html[data-theme="dark"] .language-python .py-keyword,
html[data-theme="dark"] .hljs-keyword {
  color: #c4b5fd;
}

html[data-theme="dark"] .syntax-builtin,
html[data-theme="dark"] .language-python .py-builtin,
html[data-theme="dark"] .hljs-built_in,
html[data-theme="dark"] .hljs-title {
  color: #93c5fd;
}

html[data-theme="dark"] .syntax-string,
html[data-theme="dark"] .language-python .py-string,
html[data-theme="dark"] .hljs-string {
  color: #86efac;
}

html[data-theme="dark"] .syntax-number,
html[data-theme="dark"] .language-python .py-number,
html[data-theme="dark"] .hljs-number {
  color: #fdba74;
}

html[data-theme="dark"] .hljs-subst,
html[data-theme="dark"] .hljs-operator,
html[data-theme="dark"] .hljs-punctuation,
html[data-theme="dark"] .hljs-params,
html[data-theme="dark"] .hljs-variable {
  color: #e2e8f0;
}

html[data-theme="dark"] .syntax-comment,
html[data-theme="dark"] .language-python .py-comment,
html[data-theme="dark"] .hljs-comment {
  color: #94a3b8;
}

.syntax-comment,
.language-python .py-comment {
  color: var(--muted);
  font-style: italic;
}

.lesson-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.lesson-markdown-table {
  width: 100%;
  margin: 0;
  box-shadow: none;
}

.lesson-markdown-table th,
.lesson-markdown-table td {
  text-align: left;
  vertical-align: top;
}

.lesson-color-red {
  color: #ef4444;
  font-weight: 800;
}

.lesson-color-blue {
  color: #2563eb;
  font-weight: 800;
}

.lesson-color-green {
  color: #16a34a;
  font-weight: 800;
}

.lesson-color-purple {
  color: #8b5cf6;
  font-weight: 800;
}

.lesson-color-orange {
  color: #f97316;
  font-weight: 800;
}

.lesson-color-muted {
  color: var(--muted);
  font-weight: 800;
}

.latex-block {
  width: 100%;
  overflow-x: auto;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  color: var(--text);
  text-align: center;
}

.field-label-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.markdown-help {
  position: relative;
  z-index: 30;
  width: fit-content;
  margin: 0;
}

.markdown-help-trigger {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  background: var(--muted);
  color: var(--surface);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 900;
  cursor: help;
  box-shadow: none;
  opacity: 0.72;
}

.markdown-help-trigger:hover,
.markdown-help-trigger:focus {
  opacity: 1;
}

.markdown-help-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  width: min(620px, 82vw);
  padding: 18px;
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.markdown-help.is-above .markdown-help-panel {
  top: auto;
  bottom: calc(100% + 10px);
}

.markdown-help::after {
  content: "";
  position: absolute;
  left: 0;
  top: 100%;
  width: min(620px, 82vw);
  height: 14px;
  display: none;
}

.markdown-help.is-above::after {
  top: auto;
  bottom: 100%;
}

.markdown-help:hover .markdown-help-panel,
.markdown-help:focus-within .markdown-help-panel,
.markdown-help.is-open .markdown-help-panel,
.markdown-help.is-open::after {
  display: block;
}

.markdown-help-panel strong {
  display: block;
  margin-bottom: 12px;
  font-size: 16px;
}

.markdown-help-panel dl {
  margin: 0;
  display: grid;
  gap: 10px;
}

.markdown-help-panel dt {
  color: var(--text);
  font-weight: 900;
}

.markdown-help-panel dd {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.markdown-help-panel p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.65;
}

.markdown-help-panel code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--accent);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  font-weight: 700;
}

.markdown-help-code {
  margin: 8px 0 0;
  padding: 10px 12px;
  white-space: pre;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  box-shadow: none;
}

.slide-keyboard-help {
  margin-left: 2px;
  z-index: 40;
}

.slide-keyboard-help .markdown-help-panel {
  left: auto;
  right: 0;
  top: auto;
  bottom: calc(100% + 10px);
  transform: none;
  width: min(320px, 82vw);
}

.slide-keyboard-help::after {
  top: auto;
  bottom: 100%;
  width: min(320px, 82vw);
}

.slide-keyboard-help .markdown-help-panel p {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.choice-primary {
  color: #ffffff;
  background: var(--accent);
  border-color: transparent;
}

.choice-primary:hover {
  color: #ffffff;
}

.choice-secondary {
  color: var(--text);
  background: var(--surface);
}

.choice-arrow {
  font-size: 32px;
  line-height: 1;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 0;
  box-shadow:
    0 0 0 3px rgba(79, 70, 229, 0.22),
    var(--shadow-small);
}

pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 18px;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  box-shadow: none;
}

code {
  font-family: "DM Sans", "Noto Sans TC", system-ui, sans-serif;
}

.error,
p[style*="color:red"] {
  color: var(--danger) !important;
  font-weight: 800;
}

.notice {
  width: min(100%, 720px);
  position: fixed;
  top: 92px;
  left: 50%;
  z-index: 260;
  margin: 0;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  box-shadow: var(--shadow-small);
  transform: translate(-50%, 14px);
  opacity: 0;
  animation:
    notice-in 260ms ease-out forwards,
    notice-out 360ms ease-in 4.2s forwards;
}

.notice-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #ffffff;
  font-weight: 900;
}

.notice strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, sans-serif;
  font-weight: 800;
}

.notice p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.notice-success {
  border-color: rgba(15, 118, 110, 0.24);
}

.notice-success .notice-icon {
  background: var(--accent-secondary);
}

.notice-error {
  border-color: rgba(180, 35, 58, 0.28);
}

.notice-error .notice-icon {
  background: var(--danger);
}

.notice-info .notice-icon {
  background: var(--accent);
}

@keyframes notice-in {
  from {
    opacity: 0;
    transform: translate(-50%, 14px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes notice-out {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -16px);
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(100%, 440px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

.modal-card h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.modal-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.modal-field {
  margin-bottom: 12px;
}

.modal-error {
  color: var(--danger) !important;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-secondary {
  color: var(--muted);
  background: var(--surface-soft);
}

section[style] {
  border: 1px solid var(--border) !important;
  padding: 28px !important;
  margin: 22px auto !important;
  border-radius: var(--radius-card) !important;
  box-shadow: var(--shadow-small) !important;
}

.record-list {
  width: min(100%, 980px);
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.record-item {
  display: grid;
  grid-template-columns: 1fr 220px;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
}

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

.record-title:hover {
  color: var(--accent);
}

.record-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.muted-text {
  color: var(--muted);
  font-weight: 700;
}

.record-status-form {
  display: inline-block;
  width: auto;
  max-width: none;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.record-status-form select,
.status-form select {
  max-width: 220px;
}

.record-status-form select {
  min-height: 38px;
  padding: 8px 46px 8px 12px;
  border-radius: 999px;
  box-shadow: none;
}

.status-form {
  margin-top: 18px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

@media (max-width: 768px) {
  .editor-preview-layout {
    grid-template-columns: 1fr;
  }

  .markdown-preview-card {
    position: static;
    min-height: 260px;
  }

  .record-item {
    grid-template-columns: 1fr;
  }

  .record-status-form select,
  .status-form select {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .app-nav {
    grid-template-columns: 1fr auto auto;
    width: calc(100% + 36px);
    margin: 0 -18px 28px;
    padding: 12px 18px;
    gap: 12px;
  }

  .brand-link {
    padding: 6px 8px;
  }

  .brand-link span:last-child {
    max-width: 190px;
    white-space: normal;
    line-height: 1.2;
  }

  .site-links {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .nav-search {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    min-width: 0;
  }

  .nav-search-panel {
    position: fixed;
    left: 18px;
    right: 18px;
    top: 154px;
  }

  .admin-menu {
    flex: 1 1 calc(50% - 6px);
  }

  .admin-menu summary {
    width: 100%;
  }

  .admin-panel {
    left: 0;
    right: auto;
    width: min(82vw, 260px);
  }

  .site-links a {
    flex: 1 1 calc(50% - 6px);
  }

  .account-panel {
    right: 0;
    width: min(82vw, 260px);
  }

  .login-choice-wrap {
    min-height: auto;
    display: block;
    width: 100%;
  }

  .login-choice-card {
    padding: 30px;
  }

  .login-choice-actions {
    gap: 18px;
  }

  .choice-button {
    width: 100%;
    min-width: 0;
    min-height: 72px;
    font-size: 20px;
  }

  .lesson-entry-grid {
    gap: 16px;
    margin-top: 30px;
  }

  .lesson-entry-card {
    min-height: 150px;
    padding: 28px;
  }

  .progress-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .progress-meter-main {
    grid-column: 1 / -1;
  }

  .home-block {
    padding: 22px;
  }

  .teacher-contact-grid {
    grid-template-columns: 1fr;
  }

  .notes-layout {
    grid-template-columns: 1fr;
  }
  
  body {
    padding: 0 18px 24px;
  }

  p:has(a[href="/admin"]),
  p:has(a[href="/admin/users"]),
  p:has(a[href="/admin/lessons"]),
  p:has(a[href="/admin/exercises"]),
  p:has(> a.back-link),
  p:has(> a[href="/login"]),
  p:has(a[href="/"]) {
    left: 16px;
    right: 16px;
    top: 78px;
  }

  body > form {
    max-width: 100%;
  }

  article,
  section,
  form {
    padding: 26px;
  }

  h1 {
    font-size: 34px;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  input,
  select,
  textarea {
    max-width: 100%;
  }
}
