:root {
  --bg: #fffcf7;
  --bg-2: #fef6ec;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --border: rgba(180, 150, 120, 0.18);
  --text: #22252f;
  --text-soft: #525868;
  --muted: #878d9f;
  --accent: #e07a3c;
  --accent-2: #f29e4c;
  --orb-1: #ffe5b4;
  --orb-2: #ffd1dc;
  --orb-3: #cdeac0;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Songti SC", "Noto Serif SC", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(circle at 50% 0%, #ffffff 0%, var(--bg) 55%, var(--bg-2) 100%);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Bright sunlit ambient background */
.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.72;
  transition: background 1s ease, transform 1s ease;
}
.orb-1 { width: 480px; height: 480px; background: var(--orb-1); top: -120px; left: -90px; }
.orb-2 { width: 440px; height: 440px; background: var(--orb-2); bottom: -130px; right: -70px; }
.orb-3 { width: 380px; height: 380px; background: var(--orb-3); top: 38%; left: 56%; transform: translate(-50%, -50%); }

/* Header */
header.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand .sparkle {
  color: var(--accent);
  font-size: 19px;
}
.top-actions {
  display: flex;
  gap: 10px;
}

button, input {
  font: inherit;
  color: var(--text);
}
button {
  cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 10px rgba(180, 140, 100, 0.06);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
button:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(224, 122, 60, 0.14);
}
button:active {
  transform: scale(0.98);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}

/* Main stage */
main.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 20px 44px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}
.cat {
  font-size: 13px;
  color: var(--text-soft);
  padding: 6px 15px;
}
.cat.active {
  color: var(--accent);
  font-weight: 600;
  border-color: var(--accent);
  background: rgba(255, 245, 235, 0.95);
}

/* Blessing card */
.card {
  width: 100%;
  background: var(--panel);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 26px;
  padding: 38px 42px 28px;
  box-shadow:
    0 20px 50px rgba(175, 138, 102, 0.12),
    0 2px 12px rgba(175, 138, 102, 0.06);
  transition: opacity 0.24s ease, transform 0.24s ease;
}
.card.fade {
  opacity: 0;
  transform: translateY(8px);
}
@media (max-width: 600px) {
  .card { padding: 26px 22px 22px; border-radius: 20px; }
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.tag {
  color: var(--accent);
  font-weight: 650;
}

.blessing-en {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: clamp(21px, 3.1vw, 28px);
  line-height: 1.5;
  font-weight: 400;
  color: var(--text);
}

.blessing-zh {
  margin: 0 0 26px;
  font-family: var(--serif);
  font-size: clamp(16px, 2.1vw, 19px);
  line-height: 1.7;
  color: var(--text-soft);
}

body[data-lang="en"] .blessing-zh { display: none; }
body[data-lang="zh"] .blessing-en { display: none; }
body[data-lang="zh"] .blessing-zh {
  font-size: clamp(22px, 3.2vw, 27px);
  color: var(--text);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.date {
  font-size: 13px;
  color: var(--muted);
}
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  padding: 8px 14px;
  font-size: 13px;
}
.icon-btn.saved {
  color: #e64965;
  border-color: rgba(230, 73, 101, 0.4);
  background: #fff0f3;
}
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-weight: 650;
  border: none;
  padding: 9px 20px;
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(224, 122, 60, 0.28);
}
.primary-btn:hover {
  filter: brightness(1.05);
  box-shadow: 0 8px 22px rgba(224, 122, 60, 0.36);
}

/* Recipient bar */
.recipient-bar {
  margin-top: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-soft);
}
.recipient-bar input {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  width: 260px;
  outline: none;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(180, 140, 100, 0.05);
}
.recipient-bar input:focus {
  border-color: var(--accent);
}

.hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
kbd {
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  font-size: 11px;
  color: var(--text-soft);
}

/* Saved drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 92vw);
  background: var(--panel-solid);
  border-left: 1px solid var(--border);
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-shadow: -16px 0 40px rgba(150, 120, 90, 0.14);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.drawer-head h2 {
  margin: 0;
  font-size: 17px;
}
.drawer-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.saved-item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  position: relative;
}
.saved-item p {
  margin: 0 0 6px;
  font-family: var(--serif);
}
.saved-item .rm {
  font-size: 11px;
  padding: 2px 8px;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #22252f;
  color: #ffffff;
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(34, 37, 47, 0.18);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 20;
}
.toast.show { opacity: 1; }
.hidden { display: none !important; }

/* Navigation tabs */
.nav-tabs {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 4px;
}
.nav-tab {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 6px 15px;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 550;
}
.nav-tab:hover {
  box-shadow: none;
  color: var(--text);
}
.nav-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-weight: 650;
  box-shadow: 0 3px 10px rgba(224, 122, 60, 0.25);
}

/* Unix Timestamp View */
.ts-stage {
  max-width: 960px;
  justify-content: flex-start;
  padding-top: 8px;
}
.ts-clock-card {
  padding: 22px 28px;
  margin-bottom: 16px;
}
.ts-clock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.ts-clock-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1.3fr;
  gap: 16px;
  align-items: center;
}
@media (max-width: 760px) {
  .ts-clock-grid { grid-template-columns: 1fr; }
  header.top { flex-wrap: wrap; gap: 10px; }
}
.ts-clock-box {
  background: rgba(255, 252, 247, 0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}
.ts-clock-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}
.ts-clock-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 23px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.ts-clock-sub {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 4px;
}
.ts-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 16px;
}
.ts-preset-title {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}
.ts-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 820px) {
  .ts-grid { grid-template-columns: 1fr; }
}
.ts-panel {
  padding: 24px 26px;
}
.ts-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 650;
}
.ts-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.ts-input, .ts-select {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.ts-input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-width: 0;
}
.ts-input:focus, .ts-select:focus {
  border-color: var(--accent);
}
.ts-detected {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}
.ts-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ts-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 252, 247, 0.85);
  border: 1px solid var(--border);
}
.ts-k {
  font-size: 12px;
  color: var(--muted);
  width: 92px;
  flex-shrink: 0;
}
.ts-v {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.ts-copy-btn {
  padding: 3px 10px;
  font-size: 11px;
  flex-shrink: 0;
}

/* QR Code Generator View */
.qr-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 820px) {
  .qr-grid { grid-template-columns: 1fr; }
}
.qr-textarea {
  width: 100%;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font: 13.5px/1.55 var(--sans);
  color: var(--text);
  resize: vertical;
  outline: none;
}
.qr-textarea:focus {
  border-color: var(--accent);
}
.qr-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.qr-form label, .qr-options-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-soft);
}
.qr-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0 14px;
}
.qr-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.qr-colors-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.qr-color-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
}
.qr-color-pick input[type="color"] {
  width: 30px;
  height: 30px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  cursor: pointer;
}
.qr-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}
.qr-preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.qr-canvas-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(175, 138, 102, 0.08);
  margin-bottom: 10px;
}
#qr-canvas {
  width: min(260px, 68vw);
  height: min(260px, 68vw);
  display: block;
  border-radius: 8px;
}
.qr-export-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

/* JWT Debugger View (jwt.io inspired color coding) */
:root {
  --jwt-h: #e11d48;
  --jwt-p: #7c3aed;
  --jwt-s: #0284c7;
}
.jwt-c-h { color: var(--jwt-h); font-weight: 600; }
.jwt-c-p { color: var(--jwt-p); font-weight: 600; }
.jwt-c-s { color: var(--jwt-s); font-weight: 600; }

.jwt-topbar {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.jwt-alg-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-soft);
}
.jwt-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.jwt-status-badge {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
}
.jwt-status-badge.ok {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.jwt-status-badge.err {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.jwt-status-badge.warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.jwt-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1.08fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 820px) {
  .jwt-grid { grid-template-columns: 1fr; }
}
.jwt-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.jwt-pane-head .ts-title { margin: 0; }
.jwt-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}
.jwt-head-btns {
  display: flex;
  gap: 6px;
}
.jwt-copy-btn {
  padding: 6px 14px;
  font-size: 12.5px;
}
.jwt-token-input {
  width: 100%;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  word-break: break-all;
  resize: vertical;
  outline: none;
  margin-bottom: 10px;
}
.jwt-token-input:focus {
  border-color: var(--accent);
}
.jwt-color-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.jwt-colored-box {
  background: rgba(255, 252, 247, 0.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  max-height: 150px;
  overflow-y: auto;
}
.jwt-claims-card {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.jwt-claims-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 2px;
}
.jwt-claim-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 252, 247, 0.85);
  border: 1px solid var(--border);
}
.jwt-claim-k { color: var(--text-soft); font-weight: 550; }
.jwt-claim-v { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text); text-align: right; }
.jwt-claim-ok { color: #15803d; font-weight: 600; }
.jwt-claim-err { color: #b91c1c; font-weight: 600; }

.jwt-block {
  margin-bottom: 14px;
}
.jwt-block:last-child {
  margin-bottom: 0;
}
.jwt-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.jwt-block-title small {
  color: var(--muted);
  font-weight: 500;
}
.jwt-err {
  color: #dc2626;
  font-size: 11.5px;
  font-weight: 600;
}
.jwt-json-input {
  width: 100%;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 10px 12px;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  resize: vertical;
  outline: none;
}
.jwt-border-h { border-left-color: var(--jwt-h); }
.jwt-border-p { border-left-color: var(--jwt-p); }
.jwt-border-s { border-left: 4px solid var(--jwt-s); }
.jwt-sig-box {
  background: rgba(255, 252, 247, 0.9);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.jwt-sig-formula {
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--jwt-s);
}
.jwt-secret-input {
  width: 100%;
}
.jwt-b64-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
}
