/* SPDX-FileCopyrightText: Copyright 2026 Alexander Orlov <info@lifub.com> */

/* The toolbar popup: Bitwarden's structure (header, tabs, sections) in
   Keyring's Ayu Mirage tokens. Every element that sets `display` has its
   `[hidden]` rule, so the attribute always wins. */

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

html {
  width: 480px;
  height: 600px;
}

html[data-width="narrow"] { width: 380px; }
html[data-width="wide"] { width: 600px; }

body {
  margin: 0;
  height: 100%;
  background: var(--std-back-color);
  color: var(--front-color);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* A pop-out or a test tab: the same column, centred, at full height. */
html.popout { width: auto; height: 100%; }
html.popout .app { max-width: 600px; margin: 0 auto; }

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
}

.bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  align-content: center;
  gap: 6px 8px;
  min-height: 56px;
  box-sizing: border-box;
  padding: 8px;
  container-type: inline-size;
  background: var(--back-color);
  border-bottom: 1px solid var(--info-color);
}

.title-group {
  display: flex;
  flex: 1 1 72px;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
}

.bar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-version {
  color: var(--front-color);
  font-size: 10px;
  opacity: 0.65;
  white-space: nowrap;
}

/* Keep navigation, creation, utilities and account controls distinct. The
   top bar may wrap; the content still occupies every remaining row. */
.bar-actions { display: flex; align-items: center; flex-wrap: wrap; flex-shrink: 0; max-width: 100%; gap: 6px 8px; }
.toolbar-group { display: flex; align-items: center; gap: 4px; padding-inline-start: 8px; border-inline-start: 1px solid var(--info-color); }
.item-actions:has(> button[hidden]), .account-actions:has(> button[hidden]),
.bar-actions[hidden], .toolbar-group[hidden] { display: none; }

#content {
  overflow-y: auto;
  padding: 12px;
}

.screen { display: block; }
.screen[hidden] { display: none; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stack[hidden] { display: none; }

h2 {
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: normal;
  color: var(--std-front-color);
  text-transform: none;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

.primary {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--accent-color);
  color: var(--std-back-color);
  font-weight: 600;
}

.ghost {
  border: 1px solid var(--info-color);
  border-radius: 8px;
  padding: 8px 12px;
  background: transparent;
  text-align: center;
}
.ghost:hover:not(:disabled) {
  background: var(--info-color);
  opacity: 1;
}
.screen-accounts .ghost {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.ghost.danger { color: var(--spot-color); }
.ghost[hidden], .primary[hidden] { display: none; }

.icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  box-sizing: border-box;
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  line-height: 0;
}
.icon > i {
  --fa-width: 1em;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  margin: 0;
  line-height: 1;
}
.icon > i::before {
  display: block;
  line-height: 1;
}
.icon:hover { background: var(--info-color); }
.icon[aria-busy="true"] { background: var(--info-color); cursor: progress; }
.icon[hidden] { display: none; }
.avatar[hidden] { display: none; }

.link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-color);
  text-decoration: underline;
}

.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--std-back-color);
  font-weight: 600;
}

.avatar.has-login { flex-shrink: 0; }

/* Connection failures remain readable in the default-width toolbar. */
.avatar.offline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  width: auto;
  max-width: 150px;
  padding: 0 8px;
  border-radius: 16px;
  white-space: nowrap;
}

.account-offline {
  display: inline;
  flex-shrink: 0;
  color: var(--spot-color);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.account-offline[hidden] { display: none; }

.avatar.offline::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--spot-color);
}

html[data-width="narrow"] .account-offline { display: none; }

.account-login {
  display: none;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar.has-login .account-login { display: none; }

html[data-width="narrow"] .avatar.has-login,
html[data-width="narrow"] .avatar.offline {
  width: 32px;
  padding: 0;
  border-radius: 50%;
}

html[data-width="narrow"] .avatar.has-login .account-login { display: none; }

input, select, textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--info-color);
  border-radius: 8px;
  background: var(--back-color);
  color: var(--front-color);
  font: inherit;
}

.field-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.field-row:has(> textarea) { align-items: flex-start; }
.field-row[hidden], .form-field[hidden] { display: none; }

.input-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}
.input-box > input {
  width: 100%;
  padding-inline-end: 38px;
}
.input-box > .icon {
  position: absolute;
  inset-inline-end: 4px;
  inset-block: 0;
  margin-block: auto;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--secondary-color);
}
.input-box > .icon:hover:not(:disabled) {
  color: var(--front-color);
  background: var(--info-color);
  opacity: 1;
}
.input-box > .icon:active:not(:disabled) {
  transform: none;
}
.input-box > .icon:focus-visible {
  outline-offset: 0;
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
}
.check input { width: auto; }

.hint {
  margin: 4px 0;
  color: var(--secondary-color);
  font-size: 12px;
}

.status { min-height: 1.2em; margin: 0; color: var(--spot-color); font-size: 12px; }

.confirmation-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
}

.confirmation-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.confirmation-hero .mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--std-back-color);
  font-size: 16px;
}

.confirmation-hero h2 { margin: 0; font-size: 18px; }
.confirmation-hero .eyebrow { margin: 0 0 2px; font-size: 11px; opacity: 0.65; text-transform: uppercase; }
.confirmation-dialog .explanation { margin: 0 0 14px; line-height: 1.5; }
.connection-alert:not([open]) { display: none; }
.connection-alert .primary[hidden] { display: none; }

.notice {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--info-color);
  font-size: 12px;
}
.notice[hidden], .hint[hidden] { display: none; }

.search-row {
  display: flex;
  gap: 6px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.filters[hidden] { display: none; }
.filters label { display: grid; gap: 4px; font-size: 12px; }
.filters label[hidden] { display: none; }

.list-section { display: block; }
.list-section[hidden] { display: none; }

.count { color: var(--secondary-color); font-weight: 400; }

/* A section heading folds its list, Bitwarden's way. */
h2[data-collapse] { cursor: pointer; user-select: none; }
h2[data-collapse]::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 6px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--secondary-color);
  transform: rotate(90deg);
  vertical-align: middle;
}
h2[data-collapse][aria-expanded="false"]::before { transform: none; }
.rows[hidden] { display: none; }

.filter-toggle { position: relative; }
.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--accent-color);
  color: var(--std-back-color);
  font-size: 10px;
  line-height: 14px;
  text-align: center;
}
.badge[hidden] { display: none; }

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: 10px;
  overflow: hidden;
  background: var(--back-color);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--std-back-color);
}
.row:last-child { border-bottom: 0; }

.row-main {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 10px;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
}

.row-mark {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--info-color);
}

.row-text { display: grid; min-width: 0; }
.row-title, .row-subtitle {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.row-subtitle { color: var(--secondary-color); font-size: 12px; }

.row-actions { display: flex; gap: 2px; }
/* A login action the item lacks keeps its column (`iconSlot`). */
.icon-slot { display: inline-block; flex: none; width: 32px; height: 32px; }

/* A login's monogram, tinted exactly as Keyring tools tints it. */
.row-mark.monogram {
  background: hsl(var(--login-avatar-hue, 212) 62% 32%);
  color: hsl(var(--login-avatar-hue, 212) 90% 88%);
  font-weight: 700;
  text-transform: uppercase;
}

.row-mark.has-favicon { position: relative; background: transparent; color: transparent; }
.row-favicon { position: absolute; inset: 0; width: 32px; height: 32px; object-fit: contain; border-radius: 4px; }


/* A suggestion's Autofill icon: the row's one accent action. */
.fill-button { color: var(--accent-color); }

.load-more { width: 100%; margin-top: 8px; text-align: center; }

.item-body { display: grid; gap: 12px; }
.card {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--back-color);
}
.card h3 { margin: 0 0 6px; font-size: 12px; color: var(--secondary-color); font-weight: 600; }
.field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--std-back-color);
}
.field:last-child { border-bottom: 0; }
.field-label { grid-column: 1 / -1; color: var(--secondary-color); font-size: 11px; }
.field-value { min-width: 0; overflow-wrap: anywhere; }
.note-value { white-space: break-spaces; tab-size: 4; line-height: 1.5; }
.field-actions { display: flex; gap: 2px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

textarea { resize: vertical; min-height: 64px; }
textarea.notes { min-height: 128px; }
/* A secret in a multi-line field stays unreadable until shown. */
textarea.masked { -webkit-text-security: disc; }

.new-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--accent-color);
  color: var(--std-back-color);
  font-weight: 600;
}
.new-label { display: none; }

/* Labels expand only when this toolbar itself has room, including pop-outs. */
@container (min-width: 520px) {
  .new-button { display: inline-flex; align-items: center; gap: 6px; width: auto; padding: 0 10px; }
  .new-label { display: inline; }
  .avatar.has-login { display: inline-flex; gap: 6px; width: auto; max-width: 150px; padding: 0 8px; border-radius: 16px; }
  .avatar.has-login .account-login { display: block; }
}
.new-button[hidden] { display: none; }

.menu {
  position: fixed;
  z-index: 10;
  display: grid;
  min-width: 180px;
  padding: 4px;
  border: 1px solid var(--info-color);
  border-radius: 10px;
  background: var(--back-color);
  box-shadow: 0 8px 24px hsla(220, 21%, 8%, 0.5);
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  background: transparent;
  text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--info-color); }
.menu-item.danger, .icon.danger { color: var(--spot-color); }

.item-footer {
  position: sticky;
  bottom: -12px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px -12px -12px;
  padding: 10px 12px;
  border-top: 1px solid var(--info-color);
  background: var(--std-back-color);
}
.item-footer[hidden] { display: none; }
.item-footer .icon { margin-left: auto; }

.edit-form .card { display: grid; gap: 10px; }
.form-field { display: grid; gap: 4px; }
.form-field label { color: var(--secondary-color); font-size: 12px; }
.additional-websites { display: grid; gap: 10px; }
.custom-fields { display: grid; gap: 6px; }
.custom-field {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  align-items: center;
  gap: 6px;
}
.custom-field[hidden] { display: none; }
.custom-field input[type="checkbox"] { width: auto; }
.add-field { justify-self: start; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--info-color);
  border-radius: 8px;
  overflow: hidden;
}
.segmented button {
  border: 0;
  padding: 8px;
  background: transparent;
}
.segmented button[aria-checked="true"] { background: var(--info-color); font-weight: 600; }

.generated {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--back-color);
}
.generated output { flex: 1; overflow-wrap: anywhere; font-size: 16px; }
.generated-actions { display: flex; gap: 4px; }

.options {
  display: grid;
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}
.options[hidden] { display: none; }
.options legend { margin-bottom: 6px; font-weight: 600; }

.settings { margin: 0; padding: 0; list-style: none; border-radius: 10px; overflow: hidden; background: var(--back-color); }
.settings[hidden] { display: none; }
.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid var(--std-back-color);
  background: transparent;
  text-align: left;
}
.setting-row .chevron { margin-left: auto; color: var(--secondary-color); }
.setting-row:hover { background: var(--info-color); }
.setting-label { flex: 1 1 auto; min-width: 0; }
.setting-control { cursor: default; }
.setting-control:hover { background: transparent; }
/* A row's control keeps its own width: the page-wide "input, select {
   width: 100% }" would otherwise squeeze the label to one word per line and
   leave the checkbox floating mid-row. */
.setting-control input[type="checkbox"] { flex: none; width: auto; margin: 0 0 0 auto; }
.setting-control select {
  flex: 0 1 auto;
  width: auto;
  min-width: 7rem;
  max-width: 60%;
  margin-left: auto;
  color: var(--secondary-color);
}
.setting-value { flex: none; margin-left: auto; color: var(--secondary-color); }
.settings li:last-child .setting-row { border-bottom: 0; }
.settings-group { display: grid; gap: 6px; }
.settings-group h3 { margin: 0; padding: 0 4px; font-size: 12px; color: var(--secondary-color); font-weight: 600; }
.settings-detail { display: grid; gap: 14px; }
.settings-detail[hidden] { display: none; }

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px 12px;
  text-align: center;
  color: var(--secondary-color);
}
.empty-state i { font-size: 28px; }

.lock-mark { display: grid; place-items: center; font-size: 32px; margin: 24px 0 8px; }
.auth-mark {
  width: 48px;
  height: 48px;
  margin: 4px auto 12px;
  border: 1px solid var(--info-color);
  border-radius: 14px;
  background: var(--std-back-color);
  color: var(--accent-color);
  font-size: 20px;
}

.screen-locked h2,
.screen-login h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  color: var(--front-color);
  letter-spacing: normal;
}
.screen-locked h2,
.screen-login .code-title {
  text-align: center;
}
.screen-locked .locked-who {
  margin: 0 0 16px;
  text-align: center;
  color: var(--secondary-color);
  font-size: 13px;
}
.screen-login .login-who {
  margin: 0 0 8px;
  color: var(--secondary-color);
  font-size: 13px;
}
.screen-locked label:not(.check),
.screen-login label:not(.check) {
  color: var(--std-front-color);
  font-size: 12px;
  font-weight: 600;
}
.screen-locked input:not([type="checkbox"]),
.screen-login input:not([type="checkbox"]) {
  min-height: 40px;
}
.screen-locked .primary,
.screen-login .primary,
.screen-login .ghost {
  width: 100%;
  min-height: 40px;
}

.server-mode {
  overflow: visible;
  gap: 2px;
  margin-top: 4px;
  padding: 2px;
  border-radius: 10px;
  background: var(--std-back-color);
}
.server-mode button {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--secondary-color);
  font-size: 13px;
  font-weight: 600;
  transform: none;
}
.server-mode button:hover:not(:disabled):not([aria-checked="true"]) {
  color: var(--front-color);
  opacity: 1;
}
.server-mode button:active:not(:disabled) {
  transform: none;
}
.server-mode button[aria-checked="true"] {
  background: var(--accent-color);
  color: var(--std-back-color);
}
.server-field {
  margin-top: 4px;
}
.accessing { margin: 4px 0 0; font-size: 12px; color: var(--secondary-color); }
#serverChoice { color: var(--std-front-color); font-weight: 500; }

.code-hint {
  margin: 0 0 8px;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
}
input.code-input {
  min-height: 46px;
  padding: 10px 14px;
  font: 600 20px/1.3 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  text-align: center;
}
input.code-input::placeholder {
  color: var(--secondary-color);
  opacity: 0.35;
  font-weight: 500;
}
.remember-check {
  margin: 6px 0 2px;
  padding: 10px 12px;
  border: 1px solid var(--info-color);
  border-radius: 8px;
  background: var(--std-back-color);
  color: var(--std-front-color);
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
}
.remember-check:hover {
  border-color: var(--secondary-color);
}
.remember-check input[type="checkbox"] {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent-color);
}
#screenLogin > #loginStatus {
  margin-top: 10px;
  text-align: center;
}
#screenLogin > #loginStatus:empty {
  display: none;
}

.tabs { display: flex; align-items: center; gap: 2px; flex-shrink: 0; padding: 2px; border: 1px solid var(--info-color); border-radius: 10px; }
.tabs[hidden] { display: none; }
.tab { color: var(--secondary-color); }
.tab[aria-current="page"] { color: var(--accent-color); background: var(--info-color); }
.tab i { font-size: 16px; }
.tab-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--front-color);
  color: var(--std-back-color);
  font-size: 13px;
}
.toast[hidden] { display: none; }

.dialog {
  width: min(360px, 90vw);
  border: 1px solid var(--info-color);
  border-radius: 12px;
  background: var(--back-color);
  color: var(--front-color);
}
.dialog::backdrop { background: hsla(220, 21%, 8%, 0.6); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
