:root {
  --bg: #f6f1e8;
  --paper: rgba(255, 252, 247, 0.84);
  --paper-strong: #fffdf9;
  --ink: #10263f;
  --ink-soft: #5a6a79;
  --line: rgba(16, 38, 63, 0.1);
  --primary: #10263f;
  --primary-strong: #0c2239;
  --primary-soft: rgba(16, 38, 63, 0.08);
  --accent: #c97334;
  --accent-strong: #aa5d24;
  --teal: #2d6f74;
  --teal-soft: rgba(45, 111, 116, 0.1);
  --danger: #aa3f23;
  --danger-bg: #fff0ea;
  --ok: #1f6a50;
  --ok-bg: #eaf6ef;
  --shadow: 0 28px 80px rgba(16, 38, 63, 0.1);
  --shadow-soft: 0 16px 34px rgba(16, 38, 63, 0.08);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 14%, rgba(45, 111, 116, 0.08), transparent 24%),
    radial-gradient(circle at 88% 5%, rgba(201, 115, 52, 0.12), transparent 26%),
    linear-gradient(180deg, #fbf8f1 0%, var(--bg) 60%, #efe9dd 100%);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(16, 38, 63, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 38, 63, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 82% 26%, rgba(255, 255, 255, 0.6), transparent 18%);
  background-size:
    44px 44px,
    44px 44px,
    auto;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.78), transparent 95%);
}

.page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 0 calc(64px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.18), transparent 28%),
    linear-gradient(155deg, #163a60 0%, #0c2137 100%);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.12em;
  box-shadow: var(--shadow-soft);
}

.brand-name {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.back-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
}

.back-link:hover {
  color: var(--accent-strong);
}

.card,
.upload-shell {
  border-radius: var(--radius-xl);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.eyebrow,
.section-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 0 0 14px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow,
.section-tag {
  color: var(--primary);
  background: rgba(16, 38, 63, 0.08);
}

.subcopy,
.section-copy,
.hint,
.field-hint {
  color: var(--ink-soft);
}

.stage-step,
.rule-index {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.utility-grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.utility-card,
.section,
.upload-shell {
  padding: 26px;
}

.section h2,
.utility-card h2,
.upload-shell h2,
.status-wrap h3 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.participant-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

#participant-id {
  display: inline-block;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(16, 38, 63, 0.06);
  border: 1px solid rgba(16, 38, 63, 0.1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.84rem;
  word-break: break-all;
}

.ghost-btn {
  border: 1px solid rgba(16, 38, 63, 0.12);
  background: #fff;
  color: var(--primary);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: rgba(16, 38, 63, 0.24);
}

.ghost-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ghost-btn--secondary {
  background: rgba(16, 38, 63, 0.05);
}

.hint {
  margin: 12px 0 0;
}

.participant-restore {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(16, 38, 63, 0.08);
}

.participant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.hint--compact {
  margin-top: 10px;
}

.stats-grid,
.ref-grid,
.check-stack,
.rule-list {
  display: grid;
  gap: 14px;
}

.stats-grid {
  margin-top: 18px;
}

.stats-grid article,
.check-card,
.rule-card {
  border-radius: var(--radius-md);
  background: var(--paper-strong);
  border: 1px solid rgba(16, 38, 63, 0.08);
  box-shadow: 0 14px 26px rgba(16, 38, 63, 0.05);
}

.stats-grid article {
  padding: 16px;
}

.stats-grid h3 {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats-grid p {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.stat-note {
  display: block;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

.workspace-switch {
  display: flex;
  gap: 10px;
  margin: 18px 0;
  padding: 6px;
  border-radius: 999px;
  background: rgba(16, 38, 63, 0.08);
  width: fit-content;
  max-width: 100%;
}

.workspace-tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.workspace-tab.is-active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 10px 24px rgba(16, 38, 63, 0.08);
}

.workspace-panel {
  display: block;
}

.workspace-panel[hidden] {
  display: none;
}

.guide-layout {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.ref-card {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--paper-strong);
  border: 1px solid rgba(16, 38, 63, 0.08);
  box-shadow: 0 18px 34px rgba(16, 38, 63, 0.05);
}

.ref-img-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  background: #eef2f7;
}

.ref-img-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.ref-ann {
  position: absolute;
  max-width: 124px;
  padding: 7px 10px;
  border-radius: 11px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.16);
}

.ref-card--blue .ref-ann {
  background: rgba(16, 38, 63, 0.92);
}

.ref-card--green .ref-ann {
  background: rgba(45, 111, 116, 0.94);
}

.ref-ann--tl {
  left: 12px;
  top: 12px;
}

.ref-ann--ml {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.ref-ann--bl {
  left: 12px;
  bottom: 12px;
}

.ref-ann--tr {
  right: 12px;
  top: 12px;
}

.ref-ann--mr {
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.ref-ann--br {
  right: 12px;
  bottom: 12px;
}

.guide-side {
  display: block;
}

.check-card {
  position: relative;
  padding: 18px 18px 18px 46px;
}

.check-card::before {
  content: "!";
  position: absolute;
  left: 16px;
  top: 17px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.upload-shell {
  display: grid;
  gap: 24px;
  margin-top: 18px;
}

.history-section {
  margin-top: 18px;
}

.history-layout {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.reward-overview {
  display: grid;
  gap: 14px;
}

.reward-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--paper-strong);
  border: 1px solid rgba(16, 38, 63, 0.08);
  box-shadow: 0 18px 34px rgba(16, 38, 63, 0.05);
}

.reward-card h3 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.16;
}

.reward-kicker {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress-track {
  margin-top: 16px;
  height: 12px;
  border-radius: 999px;
  background: rgba(16, 38, 63, 0.08);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--accent));
  transition: width 220ms ease;
}

.history-list-wrap {
  padding: 22px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(45, 111, 116, 0.12), transparent 30%),
    rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(16, 38, 63, 0.08);
  box-shadow: 0 20px 36px rgba(16, 38, 63, 0.06);
}

.history-list-head h3 {
  margin: 0;
  font-size: 1.2rem;
}

.history-state {
  margin-top: 16px;
  color: var(--ink-soft);
}

.history-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.history-item {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(16, 38, 63, 0.08);
  box-shadow: 0 14px 28px rgba(16, 38, 63, 0.05);
}

.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-item-date {
  font-weight: 700;
}

.history-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.history-badge--qualified {
  background: var(--ok-bg);
  color: var(--ok);
}

.history-badge--disqualified {
  background: var(--danger-bg);
  color: var(--danger);
}

.history-badge--pending {
  background: rgba(16, 38, 63, 0.08);
  color: var(--primary);
}

.history-meta-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-meta,
.history-inline {
  display: grid;
  gap: 4px;
}

.history-meta-label,
.history-inline-label {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.history-item-body {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.history-inline strong {
  font-weight: 600;
  line-height: 1.45;
}

.history-inline--reason strong {
  color: var(--ink);
 }

.rule-list {
  margin-top: 24px;
}

.rule-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 16px 18px;
}

.rule-card p {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.rule-index {
  background: var(--primary);
}

.rule-card:nth-child(2) .rule-index {
  background: var(--teal);
}

.rule-card:nth-child(3) .rule-index {
  background: var(--accent);
}

.upload-panel {
  padding: 22px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(201, 115, 52, 0.12), transparent 28%),
    rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(16, 38, 63, 0.08);
  box-shadow: 0 20px 36px rgba(16, 38, 63, 0.06);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.field--compact {
  margin-top: 0;
}

.field:first-of-type {
  margin-top: 0;
}

.field-label {
  font-weight: 700;
}

.field-hint {
  font-size: 0.92rem;
}

.field input[type="file"] {
  width: 100%;
  padding: 18px;
  border: 2px dashed rgba(16, 38, 63, 0.16);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(16, 38, 63, 0.02), rgba(16, 38, 63, 0.04));
  font: inherit;
}

.field input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(16, 38, 63, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font: inherit;
}

.field input[type="text"]:focus {
  outline: 2px solid rgba(45, 111, 116, 0.18);
  border-color: rgba(45, 111, 116, 0.44);
}

.field input[type="file"]:hover {
  border-color: rgba(16, 38, 63, 0.3);
}

.submit-btn {
  width: 100%;
  min-height: 56px;
  margin-top: 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
  box-shadow: 0 12px 26px rgba(201, 115, 52, 0.24);
}

.submit-btn:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.status-wrap {
  margin-top: 20px;
}

.status-wrap h3 {
  font-size: 1rem;
  letter-spacing: normal;
}

.status {
  margin-top: 10px;
  min-height: 60px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(16, 38, 63, 0.1);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  white-space: pre-line;
}

.status:empty {
  display: none;
}

.status.success {
  border-color: rgba(31, 106, 80, 0.24);
  background: var(--ok-bg);
  color: var(--ok);
}

.status.error {
  border-color: rgba(170, 63, 35, 0.24);
  background: var(--danger-bg);
  color: var(--danger);
}

.foot-note {
  padding: 14px 4px 0;
}

.foot-note p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

@media (min-width: 760px) {
  .stats-grid,
  .ref-grid,
  .check-stack,
  .rule-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-layout {
    grid-template-columns: minmax(0, 1.16fr) minmax(280px, 0.84fr);
    align-items: start;
  }

  .history-meta-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .utility-grid {
    grid-template-columns: 0.92fr 1.08fr;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .upload-shell {
    grid-template-columns: minmax(0, 0.92fr) minmax(420px, 1.08fr);
    align-items: start;
  }

  .rule-list {
    grid-template-columns: 1fr;
  }

  .history-layout {
    grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.08fr);
    align-items: start;
  }
}

@media (max-width: 759px) {
  .page {
    width: min(100% - 24px, 1180px);
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .utility-card,
  .section,
  .upload-shell {
    padding: 22px;
  }

  .upload-panel {
    padding: 18px;
    border-radius: 24px;
  }

  .brand-name {
    font-size: 0.9rem;
  }

  .workspace-switch {
    width: 100%;
  }

  .workspace-tab {
    flex: 1 1 0;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .submit-btn,
  .progress-fill {
    transition: none;
  }
}
