:root {
  --bg: #f5f1e8;
  --paper: #fffef9;
  --ink: #2c2620;
  --ink-light: #6b5d50;
  --accent: #8b2c1f;
  --accent-light: #c44d3a;
  --gold: #b8860b;
  --border: #d4c9b8;
  --shadow: rgba(44, 38, 32, 0.12);
  --cert-bg: #fdfbf3;
  --cert-border: #8b6f4a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1714;
    --paper: #2a241e;
    --ink: #e8dfd2;
    --ink-light: #a89888;
    --accent: #c44d3a;
    --accent-light: #e06550;
    --gold: #d4a017;
    --border: #4a3f34;
    --shadow: rgba(0, 0, 0, 0.4);
    --cert-bg: #2a241e;
    --cert-border: #8b6f4a;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Georgia', 'Noto Serif SC', serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-family: 'Georgia', serif;
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.brand .accent { color: var(--accent); }

.lang-switch button {
  background: none;
  border: 1px solid var(--border);
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink-light);
  border-radius: 3px;
  transition: all 0.2s;
}

.lang-switch button.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 24px;
  flex: 1;
}

/* Hero */
.hero-title {
  font-size: 2.4rem;
  font-weight: bold;
  line-height: 1.15;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.hero-title .dim { color: var(--ink-light); font-weight: normal; }

.hero-sub {
  font-size: 1.05rem;
  color: var(--ink-light);
  margin-bottom: 28px;
  max-width: 580px;
}

.hero-sub em { font-style: italic; color: var(--accent); }

/* Input */
.input-box {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
}

.input-box textarea {
  width: 100%;
  border: none;
  padding: 16px;
  font-family: 'Georgia', 'Noto Serif SC', serif;
  font-size: 1rem;
  background: var(--paper);
  color: var(--ink);
  resize: vertical;
  outline: none;
  line-height: 1.6;
}

.input-box textarea:focus {
  background: var(--cert-bg);
}

.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

#char-count {
  font-size: 0.8rem;
  color: var(--ink-light);
  font-family: monospace;
}

#btn-certify {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  font-family: inherit;
}

#btn-certify:hover:not(:disabled) {
  background: var(--accent-light);
  transform: translateY(-1px);
}

#btn-certify:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Samples */
.samples {
  margin-top: 20px;
}

.sample-label {
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-bottom: 8px;
}

.sample-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sample-btn {
  background: var(--paper);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 3px;
  color: var(--ink-light);
  transition: all 0.2s;
  font-family: inherit;
}

.sample-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.error-msg {
  color: var(--accent);
  padding: 10px 0;
  font-size: 0.9rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
}

.loading-stamp {
  display: inline-block;
  position: relative;
  margin-bottom: 20px;
}

.stamp-circle {
  width: 80px;
  height: 80px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

.stamp-text {
  font-size: 0.9rem;
  color: var(--ink-light);
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: var(--border);
  margin: 20px auto 0;
  border-radius: 2px;
  overflow: hidden;
}

.loading-fill {
  height: 100%;
  background: var(--accent);
  animation: loadbar 2s ease-in-out infinite;
}

@keyframes loadbar {
  0% { width: 0; }
  50% { width: 70%; }
  100% { width: 100%; }
}

/* Certificate */
.certificate {
  background: var(--cert-bg);
  border: 2px solid var(--cert-border);
  border-radius: 2px;
  padding: 0;
  box-shadow: 0 4px 20px var(--shadow);
  position: relative;
  overflow: hidden;
  animation: certAppear 0.5s ease-out;
}

@keyframes certAppear {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.cert-border {
  border: 1px solid var(--cert-border);
  margin: 8px;
  padding: 32px 28px;
  position: relative;
  min-height: 400px;
}

.cert-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gold);
}

.cert-corner.top-left { top: 0; left: 0; border-right: none; border-bottom: none; }
.cert-corner.top-right { top: 0; right: 0; border-left: none; border-bottom: none; }
.cert-corner.bottom-left { bottom: 0; left: 0; border-right: none; border-top: none; }
.cert-corner.bottom-right { bottom: 0; right: 0; border-left: none; border-top: none; }

.cert-header {
  text-align: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.cert-seal {
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.cert-org {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-light);
  font-family: monospace;
}

.cert-org-sub {
  font-size: 0.6rem;
  color: var(--ink-light);
  opacity: 0.7;
}

.cert-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: bold;
  margin: 16px 0;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.cert-body {
  text-align: center;
  padding: 8px 0;
}

.cert-presented {
  font-size: 0.85rem;
  color: var(--ink-light);
}

.cert-name {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 6px 0;
  color: var(--ink);
}

.cert-verified {
  font-size: 0.85rem;
  color: var(--ink-light);
}

.cert-score-box {
  display: inline-block;
  margin: 20px 0;
  padding: 12px 32px;
  border: 2px solid var(--cert-border);
  border-radius: 4px;
  background: var(--paper);
}

.cert-score {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--accent);
  line-height: 1;
}

.cert-score-unit {
  font-size: 0.75rem;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.cert-level {
  font-size: 1.1rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 8px 0 16px;
}

.cert-findings {
  text-align: left;
  margin: 16px 0;
  padding: 12px;
  background: rgba(184, 134, 11, 0.05);
  border-left: 3px solid var(--gold);
}

.findings-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-light);
  margin-bottom: 8px;
}

#findings-list p {
  font-size: 0.9rem;
  margin: 6px 0;
  color: var(--ink);
  padding-left: 16px;
  position: relative;
}

#findings-list p::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.cert-personality {
  margin: 16px 0;
  padding: 12px;
  text-align: center;
  border-top: 1px dashed var(--border);
}

.personality-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-light);
}

.personality-type {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent);
  margin: 4px 0;
}

.personality-desc {
  font-size: 0.85rem;
  color: var(--ink-light);
  font-style: italic;
}

.cert-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.cert-id {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--ink-light);
}

.cert-date {
  font-size: 0.75rem;
  color: var(--ink-light);
  margin: 2px 0;
}

.cert-authority {
  font-size: 0.65rem;
  color: var(--ink-light);
  opacity: 0.7;
  font-style: italic;
}

/* Actions */
.cert-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
  flex-wrap: wrap;
}

.action-btn {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 10px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  font-family: inherit;
}

.action-btn:hover { background: var(--accent); }

.action-btn.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
}

.action-btn.secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Premium */
.premium-section {
  margin-top: 24px;
}

.premium-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
  box-shadow: 0 2px 8px var(--shadow);
}

.premium-card h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.premium-desc {
  font-size: 0.9rem;
  color: var(--ink-light);
  margin-bottom: 16px;
}

.premium-payment {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.payment-info { flex: 1; min-width: 280px; }

.payment-amount {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--ink);
  margin-bottom: 8px;
}

.payment-addr-label {
  font-size: 0.8rem;
  color: var(--ink-light);
  margin-bottom: 4px;
}

.payment-addr-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.payment-addr-box code {
  font-size: 0.75rem;
  word-break: break-all;
  flex: 1;
  color: var(--ink);
}

.copy-btn {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
}

.copy-btn:hover { background: var(--accent); }

.payment-note {
  font-size: 0.75rem;
  color: var(--ink-light);
  margin-top: 8px;
}

.tx-verify-box {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.tx-verify-box input {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-family: monospace;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
}

.tx-verify-box input:focus {
  border-color: var(--accent);
}

.tx-verify-box button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  border-radius: 3px;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.2s;
}

.tx-verify-box button:hover { background: var(--accent-light); }

.tx-result {
  font-size: 0.85rem;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 3px;
}

.tx-result a {
  text-decoration: underline;
}

.qr-code-box {
  flex-shrink: 0;
}

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--ink-light);
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

/* Responsive */
@media (max-width: 600px) {
  .hero-title { font-size: 1.8rem; }
  .container { padding: 24px 16px; }
  .cert-border { padding: 20px 16px; margin: 4px; }
  .cert-title { font-size: 1.4rem; }
  .cert-score { font-size: 2rem; }
  .premium-payment { flex-direction: column; }
  .qr-code-box { align-self: center; }
}
