:root {
  --bg: #1a1b26;
  --bg-surface: #24283b;
  --bg-hover: #2f3350;
  --text: #c0caf5;
  --text-dim: #8b93b8;
  --border: #3b4261;
  --accent: #7aa2f7;
  --cyan: #7dcfff;
  --green: #9ece6a;
  --yellow: #e0af68;
  --red: #f7768e;
  --orange: #ff9e64;
  --purple: #bb9af7;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;

  /* Disclosure color palette */
  --disc-color-0: #e0af68;
  --disc-color-1: #9ece6a;
  --disc-color-2: #ff9e64;
  --disc-color-3: #7dcfff;
  --disc-color-4: #bb9af7;
  --disc-color-5: #f7768e;
  --disc-color-6: #7aa2f7;
  --disc-color-7: #c0caf5;
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --bg-surface: #ffffff;
  --bg-hover: #e8e8e8;
  --text: #343b58;
  --text-dim: #6b6f7b;
  --border: #d0d0d0;
  --accent: #2569d6;
  --cyan: #007197;
  --green: #587539;
  --yellow: #8c6c3e;
  --red: #c64343;
  --orange: #965027;
  --purple: #7847bd;

  --disc-color-0: #8c6c3e;
  --disc-color-1: #587539;
  --disc-color-2: #965027;
  --disc-color-3: #007197;
  --disc-color-4: #7847bd;
  --disc-color-5: #c64343;
  --disc-color-6: #2e7de9;
  --disc-color-7: #343b58;
}

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

/* Base link color: without this, links in unstyled containers fall back to
   the browser default dark blue, which is unreadable on the dark theme.
   Scoped rules below override where needed. */
a {
  color: var(--accent);
}

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

/* The mark is 46:51, so give it that ratio instead of a square box that
   would letterbox it and add phantom padding next to the title. */
.header-logo {
  width: 26px;
  height: 29px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

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

h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

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

.header-links {
  display: flex;
  gap: 20px;
  font-size: 11px;
}

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

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

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

.btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
}

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

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

.pane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

#demo-note {
  margin-left: auto;
  color: var(--yellow);
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.hidden {
  display: none;
}

.badge.sd-jwt {
  background: rgba(125, 207, 255, 0.15);
  color: var(--cyan);
}

.badge.jwt {
  background: rgba(158, 206, 106, 0.15);
  color: var(--green);
}

.badge.mdoc {
  background: rgba(187, 154, 247, 0.15);
  color: var(--purple);
}

/* Editor container: stacks textarea over colorized raw-view */
.input-editor {
  flex: 1;
  position: relative;
  overflow: hidden;
}

textarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: var(--bg);
  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;
}

/* When colorized view is active, make textarea text invisible but keep caret */
textarea.colorized {
  background: transparent;
  color: transparent;
  caret-color: var(--text);
}

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

textarea.colorized::placeholder {
  color: transparent;
}

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

.placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.error {
  color: var(--red);
  padding: 12px;
  background: rgba(247, 118, 142, 0.1);
  border-radius: 6px;
}

/* Sections */
.section {
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
  color: var(--cyan);
  font-weight: 600;
  font-size: 13px;
}

.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 rendering */
.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(--accent);
  text-decoration-color: currentColor;
}

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

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

.disclosure-value,
.claim-value {
  color: var(--green);
  /* A base64 image is one token thousands of characters long, and without
     this the line it sits on is as wide as the value. */
  overflow-wrap: anywhere;
}

.long-value {
  display: inline;
}

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

.long-value-toggle {
  appearance: none;
  background: none;
  border: none;
  color: var(--accent);
  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: 4px;
  border: 1px solid var(--border);
}

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

/* Validity banner */
.validity-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.validity-banner.valid {
  background: rgba(158, 206, 106, 0.12);
  color: var(--green);
}

.validity-banner.expiring {
  background: rgba(224, 175, 104, 0.12);
  color: var(--yellow);
}

.validity-banner.expired {
  background: rgba(247, 118, 142, 0.12);
  color: var(--red);
}

/* Checks that only the issuer can answer are still in flight */
.validity-banner.checking {
  background: var(--bg-surface);
  color: var(--text-dim);
}

.validity-banner.not-yet-valid {
  background: rgba(224, 175, 104, 0.12);
  color: var(--yellow);
}

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

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

/* Copy button on sections */
.section-header .copy-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  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 badges */
.issuer-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

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

.summary-chip-label {
  padding: 3px 8px;
  background: var(--bg-surface);
  color: var(--text-dim);
  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 truncation */
.digest-truncated {
  cursor: help;
  text-decoration: underline dotted var(--text-dim);
  text-underline-offset: 2px;
}

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

.resolved-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  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);
  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); }

/* Disclosure color palette — each disclosure gets a unique color */
.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); }

/* Hover cross-highlight */
.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: rgba(122, 162, 247, 0.15);
}

.section.highlight {
  background: rgba(122, 162, 247, 0.08);
  border-radius: 6px;
  margin-left: -8px;
  margin-right: -8px;
  padding-left: 8px;
  padding-right: 8px;
}

/* Disclosure item color indicators */
.disclosure-item[data-disc-index] {
  transition: background 0.1s;
}

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

/* Footer */
.shortcut-hint {
  font-size: 10px;
  color: var(--text-dim);
  padding: 4px 16px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.shortcut-hint .footer-disclaimer {
  margin-top: 2px;
  font-size: 10px;
  opacity: 0.85;
}

.shortcut-hint .footer-links {
  margin-top: 2px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

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

.shortcut-hint .footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Share toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* Validity banner — unverified state */
.validity-banner.unverified {
  background: rgba(224, 175, 104, 0.12);
  color: var(--yellow);
  cursor: pointer;
  position: relative;
}

/* Make all banners support popover */
.validity-banner {
  position: relative;
  cursor: pointer;
}

/* Validity checks popover */
.validity-banner .validity-checks {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  /* padding-top includes bridge area so hover doesn't break when moving to popover */
  margin-top: 0;
  padding-top: 12px;
  font-size: 12px;
  font-weight: 400;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Invisible bridge so mouse can travel from banner to popover without gap */
.validity-banner .validity-checks::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}

.validity-banner:hover .validity-checks,
.validity-banner.popover-pinned .validity-checks {
  display: block;
}

/* Inline verify form inside the popover */
.verify-inline-sep {
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

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

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

.verify-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  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(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

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

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

.validity-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: var(--text);
}

.check-icon {
  font-size: 13px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.check-pass .check-icon {
  color: var(--green);
}

.check-fail .check-icon {
  color: var(--red);
}

.check-skipped .check-icon {
  color: var(--text-dim);
}

.check-pending .check-icon {
  color: var(--cyan);
}

.check-name {
  font-weight: 600;
  min-width: 70px;
}

.check-detail {
  color: var(--text-dim);
}

/* Responsive */
@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);
    height: 35vh;
    min-height: 150px;
  }

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

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

  .output-content {
    overflow: visible;
  }

  /* Stack the header into left-aligned rows so nothing overflows and every
     row shares one left edge: brand, then links on their own full-width row,
     then the action buttons. */
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .header-left {
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
  }

  .header-links {
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
  }

  .header-right {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* Get the CLI modal (markup and classes shared with the wallet UI) */
.consent-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

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

.consent-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.consent-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

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

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

.cli-install-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 10px;
}

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

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

/* mdoc decoder: an explanation per section, and the salt/digest that make
   selective disclosure work shown next to each element. */
.format-note {
  font-size: 11px;
  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: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  cursor: help;
}
.mdoc-item-bad {
  color: var(--red);
}

/* A disclosure the credential never refers to discloses nothing. */
.disclosure-unreferenced {
  color: var(--red);
  font-weight: 600;
}
