/* MyPass — Modern Light/Dark Vault Theme */
:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --border: #dce3f0;
  --text: #101828;
  --muted: #5a6578;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  accent-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1b2436;
    --border: #263248;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.18);
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1b2436;
  --border: #263248;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.84rem;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* Inputs & Buttons */
label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.62rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease, border-color 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 0.42rem 0.72rem;
  font-size: 0.82rem;
}

.btn-icon {
  padding: 0.48rem 0.6rem;
  min-width: 2.2rem;
}

.btn-full {
  width: 100%;
}

.align-left {
  justify-content: flex-start;
}

.input-with-btn {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  font-weight: 400;
  cursor: pointer;
}

.checkbox-row input {
  width: 1.05rem;
  height: 1.05rem;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.5rem;
}

/* Gate Screens (Login, MFA, Unlock) */
.gate-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.gate-card {
  width: 100%;
  max-width: 470px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gate-card-wide {
  max-width: 720px;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-header h1 {
  margin: 0;
  font-size: 1.55rem;
}

.subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
}

.brand-logo-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
}

.gate-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.feature-pills {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.feature-pills li {
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.step-badge {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.auth-box,
.dev-box,
.mfa-panel {
  padding: 1rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.google-slot {
  min-height: 44px;
  display: flex;
  justify-content: center;
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.user-chip div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.mfa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.mfa-panel h3 {
  margin: 0;
  font-size: 1.02rem;
}

.qr-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.qr-box {
  background: #fff;
  padding: 0.75rem;
  border-radius: 12px;
  width: fit-content;
  margin: 0 auto;
}

.qr-box svg {
  display: block;
  width: 170px;
  height: 170px;
}

.secret-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  word-break: break-all;
}

.warn-box {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 0.84rem;
}

.error-text {
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
}

/* Strength bar */
.strength-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.strength-bar span {
  display: block;
  height: 100%;
  width: 0%;
  transition: width 0.2s ease, background 0.2s ease;
}

/* Main App Layout */
.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100dvh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.sidebar-brand > div {
  display: flex;
  flex-direction: column;
  margin-right: auto;
}

.nav-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 0.35rem;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.badge {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.badge-lg {
  font-size: 0.86rem;
  padding: 0.25rem 0.7rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1 1 240px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-controls select {
  width: auto;
}

.vault-content {
  padding: 1.25rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.vault-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.vault-header h2 {
  margin: 0 0 0.2rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}

.empty-icon {
  font-size: 2.6rem;
}

/* Vault Cards */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.vault-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-title-wrap {
  min-width: 0;
}

.card-title {
  margin: 0;
  font-size: 1.04rem;
  word-break: break-word;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.pill-shared {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.fav-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  color: var(--muted);
  padding: 0.15rem;
}

.fav-btn.is-fav {
  color: var(--warn);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.field-meta {
  min-width: 0;
  flex: 1;
}

.field-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.field-value {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-value.revealed {
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--accent);
  font-weight: 600;
}

.field-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.totp-row {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.totp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.totp-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ok);
}

.totp-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.totp-bar-fill {
  height: 100%;
  background: var(--ok);
  transition: width 0.35s linear;
}

.card-notes {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.card-footer-left,
.card-footer-right {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* Native Dialog Modals */
dialog.modal {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: min(560px, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 2rem);
  box-shadow: var(--shadow);
}

dialog.modal::backdrop {
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(3px);
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
  max-height: calc(100dvh - 2.2rem);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.modal-header h3 {
  margin: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.divider {
  height: 1px;
  background: var(--border);
}

.share-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.share-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.gen-output-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.gen-output-box code {
  font-size: 1.02rem;
  word-break: break-all;
}

.gen-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-only {
  display: none;
}

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

  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }
}
