/* Раскладка приложения-сейфа. Компоненты — в glass.css, токены — в tokens.css. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text-1);
  background: var(--bg-base);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Ambient background orbs ------------------------------------------ */

.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
}

.orb--1 {
  width: 420px; height: 420px;
  left: -120px; top: -100px;
  background: radial-gradient(circle, var(--orb-1), transparent 70%);
  animation: drift-1 26s ease-in-out infinite alternate;
}

.orb--2 {
  width: 460px; height: 460px;
  right: -160px; top: 180px;
  background: radial-gradient(circle, var(--orb-2), transparent 70%);
  animation: drift-2 32s ease-in-out infinite alternate;
}

.orb--3 {
  width: 380px; height: 380px;
  left: 40px; bottom: -160px;
  background: radial-gradient(circle, var(--orb-3), transparent 70%);
  animation: drift-3 24s ease-in-out infinite alternate;
}

@keyframes drift-1 { to { transform: translate(70px, 50px) scale(1.12); } }
@keyframes drift-2 { to { transform: translate(-60px, -70px) scale(1.08); } }
@keyframes drift-3 { to { transform: translate(50px, -40px) scale(1.15); } }

/* ---- App shell ---------------------------------------------------------- */

#app {
  position: relative;
  z-index: 1;
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px
           max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  animation: fade-in 340ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes fade-in {
  from { opacity: 0; transform: scale(0.985) translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.spacer { flex: 1; }

/* ---- Typography ---------------------------------------------------------- */

.title-xl {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--text-1);
  margin: 0;
  line-height: 1.15;
}

.title-lg {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--text-1);
  margin: 0;
}

.subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
  line-height: 1.45;
}

.footnote {
  font-size: 12px;
  color: var(--text-3);
  margin: 0;
  line-height: 1.4;
}

/* ---- Inputs -------------------------------------------------------------- */

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--field-bg);
  color: var(--text-1);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 13px;
  outline: none;
  transition: border-color 140ms ease, background 140ms ease;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  background: transparent;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.45;
}

.fld-label {
  display: block;
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 650;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.pw-row {
  display: flex;
  gap: 8px;
}

.pw-row .input { flex: 1; }

.icon-btn {
  flex-shrink: 0;
  width: 46px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--field-bg);
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:active { color: var(--text-1); }

/* ---- Lock screen ---------------------------------------------------------- */

.lock-screen {
  justify-content: center;
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}

.lock-card {
  padding: 28px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lock-head {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.lock-err {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  text-align: center;
  margin: 0;
}

.lock-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}

.warn-box {
  background: var(--tint-orange);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}

.warn-box b { color: var(--orange); }

/* ---- Vault screen ---------------------------------------------------------- */

.vault-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.vault-head .title-lg { flex: 1; }

.head-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--r-pill);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid var(--glass-border);
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.head-btn:active { color: var(--text-1); }

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-wrap .input {
  padding-left: 36px;
  border-radius: var(--r-md);
}

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

.cats-row::-webkit-scrollbar { display: none; }

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

.entry-fields {
  border-top: 1px solid var(--hairline);
  padding: 4px 14px 10px 57px;
  display: flex;
  flex-direction: column;
}

.efield {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
}

.efield:not(:last-child) {
  border-bottom: 1px solid var(--hairline);
}

.efield__k {
  flex: 0 0 84px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
}

.efield__v {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  color: var(--text-1);
  user-select: text;
  -webkit-user-select: text;
}

.efield__v--secret {
  letter-spacing: 2px;
  color: var(--text-3);
}

.efield__actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.mini-btn {
  width: 30px;
  height: 28px;
  border: none;
  border-radius: 7px;
  background: var(--field-bg);
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.mini-btn:active { color: var(--accent); }

.entry-notes {
  padding: 9px 0 4px;
  font-size: 12.5px;
  color: var(--text-2);
  font-style: italic;
  line-height: 1.45;
}

.entry-tools {
  display: flex;
  gap: 8px;
  padding: 8px 0 4px;
}

.empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 48px 20px;
  font-size: 14px;
}

/* ---- Bottom action bar ------------------------------------------------------ */

.bottom-bar {
  position: sticky;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  padding-top: 10px;
  z-index: 40;
}

/* ---- Editor sheet (модалка записи) ------------------------------------------ */

.editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: color-mix(in srgb, var(--bg-base) 45%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: sheet-in 220ms ease;
}

.editor {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-glass)) saturate(1.8);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(1.8);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  animation: editor-up 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes editor-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.editor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--hairline);
}

.editor__head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.editor__body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.editor__foot {
  display: flex;
  gap: 10px;
  padding: 12px 18px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--hairline);
}

.editor__foot .btn--primary { flex: 1; }

.frow {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 6px;
  align-items: center;
}

.frow__opts {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
}

/* iOS-style переключатель (как в Будильнике) */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  border-radius: var(--r-pill);
  background: rgba(120, 120, 128, 0.32);
  transition: background 200ms ease;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1);
}

.switch input:checked + .switch__track {
  background: var(--green);
}

.switch input:checked + .switch__track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .switch__track,
  .switch__track::after { transition: none; }
}

.frow-remove {
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.frow-remove:active { color: var(--red); }

.add-field-btn {
  border: 1px dashed var(--hairline);
  background: transparent;
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.add-field-btn:active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Toast ------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-glass)) saturate(1.8);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(1.8);
  border: 1px solid var(--glass-border);
  color: var(--text-1);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 550;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 200;
  box-shadow: var(--shadow-card);
  max-width: 86vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Offline / mode banners ---------------------------------------------------- */

.mode-banner {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  border-radius: var(--r-md);
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-2);
  background: var(--tint);
}

.mode-banner svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--accent);
}

.mode-banner--warn {
  background: var(--tint-orange);
}

.mode-banner--warn svg { color: var(--orange); }

/* ---- Шторка приватности (при сворачивании приложения) --------------------------- */

body.privacy #app,
body.privacy .editor-backdrop,
body.privacy .alert-backdrop,
body.privacy .sheet {
  filter: blur(22px);
}

/* ---- Reduced motion ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
  .screen,
  .editor-backdrop,
  .editor { animation: none; }
  .toast { transition: none; }
}
