:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-soft: #f1eee5;
  --text: #1f1f1a;
  --muted: #6e6b61;
  --line: #ddd8c9;
  --accent: #0f766e;
  --accent-soft: #d7f2ef;
  --danger: #b42318;
  --danger-soft: #fde8e5;
  --success: #166534;
  --success-soft: #dcfce7;
  --shadow: 0 10px 30px rgba(28, 28, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #fef4d4 0, transparent 34%),
    linear-gradient(180deg, #f5f4ef 0%, #ece8db 100%);
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

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

code {
  background: #f4f1e7;
  padding: 0.15rem 0.35rem;
  border-radius: 0.4rem;
  font-size: 0.92em;
}

.wrap {
  width: min(1100px, calc(100vw - 32px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(221, 216, 201, 0.85);
  background: rgba(245, 244, 239, 0.86);
  backdrop-filter: blur(18px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 70px;
}

.brand {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--muted);
  font-size: 0.96rem;
}

.link-button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.page {
  padding: 28px 0 56px;
}

.flash {
  margin-bottom: 20px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.flash-info {
  background: var(--surface);
}

.flash-success {
  background: var(--success-soft);
  border-color: #b7e3c1;
}

.flash-error {
  background: var(--danger-soft);
  border-color: #f5c4bd;
}

.hero-card,
.card {
  border: 1px solid rgba(221, 216, 201, 0.9);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  padding: 26px;
}

.hero-card {
  margin-top: 6vh;
}

.hero-card h1,
.card h1,
.card h2 {
  margin: 0 0 10px;
}

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

.lookup-form,
.stack-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.enhanced-form {
  position: relative;
}

input,
select,
button,
textarea {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: #fffdf8;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button[disabled] {
  cursor: wait;
  opacity: 0.78;
}

.button-light {
  background: #fffaf0;
  color: var(--text);
}

.primary-button {
  margin-top: 12px;
}

.card + .card,
.stats-grid + .card {
  margin-top: 20px;
}

.stats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 20px;
}

.stat-card {
  border: 1px solid rgba(221, 216, 201, 0.9);
  border-radius: 24px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 1.8rem;
}

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

.full-width {
  grid-column: 1 / -1;
}

.form-hint {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f4f1e7;
  color: var(--text);
  font-size: 0.92rem;
}

.operation-preview {
  padding: 13px 15px;
  border: 1px dashed #c8c2af;
  border-radius: 16px;
  background: #fcfaf4;
  color: var(--muted);
  line-height: 1.55;
}

.submit-feedback {
  min-height: 1.4em;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.inline-form {
  display: inline-flex;
}

.is-submitting::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.badge-created {
  background: #e0f2fe;
  color: #075985;
}

.badge-redeemed {
  background: var(--success-soft);
  color: var(--success);
}

.badge-disabled {
  background: #efefef;
  color: #555;
}

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

.meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.notice {
  margin-top: 16px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

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

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.preview-list {
  display: grid;
  gap: 14px;
}

.preview-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #fffdf8;
}

.preview-item h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.usage-instructions {
  line-height: 1.8;
  color: var(--muted);
  font-size: 0.95rem;
}

.usage-instructions p {
  margin: 6px 0;
}

.usage-instructions a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.narrow-card {
  width: min(460px, 100%);
  margin: 8vh auto 0;
}

@media (max-width: 720px) {
  .topbar-inner,
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topnav {
    flex-wrap: wrap;
  }

  .hero-card {
    margin-top: 18px;
  }
}
