/* ============================================================================
   Orion Vault — dashboard styles
   ----------------------------------------------------------------------------
   Design direction: precision instrument panel. This is a tool that businesses
   trust with their credentials, so it borrows from measuring equipment and Swiss
   technical documentation rather than consumer app conventions — hairline rules,
   a tight monospaced grid, small-caps machine labels, numeric readouts, and one
   high-visibility signal colour against ink.

   Typography note: a strict CSP forbids external font hosts, and shipping a
   webfont would add weight for no functional gain, so the type system commits to
   monospace as the *primary* face. That is a deliberate choice, not a fallback —
   secrets, fingerprints, codes and counts all read better in tabular figures.
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", "Cascadia Mono", "JetBrains Mono",
    "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-text: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
    "Segoe UI", Ubuntu, "Helvetica Neue", sans-serif;

  --step--2: 0.688rem;
  --step--1: 0.781rem;
  --step-0: 0.875rem;
  --step-1: 1.0625rem;
  --step-2: 1.375rem;
  --step-3: 1.875rem;
  --step-4: 2.5rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  /* Sharp, small radii: this is instrumentation, not a bubble. */
  --radius: 3px;
  --radius-lg: 5px;
  --hair: 1px;

  --rail-width: 15rem;
  --shell-max: 78rem;

  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Signal: high-visibility instrument lime. Used sparingly and always to mean
     "this is the live / verified / actionable thing". */
  --signal: #d9f24a;
  --signal-ink: #16190a;
}

:root,
[data-theme="dark"] {
  --bg: #0b0d0e;
  --bg-deep: #070809;
  --panel: #121618;
  --panel-2: #171c1f;
  --raised: #1d2327;
  --line: #242b30;
  --line-strong: #333c42;
  --text: #e7ebec;
  --text-dim: #949ea4;
  --text-faint: #626c72;
  --ok: #6ee7a8;
  --warn: #f5b544;
  --danger: #ff7a6b;
  --info: #7cc4ff;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 32px -12px rgba(0, 0, 0, 0.8);
  --grain-opacity: 0.035;
  --signal-on-surface: var(--signal);
}

[data-theme="light"] {
  --bg: #f2f0ea;
  --bg-deep: #e8e5dc;
  --panel: #fbfaf7;
  --panel-2: #f6f4ef;
  --raised: #ffffff;
  --line: #ddd8cc;
  --line-strong: #c3bcab;
  --text: #14181a;
  --text-dim: #57605f;
  --text-faint: #7d857f;
  --ok: #1a7f4b;
  --warn: #9a6100;
  --danger: #b4291a;
  --info: #1b5f96;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 26px -14px rgba(24, 22, 16, 0.4);
  --grain-opacity: 0.05;
  /* The lime is too light to read on paper, so the light theme darkens it while
     keeping the same hue family. */
  --signal-on-surface: #566d00;
  --signal-ink: #ffffff;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
  }
}

/* ── Reset ──────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
}

/* The `hidden` attribute must always win.
 *
 * The UA stylesheet's `[hidden] { display: none }` loses to any author rule that
 * sets `display`, so a component with `display: grid` silently re-shows itself
 * while still marked hidden. For a full-screen modal backdrop that means an
 * invisible layer covering the page and swallowing every click — the form looks
 * dimmed and nothing responds. `!important` is warranted: this is precisely the
 * case where the attribute should beat every component rule. */
[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--step-0);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

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

a {
  color: var(--signal-on-surface);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--signal-on-surface);
  outline-offset: 2px;
}

::selection {
  background: var(--signal);
  color: var(--signal-ink);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Film grain: gives flat ink surfaces a tactile, equipment-panel quality. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--signal);
  color: var(--signal-ink);
  border-radius: var(--radius);
  transition: top 160ms var(--ease);
}

.skip-link:focus {
  top: var(--space-4);
}

.noscript {
  max-width: 34rem;
  margin: 12vh auto;
  padding: var(--space-6);
  border: var(--hair) solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

/* ── Typography primitives ──────────────────────────────────────────────── */

/* The machine label: small caps, wide tracking. Used for every field label,
   section heading and status readout, which is what unifies the interface. */
.label,
.eyebrow {
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  font-weight: 500;
}

.eyebrow {
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.eyebrow::after {
  content: "";
  flex: 1;
  height: var(--hair);
  background: var(--line);
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

h1 {
  font-size: var(--step-3);
}
h2 {
  font-size: var(--step-2);
}
h3 {
  font-size: var(--step-1);
}

.prose {
  font-family: var(--font-text);
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 62ch;
}

.mono {
  font-family: var(--font-mono);
}

.dim {
  color: var(--text-dim);
}
.faint {
  color: var(--text-faint);
}
.nowrap {
  white-space: nowrap;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Shell ──────────────────────────────────────────────────────────────── */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Status strip: a hairline across the very top of the product reporting the
   workspace's security posture. Borrowed straight from instrument panels — you
   should be able to tell at a glance whether anything needs attention. */
.status-strip {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-5);
  background: var(--bg-deep);
  border-bottom: var(--hair) solid var(--line);
  font-size: var(--step--2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.status-strip__pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 22%, transparent);
  flex: none;
}

.status-strip[data-level="warn"] .status-strip__pip {
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--warn) 22%, transparent);
}

.status-strip[data-level="danger"] .status-strip__pip {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger) 22%, transparent);
  animation: pulse 2.4s var(--ease) infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--danger) 22%, transparent);
  }
  50% {
    box-shadow: 0 0 0 6px color-mix(in oklab, var(--danger) 8%, transparent);
  }
}

.status-strip__spacer {
  flex: 1;
}

.status-strip__readout {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-strip__readout b {
  color: var(--text-dim);
  font-weight: 500;
}

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  align-items: start;
  max-width: var(--shell-max);
  width: 100%;
  margin-inline: auto;
}

@media (max-width: 60rem) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Rail ───────────────────────────────────────────────────────────────── */

.rail {
  position: sticky;
  top: 2.25rem;
  padding: var(--space-5) var(--space-4) var(--space-6);
  border-right: var(--hair) solid var(--line);
  min-height: calc(100dvh - 2.25rem);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

@media (max-width: 60rem) {
  .rail {
    position: static;
    min-height: 0;
    border-right: 0;
    border-bottom: var(--hair) solid var(--line);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text);
}

.brand__mark {
  width: 26px;
  height: 26px;
  flex: none;
}

/* The name and the workspace slug are two lines, not one run of text. */
.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand__name {
  font-size: var(--step-0);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand__workspace {
  font-size: var(--step--2);
  color: var(--text-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  font-size: var(--step--1);
  letter-spacing: 0.03em;
  border: var(--hair) solid transparent;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}

.nav__item:hover {
  background: var(--panel);
  color: var(--text);
}

.nav__item[aria-current="page"] {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

/* The active marker is a bracket, not a pill — keeps the technical register. */
.nav__item[aria-current="page"]::before {
  content: "";
  width: 2px;
  height: 1em;
  background: var(--signal-on-surface);
  margin-right: calc(var(--space-1) * -1);
}

.nav__count {
  margin-left: auto;
  font-size: var(--step--2);
  color: var(--text-faint);
}

.rail__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rail__foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Vault chips in the rail */
.vault-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.vault-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  border: var(--hair) solid transparent;
  color: var(--text-dim);
  font-size: var(--step--1);
  text-align: left;
  transition: background 140ms var(--ease);
}

.vault-chip:hover {
  background: var(--panel);
  color: var(--text);
}

.vault-chip[aria-pressed="true"] {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.vault-chip__dot {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--line-strong);
  flex: none;
  transform: rotate(45deg);
}

.vault-chip[data-kind="personal"] .vault-chip__dot {
  background: var(--signal-on-surface);
}

.vault-chip[data-unavailable="true"] {
  opacity: 0.55;
}

.vault-chip[data-unavailable="true"] .vault-chip__dot {
  background: var(--warn);
}

.vault-chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vault-chip__count {
  margin-left: auto;
  font-size: var(--step--2);
  color: var(--text-faint);
}

/* ── Main ───────────────────────────────────────────────────────────────── */

.main {
  padding: var(--space-6) var(--space-6) var(--space-8);
  min-width: 0;
}

@media (max-width: 40rem) {
  .main {
    padding: var(--space-5) var(--space-4) var(--space-7);
  }
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  animation: view-in 320ms var(--ease-out) both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Staggered reveal on the first load of a list — one orchestrated moment
   rather than motion sprinkled everywhere. */
.stagger > * {
  animation: rise 420ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.view-head__titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.view-head__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ── Panels ─────────────────────────────────────────────────────────────── */

.panel {
  border: var(--hair) solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hair) solid var(--line);
  background: var(--panel-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.panel__head h2,
.panel__head h3 {
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
  color: var(--text-dim);
}

.panel__head-actions {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
}

.panel__body {
  padding: var(--space-4);
}

.panel__body--flush {
  padding: 0;
}

.panel--danger {
  border-color: color-mix(in oklab, var(--danger) 40%, var(--line));
}

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.row--between {
  justify-content: space-between;
}

.row--wrap {
  flex-wrap: wrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stack--tight {
  gap: var(--space-2);
}

.stack--loose {
  gap: var(--space-5);
}

/* ── Metrics ────────────────────────────────────────────────────────────── */

.metric {
  padding: var(--space-4);
  border: var(--hair) solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}

/* Corner tick: a tiny detail that makes each tile read as a gauge. */
.metric::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-left: var(--hair) solid var(--line);
  border-bottom: var(--hair) solid var(--line);
}

.metric__value {
  font-size: var(--step-3);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.metric__value small {
  font-size: var(--step-0);
  color: var(--text-faint);
  font-weight: 400;
  letter-spacing: 0;
}

.metric[data-tone="warn"] .metric__value {
  color: var(--warn);
}
.metric[data-tone="danger"] .metric__value {
  color: var(--danger);
}
.metric[data-tone="ok"] .metric__value {
  color: var(--ok);
}

/* ── Segmented meter (password strength, vault health) ──────────────────── */

.meter {
  display: flex;
  gap: 3px;
  height: 6px;
}

.meter__seg {
  flex: 1;
  border-radius: 1px;
  background: var(--line);
  transition: background 220ms var(--ease);
}

.meter[data-score="0"] .meter__seg:nth-child(-n + 1),
.meter[data-score="1"] .meter__seg:nth-child(-n + 1) {
  background: var(--danger);
}
.meter[data-score="2"] .meter__seg:nth-child(-n + 2) {
  background: var(--warn);
}
.meter[data-score="3"] .meter__seg:nth-child(-n + 3) {
  background: var(--ok);
}
.meter[data-score="4"] .meter__seg {
  background: var(--ok);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius);
  border: var(--hair) solid var(--line-strong);
  background: var(--raised);
  color: var(--text);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: transform 100ms var(--ease), border-color 140ms var(--ease),
    background 140ms var(--ease);
}

.btn:hover:not(:disabled) {
  border-color: var(--text-faint);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--signal-ink);
  font-weight: 600;
}

[data-theme="light"] .btn--primary {
  background: var(--signal-on-surface);
  border-color: var(--signal-on-surface);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.08);
  border-color: var(--signal);
}

.btn--ghost {
  background: none;
  border-color: transparent;
  color: var(--text-dim);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--line);
}

.btn--danger {
  border-color: color-mix(in oklab, var(--danger) 55%, var(--line));
  color: var(--danger);
  background: color-mix(in oklab, var(--danger) 8%, transparent);
}

.btn--danger:hover:not(:disabled) {
  background: color-mix(in oklab, var(--danger) 16%, transparent);
}

.btn--sm {
  padding: 0.3rem 0.55rem;
  font-size: var(--step--2);
}

.btn--block {
  width: 100%;
}

.btn--icon {
  padding: 0.4rem;
  aspect-ratio: 1;
}

.btn[data-busy="true"] {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.btn[data-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--text);
  animation: spin 700ms linear infinite;
}

.btn--primary[data-busy="true"]::after {
  color: var(--signal-ink);
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

/* ── Fields ─────────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__hint {
  font-size: var(--step--2);
  color: var(--text-faint);
  font-family: var(--font-text);
  line-height: 1.45;
}

.field__error {
  font-size: var(--step--2);
  color: var(--danger);
  font-family: var(--font-text);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius);
  border: var(--hair) solid var(--line-strong);
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--step-0);
  transition: border-color 140ms var(--ease), background 140ms var(--ease);
}

[data-theme="light"] .input,
[data-theme="light"] .select,
[data-theme="light"] .textarea {
  background: var(--raised);
}

.input:hover,
.textarea:hover {
  border-color: var(--text-faint);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--signal-on-surface);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 18%, transparent);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.textarea {
  min-height: 6rem;
  resize: vertical;
  line-height: 1.55;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.input-group {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

.input-group .input {
  flex: 1;
  min-width: 0;
}

.checkbox {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  cursor: pointer;
  font-family: var(--font-text);
  font-size: var(--step--1);
  line-height: 1.45;
}

.checkbox input {
  margin-top: 0.15em;
  accent-color: var(--signal-on-surface);
  width: 1rem;
  height: 1rem;
  flex: none;
}

/* ── Tables and lists ───────────────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.table th {
  text-align: left;
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  font-weight: 500;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hair) solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hair) solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--panel-2);
}

.table__actions {
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
}

.table-scroll {
  overflow-x: auto;
}

/* Item rows */
.items {
  display: flex;
  flex-direction: column;
}

/* The list split by credential type (P&T #459): one titled section per type. */
.item-section + .item-section {
  border-top: var(--hair) solid var(--line);
}

.item-section__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-2);
  border-bottom: var(--hair) solid var(--line);
  background: var(--panel-2);
}

.item-section__title {
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 500;
  color: var(--text-dim);
}

.item-section__count {
  font-size: var(--step--2);
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.item-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hair) solid var(--line);
  text-align: left;
  color: var(--text);
  transition: background 120ms var(--ease);
}

.item-row:last-child {
  border-bottom: 0;
}

.item-row:hover,
.item-row[aria-selected="true"] {
  background: var(--panel-2);
}

.item-row__glyph {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius);
  border: var(--hair) solid var(--line);
  background: var(--bg-deep);
  display: grid;
  place-items: center;
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--text-dim);
  flex: none;
}

.item-row__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.item-row__name {
  font-size: var(--step-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-row__sub {
  font-size: var(--step--2);
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-row__flags {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

/* ── Badges and tags ────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  border: var(--hair) solid var(--line-strong);
  font-size: var(--step--2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

/* A badge must hug its text. As a child of a `.stack` (flex column) it would
   otherwise stretch to the full column width and read as a filled bar. */
.stack > .badge {
  align-self: flex-start;
}

.badge--signal {
  border-color: var(--signal-on-surface);
  color: var(--signal-on-surface);
}
.badge--ok {
  border-color: color-mix(in oklab, var(--ok) 55%, var(--line));
  color: var(--ok);
}
.badge--warn {
  border-color: color-mix(in oklab, var(--warn) 55%, var(--line));
  color: var(--warn);
}
.badge--danger {
  border-color: color-mix(in oklab, var(--danger) 55%, var(--line));
  color: var(--danger);
}

/* ── Notices ────────────────────────────────────────────────────────────── */

.notice {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: var(--hair) solid var(--line);
  border-left-width: 2px;
  background: var(--panel-2);
  font-family: var(--font-text);
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--text-dim);
}

.notice strong {
  color: var(--text);
  font-weight: 600;
}

.notice--info {
  border-left-color: var(--info);
}
.notice--warn {
  border-left-color: var(--warn);
}
.notice--danger {
  border-left-color: var(--danger);
}
.notice--ok {
  border-left-color: var(--ok);
}
.notice--signal {
  border-left-color: var(--signal-on-surface);
}

.notice__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ── Secret display ─────────────────────────────────────────────────────── */

.secret {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  border: var(--hair) solid var(--line-strong);
  background: var(--bg-deep);
  font-family: var(--font-mono);
  min-width: 0;
}

[data-theme="light"] .secret {
  background: var(--raised);
}

.secret__value {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  letter-spacing: 0.02em;
}

.secret__value::-webkit-scrollbar {
  display: none;
}

.secret__value[data-hidden="true"] {
  letter-spacing: 0.18em;
  color: var(--text-faint);
}

/* A public key is not a secret and is long: show it whole, broken anywhere. */
.secret__value--wrap {
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: visible;
}

/* ── Credential types (Coordination #117) ───────────────────────────────── */

/* The type picker on a new credential: one row of equal options, two by two on a phone. */
.type-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
}

@media (max-width: 480px) {
  .type-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.type-picker__option {
  padding: 0.55rem var(--space-2);
  border-radius: var(--radius);
  border: var(--hair) solid var(--line-strong);
  background: var(--bg-deep);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: var(--step-0);
  text-align: center;
  transition: border-color 140ms var(--ease), background 140ms var(--ease);
}

.type-picker__option:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

.type-picker__option[aria-pressed="true"] {
  border-color: var(--signal-on-surface);
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 18%, transparent);
}

.type-picker__option:focus-visible {
  outline: none;
  border-color: var(--signal-on-surface);
}

.textarea--code {
  font-size: var(--step--1);
  word-break: break-all;
}

/* Text items keep their line breaks. */
.prose--pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A stored document: name and size, with the download beside it. */
.doc-file {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  border: var(--hair) solid var(--line-strong);
  background: var(--bg-deep);
  min-width: 0;
}

[data-theme="light"] .doc-file {
  background: var(--raised);
}

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

.doc-file__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* TOTP readout with a depleting bar — reads as a live instrument. */
.totp {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.totp__code {
  font-size: var(--step-2);
  letter-spacing: 0.16em;
  font-weight: 600;
  color: var(--signal-on-surface);
}

.totp__timer {
  width: 3rem;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.totp__timer span {
  display: block;
  height: 100%;
  width: var(--pct, 100%);
  background: var(--signal-on-surface);
  transition: width 1s linear;
}

/* ── Auth screens ───────────────────────────────────────────────────────── */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  align-items: stretch;
}

@media (max-width: 62rem) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
  }
  .auth__aside {
    display: none;
  }
}

.auth__panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-7) clamp(var(--space-5), 6vw, var(--space-8));
  max-width: 34rem;
  margin-inline: auto;
  width: 100%;
}

/* The aside is the one place the interface indulges: a large diagonal field of
   hairlines behind the security claims, so signing in feels like stepping up to
   a machine rather than filling a form. */
.auth__aside {
  position: relative;
  overflow: hidden;
  border-left: var(--hair) solid var(--line);
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-5);
  padding: var(--space-7) var(--space-6);
}

.auth__aside::before {
  content: "";
  position: absolute;
  inset: -40% -20%;
  background: repeating-linear-gradient(
    58deg,
    transparent 0 22px,
    color-mix(in oklab, var(--line) 80%, transparent) 22px 23px
  );
  mask-image: radial-gradient(120% 90% at 80% 10%, #000 20%, transparent 72%);
  pointer-events: none;
}

.auth__aside::after {
  content: "";
  position: absolute;
  top: -12rem;
  right: -12rem;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  border: var(--hair) solid color-mix(in oklab, var(--signal) 25%, transparent);
  pointer-events: none;
}

.auth__claims {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth__claim {
  display: flex;
  gap: var(--space-3);
  font-family: var(--font-text);
  font-size: var(--step--1);
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 30ch;
}

.auth__claim b {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--signal-on-surface);
  font-weight: 500;
  margin-bottom: 2px;
}

.auth__claim-index {
  font-size: var(--step--2);
  color: var(--text-faint);
  padding-top: 0.15em;
  flex: none;
}

.auth__title {
  font-size: var(--step-4);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.auth__steps {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-size: var(--step--2);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.auth__steps span[aria-current="step"] {
  color: var(--signal-on-surface);
}

/* ── Master password strength readout ───────────────────────────────────── */

.strength {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.strength__row {
  display: flex;
  justify-content: space-between;
  font-size: var(--step--2);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.strength__label[data-score="0"],
.strength__label[data-score="1"] {
  color: var(--danger);
}
.strength__label[data-score="2"] {
  color: var(--warn);
}
.strength__label[data-score="3"],
.strength__label[data-score="4"] {
  color: var(--ok);
}

.strength__warnings {
  font-family: var(--font-text);
  font-size: var(--step--2);
  color: var(--warn);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Recovery codes ─────────────────────────────────────────────────────── */

.codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-2);
  padding: var(--space-4);
  border: var(--hair) dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-deep);
}

.codes code {
  font-size: var(--step-0);
  letter-spacing: 0.06em;
  color: var(--text);
}

/* ── QR code ────────────────────────────────────────────────────────────── */

.qr {
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: #fff;
  border-radius: var(--radius);
  width: fit-content;
}

.qr svg {
  width: 176px;
  height: 176px;
  image-rendering: pixelated;
}

/* ── Empty states ───────────────────────────────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text-dim);
}

.empty__mark {
  width: 2.5rem;
  height: 2.5rem;
  border: var(--hair) dashed var(--line-strong);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--text-faint);
}

.empty p {
  font-family: var(--font-text);
  max-width: 40ch;
  font-size: var(--step--1);
}

/* ── Two-pane vault layout ──────────────────────────────────────────────── */

.vault-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
}

@media (min-width: 68rem) {
  .vault-layout--detail {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    align-items: start;
  }
  .vault-layout--detail > :last-child {
    position: sticky;
    top: 4rem;
  }
}

.search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 0.6rem;
  border: var(--hair) solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-deep);
}

[data-theme="light"] .search {
  background: var(--raised);
}

.search:focus-within {
  border-color: var(--signal-on-surface);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: var(--step-0);
}

.search kbd {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--text-faint);
  border: var(--hair) solid var(--line);
  border-radius: 2px;
  padding: 0 0.25rem;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: color-mix(in oklab, var(--bg-deep) 78%, transparent);
  backdrop-filter: blur(3px);
  animation: fade 160ms var(--ease) both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: min(34rem, 100%);
  max-height: min(85dvh, 44rem);
  overflow-y: auto;
  border: var(--hair) solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  animation: modal-in 220ms var(--ease-out) both;
}

.modal--wide {
  width: min(48rem, 100%);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
}

.modal__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: var(--hair) solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
}

.modal__head h2 {
  font-size: var(--step-1);
  flex: 1;
}

.modal__body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal__foot {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  padding: var(--space-4);
  border-top: var(--hair) solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--panel);
}

/* ── Installed app (Coordination #81) ───────────────────────────────────── */

/* viewport-fit=cover lets the page run under the notch and the home bar; these insets keep
   content clear of them. They are 0 in a normal browser tab. */
body {
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.install-hint {
  position: fixed;
  left: calc(var(--space-3) + env(safe-area-inset-left));
  right: calc(var(--space-3) + env(safe-area-inset-right));
  bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  z-index: 250;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  max-width: 34rem;
  margin-inline: auto;
  padding: var(--space-3) var(--space-4);
  background: var(--raised);
  border: var(--hair) solid var(--line-strong);
}

.install-hint__icon {
  flex: none;
}

.install-hint__body {
  flex: 1 1 12rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.install-hint__body span {
  color: var(--text-dim);
}

.offline {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-4);
  text-align: center;
}

.offline__title {
  font-size: var(--step-2);
  max-width: 22ch;
}

.offline__text {
  color: var(--text-dim);
  max-width: 40ch;
}

/* ── Privacy policy page (P&T #436): /privacy, a static page in the app's look ─────────────── */

.policy {
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom));
}

.policy__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.policy__text {
  color: var(--text-dim);
  font-family: var(--font-text);
  line-height: 1.6;
}

/* the headings keep the app's monospace; the long text reads in the text face */
.policy__text h1,
.policy__text h2,
.policy__text h3 {
  font-family: var(--font-mono);
}

.policy__text h1,
.policy__text h2,
.policy__text h3,
.policy__text strong {
  color: var(--text);
}

.policy__text h1 {
  font-size: var(--step-2);
  margin: var(--space-5) 0 var(--space-2);
}

.policy__text h2 {
  font-size: var(--step-1);
  margin: var(--space-5) 0 var(--space-2);
}

.policy__text h3 {
  font-size: var(--step-0);
  margin: var(--space-4) 0 var(--space-2);
}

.policy__text p,
.policy__text ul,
.policy__text ol {
  margin: 0 0 var(--space-3);
}

.policy__text ul,
.policy__text ol {
  padding-left: var(--space-5);
}

.policy__text hr {
  border: 0;
  border-top: var(--hair) solid var(--line);
  margin: var(--space-5) 0;
}

.policy__text code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text);
}

.policy__table {
  overflow-x: auto;
  margin: 0 0 var(--space-3);
}

.policy__table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

.policy__table th,
.policy__table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2) var(--space-3) var(--space-2) 0;
  border-bottom: var(--hair) solid var(--line);
}

.policy__table th {
  color: var(--text);
  font-weight: 600;
}

/* ── Toasts ─────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  right: calc(var(--space-4) + env(safe-area-inset-right));
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(26rem, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: var(--hair) solid var(--line-strong);
  border-left-width: 2px;
  border-radius: var(--radius);
  background: var(--raised);
  box-shadow: var(--shadow);
  font-family: var(--font-text);
  font-size: var(--step--1);
  animation: toast-in 220ms var(--ease-out) both;
}

.toast[data-tone="ok"] {
  border-left-color: var(--ok);
}
.toast[data-tone="error"] {
  border-left-color: var(--danger);
}
.toast[data-tone="warn"] {
  border-left-color: var(--warn);
}
.toast[data-tone="info"] {
  border-left-color: var(--info);
}

.toast[data-leaving="true"] {
  animation: toast-out 180ms var(--ease) both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(12px);
  }
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 2px;
}

/* ── Utility ────────────────────────────────────────────────────────────── */

.divider {
  height: var(--hair);
  background: var(--line);
  border: 0;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--line-strong);
  border-top-color: var(--signal-on-surface);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  gap: var(--space-4);
  color: var(--text-faint);
}

.boot__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

/* Print: an exported recovery sheet should be legible on paper. */
@media print {
  .grain,
  .rail,
  .status-strip,
  .toasts,
  .view-head__actions {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .panel {
    border-color: #999;
    box-shadow: none;
  }
}
