:root {
  --ink: #12201c;
  --muted: #5a6b64;
  --line: rgba(18, 32, 28, 0.12);
  --paper: #f3efe6;
  --panel: rgba(255, 252, 246, 0.92);
  --accent: #0f6b4c;
  --accent-2: #c45c26;
  --danger: #b42318;
  --shadow: 0 24px 60px rgba(18, 32, 28, 0.12);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 10% -10%, #d8efe3 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, #f0d8c4 0%, transparent 50%),
    linear-gradient(160deg, #f7f3ea 0%, #ebe4d6 45%, #e4efe8 100%);
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  pointer-events: none;
}

.shell {
  width: min(560px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.5rem 0 2.5rem;
  animation: rise 0.55s ease both;
}

.admin-shell {
  width: min(980px, calc(100% - 2rem));
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.brand-mark {
  margin: 0 0 0.45rem;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  text-transform: none;
  line-height: 1.05;
  color: var(--accent);
}

.brand-beta {
  font-family: var(--font);
  font-size: 0.42em;
  font-weight: 500;
  letter-spacing: 0.02em;
  vertical-align: 0.35em;
  color: var(--accent);
  opacity: 0.85;
}

.brand h1 {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1.05rem, 3vw, 1.25rem);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.35;
  color: var(--muted);
}

.vip-text {
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #f5e6a8 0%, #d4a017 35%, #f0d060 55%, #b8860b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 1px 0 rgba(184, 134, 11, 0.25));
}

.brand-sub {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 0.4rem;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--muted);
  background: rgba(255, 252, 246, 0.55);
  border: 1px solid transparent;
  transition: 0.2s ease;
}

.step span {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(18, 32, 28, 0.08);
}

.step.is-active {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
  box-shadow: 0 8px 20px rgba(18, 32, 28, 0.06);
}

.step.is-active span,
.step.is-done span {
  background: var(--accent);
  color: #fff;
}

.step.is-done {
  color: var(--ink);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 1.6rem 1.5rem 1.7rem;
}

.form h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 600;
}

.hint {
  margin: 0.45rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

label {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-row label {
  margin-bottom: 1rem;
}

.grade-fieldset {
  margin: 0 0 1rem;
  padding: 0;
  border: none;
}

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

.grade-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.grade-options.is-invalid .grade-option {
  border-color: rgba(180, 35, 24, 0.45);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

.grade-option {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.grade-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.grade-option span {
  display: grid;
  place-items: center;
  min-height: 3.1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf8;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.grade-option:hover span {
  border-color: rgba(15, 107, 76, 0.35);
}

.grade-option input:focus-visible + span {
  border-color: rgba(15, 107, 76, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

.grade-option input:checked + span {
  color: #fff;
  background: linear-gradient(135deg, #127a57, #0f6b4c);
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(15, 107, 76, 0.2);
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fffdf8;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
  border-color: rgba(15, 107, 76, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 107, 76, 0.12);
}

input.is-invalid {
  border-color: rgba(180, 35, 24, 0.45);
  background: #fff8f6;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

.error {
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  color: #8f2f24;
  font-size: 0.88rem;
  background: rgba(180, 35, 24, 0.06);
  border: 1px solid rgba(180, 35, 24, 0.14);
}

.toast {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.toast[hidden] {
  display: none !important;
}

.toast-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 32, 28, 0.38);
  backdrop-filter: blur(4px);
}

.toast-card {
  position: relative;
  width: min(360px, 100%);
  padding: 1.45rem 1.35rem 1.3rem;
  border-radius: 18px;
  background: rgba(255, 252, 246, 0.97);
  border: 1px solid var(--line);
  box-shadow: 0 28px 60px rgba(18, 32, 28, 0.22);
  text-align: center;
  animation: toast-in 0.22s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.toast-mark {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
}

.toast-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
}

.toast-msg {
  margin: 0.55rem 0 1.2rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.toast-card .btn {
  width: 100%;
}

body.toast-open {
  overflow: hidden;
}

.actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 0.25rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.35rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, #127a57, #0f6b4c);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 10px 24px rgba(15, 107, 76, 0.22);
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn-copy {
  width: 100%;
  margin-top: 0.9rem;
  background: linear-gradient(135deg, #d9783a, #c45c26);
  box-shadow: 0 10px 24px rgba(196, 92, 38, 0.22);
}

.summary {
  margin: 0 0 1.2rem;
  display: grid;
  gap: 0.7rem;
  padding: 1rem;
  border-radius: 14px;
  background: rgba(15, 107, 76, 0.05);
  border: 1px solid rgba(15, 107, 76, 0.1);
}

.summary > div {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.summary dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.summary dd {
  margin: 0;
  font-weight: 600;
}

.summary.compact {
  margin-top: 1.2rem;
  margin-bottom: 0;
}

.activate-tip {
  margin: 1.1rem 0 0;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(15, 107, 76, 0.07);
  border: 1px solid rgba(15, 107, 76, 0.14);
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.55;
}

.activate-tip a {
  color: var(--accent);
  font-weight: 600;
  word-break: break-all;
}

.activate-tip a:hover {
  text-decoration: underline;
}

#form-step3 .activate-tip {
  margin: 0 0 1rem;
}

.howto {
  margin: 0 0 1.1rem;
  padding: 1rem 1rem 0.95rem;
  border-radius: 14px;
  background: rgba(15, 107, 76, 0.06);
  border: 1px solid rgba(15, 107, 76, 0.12);
}

#result .howto {
  margin: 1.1rem 0 0;
}

.howto-title {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.howto-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.howto-steps li {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
}

.howto-num {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.1rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.howto-steps a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.howto-steps a:hover {
  text-decoration: underline;
}

.code-highlight {
  display: inline-block;
  margin: 0 0.15rem;
  padding: 0.08rem 0.45rem;
  border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.95em;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #8a5a00;
  background: linear-gradient(135deg, #fff3c4, #ffe08a);
  border: 1px solid rgba(196, 146, 20, 0.45);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.menu-icon {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0 0.25rem;
  padding: 0.18rem 0.2rem;
  vertical-align: -0.2em;
  border-radius: 4px;
  background: var(--ink);
  box-shadow: 0 1px 3px rgba(18, 32, 28, 0.2);
}

.menu-icon span {
  display: block;
  height: 2px;
  border-radius: 1px;
  background: #fff;
}

.code-box {
  text-align: center;
  padding: 1.3rem 1rem;
  border-radius: 16px;
  background: linear-gradient(160deg, #12352b, #0f6b4c);
  color: #fff;
}

.code-label {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}

.code {
  margin: 0.55rem 0 0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: clamp(1.2rem, 4vw, 1.55rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  word-break: break-all;
}

.foot {
  margin-top: 1.5rem;
  text-align: center;
}

.foot a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.foot a:hover {
  color: var(--accent);
}

.code-settings {
  margin-bottom: 1.5rem;
  padding-bottom: 1.35rem;
  border-bottom: 1px solid var(--line);
}

.code-settings h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.4rem;
}

.code-settings .hint {
  margin: 0.3rem 0 1rem;
}

.code-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: end;
}

.code-label-inline {
  flex: 1 1 240px;
  margin: 0;
}

.code-form .btn {
  flex: 0 0 auto;
}

.success {
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  color: #0f5132;
  font-size: 0.88rem;
  background: rgba(15, 107, 76, 0.08);
  border: 1px solid rgba(15, 107, 76, 0.16);
}

.code-settings .error,
.code-settings .success {
  margin-top: 0.75rem;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  align-items: end;
}

.admin-toolbar h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.4rem;
}

.admin-toolbar .hint {
  margin: 0.3rem 0 0;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.admin-actions input {
  min-width: min(280px, 100%);
  padding: 0.7rem 0.9rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf8;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.85rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(18, 32, 28, 0.03);
}

tbody tr:last-child td {
  border-bottom: none;
}

td.code-cell {
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 600;
  color: var(--accent);
}

.btn-delete {
  appearance: none;
  border: 1px solid rgba(180, 35, 24, 0.25);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger);
  background: rgba(180, 35, 24, 0.06);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-delete:hover {
  background: rgba(180, 35, 24, 0.12);
  border-color: rgba(180, 35, 24, 0.4);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem !important;
}

@media (max-width: 640px) {
  .shell {
    padding-top: 2.2rem;
  }

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

  .grade-options {
    grid-template-columns: 1fr 1fr;
  }

  .code-form .btn {
    width: 100%;
  }

  .steps {
    gap: 0.35rem;
  }

  .step {
    font-size: 0.72rem;
    padding: 0.55rem 0.25rem;
  }

  .actions {
    flex-direction: column;
  }

  .btn,
  .btn-ghost {
    width: 100%;
  }

  .admin-actions {
    width: 100%;
  }

  .admin-actions input {
    min-width: 100%;
  }
}
