/* ---------- tokens ---------- */
:root {
  --ink: #162147;
  --slate: color-mix(in srgb, var(--ink) 60%, white);
  --paper: color-mix(in srgb, #4CACD4 6%, white);
  --paper-dim: color-mix(in srgb, #4CACD4 12%, white);
  --line: color-mix(in srgb, #3F90CE 30%, white);
  --brass: #3F90CE;
  --brass-deep: color-mix(in srgb, #3F90CE 80%, var(--ink));
  --moss: #4CACD4;
  --rust: var(--ink);
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --serif: "IBM Plex Serif", Georgia, serif;
  --radius: 3px;
  --shadow: 0 1px 0 rgba(22,33,71,0.08);
}

@font-face {
  font-family: "IBM Plex Sans";
  src: local("Segoe UI");
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brass-deep); }

button {
  font-family: inherit;
  cursor: pointer;
}

::selection { background: color-mix(in srgb, #4CACD4 35%, white); }

/* ---------- layout ---------- */
.frame {
  display: flex;
  min-height: 100vh;
}

.rail {
  width: 250px;
  flex: 0 0 250px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 22px;
  border-bottom: 1px solid rgba(76,172,212,0.22);
  margin-bottom: 18px;
}
.brand-mark { color: #4CACD4; flex-shrink: 0; }
.brand-name {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.01em;
}
.brand-sub {
  font-size: 12px;
  color: color-mix(in srgb, #4CACD4 55%, white);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  text-align: left;
  background: transparent;
  border: none;
  color: color-mix(in srgb, #46A1D1 60%, white);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: rgba(76,172,212,0.14); color: var(--paper); }
.nav-item.is-active {
  background: #4CACD4;
  color: var(--ink);
  font-weight: 600;
}
.nav-item .count {
  font-family: var(--mono);
  font-size: 11.5px;
  background: rgba(0,0,0,0.2);
  padding: 1px 6px;
  border-radius: 10px;
}
.nav-item.is-active .count { background: rgba(22,33,71,0.16); }

.rail-footer {
  border-top: 1px solid rgba(76,172,212,0.22);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail-note {
  font-size: 12px;
  color: color-mix(in srgb, #3F90CE 50%, white);
  line-height: 1.45;
  margin-bottom: 4px;
}
.link-btn {
  background: none;
  border: none;
  color: color-mix(in srgb, #46A1D1 60%, white);
  text-align: left;
  font-size: 13px;
  padding: 4px 0;
}
.link-btn:hover { color: var(--paper); text-decoration: underline; }
.link-btn.danger { color: #4CACD4; }
.link-btn.danger:hover { color: color-mix(in srgb, #4CACD4 70%, white); }

.stage {
  flex: 1;
  padding: 40px 48px 80px;
  max-width: 880px;
}

@media (max-width: 860px) {
  .frame { flex-direction: column; }
  .rail { width: auto; flex: none; position: static; height: auto; }
  .stage { padding: 28px 20px 60px; max-width: none; }
}

/* ---------- typography ---------- */
h1 {
  font-family: var(--serif);
  font-size: 30px;
  margin: 0 0 6px;
  font-weight: 600;
}
h2 {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 14px;
  font-weight: 600;
}
.lede {
  color: var(--slate);
  font-size: 15px;
  max-width: 60ch;
  margin: 0 0 28px;
}

/* ---------- form controls ---------- */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--slate);
}
.field .hint {
  font-size: 12px;
  color: color-mix(in srgb, var(--ink) 45%, white);
  margin-top: 5px;
}
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 13.5px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}

.radio-row, .chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 13px;
  border-radius: 20px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--slate);
}
.chip.is-selected {
  border-color: var(--brass-deep);
  background: color-mix(in srgb, #3F90CE 16%, white);
  color: var(--brass-deep);
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #3F90CE;
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}
.btn:hover { background: #46A1D1; }
.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
}
.btn.secondary:hover { background: var(--paper-dim); }
.btn.danger { background: var(--ink); color: #fff; }
.btn.danger:hover { background: color-mix(in srgb, var(--ink) 85%, #3F90CE 15%); }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

/* ---------- cards / panels ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel.result {
  border-left: 3px solid #4CACD4;
}
.panel.result-bad {
  border-left: 3px solid var(--ink);
}

/* ---------- key list ---------- */
.key-list { display: flex; flex-direction: column; gap: 10px; }
.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: #fff;
}
.key-row .meta-block { min-width: 0; }
.key-row .key-name {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 14.5px;
}
.key-row .key-meta {
  font-size: 12.5px;
  color: var(--slate);
  margin-top: 3px;
}
.key-row .key-meta code {
  background: var(--paper-dim);
  padding: 1px 5px;
  border-radius: 3px;
}
.key-row .key-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--slate);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ---------- output blocks ---------- */
.output-block { margin-bottom: 16px; }
.output-block .output-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 6px;
}
pre.code-box, textarea.code-box {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--ink);
  color: color-mix(in srgb, #4CACD4 25%, white);
  padding: 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
.copy-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 11.5px;
  padding: 3px 9px;
  color: var(--slate);
}
.copy-btn:hover { background: var(--paper-dim); }

.jwt-parts { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.jwt-parts .p-header { color: #3F90CE; }
.jwt-parts .p-payload { color: #46A1D1; }
.jwt-parts .p-sig { color: #4CACD4; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 20px;
}
.badge.ok { background: color-mix(in srgb, #4CACD4 22%, white); color: color-mix(in srgb, #4CACD4 70%, var(--ink)); }
.badge.bad { background: color-mix(in srgb, var(--ink) 12%, white); color: var(--ink); }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  max-width: 340px;
  box-shadow: 0 6px 20px rgba(22,33,71,0.28);
  animation: rise 0.18s ease;
}
.toast.bad { background: var(--ink); }
.toast.good { background: #3F90CE; }
@keyframes rise {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22,33,71,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 100%;
}
.modal h3 { font-family: var(--serif); margin: 0 0 10px; font-size: 18px; }
.modal p { color: var(--slate); font-size: 14px; margin: 0 0 16px; }
.modal .actions-row { margin-top: 0; justify-content: flex-end; }

/* ---------- misc ---------- */
.divider { border: none; border-top: 1px solid var(--line); margin: 24px 0; }
.kv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv-table tr td { padding: 6px 0; vertical-align: top; }
.kv-table tr td:first-child { color: var(--slate); width: 160px; }
.kv-table code { font-family: var(--mono); font-size: 12.5px; }
