:root {
  color-scheme: dark;
  --bg: #0f1117;
  --panel: #171a22;
  --text: #e8eaef;
  --muted: #9aa3b2;
  --ok: #3dd68c;
  --fail: #ff6b6b;
  --pending: #f0c14b;
  --timeout: #8b949e;
  --accent: #6ea8fe;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.banner-demo,
.banner-fail,
.banner-conn {
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
}

.banner-demo {
  background: #2a2410;
  border-bottom: 1px solid #4a4020;
}

.banner-fail {
  background: #3a1515;
  color: #ffd6d6;
}

.banner-conn {
  background: #15253a;
  color: #cfe4ff;
}

.hidden {
  display: none !important;
}

.shell {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  grid-template-areas:
    'hint'
    'controls'
    'media'
    'verdicts';
}

.shell-hint {
  grid-area: hint;
  margin: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: rgba(110, 168, 254, 0.08);
  border: 1px solid rgba(110, 168, 254, 0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hint-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
  outline: none;
}

.hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid rgba(110, 168, 254, 0.35);
  border-radius: 50%;
}

.hint-tooltip {
  position: absolute;
  left: 50%;
  top: calc(100% + 0.45rem);
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.55rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text);
  background: #1a1f2a;
  border: 1px solid #3d4658;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.hint-trigger:hover .hint-tooltip,
.hint-trigger:focus .hint-tooltip,
.hint-trigger:focus-within .hint-tooltip {
  opacity: 1;
  visibility: visible;
}

.controls {
  grid-area: controls;
}

.media {
  grid-area: media;
  display: flex;
  flex-direction: column;
}

.verdicts {
  grid-area: verdicts;
}

@media (min-width: 960px) {
  .shell {
    grid-template-columns: minmax(260px, 320px) 1fr;
    grid-template-areas:
      'hint hint'
      'controls media'
      'verdicts verdicts';
  }
}

.panel {
  background: var(--panel);
  border: 1px solid #2a2f3a;
  border-radius: 8px;
  padding: 1rem;
}

.form-grid {
  display: grid;
  gap: 0.75rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.advanced-settings {
  margin: 0;
}

.advanced-settings summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--accent);
  user-select: none;
  list-style: none;
}

.advanced-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-settings summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.35rem;
  transition: transform 0.15s ease;
}

.advanced-settings[open] summary::before {
  transform: rotate(90deg);
}

.advanced-fields {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid #2a2f3a;
}

label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
}

input {
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #3a4150;
  background: #0c0e13;
  color: var(--text);
}

button {
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  border: 1px solid #3a4150;
  background: #222833;
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#connect-btn {
  background: #1e3a5f;
  border-color: var(--accent);
}

.conn-status {
  margin: 0.75rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.base-manifest-open {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.88rem;
  color: var(--accent);
  background: rgba(110, 168, 254, 0.1);
  border: 1px solid rgba(110, 168, 254, 0.35);
  border-radius: 6px;
  cursor: pointer;
}

.base-manifest-open:hover {
  background: rgba(110, 168, 254, 0.18);
}

.base-manifest-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.base-manifest-modal.hidden {
  display: none !important;
}

body.base-manifest-modal-open {
  overflow: hidden;
}

.base-manifest-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.base-manifest-dialog {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  padding: 1rem 1.15rem;
  background: var(--panel);
  border: 1px solid #3a4558;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.base-manifest-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.base-manifest-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.base-manifest-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid #3a4558;
  border-radius: 6px;
  cursor: pointer;
}

.base-manifest-close:hover {
  color: var(--text);
  border-color: var(--accent);
}

.base-manifest-hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.base-manifest-meta {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
}

.base-manifest-meta dt {
  color: var(--muted);
  margin: 0;
}

.base-manifest-meta dd {
  margin: 0;
  word-break: break-all;
}

.base-manifest-error {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--fail);
}

.base-manifest-json {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.65rem;
  font-size: 0.72rem;
  line-height: 1.35;
  background: #0c0e14;
  border: 1px solid #2a2f3a;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

video {
  width: 100%;
  max-height: 420px;
  background: #000;
  border-radius: 6px;
}

.latest-chip {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.media .timeline-block {
  margin-top: 0.75rem;
}

.verdict-row {
  border: 1px solid #2a2f3a;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
}

.verdict-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.row-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.2rem;
  word-break: break-all;
}

.attestation-details {
  margin-top: 0.45rem;
  font-size: 0.78rem;
}

.attestation-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  user-select: none;
}

.attestation-details summary:hover {
  text-decoration: underline;
}

.attestation-json {
  margin: 0.35rem 0 0;
  padding: 0.5rem 0.55rem;
  max-height: 220px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0c0e13;
  border: 1px solid #2a2f3a;
  border-radius: 4px;
  color: #c5cad3;
}

.verdict-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-height: 480px;
  overflow: auto;
}

.verdict-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: lowercase;
  margin-right: 0.5rem;
}

.vb-ok {
  background: rgba(61, 214, 140, 0.15);
  color: var(--ok);
}

.vb-fail {
  background: rgba(255, 107, 107, 0.15);
  color: var(--fail);
}

.vb-pending {
  background: rgba(240, 193, 75, 0.15);
  color: var(--pending);
}

.vb-timeout {
  background: rgba(139, 148, 158, 0.15);
  color: var(--timeout);
}

.empty-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.verdict-hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 0.75rem;
}

/* Collapsible verdicts panel */
.verdicts-panel {
  margin: 0;
}

.verdicts-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 0.15rem 0;
  margin-bottom: 0.75rem;
}

.verdicts-summary::-webkit-details-marker {
  display: none;
}

.verdicts-summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.45rem;
  color: var(--accent);
  transition: transform 0.15s ease;
}

.verdicts-panel[open] .verdicts-summary::before {
  transform: rotate(90deg);
}

.verdicts-summary-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.verdict-count {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Attestation timeline — always visible above collapsible list */
.timeline-block {
  padding: 0.65rem 0.75rem;
  background: #0c0e13;
  border: 1px solid #2a2f3a;
  border-radius: 6px;
}

.timeline-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.timeline-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.timeline-time-range {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.attest-timeline {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 8px;
  min-height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(139, 148, 158, 0.65);
}

.attest-timeline:empty {
  display: none;
}

.timeline-empty {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.attest-timeline:not(:empty) + .timeline-empty {
  display: none;
}

.timeline-empty.hidden {
  display: none !important;
}

.tl-seg {
  flex: 0 0 auto;
  min-width: 1px;
  height: 100%;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: filter 0.1s ease, box-shadow 0.1s ease;
}

.tl-seg:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.tl-seg:last-of-type {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.tl-seg:hover,
.tl-seg.tl-hover {
  filter: brightness(1.15);
  z-index: 2;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.tl-seg.tl-trusted,
.tl-seg.tl-ok {
  background: var(--ok);
}

.tl-seg.tl-untrusted,
.tl-seg.tl-fail,
.tl-seg.tl-timeout {
  background: var(--fail);
}

.tl-seg.tl-unknown,
.tl-seg.tl-pending {
  background: rgba(139, 148, 158, 0.65);
}

/* Floating attestation tooltip */
.timeline-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 24px));
  padding: 0.55rem 0.65rem;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text);
  background: #1a1f2a;
  border: 1px solid #3d4658;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.timeline-tooltip .tt-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.timeline-tooltip .tt-row {
  color: var(--muted);
  margin: 0.15rem 0;
  word-break: break-all;
}

.timeline-tooltip .tt-verdict-fail {
  color: var(--fail);
}

.timeline-tooltip .tt-verdict-ok {
  color: var(--ok);
}
