/* PocketVault. A card-index drawer: cool paper, navy ink, brass tabs. */

:root {
  --paper: #e9eef3;
  --card: #ffffff;
  --ink: #14213d;
  --soft: #55627a;
  --line: #cdd6e1;
  --brass: #8a5d0c;
  --brass-wash: #f4e8cc;
  --danger: #a1241d;
  --on-ink: #ffffff;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Roboto Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1a2c;
    --card: #18263d;
    --ink: #e8edf6;
    --soft: #a3b2ca;
    --line: #2c3d5a;
    --brass: #e2b04a;
    --brass-wash: #3a2f15;
    --danger: #ff8a80;
    --on-ink: #0f1a2c;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

h1,
h2,
p {
  margin: 0;
}

a {
  color: inherit;
  overflow-wrap: anywhere;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

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

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

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  appearance: none;
}

textarea {
  resize: vertical;
}

input::placeholder {
  color: var(--soft);
  opacity: 0.8;
}

.btn {
  min-height: 44px;
  padding: 9px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

.btn.danger {
  color: var(--danger);
  border-color: currentColor;
  background: transparent;
}

.btn.quiet {
  background: transparent;
  border-color: transparent;
  padding-inline: 10px;
  color: var(--soft);
}

.btn.small {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 14px;
  flex: none;
}

.btn.wide {
  width: 100%;
}

.link {
  background: none;
  border: 0;
  padding: 10px;
  color: var(--soft);
  text-decoration: underline;
  cursor: pointer;
  font-size: 14px;
}

.stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
}

.hint {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--soft);
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 600;
}

.check.small {
  font-size: 14px;
  font-weight: 400;
  color: var(--soft);
  align-items: center;
}

.check input {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--brass);
}

.error {
  color: var(--danger);
  font-size: 14px;
  min-height: 1.45em;
}

.error:empty {
  display: none;
}

.warn,
.notice {
  padding: 12px 14px;
  border-left: 4px solid var(--brass);
  background: var(--brass-wash);
  border-radius: 0 10px 10px 0;
  font-size: 14px;
}

.boot {
  padding: 48px 24px;
  text-align: center;
  color: var(--soft);
}

/* ---------- unlock / create ---------- */

.gate {
  display: grid;
  gap: 16px;
  padding: calc(40px + env(safe-area-inset-top)) 24px 24px;
}

.brand {
  display: grid;
  justify-items: start;
  gap: 8px;
  margin-bottom: 8px;
}

.brand img {
  border-radius: 14px;
}

.brand h1 {
  font-size: 30px;
  letter-spacing: -0.02em;
}

.brand p {
  color: var(--soft);
}

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

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.top-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-row h1 {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top.sub .top-row h1 {
  text-align: center;
}

.search {
  font-size: 17px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 2px 16px;
}

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

.chip {
  flex: none;
  min-height: 36px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}

.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

.chip .count {
  margin-left: 6px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.list-wrap {
  padding: 0 16px;
}

.sync {
  font-size: 13px;
  padding: 10px 0 2px;
  color: var(--soft);
}

.sync:empty {
  display: none;
}

.sync.alert {
  color: var(--ink);
  padding: 10px 12px;
  margin-top: 10px;
  border-left: 4px solid var(--brass);
  background: var(--brass-wash);
  border-radius: 0 10px 10px 0;
}

.letter {
  margin: 18px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brass);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  margin-top: 6px;
  padding: 8px 12px 8px 8px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

/* The index-card tab: the entry's first letter on a brass tab. */
.tab {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 44px;
  background: var(--brass-wash);
  color: var(--brass);
  border-radius: 10px 10px 3px 3px;
  font-size: 19px;
  font-weight: 700;
}

.row-main {
  flex: 1;
  min-width: 0;
  display: grid;
}

.row-name {
  font-weight: 600;
}

.row-name,
.row-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  font-size: 14px;
  color: var(--soft);
}

.flag {
  flex: none;
  padding: 2px 8px;
  border: 1px solid var(--brass);
  border-radius: 999px;
  color: var(--brass);
  font-size: 12px;
  font-weight: 600;
}

.flag.block {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 400;
  background: var(--brass-wash);
  color: var(--ink);
}

.empty {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 32px 4px;
  color: var(--soft);
}

.empty p:first-child {
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
}

.fab {
  position: fixed;
  right: max(20px, calc(50vw - 260px));
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgb(20 33 61 / 0.35);
}

/* ---------- entry, edit, settings ---------- */

.detail {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.item {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.item h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--soft);
}

.value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.value,
.secret {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.secret,
.mono {
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: 0.02em;
}

.notes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.meta {
  font-size: 13px;
  color: var(--soft);
}

/* ---------- dialog and toast ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(8 14 26 / 0.6);
}

.dialog {
  display: grid;
  gap: 12px;
  width: min(100%, 440px);
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.dialog h2 {
  font-size: 19px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 30;
  width: max-content;
  max-width: min(92vw, 520px);
  padding: 12px 16px;
  background: var(--ink);
  color: var(--on-ink);
  border-radius: 10px;
  font-size: 14px;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

#toast.on {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  #toast {
    transition: none;
  }
}
