:root {
  --bg: #0d0f14;
  --surface: #141821;
  --surface-2: #1a1f2b;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent-a: #6c5ce7;
  --accent-b: #00d1ff;
  --danger: #ff6b6b;
  --success: #3ddc97;
  --warning: #f5b942;
  --radius: 14px;
  --header-h: 60px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden { display: none !important; }

.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;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 4px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: #fff;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
}

/* ---------- Hero ---------- */
main { flex: 1; }

.hero {
  text-align: center;
  padding: 44px 0 28px;
}

.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  margin-top: 8px;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
}

/* ---------- Cards & layout ---------- */
.panel { padding-bottom: 48px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h2 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.seg-header { background: var(--accent-a); }
.seg-payload { background: var(--accent-b); }
.seg-signature { background: var(--warning); }

/* ---------- Inputs ---------- */
.code-input {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.code-input:focus {
  outline: none;
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.18);
}

.token-input {
  min-height: 110px;
  word-break: break-all;
}

.json-input { min-height: 190px; }

.token-output {
  min-height: 110px;
  word-break: break-all;
}

.text-input {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent-a);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.18);
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  margin: 0;
  white-space: nowrap;
  user-select: none;
}

.checkbox-label input { accent-color: var(--accent-a); }

/* ---------- Buttons ---------- */
.btn {
  border: 0;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

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

.btn-primary {
  color: #fff;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.35);
}

.btn-primary:hover { opacity: 0.92; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-valid { background: rgba(61, 220, 151, 0.14); color: var(--success); }
.badge-expired { background: rgba(255, 107, 107, 0.14); color: var(--danger); }
.badge-warning { background: rgba(245, 185, 66, 0.14); color: var(--warning); }
.badge-muted { background: rgba(154, 163, 178, 0.14); color: var(--muted); }

/* ---------- JSON view ---------- */
.json-view {
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.83rem;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  min-height: 60px;
}

.signature-view {
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--warning);
}

.j-key { color: var(--accent-b); }
.j-string { color: #a8e6a1; }
.j-number { color: #f5b942; }
.j-bool { color: #c792ea; }
.j-null { color: var(--muted); font-style: italic; }
.j-punct { color: var(--muted); }

/* ---------- Claims table ---------- */
.table-wrap { overflow-x: auto; }

.claims-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.claims-table th,
.claims-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

.claims-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.claims-table td:first-child {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  color: var(--accent-b);
  white-space: nowrap;
}

.claims-table tr:last-child td { border-bottom: 0; }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* ---------- Verify & sign ---------- */
.verify-box { margin-top: 16px; }

.verify-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.verify-row .text-input { flex: 1 1 220px; }

#verify-result {
  margin-top: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

#verify-result.ok { color: var(--success); }
#verify-result.bad { color: var(--danger); }
#verify-result.note { color: var(--muted); font-weight: 500; }

.sign-grid {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 16px;
}

.sign-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ---------- Errors & toast ---------- */
.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 10px;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  z-index: 100;
  animation: toast-in 0.18s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 22px 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sign-grid { grid-template-columns: 1fr; }
  .hero { padding: 32px 0 20px; }
  .card { padding: 16px; }
  .tab { padding: 6px 14px; }
}
