/* LegacyVault MVP GUI — styles
   Design language: dark theme, #89b4fa primary, Segoe UI, rounded + minimal.
   Palette (Catppuccin Mocha, WCAG-friendly on #1e1e2e). */

:root {
  --bg: #1e1e2e;
  --bg-mantle: #181825;
  --bg-surface: #313244;
  --bg-surface-hi: #45475a;
  --text: #cdd6f4;
  --text-sub: #a6adc8;
  --text-faint: #7f849c;
  --blue: #89b4fa;
  --blue-ink: #11131f;
  --green: #a6e3a1;
  --green-ink: #0f1a12;
  --yellow: #f9e2af;
  --yellow-ink: #221d08;
  --red: #f38ba8;
  --red-ink: #2a0d15;
  --teal: #94e2d5;
  --mauve: #cba6f7;
  --peach: #fab387;
  --border: rgba(205, 214, 244, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(137, 180, 250, 0.35); }

h1, h2, h3, h4 { margin: 0 0 0.4em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.8em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-surface); padding: 1px 5px; border-radius: 5px; }

/* ---------- layout ---------- */

.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: rgba(24, 24, 37, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--mauve));
  display: grid; place-items: center; color: var(--blue-ink); font-weight: 800; font-size: 0.85rem;
  box-shadow: 0 0 18px rgba(137, 180, 250, 0.45);
}

.header-nav { display: flex; gap: 6px; margin-left: auto; }
.nav-link {
  border: 0; cursor: pointer; font: inherit; color: var(--text-sub);
  background: transparent; padding: 8px 14px; border-radius: 999px;
}
.nav-link:hover { color: var(--text); background: var(--bg-surface); }
.nav-link.active { color: var(--blue); background: rgba(137, 180, 250, 0.14); }

.mode-badge {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.mode-badge.server { color: var(--green); background: rgba(166, 227, 161, 0.12); border: 1px solid rgba(166, 227, 161, 0.35); }
.mode-badge.sim { color: var(--yellow); background: rgba(249, 226, 175, 0.1); border: 1px solid rgba(249, 226, 175, 0.35); }

/* Demo-only responsive fix: the header's three items (brand, mode badge, nav) hold a
   min content width of ~421px, so at a 320-390px phone width the page scrolled
   sideways. Letting the nav drop to its own line is the smallest change that removes
   the horizontal overflow without altering the product's look at desktop widths. */
@media (max-width: 640px) {
  .app-header { flex-wrap: wrap; row-gap: 8px; padding: 10px 14px; }
  .header-nav { width: 100%; margin-left: 0; }
  .nav-link { flex: 1 1 auto; padding: 10px 14px; }
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 80px; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* ---------- cards ---------- */

.card {
  background: var(--bg-mantle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-title { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 12px; }
.card-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }

.muted { color: var(--text-faint); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); word-break: break-all; }

/* ---------- forms ---------- */

label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-sub); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(137, 180, 250, 0.18); }
textarea { resize: vertical; min-height: 110px; font-family: var(--mono); font-size: 0.9rem; }
.hint { font-size: 0.8rem; color: var(--text-faint); margin-top: 6px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; cursor: pointer; user-select: none;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; background: var(--bg-surface-hi); color: var(--text);
  transition: filter 0.12s ease, transform 0.06s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary { background: var(--blue); color: var(--blue-ink); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-sub); }
.btn.ghost:hover { color: var(--text); background: var(--bg-surface); }
.btn.danger { background: rgba(243, 139, 168, 0.14); color: var(--red); border-color: rgba(243, 139, 168, 0.3); }
.btn.success { background: var(--green); color: var(--green-ink); }
.btn.small { padding: 6px 10px; font-size: 0.82rem; border-radius: 7px; }
.btn.block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600;
  padding: 4px 11px; border-radius: 999px; background: var(--bg-surface);
  border: 1px solid transparent; cursor: pointer; color: var(--text-sub); font-family: var(--font);
}
.chip.active { background: rgba(137, 180, 250, 0.18); color: var(--blue); border-color: rgba(137, 180, 250, 0.4); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.type-tag { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.type-password { background: rgba(137, 180, 250, 0.15); color: var(--blue); }
.type-document { background: rgba(203, 166, 247, 0.15); color: var(--mauve); }
.type-crypto { background: rgba(148, 226, 213, 0.15); color: var(--teal); }
.type-note { background: rgba(250, 179, 135, 0.15); color: var(--peach); }

/* ---------- secret list ---------- */

.secret-list { display: flex; flex-direction: column; gap: 10px; }
.secret-row {
  display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 15px;
}
.secret-row .grow { flex: 1 1 220px; min-width: 0; }
.secret-row .title { font-weight: 650; font-size: 1rem; }
.secret-row .meta { font-size: 0.8rem; color: var(--text-faint); margin-top: 3px; }
.recipient-mini {
  font-size: 0.75rem; background: rgba(148, 226, 213, 0.12); color: var(--teal);
  padding: 2px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
}
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- shard health ---------- */

.shard-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.shard-row:last-child { border-bottom: 0; }
.shard-role { font-size: 0.78rem; font-weight: 700; color: var(--text-sub); width: 66px; }
.shard-name { flex: 1; }
.shard-state { font-size: 0.85rem; font-weight: 700; }
.shard-state.ok { color: var(--green); }
.shard-state.warn { color: var(--yellow); }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 8px rgba(166, 227, 161, 0.5); }
.dot.warn { background: var(--yellow); }
.dot.bad { background: var(--red); }

/* ---------- status / ladder ---------- */

.banner {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.9rem;
  display: flex; gap: 10px; align-items: flex-start;
}
.banner.info { background: rgba(137, 180, 250, 0.12); color: var(--blue); border: 1px solid rgba(137, 180, 250, 0.3); }
.banner.ok { background: rgba(166, 227, 161, 0.1); color: var(--green); border: 1px solid rgba(166, 227, 161, 0.3); }
.banner.warn { background: rgba(249, 226, 175, 0.1); color: var(--yellow); border: 1px solid rgba(249, 226, 175, 0.3); }
.banner.danger { background: rgba(243, 139, 168, 0.1); color: var(--red); border: 1px solid rgba(243, 139, 168, 0.3); }

.progress { height: 10px; border-radius: 999px; background: var(--bg-surface); overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); transition: width 0.4s ease; }
.progress-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-faint); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 0.9rem; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-weight: 600; }

/* ---------- hero / setup ---------- */

.hero { text-align: center; padding: 26px 0 8px; }
.hero .kicker { color: var(--blue); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.75rem; font-weight: 700; }
.hero h1 { font-size: 2.1rem; margin-top: 6px; }
.hero p.lead { color: var(--text-sub); max-width: 620px; margin: 10px auto 0; }

.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0; }
@media (max-width: 720px) { .pillars { grid-template-columns: 1fr; } }
.pillar { background: var(--bg-mantle); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.pillar .icon { font-size: 1.4rem; }
.pillar b { display: block; margin: 6px 0 4px; }

details.how { background: var(--bg-mantle); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; }
details.how summary { cursor: pointer; font-weight: 650; }
details.how .body { margin-top: 12px; font-size: 0.92rem; color: var(--text-sub); }

/* ---------- page visibility ---------- */

.page { display: none; }
.page.active { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 10, 15, 0.7);
  display: grid; place-items: center; z-index: 50; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  background: var(--bg-mantle); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 22px;
}
.modal h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ---------- toasts ---------- */

.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast {
  background: var(--bg-surface); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.9rem; box-shadow: var(--shadow);
  animation: slidein 0.2s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }
@keyframes slidein { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ---------- events / logs ---------- */

.event-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.event-list li {
  font-size: 0.87rem; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--bg-surface); border: 1px solid var(--border);
}
.event-list li .when { color: var(--text-faint); font-size: 0.78rem; }
.tag { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; margin-right: 8px; }
.tag.release { background: rgba(243, 139, 168, 0.18); color: var(--red); }
.tag.reminder { background: rgba(249, 226, 175, 0.16); color: var(--yellow); }
.tag.sent { background: rgba(148, 226, 213, 0.14); color: var(--teal); }
.tag.opened { background: rgba(137, 180, 250, 0.16); color: var(--blue); }
.tag.completed { background: rgba(166, 227, 161, 0.16); color: var(--green); }

/* ---------- recover ---------- */

.steps { display: flex; gap: 8px; margin: 0 0 20px; flex-wrap: wrap; }
.step-pill {
  font-size: 0.78rem; font-weight: 700; padding: 6px 12px; border-radius: 999px;
  background: var(--bg-surface); color: var(--text-faint);
}
.step-pill.done { background: rgba(166, 227, 161, 0.14); color: var(--green); }
.step-pill.now { background: rgba(137, 180, 250, 0.2); color: var(--blue); box-shadow: 0 0 0 2px rgba(137, 180, 250, 0.25); }

.secret-reveal { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); padding: 13px; margin-top: 10px; }
.reveal-box {
  font-family: var(--mono); font-size: 0.88rem; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 12px; margin: 8px 0; max-height: 260px; overflow: auto;
}

/* ---------- print (Shard C paper card) ---------- */

#print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { display: block; position: absolute; inset: 0; padding: 24px; }
  .no-print { display: none !important; }
}

/* ---------- misc ---------- */

.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.empty-state { text-align: center; color: var(--text-faint); padding: 26px 12px; }
.empty-state .big { font-size: 1.9rem; margin-bottom: 6px; }

.password-meter { height: 6px; border-radius: 999px; background: var(--bg-surface); margin-top: 8px; overflow: hidden; }
.password-meter > div { height: 100%; width: 0; transition: width 0.25s ease, background 0.25s ease; }

/* ---------- demo-only: utilities that replaced inline style="…" ----------
   The published CSP is `style-src 'self'` with no 'unsafe-inline', so the
   browser REFUSES an inline style attribute. Every declaration the product's
   markup carried inline now lives here as a class, one for one. */

.mb-14 { margin-bottom: 14px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }
.card--narrow { max-width: 520px; margin: 30px auto; }
.label-plain { text-transform: none; letter-spacing: 0; }
.field--flush { margin: 0; flex: 1; min-width: 240px; }
.field--flush-2 { margin: 0; flex: 1; }
.hero--tight { padding-bottom: 4px; }
.file-label { cursor: pointer; }
.self-end { align-self: end; }
.dot--red { background: var(--red); }
.dot--mauve { background: var(--mauve); }
.dot--teal { background: var(--teal); }
#mailbox-card[hidden] { display: none; }
