:root {
  font-family: "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
}

@font-face {
  font-family: "Noto Sans SC";
  src: url("/fonts/NotoSansSC-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ink: #171915;
  --paper: #f4f3ee;
  --white: #ffffff;
  --line: #c9cbc2;
  --muted: #686b63;
  --green: #0f6b4d;
  --green-dark: #084d37;
  --signal: #ffcd3c;
  --danger: #b42318;
  --success-bg: #dff4e9;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--paper);
  background-size: 48px 48px;
  font-family: "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }

.site-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 5vw, 72px);
  color: var(--white);
  background: var(--ink);
  border-bottom: 4px solid var(--signal);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-weight: 750;
  font-size: 17px;
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  display: block;
  border: 2px solid var(--white);
}

.brand-mark i { position: absolute; width: 7px; height: 7px; background: var(--signal); }
.brand-mark i:nth-child(1) { left: 4px; top: 4px; }
.brand-mark i:nth-child(2) { right: 4px; top: 4px; }
.brand-mark i:nth-child(3) { left: 4px; bottom: 4px; }

.security-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d8dbd3;
  font-size: 13px;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #5fe0a7; box-shadow: 0 0 0 3px rgba(95, 224, 167, .18); }

.redeem-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 144px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  align-items: stretch;
  background: var(--white);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.redeem-panel { padding: clamp(48px, 7vw, 96px); align-self: center; }

.section-index {
  display: inline-block;
  margin-bottom: 28px;
  padding-bottom: 6px;
  color: var(--green);
  border-bottom: 3px solid var(--signal);
  font-size: 12px;
  font-weight: 800;
}

h1 {
  max-width: 560px;
  margin: 0;
  font-size: 64px;
  line-height: 1.06;
  font-weight: 850;
}

.lead { max-width: 520px; margin: 24px 0 38px; color: var(--muted); font-size: 16px; line-height: 1.8; }

form { max-width: 560px; }
label { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 800; }

.key-input-wrap { position: relative; }

input, textarea {
  width: 100%;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 0;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input { height: 62px; padding: 0 52px 0 18px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 18px; text-transform: uppercase; }
input::placeholder { color: #999d94; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 5px 5px 0 var(--signal); }

.key-corner { position: absolute; top: 0; right: 0; width: 34px; height: 34px; border-top: 12px solid var(--signal); border-right: 12px solid var(--signal); pointer-events: none; }

.form-message { min-height: 22px; margin: 10px 0; color: var(--danger); font-size: 13px; }
.form-message.success { color: var(--green); }

.primary-button, .secondary-button, .danger-button {
  min-height: 50px;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  color: var(--white);
  background: var(--green);
  box-shadow: 5px 5px 0 var(--ink);
}

.primary-button:hover { background: var(--green-dark); }
.primary-button:focus-visible, .secondary-button:focus-visible, .danger-button:focus-visible { outline: 3px solid var(--signal); outline-offset: 3px; }
.primary-button:disabled { cursor: wait; opacity: .65; }
.button-arrow { font-size: 25px; line-height: 1; }

.process-strip {
  max-width: 560px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 52px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.process-strip span { display: flex; gap: 8px; }
.process-strip b { color: var(--ink); }

.file-visual {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--green);
  border-left: 1px solid var(--ink);
}

.visual-grid { position: absolute; inset: 0; opacity: .24; background: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px); background-size: 44px 44px; }

.json-document {
  position: relative;
  width: min(64%, 310px);
  aspect-ratio: .76;
  padding: 28px;
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 14px 14px 0 var(--signal), 17px 17px 0 var(--ink);
  transform: rotate(-3deg);
}

.doc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 46px; font-family: ui-monospace, monospace; font-weight: 900; font-size: 24px; }
.doc-top i { width: 32px; height: 32px; background: var(--ink); clip-path: polygon(0 0, 100% 100%, 0 100%); }
.code-line { height: 9px; margin: 17px 0; background: var(--ink); }
.line-a { width: 78%; }
.line-b { width: 48%; margin-left: 13%; background: var(--green); }
.line-c { width: 68%; margin-left: 13%; }
.line-d { width: 42%; background: var(--green); }
.seal { position: absolute; right: 22px; bottom: 24px; width: 76px; height: 76px; display: grid; place-content: center; text-align: center; color: var(--white); background: var(--ink); border-radius: 50%; transform: rotate(7deg); }
.seal span { font-size: 24px; font-weight: 900; line-height: 1; }
.seal small { margin-top: 4px; font-size: 8px; }

.visual-caption { position: absolute; left: 28px; right: 28px; bottom: 26px; display: flex; justify-content: space-between; align-items: end; color: var(--white); border-top: 1px solid rgba(255,255,255,.5); padding-top: 10px; font-size: 10px; font-weight: 800; }
.visual-caption b { color: var(--signal); font-size: 26px; }

footer { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 5vw, 72px); color: var(--muted); background: var(--paper); border-top: 1px solid var(--line); font-size: 10px; font-weight: 750; }

/* Admin */
.admin-body { background: var(--paper); }
.admin-main { width: min(1180px, calc(100% - 40px)); min-height: calc(100vh - 72px); margin: 0 auto; padding: 48px 0 80px; }
.admin-header-row { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 32px; }
.admin-header-row h1 { font-size: 40px; }
.admin-header-row p { margin: 8px 0 0; color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(0, 1.2fr); gap: 24px; align-items: start; }
.tool-panel { background: var(--white); border: 1px solid var(--line); border-top: 5px solid var(--green); padding: 26px; }
.tool-panel h2 { margin: 0 0 22px; font-size: 20px; }
.field { margin-bottom: 18px; }
.field input { height: 50px; font-size: 14px; }
textarea { min-height: 230px; resize: vertical; padding: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; }
.file-picker-row {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px;
  background: #f7f7f3;
  border: 1px solid var(--line);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.file-picker-row.is-dragging { background: var(--success-bg); border-color: var(--green); box-shadow: 4px 4px 0 var(--signal); }
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}
label.file-picker-button {
  min-height: 38px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  margin: 0;
  padding: 0 14px;
  color: var(--white);
  background: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.file-input:focus-visible + .file-picker-button { outline: 3px solid var(--signal); outline-offset: 2px; }
.selected-file-name { min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.button-row { display: flex; gap: 10px; }
.secondary-button { padding: 0 18px; color: var(--white); background: var(--ink); }
.secondary-button:hover { background: #343831; }
.danger-button { min-height: 34px; padding: 0 12px; color: var(--danger); background: #fff0ed; border: 1px solid #efb7af; font-size: 12px; }
.login-panel { width: min(520px, 100%); margin: 12vh auto 0; }
.login-panel h1 { font-size: 36px; }
.login-panel .primary-button { margin-top: 12px; }
.is-hidden { display: none !important; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid #e2e3de; }
th { color: var(--muted); background: #f7f7f3; font-size: 11px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 4px 8px; color: var(--green-dark); background: var(--success-bg); font-size: 11px; font-weight: 800; }
.badge.used { color: #575b53; background: #e7e8e3; }
.badge.revoked { color: var(--danger); background: #fff0ed; }
.empty-row { padding: 32px; text-align: center; color: var(--muted); }

@media (max-width: 840px) {
  .redeem-shell { width: 100%; grid-template-columns: 1fr; border: 0; }
  .file-visual { min-height: 300px; border: 0; border-top: 1px solid var(--ink); }
  .json-document { width: 160px; padding: 16px; box-shadow: 9px 9px 0 var(--signal), 11px 11px 0 var(--ink); }
  .doc-top { margin-bottom: 20px; font-size: 16px; }
  .doc-top i { width: 20px; height: 20px; }
  .code-line { height: 6px; margin: 10px 0; }
  .seal { width: 50px; height: 50px; right: 12px; bottom: 12px; }
  .seal span { font-size: 16px; }
  .seal small { font-size: 6px; }
  .admin-grid { grid-template-columns: 1fr; }
  h1 { font-size: 52px; }
}

@media (max-width: 560px) {
  .site-header { height: 64px; }
  .security-label { font-size: 0; }
  .redeem-panel { padding: 48px 20px; }
  h1 { font-size: 40px; }
  .lead { margin: 20px 0 30px; }
  input { font-size: 15px; }
  .process-strip { grid-template-columns: 1fr; gap: 10px; margin-top: 40px; }
  footer { height: auto; min-height: 70px; gap: 10px; flex-wrap: wrap; }
  .admin-main { width: calc(100% - 24px); padding-top: 28px; }
  .admin-header-row { align-items: start; flex-direction: column; }
  .admin-header-row h1 { font-size: 32px; }
  .tool-panel { padding: 20px; }
  .file-picker-row { align-items: stretch; flex-direction: column; }
  label.file-picker-button { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
