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

html[data-web],
html[data-web] *,
html[data-web] *::before,
html[data-web] *::after {
  box-sizing: border-box;
}

html[data-web],
html[data-web][data-width] {
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background: var(--std-back-color);
}

html[data-web] body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

html[data-web] .app {
  --web-gutter: 16px;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(1080px, 100%);
  min-width: 0;
  height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
  overflow: hidden;
}

html[data-web][data-width="narrow"] .app { max-width: min(600px, 100%); }
html[data-web][data-width="wide"] .app { max-width: min(1280px, 100%); }
html[data-web] #popOut { display: none; }

/* Unified horizontal alignment across header bar, connection card and vault content */
html[data-web] .bar {
  flex: none;
  margin: 12px var(--web-gutter) 0;
  padding: 10px 14px;
  border: 1px solid var(--info-color);
  border-radius: 12px;
  background: var(--back-color);
}

html[data-web] #content {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px var(--web-gutter) calc(24px + env(safe-area-inset-bottom, 0px));
}

html[data-web] .search-row {
  align-items: center;
  gap: 8px;
}

html[data-web] .icon {
  flex: none;
}

html[data-web] .filters {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-web] .custom-field {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
}

html[data-web] .item-body .card {
  margin-top: 0;
}

html[data-web] .rows,
html[data-web] .settings,
html[data-web] .card,
html[data-web] .generated {
  border: 1px solid var(--info-color);
  border-radius: 12px;
}

html[data-web] .item-footer {
  bottom: 0;
  margin: 12px calc(-1 * var(--web-gutter)) calc(-24px - env(safe-area-inset-bottom, 0px));
  padding: 10px var(--web-gutter) calc(10px + env(safe-area-inset-bottom, 0px));
}

html[data-web] .toast {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100vw - 24px);
}

html[data-web] .dialog {
  max-width: calc(100vw - 24px);
}

html[data-web] .screen-login,
html[data-web] .screen-locked {
  width: 100%;
  max-width: 460px;
  margin: 20px auto;
  padding: 24px;
  border: 1px solid var(--info-color);
  border-radius: 12px;
  background: var(--back-color);
}

html[data-web] .screen-login[hidden],
html[data-web] .screen-locked[hidden] {
  display: none;
}

/* Header connection status chip (icon-only in Direct mode; labeled in Bridge mode) */
.web-connection-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--info-color);
  border-radius: 8px;
  background: transparent;
  color: var(--secondary-color);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transform: none;
}

.web-connection-chip.is-subtle {
  width: 32px;
  padding: 0;
  justify-content: center;
  border-color: transparent;
}
.web-connection-chip.is-subtle .web-chip-label {
  display: none;
}
.web-connection-chip.is-bridge {
  background: var(--std-back-color);
  color: var(--front-color);
  border-color: var(--accent-color);
}

.web-connection-chip[hidden] { display: none; }
.web-connection-chip > i { color: var(--secondary-color); font-size: 12px; }
.web-connection-chip.is-bridge > i,
.web-connection-chip[aria-expanded="true"] > i { color: var(--accent-color); }
.web-connection-chip:hover:not(:disabled) {
  background: var(--info-color);
  border-color: var(--info-color);
  color: var(--front-color);
  opacity: 1;
}
.web-connection-chip:active:not(:disabled) { transform: none; opacity: 1; }
.web-connection-chip[aria-expanded="true"] {
  border-color: var(--accent-color);
  color: var(--front-color);
}

@container (max-width: 519px) {
  .web-connection-chip {
    width: 32px;
    padding: 0;
    justify-content: center;
  }
  .web-chip-label { display: none; }
}

/* Subordinate vault connection bar */
.web-connection {
  flex: none;
  margin: 8px var(--web-gutter) 0;
  padding: 7px 12px;
  border: 1px solid var(--info-color);
  border-radius: 10px;
  background: var(--std-back-color);
}

.web-connection[hidden] { display: none; }

.web-connection-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.web-connection-lead {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 0;
}

.web-connection-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--back-color);
  border: 1px solid var(--info-color);
  color: var(--secondary-color);
  font-size: 12px;
}
.web-connection[data-mode="bridge"] .web-connection-mark {
  color: var(--accent-color);
}

.web-connection-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.web-connection-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.web-connection-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--std-front-color);
  white-space: nowrap;
}

.web-connection-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--info-color);
  border-radius: 999px;
  background: var(--std-back-color);
  color: var(--secondary-color);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.web-connection-badge[hidden] { display: none; }

.web-connection-summary {
  margin: 0;
  color: var(--secondary-color);
  font-size: 12px;
  line-height: 1.35;
}

.web-connection-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: none;
  max-width: 100%;
}

.web-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--info-color);
  border-radius: 10px;
  background: var(--std-back-color);
  max-width: 100%;
}

.web-mode-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 28px;
  padding: 5px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--secondary-color);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transform: none;
}

.web-mode-option > i { flex: none; font-size: 12px; }
.web-mode-option > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.web-mode-option:hover:not(:disabled):not([aria-checked="true"]) {
  color: var(--front-color);
  opacity: 1;
}
.web-mode-option:active:not(:disabled) { transform: none; opacity: 1; }
.web-mode-option[aria-checked="true"] {
  background: var(--accent-color);
  color: var(--std-back-color);
}
.web-mode-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.web-lock-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--info-color);
  border-radius: 8px;
  background: transparent;
  color: var(--front-color);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transform: none;
}

.web-lock-switch[hidden] { display: none; }
.web-lock-switch:hover:not(:disabled) {
  background: var(--info-color);
  opacity: 1;
}
.web-lock-switch:active:not(:disabled) { transform: none; opacity: 1; }

.web-info-toggle {
  color: var(--secondary-color);
  transform: none;
}
.web-info-toggle:hover:not(:disabled) {
  color: var(--front-color);
  opacity: 1;
}
.web-info-toggle[aria-expanded="true"] {
  background: var(--info-color);
  color: var(--accent-color);
}

.web-connection-notice {
  margin: 8px 0 0;
  padding: 7px 10px;
  border: 1px solid var(--info-color);
  border-radius: 8px;
  background: var(--std-back-color);
  color: var(--std-front-color);
  font-size: 12px;
  line-height: 1.4;
}

.web-connection-notice.is-warning {
  color: var(--spot-color);
}

.web-connection-notice[hidden],
.web-connection-notice:empty {
  display: none;
}

.web-connection-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--info-color);
}

.web-connection-details[hidden] { display: none; }

.web-detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--std-back-color);
  font-size: 12px;
  line-height: 1.45;
  color: var(--std-front-color);
}

.web-detail-item strong {
  color: var(--front-color);
  font-size: 12px;
  font-weight: 600;
}

.web-tools {
  width: min(90vw, 640px);
  max-height: 85dvh;
  overflow: auto;
}
.web-tools form { margin-bottom: 1rem; }
.web-tools p { line-height: 1.5; }

/* Prevent iOS Safari from zooming the viewport when tapping text fields. */
@media (max-width: 680px), (pointer: coarse) {
  html[data-web] input:not([type="checkbox"]):not([type="radio"]):not(.code-input),
  html[data-web] select,
  html[data-web] textarea {
    font-size: 16px;
  }
}

@media (max-width: 680px) {
  html[data-web] .app { --web-gutter: 10px; }
  html[data-web] .screen-login,
  html[data-web] .screen-locked {
    margin: 8px auto;
    padding: 16px;
  }
  .web-connection {
    padding: 9px 10px;
  }
  .web-connection-controls {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
  }
  .web-mode-switch {
    flex: 1 1 0;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .web-mode-option {
    padding: 5px 8px;
  }
  .web-connection-details {
    grid-template-columns: 1fr;
  }
}

/* Single-row mobile top bar sized cleanly for iPhone viewports (390px-430px). */
@media (max-width: 560px) {
  html[data-web] .app { --web-gutter: 8px; }
  html[data-web] .bar {
    flex-wrap: nowrap;
    gap: 5px;
    min-height: 46px;
    margin-top: 8px;
    padding: 6px 8px;
  }
  html[data-web] .bar .title-group {
    flex: 1 1 0;
    min-width: 0;
  }
  html[data-web] .bar h1 {
    font-size: 14px;
    line-height: 1.15;
  }
  html[data-web] .bar .app-version {
    font-size: 9.5px;
    line-height: 1.1;
  }
  html[data-web] .bar .tabs {
    gap: 1px;
    padding: 2px;
  }
  html[data-web] .bar .bar-actions {
    flex-wrap: nowrap;
    gap: 4px;
  }
  html[data-web] .bar .toolbar-group {
    gap: 2px;
    padding-inline-start: 4px;
  }
  html[data-web] .bar .icon,
  html[data-web] .bar .new-button,
  html[data-web] .bar .web-connection-chip,
  html[data-web] .bar .avatar {
    width: 28px;
    height: 28px;
    padding: 0;
    justify-content: center;
  }
  html[data-web] .bar .new-label,
  html[data-web] .bar .web-chip-label,
  html[data-web] .bar .account-login,
  html[data-web] .bar .account-offline {
    display: none;
  }
  html[data-web] .bar .avatar.has-login,
  html[data-web] .bar .avatar.offline {
    width: 28px;
    padding: 0;
    border-radius: 50%;
  }
  html[data-web] .bar [hidden] {
    display: none;
  }
  html[data-web] .custom-field {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }
  html[data-web] .custom-field > input:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  html[data-web] .bar #shortcutsButton {
    display: none;
  }
}
