@font-face {
  font-family: 'Jakarta';
  src: url('fonts/plus-jakarta-sans-latin.woff2') format('woff2');
  font-weight: 300 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212;
}

@font-face {
  font-family: 'JetBrains';
  src: url('fonts/jetbrains-mono-latin.woff2') format('woff2');
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122, U+2212;
}

/* --------------------------------------------------------------------------
   Monochrome only. No hue anywhere: state is carried by weight, contrast and
   position instead, which is what keeps a dense dashboard calm.
   -------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  --bg: #0a0a0b;
  --panel: #0f0f11;
  --raised: #151518;
  --sunken: #070708;

  --line: #232327;
  --line-soft: #1a1a1d;

  --text: #f4f4f5;
  --muted: #9a9aa2;
  --faint: #65656d;

  --radius: 10px;
  --radius-sm: 7px;

  --sidebar: 232px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Jakarta', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: 'JetBrains', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-feature-settings: 'zero' 1;
}

[hidden] { display: none !important; }

::selection { background: #2e2e34; }

/* ------------------------------------------------------------------ login -- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 320px;
}

.login-mark {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
}

.login-mark svg { width: 1.125rem; height: 1.125rem; }

.login h1 {
  margin: 0 0 0.35rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login p {
  margin: 0 0 1.5rem;
  color: var(--faint);
  font-size: 0.8125rem;
}

.login form { display: grid; gap: 0.625rem; }

.login-error {
  margin: 0.875rem 0 0;
  font-size: 0.8125rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

/* ----------------------------------------------------------------- shell --- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.25rem 0.875rem;
  border-right: 1px solid var(--line-soft);
  background: var(--panel);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.625rem;
  height: 1.625rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.brand-mark svg { width: 0.9375rem; height: 0.9375rem; }

.nav {
  display: grid;
  gap: 1px;
  align-content: start;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.nav-item svg {
  width: 1rem;
  height: 1rem;
  flex: none;
  opacity: 0.8;
}

.nav-item:hover { background: var(--raised); color: var(--text); }

.nav-item[aria-current='page'] {
  background: var(--raised);
  color: var(--text);
  font-weight: 550;
}

.nav-item[aria-current='page'] svg { opacity: 1; }

.nav-foot {
  display: grid;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}

.nav-note {
  padding: 0 0.625rem;
  font-size: 0.6875rem;
  color: var(--faint);
}

/* ------------------------------------------------------------------ main --- */

.main { min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.125rem 1.75rem;
  border-bottom: 1px solid var(--line-soft);
}

.topbar-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }

.topbar h1 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar-sub {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: var(--faint);
}

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

.view { padding: 1.75rem; max-width: 1040px; }

.stack { display: grid; gap: 1.125rem; }

/* ------------------------------------------------------------------ card --- */

.card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--line-soft);
}

.card-title {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
  font-weight: 500;
}

.card-body { padding: 1.125rem; }
.card-body-flush { padding: 0; }

/* --------------------------------------------------------------- controls -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), opacity 0.2s var(--ease);
}

.btn:hover:not(:disabled) { background: #1d1d21; border-color: #34343a; }
.btn:active:not(:disabled) { background: #161619; }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: #09090a;
}

.btn-primary:hover:not(:disabled) { background: #ffffff; border-color: #ffffff; }
.btn-primary:active:not(:disabled) { background: #e4e4e6; }

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding-inline: 0.5rem;
}

.btn-quiet:hover:not(:disabled) { background: var(--raised); border-color: transparent; color: var(--text); }

.btn-block { width: 100%; }

.btn svg { width: 0.875rem; height: 0.875rem; }

input[type='text'],
input[type='password'],
input[type='number'],
input[type='email'],
textarea,
select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
}

textarea { resize: vertical; min-height: 4.5rem; }

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

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #3a3a42;
}

label.field { display: grid; gap: 0.3125rem; }

label.field > span {
  font-size: 0.75rem;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
}

/* ---------------------------------------------------------------- output --- */

.readout { display: flex; align-items: center; gap: 0.75rem; }

.readout code {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  font-size: 0.875rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--faint);
}

.dot {
  width: 2px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}

.tag {
  padding: 0.125rem 0.4375rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.6875rem;
  color: var(--muted);
}

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

.list { list-style: none; margin: 0; padding: 0; }

.list li {
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--line-soft);
}

.list li:last-child { border-bottom: 0; }

.list li.empty {
  padding: 3rem 1.125rem;
  text-align: center;
  color: var(--faint);
  font-size: 0.8125rem;
}

.list li.item {
  display: grid;
  gap: 0.1875rem;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}

.list li.item:hover { background: var(--raised); }
.list li.item:focus-visible { outline: none; background: var(--raised); }

.item-subject { font-weight: 550; }

.item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--faint);
  min-width: 0;
}

.item-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.item-code {
  margin-left: auto;
  padding: 0.1875rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  color: var(--text);
  font-family: 'JetBrains', ui-monospace, monospace;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.item-code:hover { border-color: #3a3a42; }

/* ---------------------------------------------------------------- viewer --- */

.viewer { padding: 1.125rem; }

.viewer h2 {
  margin: 0.875rem 0 0.375rem;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.viewer-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--faint);
}

.viewer-body {
  margin-top: 1.125rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--line-soft);
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

.viewer-body iframe {
  width: 100%;
  min-height: 24rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: #fff;
}

/* --------------------------------------------------------------- pwgen ----- */

.pw-strength { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.875rem; }

.pw-bar {
  flex: 1;
  height: 2px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.pw-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.4s var(--ease), background 0.4s var(--ease);
}

.pw-bar span[data-level='schwach'] { background: var(--faint); }
.pw-bar span[data-level='okay'] { background: var(--muted); }

.pw-entropy {
  font-size: 0.75rem;
  color: var(--faint);
  min-width: 7.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pw-controls {
  display: grid;
  gap: 1rem;
  margin-top: 1.125rem;
  padding-top: 1.125rem;
  border-top: 1px solid var(--line-soft);
}

.pw-length { display: flex; align-items: center; gap: 0.75rem; font-size: 0.8125rem; color: var(--muted); }

.pw-length output {
  min-width: 1.75rem;
  font-family: 'JetBrains', ui-monospace, monospace;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.pw-length input[type='range'] {
  flex: 1;
  appearance: none;
  height: 1rem;
  background: none;
  cursor: pointer;
}

.pw-length input[type='range']::-webkit-slider-runnable-track {
  height: 2px; border-radius: 999px; background: var(--line);
}
.pw-length input[type='range']::-moz-range-track {
  height: 2px; border-radius: 999px; background: var(--line);
}
.pw-length input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 0.75rem; height: 0.75rem; margin-top: -0.3125rem;
  border-radius: 999px; background: var(--text);
}
.pw-length input[type='range']::-moz-range-thumb {
  width: 0.75rem; height: 0.75rem; border: 0;
  border-radius: 999px; background: var(--text);
}

.chips { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.3125rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.chip:hover { border-color: #34343a; }

.chip:has(input:checked) {
  background: var(--text);
  border-color: var(--text);
  color: #09090a;
}

.chip input {
  appearance: none;
  width: 0.625rem; height: 0.625rem; margin: 0;
  border: 1px solid currentColor;
  border-radius: 2px;
  opacity: 0.6;
}

.chip:has(input:checked) input { background: #09090a; opacity: 1; }

/* ----------------------------------------------------------------- rows ---- */

.row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--line-soft);
}

.row:last-child { border-bottom: 0; }
.row:hover { background: var(--raised); }

.row-main { min-width: 0; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 0.75rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-mid {
  min-width: 0;
  font-family: 'JetBrains', ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions { display: flex; gap: 0.25rem; justify-self: end; }

.note {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: var(--faint);
  line-height: 1.6;
}

.note code { font-size: 0.6875rem; color: var(--muted); }

/* ---------------------------------------------------------------- toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--raised);
  font-size: 0.8125rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  z-index: 50;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- mobile ---- */

.burger { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, var(--sidebar));
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.4s var(--ease);
    border-right: 1px solid var(--line);
  }

  body.nav-open .sidebar { transform: none; }

  body.nav-open::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.6);
  }

  .burger {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--raised);
    color: var(--text);
    cursor: pointer;
  }

  .burger svg { width: 1rem; height: 1rem; }

  .topbar { padding: 0.875rem 1rem; }
  .view { padding: 1rem; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row-mid { grid-column: 1 / -1; }
  .pw-entropy { min-width: auto; }
}

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