:root {
  --disc-color-0: #f0c674;
  --disc-color-1: #9fdcae;
  --disc-color-2: #f5a97f;
  --disc-color-3: #8bd3ea;
  --disc-color-4: #c4a7f5;
  --disc-color-5: #ff9b8f;
  --disc-color-6: #8fb4ff;
  --disc-color-7: #f1f2f4;
}

[data-theme="light"] {
  --disc-color-0: #7a5600;
  --disc-color-1: #17602e;
  --disc-color-2: #9a4a12;
  --disc-color-3: #0a6a87;
  --disc-color-4: #6b3fb8;
  --disc-color-5: #b3261e;
  --disc-color-6: #1f4fd1;
  --disc-color-7: #15171a;
}

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

/* The default link color is unreadable on dark backgrounds. */
a {
  color: var(--link);
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-header);
  flex-shrink: 0;
  position: relative;
}

/* The logo's aspect ratio is 42:47. A square box adds padding. */
.header-logo {
  width: 24px;
  height: 27px;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.subtitle {
  font-size: 13px;
  color: var(--text-dim);
}

/* On wide screens the links sit next to the brand and the buttons on the
   right. Narrow screens move the links and the input actions into a menu. */
.header-right,
.header-menu {
  display: contents;
}

.header-links {
  display: flex;
  gap: 16px;
  font-size: 13px;
  margin: 0 auto 0 12px;
}

/* IBM Plex Sans at 13px draws its glyphs about 1px above the middle of the
   line box. The nudge puts the links and buttons on the title's center line. */
.header-links {
  position: relative;
  top: 1px;
}

header .btn {
  padding: 8px 14px 6px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.header-menu-toggle {
  display: none;
}

.header-links a {
  color: var(--text-dim);
  text-decoration: none;
}

.header-links a:hover {
  color: var(--text);
}

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--bg-btn);
  color: var(--text);
  cursor: pointer;
}

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

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#theme-btn {
  background: transparent;
  border-color: var(--border);
}

#theme-btn:hover {
  background: var(--bg-btn);
}

main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.input-pane {
  border-right: 1px solid var(--border-subtle);
}

.pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
}

#demo-note {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-fg);
  font-size: 12px;
  font-weight: 500;
}

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 9px;
  border-radius: 10px;
  text-transform: uppercase;
}

.badge.hidden {
  display: none;
}

.badge.sd-jwt {
  background: var(--info-bg);
  color: var(--info-fg);
}

.badge.jwt {
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.badge.mdoc {
  background: color-mix(in srgb, var(--purple) 16%, var(--bg-surface));
  color: var(--purple);
}

.input-editor {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Only the credential editor has a transparent overlay. Other textareas stay visible. */
.input-editor textarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  color: var(--text);
  border: none;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
  overflow-y: scroll;
  overflow-x: hidden;
  z-index: 2;
  word-break: break-all;
  overflow-wrap: normal;
}

.input-editor textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Credentials break anywhere. The placeholder breaks between words. */
.input-editor textarea:placeholder-shown {
  word-break: normal;
}

.input-editor textarea.colorized {
  background: transparent;
  color: transparent;
  caret-color: var(--text);
}

.input-editor textarea::placeholder {
  color: var(--text-dim);
}

.input-editor textarea.colorized::placeholder {
  color: transparent;
}

.output-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

.placeholder {
  font-family: var(--font-sans);
  color: var(--text-dim);
}

.error {
  color: var(--danger);
  padding: 12px 14px;
  background: var(--danger-bg);
  border-radius: 12px;
}

.section {
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 15px;
}

.section-header:hover {
  opacity: 0.8;
}

.section-header .arrow {
  font-size: 10px;
  transition: transform 0.15s;
  display: inline-block;
  width: 14px;
}

.section-header .arrow.collapsed {
  transform: rotate(-90deg);
}

.section-body {
  padding-left: 20px;
  overflow: hidden;
}

.section-body.collapsed {
  display: none;
}

.json-key {
  color: var(--cyan);
}

.json-string {
  color: var(--green);
}

.json-number {
  color: var(--yellow);
}

.json-bool {
  color: var(--orange);
}

.json-null {
  color: var(--text-dim);
}

.json-line {
  white-space: pre;
}

.json-block {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.embedded-token {
  appearance: none;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  margin: 0;
  padding: 0;
  text-align: left;
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 2px;
}

.embedded-token:hover {
  color: var(--link);
  text-decoration-color: currentColor;
}

.disclosure-item,
.claim-item {
  margin: 4px 0;
  padding: 7px 12px;
  background: var(--bg-surface);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
}

.disclosure-name,
.claim-name {
  color: var(--yellow);
  font-weight: 600;
}

.disclosure-value,
.claim-value {
  color: var(--green);
  /* Long Base64 image claims must not widen the pane. */
  overflow-wrap: anywhere;
}

.long-value {
  display: inline;
}

.long-value-token {
  overflow-wrap: anywhere;
}

.long-value-toggle {
  appearance: none;
  background: none;
  border: none;
  color: var(--link);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  margin-left: 6px;
  padding: 0;
  text-decoration: underline;
}

.value-image {
  display: block;
  margin-top: 6px;
  max-width: 160px;
  max-height: 160px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.disclosure-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.validity-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  margin-bottom: 12px;
}

.validity-banner.valid { background: color-mix(in srgb, var(--ok-bg) 60%, var(--bg-surface)); }
.validity-banner.expired { background: color-mix(in srgb, var(--danger-bg) 60%, var(--bg-surface)); }
.validity-banner.unverified { background: color-mix(in srgb, var(--warn-bg) 60%, var(--bg-surface)); }
.validity-banner.checking { background: var(--bg-surface); }

.verification-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
}

.verification-verdict {
  font-weight: 700;
}

.validity-banner.valid .verification-verdict { color: var(--ok-fg); }
.validity-banner.expired .verification-verdict { color: var(--danger); }
.validity-banner.unverified .verification-verdict { color: var(--yellow); }
.validity-banner.checking .verification-verdict { color: var(--text-dim); }

.verification-groups {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* One grid per group, so the names of its checks share a column. */
.verification-group {
  display: grid;
  grid-template-columns: 14px max-content minmax(0, 1fr);
  gap: 2px 8px;
  align-items: baseline;
  line-height: 1.4;
}

.verification-group .vg-title {
  grid-column: 1 / -1;
}

.vg-title {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.vg-item {
  display: contents;
}

.vg-icon {
  width: 14px;
  flex-shrink: 0;
  text-align: center;
  font-weight: 700;
}

.vg-name {
  font-weight: 600;
}

.vg-detail {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text-dim);
}

.vg-anchor-line {
  display: block;
}

.vg-anchor a {
  color: var(--link);
}

.vg-violations .vg-icon { color: var(--danger); }
.vg-warnings .vg-icon { color: var(--yellow); }
.vg-cant .vg-icon { color: var(--text-dim); }
.vg-valid .vg-icon { color: var(--green); }

.verify-details {
  max-width: 460px;
}

.verify-details summary {
  cursor: pointer;
  width: fit-content;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}

.verify-details[open] summary {
  margin-bottom: 6px;
}

.validity-detail {
  font-weight: 400;
  color: var(--text-dim);
}

.timestamp-hover {
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 2px;
  cursor: help;
}

.section-header .copy-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.section-header:hover .copy-btn {
  opacity: 1;
}

.section-header .copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.section-header .copy-btn.copied {
  color: var(--green);
  opacity: 1;
}

.issuer-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  font-size: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 100%;
}

.summary-chip-label {
  padding: 3px 9px;
  background: var(--bg-btn);
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-weight: 600;
  white-space: nowrap;
}

.summary-chip-value {
  padding: 3px 8px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.digest-truncated {
  cursor: help;
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 2px;
}

.resolved-claims-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.resolved-group-label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 8px;
  margin-bottom: 2px;
}

.resolved-group-label:first-child {
  margin-top: 0;
}

.resolved-group-label.disclosed {
  color: var(--green);
}

.claim-item.claim-disclosed {
  border-left-color: var(--green);
}

.raw-view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-input);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-y: scroll;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-all;
  display: none;
  z-index: 1;
  box-sizing: border-box;
  pointer-events: none;
}

.raw-view .jwt-header { color: var(--red); }
.raw-view .jwt-payload { color: var(--purple); }
.raw-view .jwt-signature { color: var(--cyan); }
.raw-view .jwt-separator { color: var(--text-dim); }

.raw-view .jwt-disc-0 { color: var(--yellow); }
.raw-view .jwt-disc-1 { color: var(--green); }
.raw-view .jwt-disc-2 { color: var(--orange); }
.raw-view .jwt-disc-3 { color: var(--cyan); }
.raw-view .jwt-disc-4 { color: var(--purple); }
.raw-view .jwt-disc-5 { color: var(--red); }
.raw-view .jwt-disc-6 { color: var(--accent); }
.raw-view .jwt-disc-7 { color: var(--text); }

.raw-view [data-section] {
  border-radius: 2px;
  transition: background 0.1s;
}

.raw-view [data-section="kb-jwt"] {
  border-bottom: 1px dashed var(--text-dim);
}

.raw-view [data-section].highlight {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.section.highlight {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border-radius: 10px;
  margin-left: -8px;
  margin-right: -8px;
  padding-left: 8px;
  padding-right: 8px;
}

.disclosure-item[data-disc-index] {
  transition: background 0.1s;
}

.disclosure-item.highlight {
  background: var(--bg-hover);
}

.shortcut-hint {
  padding: 8px 16px 10px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dialog);
  color: var(--text);
  border: 1px solid var(--border-dialog);
  border-radius: 999px;
  box-shadow: var(--shadow-dialog);
  padding: 8px 18px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

.verify-inline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 460px;
}

.verify-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.verify-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
  outline: none;
}

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

.verify-btn {
  align-self: flex-start;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 7px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.verify-btn:hover {
  opacity: 0.9;
}

.verify-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 480px) {
  .verification-group {
    grid-template-columns: 14px minmax(0, 1fr);
    row-gap: 0;
  }

  .vg-detail {
    grid-column: 2;
    margin-bottom: 2px;
  }
}

@media (max-width: 768px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  main {
    flex-direction: column;
    overflow: visible;
    flex: none;
  }

  .pane {
    flex: none;
  }

  .input-pane {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    height: 35vh;
    min-height: 150px;
  }

  .input-editor {
    min-height: 0;
  }

  .output-pane {
    min-height: 50vh;
  }

  .output-content {
    overflow: visible;
  }

  header {
    justify-content: space-between;
    padding: 12px 16px;
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .header-menu-toggle {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border-color: var(--border);
  }

  .header-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 50;
  }

  .header-menu.open {
    display: flex;
  }

  .header-links {
    flex-direction: column;
    gap: 14px;
    margin: 0;
    font-size: 14px;
  }

  .header-actions {
    gap: 8px;
  }
}

.consent-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.consent-overlay.active {
  display: flex;
}

.consent-dialog {
  position: relative;
  background: var(--bg-dialog);
  border: 1px solid var(--border-dialog);
  border-radius: 22px;
  box-shadow: var(--shadow-dialog);
  padding: 22px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.consent-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.dialog-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.dialog-hint a {
  color: var(--link);
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.cli-install-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 12px;
}

.cli-install pre {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-dialog);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 4px 0;
  overflow-x: auto;
  user-select: all;
}

.consent-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

.format-note {
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  border-left: 2px solid var(--border);
  padding: 2px 0 2px 8px;
  margin-bottom: 8px;
}
.mdoc-item {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.mdoc-item:last-child {
  border-bottom: 0;
}
.mdoc-item-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  cursor: help;
}
.mdoc-item-bad {
  color: var(--danger);
}

.disclosure-unreferenced {
  color: var(--danger);
  font-weight: 600;
}
