* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--land-bg);
  color: var(--land-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.view { display: none; min-height: 100dvh; }
.view.active { display: block; }

/* ============ ЭКРАН 1: ЛЕНДИНГ ============ */
#screen-landing {
  background: var(--land-bg);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
#screen-landing.active { display: flex; }

.land-wrap {
  width: min(600px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  animation: landIn .5s ease both;
}
@keyframes landIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.land-logo {
  display: flex;
  align-items: baseline;
  font-size: 54px;
  font-weight: 600;
  letter-spacing: -5px;
  line-height: 1;
}
.g1 { color: #4285f4; }
.g2 { color: #ea4335; }
.g3 { color: #fbbc05; }
.g4 { color: #4285f4; }
.g5 { color: #34a853; }
.g6 { color: #ea4335; }

.land-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 4px 4px 4px 20px;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 24px;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.10);
  transition: box-shadow .15s ease;
}
.land-search:focus-within {
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.30);
  border-color: rgba(26, 115, 232, 0.4);
}

.search-ic {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: #9aa0a6;
}

#search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--land-text);
  padding: 10px 0;
}
#search-input::selection { background: var(--google-blue); color: #fff; }

#search-btn {
  flex: 0 0 auto;
  border: none;
  background: var(--google-blue);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s ease;
}
#search-btn:hover { background: #1765cc; }
#search-btn:active { background: #1558b0; }

.land-hint {
  font-size: 13px;
  color: var(--land-muted);
  text-align: center;
}

/* ============ ЭКРАН 2: ДАШБОРД ============ */
#screen-dash {
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(86, 240, 196, 0.06), transparent 55%),
    var(--dash-bg);
  color: var(--dash-text);
}

.dash-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  padding-top: calc(16px + env(safe-area-inset-top));
}
.dash-name {
  font-size: 18px;
  font-weight: 700;
}
.dash-mail {
  color: var(--dash-muted);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  margin-left: 8px;
  border-bottom: 1px dashed var(--dash-border);
}
.dash-mail:hover { color: var(--accent-2); border-bottom-color: var(--accent-2); }

/* Языковая пилюля */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--dash-border);
  background: var(--dash-panel);
  cursor: pointer;
  font-family: inherit;
}
.lang-opt {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .4px;
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--dash-muted);
  transition: background .2s ease, color .2s ease;
}
.lang-opt.active {
  background: var(--accent);
  color: #fff;
}

.dash-body {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 6px var(--accent-soft);
  background: var(--dash-panel);
}
.avatar-fallback {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 48px;
  font-weight: 800;
  color: var(--accent-2);
  border: 3px dashed var(--accent);
  background: var(--dash-panel);
}

.dash-tagline {
  margin-top: 20px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
}
.dash-about {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--dash-muted);
  max-width: 52ch;
}

.storage-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  margin-top: 28px;
}
.storage-folder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 12px;
  border-radius: 18px;
  background: var(--dash-panel);
  border: 1px solid var(--dash-border);
  color: var(--dash-text);
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.storage-folder:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .25);
}
.storage-folder:active { transform: translateY(-1px); }
.sf-icon { font-size: 30px; }
.sf-label { font-size: 15px; font-weight: 600; }
.sf-count {
  font-size: 12px;
  color: var(--dash-muted);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 999px;
}

/* ============ ОКНО-ХРАНИЛИЩЕ ============ */
.storage-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
}
.storage-modal[hidden] { display: none; }
.storage-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 4, 12, 0.6);
  backdrop-filter: blur(4px);
}
.storage-window {
  position: relative;
  width: 100%;
  max-height: 86dvh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  background: var(--dash-panel);
  border: 1px solid var(--dash-border);
  border-bottom: none;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .45);
  animation: sheetUp .28s ease both;
}
@keyframes sheetUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.sw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
  position: sticky;
  top: 0;
  background: var(--dash-panel);
  z-index: 1;
}
.sw-title { font-size: 17px; font-weight: 700; }
.sw-close {
  border: none;
  background: var(--accent-soft);
  color: var(--dash-text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
}
.sw-list {
  list-style: none;
  padding: 4px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.storage-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--dash-border);
  background: var(--dash-bg);
}
.si-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}
.si-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #06231a;
}
.si-desc { font-size: 13px; line-height: 1.45; color: var(--dash-muted); }
.si-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.si-action {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  transition: filter .15s ease;
}
.si-action:hover { filter: brightness(1.12); }
.si-action.ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

/* ============ ПОРТАЛ (rick & morty) ============ */
#portal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 9, .85);
  opacity: 0;
  transition: opacity .3s ease;
  overflow: hidden;
  cursor: none;
}
#portal.open {
  display: flex;
  opacity: 1;
}
.portal-frame {
  width: min(82vmin, 560px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  transform: scale(.2) rotate(-14deg);
  transition: transform .55s cubic-bezier(.22, 1, .36, 1);
  box-shadow:
    0 0 0 14px rgba(86, 240, 196, .16),
    0 0 90px 24px rgba(86, 240, 196, .45),
    inset 0 0 60px rgba(0, 0, 0, .55);
}
#portal.open .portal-frame {
  transform: scale(1.05) rotate(0deg);
}
.portal-gif {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.25) brightness(1.05);
}
#portal.flash {
  background: #fff;
  transition: background .16s ease;
}
#portal.flash .portal-frame {
  opacity: 0;
  transform: scale(1.9);
  transition: opacity .16s ease, transform .2s ease;
}

body.portaling {
  filter: saturate(.6) contrast(1.15) blur(6px);
  transition: filter .3s ease;
}

/* ============ АДАПТИВ ============ */
@media (min-width: 700px) {
  .dash-body { padding-top: 20px; }
  .storage-modal { align-items: center; padding: 20px; }
  .storage-window { border-radius: 22px; border-bottom: 1px solid var(--dash-border); max-width: 480px; }
  .land-logo { font-size: 62px; }
}

/* ============ ФОКУС ============ */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
  body.portaling { filter: none; }
}