:root {
  color-scheme: light;
  --ink: #171923;
  --muted: #64748b;
  --line: rgba(255, 255, 255, 0.22);
  --panel: rgba(255, 255, 255, 0.9);
  --paper: #fffaf0;
  --teal: #0f766e;
  --teal-dark: #0f4f4b;
  --red: #b91c1c;
  --gold: #f5c76a;
  --primary: #b91c1c;
  --accent: #0f766e;
  --hero-image: url("/forum-visual.jpg");
  --overlay: 0.72;
  --admin-bg: #f3f6f8;
  --danger: #b91c1c;
  --shadow: 0 24px 70px rgba(19, 24, 38, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #e96b2c);
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
}

button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.secondary-button {
  color: #334155;
  background: #e2e8f0;
}

.danger-button,
.mini-danger-button {
  background: #b91c1c;
}

.mini-danger-button {
  min-width: 64px;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  line-height: 1.15;
}

.student-page {
  background: #150f12;
}

.student-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  min-height: 100vh;
}

.student-hero {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px;
  overflow: hidden;
  background-image: linear-gradient(90deg, rgba(12, 17, 22, var(--overlay)), rgba(12, 17, 22, 0.18)), var(--hero-image);
  background-position: center;
  background-size: cover;
}

.student-copy {
  width: min(760px, 100%);
  color: #fff;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.4);
}

.student-copy h1 {
  margin-top: 14px;
  font-size: 50px;
  font-weight: 900;
  letter-spacing: 0;
}

.student-copy p {
  margin-top: 16px;
  color: #fef3c7;
  font-size: 24px;
}

.event-kicker {
  display: inline-flex;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.search-panel {
  width: min(560px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.search-form,
.stack {
  display: grid;
  gap: 12px;
}

.search-form label,
.stack label {
  color: #334155;
  font-weight: 700;
}

.input-row,
.action-row {
  display: flex;
  gap: 10px;
}

.input-row button,
.action-row button,
.section-title button,
.result-card button,
.stack button {
  min-width: 120px;
  height: 44px;
  padding: 0 16px;
  white-space: nowrap;
}

.result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #f5c76a;
  border-radius: 8px;
  background: #fff8e7;
}

.result-card span,
.result-card strong {
  display: block;
}

.result-card span {
  color: var(--muted);
  font-size: 13px;
}

.student-preview {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
  background: linear-gradient(180deg, #fff7e6, #f0fbfb);
}

.preview-empty {
  display: grid;
  width: 100%;
  min-height: 520px;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--accent);
  text-align: center;
}

.preview-empty span {
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.preview-empty strong {
  font-size: 24px;
}

canvas {
  width: 100%;
  max-width: 900px;
  height: auto;
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.admin-page {
  background: var(--admin-bg);
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 32px;
  color: #fff;
  background-image: linear-gradient(90deg, rgba(9, 35, 45, 0.92), rgba(185, 28, 28, 0.78)), var(--hero-image);
  background-position: center;
  background-size: cover;
}

.admin-topbar h1 {
  margin-top: 6px;
  font-size: 30px;
}

.ghost-link {
  height: 40px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
}

.admin-shell {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 560px);
  gap: 22px;
  align-items: start;
}

.admin-controls {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 24px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.login-panel {
  width: min(440px, 100%);
  margin: 80px auto;
}

.login-panel h2 {
  margin: 8px 0 22px;
}

.section-title,
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-actions .danger-button {
  height: 36px;
  padding: 0 12px;
}

.section-title span,
.section-title strong,
.preview-head span {
  color: var(--muted);
  white-space: nowrap;
}

.section-title .event-kicker,
.preview-head .event-kicker {
  color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wide-field {
  grid-column: 1 / -1;
}

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input[type="range"] {
  padding: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #f8fafc;
}

.check-field input {
  width: 18px;
  height: 18px;
}

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

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

.position-grid h3 {
  grid-column: 1 / -1;
  margin: 0;
  color: #334155;
  font-size: 16px;
}

.position-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--muted);
  background: #f8fafc;
  line-height: 1.55;
}

.notice.success {
  border-color: #99f6e4;
  color: #115e59;
  background: #f0fdfa;
}

.notice.error {
  border-color: #fecaca;
  color: var(--danger);
  background: #fef2f2;
}

.preview-dock {
  position: sticky;
  top: 24px;
  padding: 20px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
}

.certificate-stage {
  display: grid;
  min-height: 420px;
  place-items: center;
  padding: 16px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #edf2f7;
}

.table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #d8dee8;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
}

.hidden {
  display: none !important;
}

@media (max-width: 1060px) {
  .student-shell,
  .admin-workspace {
    grid-template-columns: 1fr;
  }

  .student-hero,
  .student-preview {
    min-height: auto;
  }

  .student-preview {
    padding: 22px;
  }

  .preview-dock {
    position: static;
  }
}

@media (max-width: 720px) {
  .student-hero,
  .admin-shell {
    padding: 18px;
  }

  .student-copy h1 {
    font-size: 34px;
  }

  .student-copy p {
    font-size: 20px;
  }

  .input-row,
  .action-row,
  .section-title,
  .preview-head,
  .admin-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .position-grid {
    grid-template-columns: 1fr;
  }
}
