:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #16202b;
  --muted: #5b6777;
  --border: #dde3ea;
  --accent: #1f4e79;
  --accent-text: #ffffff;
  --accent-soft: #e6eef7;
  --error: #b42318;
  --ok: #1a7f37;
  --digit: #0b62c4;
  --symbol: #b54708;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #1a2129;
    --text: #e6ebf0;
    --muted: #93a0ae;
    --border: #2c3640;
    --accent: #5b9bd5;
    --accent-text: #0f1419;
    --accent-soft: #1f2d3b;
    --error: #f97066;
    --ok: #47cd89;
    --digit: #6cb6ff;
    --symbol: #f5a35c;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.who .link { white-space: nowrap; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who #userName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px);
}

h1 { font-size: 1.4rem; margin: 8px 0 4px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error-text { color: var(--error); }
.ok-text { color: var(--ok); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.banner { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 0.9rem; }
.banner.error { background: color-mix(in srgb, var(--error) 14%, transparent); color: var(--error); }
.banner.info { background: var(--accent-soft); color: var(--text); }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 12px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 9px;
  font-weight: 500;
  color: var(--muted);
}
.segmented button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }

.search input {
  width: 100%;
  font-size: 1.1rem;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.item {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.item:active { background: var(--accent-soft); }
.item .title { font-weight: 600; word-break: break-all; }
.item .sub { color: var(--muted); font-size: 0.875rem; }
.tag {
  justify-self: start;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--error) 14%, transparent);
  color: var(--error);
}

.back { border: 0; background: none; color: var(--accent); padding: 4px 0; font-weight: 500; }
.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: 0.875rem; }

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 12px 0 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-all; }

button.primary, .actions button {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button:disabled { opacity: 0.6; cursor: default; }
.signin { margin-bottom: 16px; }

.card {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; }
.password {
  margin: 14px 0;
  padding: 16px 12px;
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  background: var(--bg);
  border-radius: 10px;
  word-break: break-all;
  user-select: all;
}
.password.masked { color: var(--muted); letter-spacing: 0.15em; }
.password .d { color: var(--digit); }
.password .s { color: var(--symbol); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
