:root {
  --bg: #05070d;
  --panel: rgba(13, 18, 31, 0.78);
  --panel-strong: rgba(18, 26, 44, 0.96);
  --line: rgba(255,255,255,0.11);
  --text: #edf4ff;
  --muted: #94a3b8;
  --accent: #67e8f9;
  --accent2: #8b5cf6;
  --danger: #ff4d6d;
  --good: #4ade80;
  --shadow: 0 24px 80px rgba(0,0,0,0.42);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(103,232,249,0.17), transparent 28%),
    radial-gradient(circle at bottom left, rgba(139,92,246,0.18), transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  color: var(--text);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 36px 36px;
}

.screen { display: none; min-height: 100dvh; position: relative; z-index: 1; }
.screen.active { display: block; }

.auth-screen {
  display: none;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.auth-screen.active { display: grid; }

.auth-card {
  width: min(420px, 100%);
  padding: 28px 20px 24px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  text-align: center;
}

.auth-orb {
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(103,232,249,0.95), rgba(139,92,246,0.84)),
    radial-gradient(circle, white, transparent);
  box-shadow: 0 0 42px rgba(103,232,249,.25);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
.auth-card h1 { margin-bottom: 4px; font-size: 38px; letter-spacing: -0.04em; }
.muted { color: var(--muted); line-height: 1.5; }

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 25px 0 12px;
}

.pin-dots span {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.06);
  transition: .2s ease;
}

.pin-dots span.filled {
  background: var(--accent);
  box-shadow: 0 0 18px rgba(103,232,249,.7);
}

.auth-message {
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.auth-card.error, .mini-auth.error {
  animation: shake .32s ease;
  border-color: rgba(255,77,109,.62);
}

.auth-card.error .pin-dots span.filled { background: var(--danger); box-shadow: 0 0 18px rgba(255,77,109,.6); }
.auth-card.success .pin-dots span.filled { background: var(--good); box-shadow: 0 0 18px rgba(74,222,128,.5); }

@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.keypad button {
  min-height: 62px;
  border-radius: 22px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 22px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.keypad button:active { transform: scale(.96); background: rgba(103,232,249,.16); }
.ghost-key { font-size: 13px !important; color: var(--muted); }

.app-screen {
  padding-top: max(14px, env(safe-area-inset-top));
  padding-left: 6px;
  padding-right: 8px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px 16px;
  backdrop-filter: blur(18px);
}

.topbar h2 { margin: 0; font-size: 28px; letter-spacing: -0.04em; }

.icon-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  border: 1px solid var(--line);
  font-size: 22px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.danger-icon {
  background: rgba(255,77,109,.13);
  border-color: rgba(255,77,109,.35);
}

.side-rail {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(7, 10, 18, .72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.rail-btn {
  width: 58px;
  min-height: 58px;
  border-radius: 20px;
  background: transparent;
  border: 1px solid transparent;
  display: grid;
  place-items: center;
  gap: 2px;
}

.rail-btn span { font-size: 20px; }
.rail-btn small { color: var(--muted); font-size: 9px; font-weight: 700; }
.rail-btn.active {
  background: linear-gradient(135deg, rgba(103,232,249,.2), rgba(139,92,246,.22));
  border-color: rgba(103,232,249,.26);
}
.rail-btn.active small { color: var(--text); }

.page {
  display: none;
  padding-left: 6px;
  padding-right: 8px;
  margin-left: 86px;
  max-width: none;
  width: calc(100vw - 110px);
  animation: fadeUp .22s ease both;
}
.page.active { display: block; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

.hero-panel, .info-card, .stat-card, .folder-card, .modal-card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: 0 16px 60px rgba(0,0,0,.25);
}

.hero-panel {
  min-height: 240px;
  width: 100%;
  border-radius: 34px;
  padding: 24px;
  display: grid;
  align-content: space-between;
  overflow: hidden;
}

.hero-panel h1 { font-size: clamp(31px, 9vw, 48px); line-height: .94; letter-spacing: -0.07em; }

.primary-btn, .secondary-btn, .danger-btn {
  min-height: 46px;
  border-radius: 17px;
  padding: 0 15px;
  font-weight: 800;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #031018;
  box-shadow: 0 10px 30px rgba(103,232,249,.18);
}

.secondary-btn { background: rgba(255,255,255,.08); border: 1px solid var(--line); }
.danger-btn { background: rgba(255,77,109,.14); border: 1px solid rgba(255,77,109,.35); color: #ffd3db; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin: 14px 0;
}

.stat-card {
  border-radius: 24px;
  padding: 16px 10px;
  text-align: center;
}

.stat-card span { font-size: 25px; font-weight: 900; }
.stat-card p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.info-card { border-radius: 28px; padding: 18px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2 { margin-bottom: 2px; font-size: 30px; letter-spacing: -0.05em; }

.folder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.folder-card {
  min-height: 170px;
  border-radius: 28px;
  padding: 14px;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.folder-thumb {
  width: 100%;
  height: 88px;
  border-radius: 20px;
  margin-bottom: 10px;
  background:
    linear-gradient(135deg, rgba(103,232,249,.14), rgba(139,92,246,.16)),
    rgba(255,255,255,.05);
  display: grid;
  place-items: center;
  color: var(--muted);
  overflow: hidden;
}

.folder-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.folder-card h3 {
  margin-bottom: 3px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.folder-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 16px;
  background: rgba(0,0,0,.58);
  backdrop-filter: blur(10px);
}

.modal.active { display: grid; }

.modal-card {
  width: min(560px, 100%);
  max-height: min(86dvh, 760px);
  overflow: auto;
  border-radius: 30px;
  padding: 18px;
  background: var(--panel-strong);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-head h2 { margin: 0; letter-spacing: -0.04em; }

.folder-actions {
  display: flex;
  overflow-x: auto;
  gap: 9px;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.folder-actions button { white-space: nowrap; }

.item-list { display: grid; gap: 10px; }

.item-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px;
  background: rgba(255,255,255,.055);
}

.item-card img.photo-item {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 18px;
  display: block;
  margin-bottom: 9px;
}

.item-card h3 { margin-bottom: 5px; }
.item-card p, .item-card a { color: var(--muted); overflow-wrap: anywhere; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.text-input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.07);
  border-radius: 18px;
  color: var(--text);
  padding: 14px;
  outline: none;
  margin-bottom: 10px;
}

textarea { min-height: 130px; resize: vertical; }
.row { display: flex; gap: 10px; justify-content: flex-end; }

.gallery {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  background: rgba(0,0,0,.94);
  touch-action: pan-y;
}

.gallery.active { display: grid; }

.gallery img {
  max-width: 100vw;
  max-height: 82dvh;
  object-fit: contain;
  user-select: none;
}

.gallery-close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: rgba(255,255,255,.13);
  font-size: 30px;
}

.gallery-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 74px;
  border-radius: 20px;
  background: rgba(255,255,255,.12);
  font-size: 48px;
  line-height: 0;
}

.gallery-nav.left { left: 12px; }
.gallery-nav.right { right: 12px; }

#galleryCounter {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  color: var(--muted);
  margin: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120px);
  z-index: 80;
  min-width: 210px;
  max-width: 90vw;
  padding: 13px 16px;
  border-radius: 18px;
  background: rgba(10,16,29,.94);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: center;
  box-shadow: var(--shadow);
  transition: .25s ease;
}

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

.empty-state {
  padding: 24px;
  border: 1px dashed rgba(255,255,255,.16);
  border-radius: 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 380px) {
  .folder-grid { grid-template-columns: 1fr; }
  .side-rail { gap: 6px; padding: 7px; }
  .rail-btn { width: 52px; min-height: 52px; }
  .page {
  display: none;
  padding-left: 6px;
  padding-right: 8px;
  margin-left: 86px;
  max-width: none;
  width: calc(100vw - 110px);
  animation: fadeUp .22s ease both;
}
}


html,
body {
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

.auth-screen,
.app-screen,
.modal,
.gallery {
  touch-action: manipulation;
}

.keypad,
.keypad button,
.icon-btn,
.primary-btn,
.secondary-btn,
.danger-btn,
.rail-btn {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
