:root {
  /* 前台色板只改这里，不要写进数据库或模板。 */
  --paper: #feffd6;
  --paper-library: #eaf4e3;
  --paper-deep: #f5f5f5;
  --ink: #1a1a1a;
  --muted: #888888;
  --line: #cccccc;
  --line-dark: #333333;
  --accent: #1a1a1a;
  --accent-soft: #e8e8e8;
  --white: #fff;
  --side-nav-width: 220px;
  --site-ticker-height: 28px;
}

site-ticker:not([inline]) {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--site-ticker-height);
  background: #000;
}

site-ticker[inline] {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 32px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #111;
  background: #000;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: #1a1a1a;
  text-decoration: none;
}

a:hover {
  color: #000;
  text-decoration: underline;
}

.page {
  margin-left: var(--side-nav-width);
  padding: 12px 24px 32px;
  min-height: 100vh;
  max-width: 1440px;
}

.flash-message {
  margin: 14px 0;
  padding: 12px 16px;
  border: 1px solid;
  font-weight: 600;
}

.flash-error {
  background: #fde8e8;
  border-color: #c0392b;
  color: #8b1e1e;
}

.flash-success {
  background: #f7f7f7;
  border-color: #bbb;
  color: #333;
}

.flash-info {
  background: #f5f5f5;
  border-color: #aaa;
  color: #333;
}

.flash-warning {
  background: #eee;
  border-color: #888;
  color: #333;
}

.brand {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

.nav-logout {
  display: block;
  padding: 6px 10px;
  color: var(--ink);
  cursor: pointer;
}

.nav-logout button {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.side-nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--side-nav-width);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 2px solid var(--line-dark);
  background: var(--paper-deep);
  z-index: 100;
}

.side-cabinet {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.side-cabinet:last-child {
  border-bottom: none;
}

.side-link {
  display: block;
  padding: 6px 8px;
  color: var(--ink);
}

.side-link:hover,
.side-link.is-current {
  background: var(--accent-soft);
  text-decoration: none;
}

.side-link.is-current {
  font-weight: 700;
}

.nav-logout:hover {
  background: var(--accent-soft);
}

.nav-logout button:hover {
  color: var(--ink);
}

.page-logo {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px 0 10px;
  border-bottom: 2px solid var(--line-dark);
  margin-bottom: 14px;
}

.brand-logo {
  display: block;
  width: min(520px, 100%);
  height: auto;
  max-height: 140px;
  object-fit: contain;
}

.brand-tagline {
  color: var(--muted);
  font-size: 12px;
}

.brand-noticeboard {
  height: 240px;
  width: auto;
  margin-left: 26px;
  align-self: center;
}

.announcement {
  margin: 0 0 14px;
  padding: 8px 12px;
  border: 1px solid var(--line-dark);
  background: var(--accent-soft);
}

.announcement p {
  margin: 0;
}

.site-footer {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.site-footer p {
  margin: 0 0 4px;
}

.intro-panel,
.plain-box,
.detail-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--white);
}

.intro-panel {
  padding: 16px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--line-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.intro-panel h1,
.detail-copy h1 {
  margin-bottom: 8px;
  font-size: 30px;
  line-height: 1.2;
}

.intro-panel p:last-child,
.plain-box p:last-child,
.detail-copy p:last-child {
  margin-bottom: 0;
}

.category-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px;
  border: 1px solid var(--line);
  background: var(--paper-deep);
}

.strip-label {
  padding: 2px 8px;
  border: 1px solid var(--line-dark);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.category-strip a {
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: var(--white);
}

.room-door {
  margin: 0 0 14px;
}

.room-door img {
  display: block;
  max-width: 320px;
  height: auto;
}

.room-plaque {
  display: inline-block;
  margin: 2px 0 18px;
  padding: 12px 20px 14px;
  border: 2px solid var(--line-dark);
  background: var(--paper-deep);
}

.room-plaque .kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.room-plaque h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.2;
}

.room-plaque p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.room-plaque .room-count {
  margin-top: 8px;
  color: var(--ink);
  font-size: 12px;
}

body.is-room .page {
  padding-top: 18px;
}

body.is-room-library {
  --font-body: var(--font-heiti);
  --font-sans: var(--font-heiti);
  --font-mono: var(--font-heiti);
  --paper: var(--paper-library);
  font-family: var(--font-heiti);
}

body.is-room-library .room-plaque {
  border-left-width: 8px;
  border-left-color: #3d5c4a;
}

body.is-room-pixel .room-plaque {
  border-width: 3px;
  box-shadow:
    3px 0 0 var(--line-dark),
    0 3px 0 var(--line-dark),
    3px 3px 0 var(--line-dark);
}

.course-discovery {
  margin-top: 16px;
}

.course-search {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 720px;
}

.course-search input {
  flex: 1;
  min-width: 0;
  padding: 10px 13px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  background: var(--white);
  font: inherit;
}

.course-search button {
  cursor: pointer;
  font: inherit;
}

.clear-search {
  color: var(--muted);
  white-space: nowrap;
}

.course-result-summary {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.course-result-summary span {
  margin-left: 8px;
}

.course-ticker {
  width: min(480px, 100%);
  margin: 16px 0 0;
}

.course-section {
  margin-top: 16px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line-dark);
  background: var(--accent-soft);
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px 20px;
}

.course-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.pagination-summary {
  color: var(--muted);
  font-size: 13px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-controls a,
.pagination-current,
.pagination-disabled,
.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
}

.pagination-controls a:hover,
.pagination-current {
  background: var(--accent);
  color: #fff;
}

.pagination-disabled {
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.pagination-ellipsis {
  min-width: auto;
  border-color: transparent;
  padding: 0 2px;
}


.plain-box {
  padding: 12px;
}

.plain-box h2 {
  margin-bottom: 6px;
  font-size: 17px;
}

.course-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: start;
}

.detail-main-panel {
  min-width: 0;
}

.detail-panel {
  padding: 18px 20px;
}

.detail-intro-panel {
  margin-top: 0;
}

.detail-copy {
  min-width: 0;
}

.detail-author {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--muted);
}

.detail-description {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.6;
  white-space: pre-line;
}

.slideshow-slot {
  position: relative;
  margin-top: 16px;
}

.detail-cover-slot {
  margin-top: 16px;
  max-width: 240px;
}

.detail-cover-slot img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--paper-deep);
}

.slideshow-track {
  position: relative;
  min-height: 120px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-deep);
  text-align: center;
}

.slideshow-slide {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
}

.slideshow-slide.active {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  display: inline-block;
  vertical-align: middle;
  opacity: 1;
}

.slideshow-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 36px;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s;
}

.slideshow-arrow:hover {
  background: rgba(0, 0, 0, 0.7);
}

.slideshow-prev {
  left: 0;
}

.slideshow-next {
  right: 0;
}

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

.slideshow-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--line);
  cursor: pointer;
  transition: background 0.2s;
}

.slideshow-dot.active {
  background: var(--line-dark);
}

.detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-sidebar-card {
  border: 1px solid var(--line);
  background: var(--white);
  padding: 16px;
}

.detail-sidebar-card h2 {
  margin-bottom: 10px;
  font-size: 17px;
}

.detail-purchase-card .detail-price {
  margin: 0 0 12px;
  text-align: center;
}

.detail-purchase-card .detail-actions,
.detail-purchase-card form,
.detail-purchase-card .button-link,
.detail-purchase-card .back-link {
  width: 100%;
}

.detail-purchase-card .detail-actions {
  align-items: stretch;
  flex-direction: column;
}

.detail-sidebar .course-tags {
  margin-top: 0;
}

.detail-sidebar .course-tag {
  background: var(--accent-soft);
  color: var(--ink);
  border-radius: 3px;
}

.muted {
  color: var(--muted);
}

.back-link {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 9px;
  border: 1px solid var(--line-dark);
  background: var(--accent-soft);
}

/* Auth & forms */
.auth-panel .flash-message {
  margin: 0 0 14px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.form-stack label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.form-stack input {
  padding: 6px 8px;
  border: 1px solid var(--line-dark);
  background: var(--white);
  font-size: 14px;
}

/* Buttons */
.button-link {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--line-dark);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-align: center;
}

.button-link:hover {
  background: var(--line-dark);
  color: #fff;
  text-decoration: none;
}

.ghost-button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.ghost-button:hover {
  background: var(--accent-soft);
}

/* Price */
.price {
  font-size: 18px;
  font-weight: 700;
  color: var(--line-dark);
}

.detail-price {
  margin: 8px 0;
  font-size: 22px;
}

/* Detail actions */
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

/* Account grid */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.data-table th {
  background: var(--accent-soft);
  font-weight: 600;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Empty state */
.empty-state {
  padding: 20px;
  text-align: center;
  color: var(--muted);
}

/* Recharge presets */
.recharge-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.recharge-form {
  display: inline;
}

.recharge-page {
  padding: 16px;
}

.recharge-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #f5f5f5;
}

.recharge-summary h1 {
  margin-bottom: 6px;
}

.recharge-balance {
  margin: 0;
  font-size: 16px;
}

.recharge-page-form {
  margin-top: 16px;
}

.recharge-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.recharge-option-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  text-align: center;
}

.recharge-option-card input {
  display: none;
}

.recharge-option-card:has(input:checked) {
  border-color: var(--line-dark);
  background: var(--accent-soft);
}

.recharge-methods {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
}

.recharge-method-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 66px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.payment-logo {
  height: 28px;
  width: auto;
  vertical-align: middle;
}

.payment-logo-alipay {
  height: 40px;
}

.recharge-custom-card {
  border-style: dashed;
}

.recharge-custom-input {
  margin-top: 14px;
}

.recharge-custom-input label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.recharge-custom-input input {
  padding: 6px 8px;
  border: 1px solid var(--line-dark);
  background: var(--white);
  font-size: 14px;
  max-width: 200px;
}

.recharge-note {
  margin-top: 18px;
  color: #555;
}

/* Transaction colors */
.text-green {
  color: #555;
  font-weight: 600;
}

.text-red {
  color: #333;
  font-weight: 600;
}

/* Download link box */
.download-link-box {
  margin: 14px 0;
  padding: 12px 16px;
  border: 2px solid var(--line-dark);
  background: #f5f5f5;
  border-radius: 4px;
}

.download-link-label {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #333;
}

.download-link-text {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 14px;
  word-break: break-all;
  white-space: pre-wrap;
  user-select: all;
}

/* Course unlock box (bottom of course page) */
.unlock-panel {
  padding: 16px 18px;
}

.unlock-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.unlock-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 2px solid #6b57d3;
  border-radius: 50%;
  color: #6b57d3;
  font-size: 16px;
  line-height: 1;
}

.unlock-title {
  font-size: 16px;
  font-weight: 700;
  color: #333;
}

.unlock-action {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.unlock-button {
  display: inline-block;
  padding: 8px 18px;
  border: none;
  border-radius: 4px;
  background: #52c41a;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.unlock-button:hover {
  background: #46a916;
  color: #fff;
  text-decoration: none;
}

.unlock-button:disabled {
  background: #9bd97a;
  cursor: default;
}

.unlock-hint {
  color: #999;
  font-size: 13px;
}

.unlock-hint b {
  color: #f57c00;
}

.unlock-result {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.unlock-result[hidden] {
  display: none;
}

.unlock-badge {
  flex: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
}

.unlock-badge-done {
  background: #e8f7e0;
  color: #46a916;
}

.unlock-link-text {
  flex: 1 1 260px;
  min-width: 0;
  margin: 0;
}

.unlock-ttl {
  flex: 1 1 100%;
  margin: 4px 0 0;
  color: #666;
  font-size: 13px;
}

.unlock-error {
  margin: 10px 0 0;
  color: #d4380d;
  font-size: 13px;
}

@media (max-width: 860px) {
  .course-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 12px;
  }

  .course-pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination-controls {
    flex-wrap: wrap;
  }
}

@media (max-width: 620px) {
  .side-nav {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 2px solid var(--line-dark);
  }

  .page {
    width: 100%;
    margin-left: 0;
    padding: 8px 12px 24px;
  }

  .brand-logo {
    width: min(420px, 100%);
    max-height: 88px;
  }

  .brand-noticeboard {
    height: 88px;
    margin-left: 0;
  }

  .intro-panel h1,
  .detail-copy h1 {
    font-size: 22px;
  }

  .course-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 10px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .course-detail-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .detail-panel,
  .detail-media-section,
  .detail-sidebar-card {
    padding: 12px;
  }
}

.static-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
}

.static-page h1 {
  font-size: 24px;
  margin-bottom: 24px;
}

.static-page section {
  margin-bottom: 24px;
}

.static-page h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.static-page p {
  margin: 0 0 8px;
  line-height: 1.7;
}

.static-page ul {
  padding-left: 20px;
  margin: 0 0 8px;
}

.static-page li {
  margin-bottom: 4px;
  line-height: 1.7;
}

.csrf-error-body {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 32px;
}

.csrf-error-sheet {
  width: 100%;
  max-width: 520px;
  padding: 22px 22px 20px;
  border: 2px solid var(--line-dark);
  background: var(--paper-deep);
}

.csrf-error-sheet h1 {
  font-size: 22px;
  line-height: 1.3;
  margin-bottom: 10px;
}

.csrf-error-sheet p {
  margin: 0 0 12px;
  line-height: 1.6;
}

.csrf-error-contact {
  padding: 10px 12px;
  border: 1px solid var(--line-dark);
  background: var(--white);
  font-size: 15px;
}

.csrf-error-contact strong {
  font-size: 18px;
  letter-spacing: 0.04em;
}

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

.csrf-error-report {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line-dark);
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

