/* Vault UI — adopts the StudioDome / BloodStream design system. Components are
 * styled against the --theme-* tokens defined per body.theme-<brand> (see
 * studiodome.css / bloodstream.css), mirroring studiodome-com's themed
 * component library. Neutral fallbacks below keep it usable with no theme class.
 * No external assets (strict CSP): Poppins is named with a system fallback. */
body {
  --theme-bg-primary: #0b1020;
  --theme-bg-secondary: #111b37;
  --theme-bg-tertiary: #17244b;
  --theme-accent-primary: #3b82f6;
  --theme-accent-secondary: #2563eb;
  --theme-accent-primary-rgb: 59, 130, 246;
  --theme-link-color: #93c5fd;
  --theme-surface: rgba(59, 130, 246, 0.14);
  --theme-surface-hover: rgba(59, 130, 246, 0.20);
  --theme-border: rgba(59, 130, 246, 0.35);
  --theme-border-hover: rgba(59, 130, 246, 0.50);
  --theme-card-bg: rgba(16, 31, 68, 0.96);
  --theme-text-primary: #f8fbff;
  --theme-text-muted: #9db2d9;
  --theme-page-bg: linear-gradient(145deg, #0b1020 0%, #101f44 55%, #17244b 100%);

  --ok: #22c55e;
  --err: #f87171;
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--theme-text-primary);
  background: var(--theme-page-bg);
  background-attachment: fixed;
}

/* ---- top bar ---- */
.topbar {
  padding: 16px 22px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--theme-border);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand-logo { height: 30px; display: block; }
.whoami { text-align: right; font-size: .8rem; line-height: 1.25; color: var(--theme-text-muted); }
.whoami-name { display: block; color: var(--theme-text-primary); font-weight: 500; }
.whoami-email { display: block; font-size: .75rem; }

.wrap { max-width: 640px; margin: 28px auto 60px; padding: 0 16px; }

/* ---- card (design-system surface) ---- */
.card {
  display: block;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 16px;
  padding: 26px 26px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 .35rem; }
h2 { font-size: 1.2rem; font-weight: 600; margin: 1rem 0 .5rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 1.4rem 0 .5rem; color: var(--theme-text-muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 1rem; }
.muted { color: var(--theme-text-muted); }
a { color: var(--theme-link-color); }

/* ---- form groups ---- */
.field { display: block; margin: 14px 0; }
.field > span { display: block; font-size: .82rem; font-weight: 500; color: var(--theme-text-muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--theme-border);
  border-radius: 10px;
  background: var(--theme-bg-secondary);
  color: var(--theme-text-primary);
  font-family: var(--font); font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--theme-text-muted); opacity: .7; }
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--theme-accent-primary);
  box-shadow: 0 0 0 3px rgba(var(--theme-accent-primary-rgb), 0.30);
}
.field select { appearance: none; -webkit-appearance: none; cursor: pointer; }

/* invalid state + inline messages */
.field.invalid input, .field.invalid select { border-color: var(--err); }
.field.invalid input:focus, .field.invalid select:focus { box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.30); }
.field-error { display: block; color: var(--err); font-size: .8rem; margin-top: 5px; }
.field-error::before { content: '⚠ '; }

/* ---- signature + attestation ---- */
.sig {
  border: 1px dashed var(--theme-border-hover); border-radius: 10px;
  background: rgba(0, 0, 0, 0.25); touch-action: none; display: block; margin: 6px 0; max-width: 100%;
}
.attest { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-size: .88rem; color: var(--theme-text-muted); }
.attest input { margin-top: 3px; }

/* ---- buttons ---- */
.btn {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--theme-border-hover);
  background: var(--theme-surface); color: var(--theme-text-primary);
  padding: 11px 18px; border-radius: 10px; cursor: pointer;
  font-family: var(--font); font-size: .95rem; font-weight: 500; letter-spacing: -0.01em;
  text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--theme-surface-hover); border-color: var(--theme-border-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--theme-accent-primary); border-color: var(--theme-accent-primary); color: #fff; }
.btn.primary:hover { background: var(--theme-accent-secondary); border-color: var(--theme-accent-secondary); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.disabled, .btn[disabled] { opacity: .5; pointer-events: none; cursor: default; }
form .btn.primary { margin-top: 12px; }

/* ---- callouts / notifications (design-system) ---- */
.callout {
  border: 1px solid var(--theme-border); border-left-width: 4px;
  border-radius: 10px; padding: 12px 14px; margin: 14px 0;
  background: var(--theme-surface); color: var(--theme-text-primary); font-size: .9rem;
}
.callout.error { border-color: var(--err); border-left-color: var(--err); background: rgba(248, 113, 113, 0.12); }
.callout.success { border-color: var(--ok); border-left-color: var(--ok); background: rgba(34, 197, 94, 0.12); }

/* ---- step wizard ---- */
.wiz-progress { height: 6px; border-radius: 4px; background: var(--theme-surface); overflow: hidden; margin: 8px 0 18px; }
.wiz-progress > span { display: block; height: 100%; background: var(--theme-accent-primary); border-radius: 4px; transition: width .3s; }
.wiz-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--theme-surface); border: 1px solid var(--theme-border);
  border-radius: 12px; padding: 14px 16px; margin: 10px 0;
}
.wiz-badge {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; color: #fff;
}
.wiz-badge.done { background: var(--ok); }
.wiz-badge.req { background: var(--theme-accent-primary); }
.wiz-badge.opt { background: transparent; border: 1px solid var(--theme-border-hover); color: var(--theme-text-muted); }
.wiz-label { flex: 1; }
.wiz-label small { display: block; color: var(--theme-text-muted); font-size: .78rem; }
.wiz-row .btn { margin-top: 0; }

/* ---- proof-of-work gate ---- */
.cap { margin: 12px 0 4px; font-size: .88rem; color: var(--theme-text-muted); }
.cap.ok { color: var(--ok); }
.cap.err { color: var(--err); }

/* ---- decrypt tool bits ---- */
.keyrow { display: flex; gap: 8px; margin: 14px 0; }
.keyrow input { flex: 1; padding: 11px 13px; border: 1px solid var(--theme-border); border-radius: 10px; background: var(--theme-bg-secondary); color: var(--theme-text-primary); }
table { width: 100%; border-collapse: collapse; margin: 14px 0; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--theme-border); font-size: .9rem; }
.kv td:first-child { color: var(--theme-text-muted); width: 38%; text-transform: capitalize; }
.sigimg { max-width: 320px; border: 1px solid var(--theme-border); border-radius: 8px; background: var(--theme-bg-secondary); }
@media print { .topbar, .keyrow, .doclist, .btn { display: none !important; } .viewer { margin: 0; } body { background: #fff; color: #000; } }
.wiz-group { margin: 20px 0 8px; font-size: .78rem; }
.wiz-group:first-of-type { margin-top: 8px; }

/* ---- back link ---- */
.backlink { display: inline-block; margin: 0 0 12px; font-size: .85rem; color: var(--theme-text-muted); text-decoration: none; }
.backlink:hover { color: var(--theme-text-primary); }

/* ---- warn callout ---- */
.callout.warn { border-color: #f59e0b; border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.12); }

/* ---- searchable select (type-to-filter combobox) ---- */
.ss { position: relative; }
.ss-input { width: 100%; padding: 11px 13px; border: 1px solid var(--theme-border); border-radius: 10px; background: var(--theme-bg-secondary); color: var(--theme-text-primary); font-family: var(--font); font-size: 1rem; }
.ss-input:focus { outline: none; border-color: var(--theme-accent-primary); box-shadow: 0 0 0 3px rgba(var(--theme-accent-primary-rgb), 0.30); }
.field.invalid .ss-input { border-color: var(--err); }
.ss-list { display: none; position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto; background: var(--theme-bg-tertiary); border: 1px solid var(--theme-border-hover); border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,0.45); }
.ss-list.open { display: block; }
.ss-item { padding: 9px 13px; cursor: pointer; font-size: .95rem; }
.ss-item:hover, .ss-item.active { background: var(--theme-surface-hover); }
/* whoami sign-out + how-to lists */
.whoami-signout { display: inline-block; margin-top: 4px; font-size: .75rem; color: var(--theme-link-color); text-decoration: none; }
.whoami-signout:hover { text-decoration: underline; }
.howto { margin: 8px 0 0; padding-left: 18px; }
.howto li { margin: 3px 0; font-size: .88rem; }

/* ---- wide layout (decrypt tool: data tables) + responsiveness ---- */
.wrap.wide { max-width: 1080px; }
.doclist th, .doclist td { white-space: nowrap; }
@media (max-width: 720px) {
  .wrap, .wrap.wide { padding: 0 10px; margin-top: 18px; }
  .card { padding: 18px 14px; overflow-x: auto; }   /* let wide tables scroll */
  .topbar { padding: 12px 14px; }
  h1 { font-size: 1.3rem; }
  .keyrow { flex-wrap: wrap; }
  .keyrow input, .keyrow .btn { flex: 1 1 100%; }
  table { font-size: .82rem; }
  th, td { padding: 7px 8px; }
  .wiz-row { flex-wrap: wrap; }
  .wiz-row .btn { margin-left: auto; }
}
