:root {
  --portal-purple: #7138ed;
  --portal-violet: #9a45f7;
  --portal-ink: #111426;
  --portal-muted: #5d6880;
  --portal-glass: rgba(250, 252, 255, .82);
  --portal-border: rgba(255, 255, 255, .82);
  --portal-shadow: 0 22px 55px rgba(39, 73, 128, .18);
}

body.portal-mode {
  min-height: 100vh;
  overflow-x: hidden;
  background: #c9ecff;
  color: var(--portal-ink);
}

.portal-app-hidden { display: none !important; }
.portal-shell[hidden], .portal-guest[hidden], .portal-member[hidden], .portal-loading[hidden] { display: none !important; }

.portal-shell {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  color: var(--portal-ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.portal-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: #c8ecff url("./assets/digital-self-portal-bg-v1.png?v=57") center / cover no-repeat;
  transform: scale(1.006);
}

.portal-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(250, 253, 255, .94) 0%, rgba(250, 253, 255, .76) 25%, rgba(246, 251, 255, .13) 53%, rgba(238, 249, 255, .05) 100%),
    linear-gradient(0deg, rgba(224, 241, 252, .9) 0%, transparent 35%);
}

.portal-shell.portal-authenticated::before {
  background: linear-gradient(180deg, rgba(220, 244, 255, .08), rgba(222, 240, 248, .14) 55%, rgba(23, 65, 60, .25));
}

.portal-header {
  position: relative;
  z-index: 5;
  min-height: 96px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 28px;
  padding: 22px clamp(24px, 3.2vw, 58px);
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 10px;
  color: #070a12;
  text-decoration: none;
  font-size: 21px;
  font-weight: 950;
  line-height: .98;
  letter-spacing: -.035em;
}

.portal-brand-orbit {
  position: relative;
  width: 50px;
  height: 42px;
  display: block;
  transform: rotate(-12deg);
}

.portal-brand-orbit::before {
  content: "";
  position: absolute;
  inset: 3px 7px;
  border-radius: 50%;
  background: linear-gradient(145deg, #5ebcff, #6d35ec 62%, #a240ee);
  box-shadow: inset 8px -7px 16px rgba(29, 19, 148, .2), 0 7px 18px rgba(83, 54, 225, .25);
}

.portal-brand-orbit::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 16px;
  height: 13px;
  border: 3px solid #7651f0;
  border-top-color: rgba(137, 228, 255, .85);
  border-radius: 50%;
}

.portal-brand-orbit i {
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 8px;
  right: 3px;
  top: 10px;
  border-radius: 50%;
  background: #9df5ff;
  box-shadow: 0 0 12px #5fefff;
}

.portal-desktop-nav {
  display: flex;
  align-items: center;
  gap: clamp(24px, 3.4vw, 62px);
}

.portal-desktop-nav a {
  color: #11182b;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.portal-desktop-nav a:hover { color: var(--portal-purple); }

.portal-guest-actions, .portal-member-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-login-link, .portal-primary-link {
  min-width: 112px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 999px;
  color: #171b28;
  text-decoration: none;
  font-weight: 850;
}

.portal-login-link {
  border: 1px solid rgba(255,255,255,.85);
  background: rgba(249,252,255,.7);
  backdrop-filter: blur(16px);
}

.portal-primary-link, .portal-cta {
  color: white;
  background: linear-gradient(135deg, #7050f7, #8e2ee7);
  box-shadow: 0 14px 34px rgba(103, 47, 225, .26);
}

.portal-primary-link { min-width: 148px; }
.portal-primary-link:hover, .portal-cta:hover { transform: translateY(-2px); }

.portal-resource-pill {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 17px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 999px;
  background: rgba(246,252,255,.62);
  box-shadow: 0 10px 25px rgba(50,89,134,.12);
  backdrop-filter: blur(16px);
  font-size: 15px;
}

.portal-resource-pill strong { font-size: 18px; }
.portal-icon-button, .portal-avatar-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 50%;
  background: rgba(246,252,255,.65);
  color: #121725;
  cursor: pointer;
}
.portal-icon-button { font-size: 10px; }
.portal-avatar-button { padding: 0; overflow: hidden; }
.portal-avatar-button img { width: 100%; height: 100%; object-fit: cover; }

.portal-loading {
  min-height: calc(100svh - 96px);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: #303a50;
}

.portal-loader {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(108, 57, 231, .18);
  border-top-color: var(--portal-purple);
  border-radius: 50%;
  animation: portal-spin .8s linear infinite;
}

@keyframes portal-spin { to { transform: rotate(360deg); } }

.portal-guest {
  min-height: calc(100svh - 96px);
  display: grid;
  grid-template-rows: minmax(500px, 1fr) auto auto;
  align-content: stretch;
  gap: 22px;
  padding: 18px clamp(34px, 5.6vw, 90px) clamp(34px, 6vh, 66px);
}

.portal-hero {
  width: min(610px, 47vw);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding-bottom: 18px;
}

.portal-kicker {
  margin: 0 0 18px;
  color: #6740d9;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .16em;
}

.portal-hero h1 {
  margin: 0;
  color: #080a11;
  font-size: clamp(44px, 4.2vw, 68px);
  line-height: 1.11;
  letter-spacing: -.055em;
}

.portal-hero h1 span {
  color: transparent;
  background: linear-gradient(90deg, #356cf3, #8535e6);
  background-clip: text;
  -webkit-background-clip: text;
}

.portal-lead {
  margin: 18px 0 0;
  color: #333b4c;
  font-size: clamp(14px, 1.15vw, 18px);
  line-height: 1.75;
}

.portal-hero-actions { display: flex; gap: 18px; margin-top: 28px; }
.portal-cta, .portal-secondary-cta {
  min-width: 184px;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 900;
  transition: transform .18s ease, box-shadow .18s ease;
}
.portal-cta b { margin-left: 8px; font-size: 22px; }
.portal-secondary-cta {
  border: 1px solid rgba(255,255,255,.8);
  background: rgba(244,249,252,.64);
  color: #2c3340;
  backdrop-filter: blur(15px);
}
.portal-social-proof { display: flex; align-items: center; gap: 16px; margin-top: 28px; color: #30394c; font-size: 14px; }
.portal-face-stack { display: flex; }
.portal-face-stack img { width: 38px; height: 38px; margin-right: -9px; border: 3px solid rgba(247,252,255,.95); border-radius: 50%; object-fit: cover; background: #dcecff; }

.portal-feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.portal-feature-grid article {
  min-height: 134px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 23px clamp(18px, 2vw, 30px);
  border: 1px solid var(--portal-border);
  border-radius: 24px;
  background: var(--portal-glass);
  box-shadow: var(--portal-shadow);
  backdrop-filter: blur(18px);
}
.portal-feature-icon { font-size: 43px; font-weight: 900; line-height: 1; }
.portal-feature-icon.purple { color: #7437ed; }.portal-feature-icon.green { color: #27b878; }.portal-feature-icon.orange { color: #ff722e; }.portal-feature-icon.blue { color: #4168f4; }
.portal-feature-grid h2 { margin: 0 0 7px; font-size: 18px; color: #5f2ee7; }
.portal-feature-grid article:nth-child(2) h2 { color: #1c9f71; }.portal-feature-grid article:nth-child(3) h2 { color: #fa6b26; }.portal-feature-grid article:nth-child(4) h2 { color: #3860eb; }
.portal-feature-grid p { margin: 0; color: #3e4656; font-size: 13px; line-height: 1.65; }

.portal-stats {
  min-height: 108px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  border: 1px solid var(--portal-border);
  border-radius: 24px;
  background: rgba(249,252,255,.85);
  box-shadow: var(--portal-shadow);
  backdrop-filter: blur(18px);
}
.portal-stats > div { display: flex; align-items: center; justify-content: center; gap: 18px; min-width: 0; padding: 14px 20px; border-right: 1px solid rgba(77,102,134,.15); }
.portal-stats > div:last-child { border-right: 0; }
.portal-stats > div > span { color: #7440ea; font-size: 28px; }
.portal-stats strong { color: #111522; font-size: clamp(17px, 1.45vw, 24px); white-space: nowrap; }
.portal-stats small { display: block; margin-top: 4px; color: #4c5565; font-size: 11px; font-weight: 500; }

.portal-member {
  min-height: calc(100svh - 96px);
  display: grid;
  grid-template-columns: minmax(420px, .95fr) minmax(430px, .88fr);
  grid-template-areas:
    "intro actions"
    "self actions"
    "activity today"
    "dock today"
    "bottom bottom";
  grid-template-rows: auto minmax(280px, 1fr) minmax(190px, auto) auto auto;
  gap: 16px clamp(28px, 4vw, 62px);
  align-content: center;
  padding: 22px clamp(34px, 4vw, 70px) 24px;
}
.portal-member-intro { grid-area: intro; align-self: end; }
.portal-member-intro p { margin: 0; font-size: clamp(32px, 3vw, 48px); font-weight: 950; letter-spacing: -.045em; }
.portal-member-intro p::first-line { color: #5224c9; }
.portal-member-intro span { display: block; margin-top: 10px; color: #465063; font-size: 16px; }

.portal-self-card, .portal-activity-card, .portal-today-card {
  border: 1px solid var(--portal-border);
  background: rgba(249,252,255,.82);
  box-shadow: var(--portal-shadow);
  backdrop-filter: blur(20px);
}
.portal-self-card {
  grid-area: self;
  position: relative;
  min-height: 278px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 39%;
  border-radius: 26px;
  padding: 25px 22px 20px 28px;
}
.portal-self-card::after { content: ""; position: absolute; right: -10%; bottom: -40%; width: 58%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(133,70,238,.17), transparent 65%); }
.portal-self-copy { position: relative; z-index: 2; min-width: 0; }
.portal-self-copy > p { margin: 0; font-size: 18px; font-weight: 800; }
.portal-self-copy > p strong { font-size: 22px; }
.portal-self-copy > span { display: block; margin: 8px 0 23px; color: #3e4654; font-size: 12px; }
.portal-self-copy > span i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #22d962; }
.portal-self-copy > span b { color: #272d38; }
.portal-meter { margin-bottom: 14px; }
.portal-meter label { display: flex; justify-content: space-between; color: #455064; font-size: 11px; }
.portal-meter > i { display: block; width: 100%; height: 5px; margin-top: 7px; overflow: hidden; border-radius: 99px; background: #dbe6ef; }
.portal-meter > i b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#7543e9,#9d48ee); }
.portal-self-copy > button { width: 100%; min-height: 45px; border: 0; border-radius: 999px; background: linear-gradient(135deg,#7336e9,#9041e8); color: white; font-weight: 850; cursor: pointer; }
.portal-self-card > img { position: relative; z-index: 1; width: 165%; max-width: none; align-self: end; justify-self: center; transform: translateX(-15%); filter: drop-shadow(0 14px 16px rgba(31,49,83,.22)); }

.portal-activity-card { grid-area: activity; border-radius: 24px; padding: 18px 20px; }
.portal-activity-card header, .portal-today-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.portal-activity-card header strong, .portal-today-card header strong { font-size: 15px; }
.portal-activity-card header button, .portal-today-card header button { border: 0; background: transparent; color: #687285; cursor: pointer; }
#portalActivityList { display: grid; gap: 7px; }
.portal-activity-item { min-height: 45px; display: grid; grid-template-columns: 28px minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 13px; background: rgba(255,255,255,.65); color: #242a35; font-size: 12px; }
.portal-activity-item time { color: #8992a0; }

.portal-member-actions-grid { grid-area: actions; display: grid; grid-template-rows: repeat(4, minmax(88px, 1fr)); gap: 13px; }
.portal-member-actions-grid button {
  display: grid;
  grid-template-columns: 72px minmax(0,1fr) 42px;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 24px;
  color: white;
  text-align: left;
  box-shadow: 0 17px 35px rgba(37, 82, 126, .16);
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease;
}
.portal-member-actions-grid button:hover { transform: translateY(-2px); filter: saturate(1.1); }
.portal-member-actions-grid .world { background: linear-gradient(135deg,#742be5,#a845ee); }
.portal-member-actions-grid .create { background: linear-gradient(135deg,#6bbd49,#8bd45c); }
.portal-member-actions-grid .friends { background: linear-gradient(135deg,#3687e9,#62a9f7); }
.portal-member-actions-grid .market { background: linear-gradient(135deg,#f1a41e,#f7bf48); }
.portal-member-actions-grid button > span { font-size: 42px; text-align: center; }
.portal-member-actions-grid strong { font-size: 21px; }
.portal-member-actions-grid small { display: block; margin-top: 4px; font-size: 12px; font-weight: 500; }
.portal-member-actions-grid button > b { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.88); color: #202636; font-size: 20px; }

.portal-today-card { grid-area: today; align-self: end; border-radius: 24px; padding: 18px 20px; }
.portal-today-card > div { display: grid; grid-template-columns: 62px minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 8px; border-radius: 15px; background: rgba(255,255,255,.6); }
.portal-event-art { width: 62px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(135deg,#66c4ee,#8d5ae8); font-size: 27px; }
.portal-today-card strong { font-size: 13px; }.portal-today-card small { display: block; margin-top: 4px; font-weight: 500; }.portal-today-card time { padding: 8px 11px; border-radius: 999px; background: #dfd0ff; color: #6a39dc; font-size: 11px; font-weight: 800; }

.portal-quick-dock { grid-area: dock; justify-self: end; display: flex; align-items: center; gap: 9px; padding: 9px 18px; border: 1px solid var(--portal-border); border-radius: 999px; background: rgba(249,252,255,.82); box-shadow: var(--portal-shadow); backdrop-filter: blur(18px); }
.portal-quick-dock button { width: 64px; display: grid; justify-items: center; gap: 3px; border: 0; background: transparent; color: #2f3642; font-size: 22px; cursor: pointer; }.portal-quick-dock span { font-size: 10px; }

.portal-bottom-nav { grid-area: bottom; justify-self: center; width: min(840px, 75vw); min-height: 72px; display: grid; grid-template-columns: repeat(5,1fr); align-items: center; padding: 7px; border: 1px solid var(--portal-border); border-radius: 999px; background: rgba(248,249,243,.83); box-shadow: 0 20px 50px rgba(32,60,74,.24); backdrop-filter: blur(20px); }
.portal-bottom-nav button { min-height: 56px; border: 0; border-radius: 999px; background: transparent; color: #30353e; font-size: 24px; cursor: pointer; }.portal-bottom-nav button span { margin-left: 8px; font-size: 15px; }.portal-bottom-nav .active { border: 2px solid #8e50ed; background: rgba(255,255,255,.75); color: #6630dc; }.portal-bottom-nav .add { justify-self: center; width: 58px; color: white; background: linear-gradient(135deg,#7442ed,#8e3beb); box-shadow: 0 9px 22px rgba(105,51,222,.32); font-size: 34px; }

.portal-notice { position: fixed; z-index: 20; left: 50%; bottom: 26px; max-width: min(520px, calc(100vw - 34px)); padding: 12px 18px; border-radius: 999px; background: rgba(21,27,46,.9); color: white; box-shadow: 0 14px 38px rgba(0,0,0,.24); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s ease; }
.portal-notice.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 1100px) {
  .portal-header { grid-template-columns: 1fr auto; }
  .portal-desktop-nav { display: none; }
  .portal-hero { width: min(570px, 58vw); }
  .portal-feature-grid { grid-template-columns: repeat(2,1fr); }
  .portal-stats { grid-template-columns: repeat(3,1fr); }
  .portal-stats > div:nth-child(3) { border-right: 0; }
  .portal-member { grid-template-columns: minmax(340px,1fr) minmax(350px,.9fr); gap: 15px 22px; }
}

@media (max-width: 820px) {
  .portal-shell { overflow: auto; }
  .portal-header { position: relative; min-height: 78px; padding: 15px 18px; }
  .portal-brand { font-size: 16px; }.portal-brand-orbit { width: 42px; height: 36px; }
  .portal-primary-link { min-width: 105px; }.portal-login-link { min-width: 76px; }
  .portal-member-actions .portal-resource-pill { display: none; }
  .portal-guest { min-height: auto; grid-template-rows: auto; padding: 54px 18px 30px; }
  .portal-hero { width: 100%; min-height: 620px; justify-content: flex-start; padding-top: 40px; }
  .portal-shell::before { background: linear-gradient(180deg,rgba(249,253,255,.9),rgba(249,253,255,.38) 58%,rgba(226,241,250,.82)); }
  .portal-backdrop { background-position: 61% center; }
  .portal-hero h1 { font-size: clamp(39px,11vw,56px); }.portal-lead br { display: none; }
  .portal-feature-grid { grid-template-columns: 1fr; }.portal-feature-grid article { min-height: 108px; }
  .portal-stats { grid-template-columns: repeat(2,1fr); }.portal-stats > div { border-bottom: 1px solid rgba(77,102,134,.12); }.portal-stats > div:nth-child(even) { border-right: 0; }.portal-stats > div:last-child { grid-column: 1/-1; }
  .portal-member { min-height: auto; grid-template-columns: 1fr; grid-template-areas: "intro" "self" "actions" "activity" "today" "dock" "bottom"; grid-template-rows: auto; padding: 46px 18px 110px; }
  .portal-member-intro p { font-size: 34px; }.portal-member-actions-grid { grid-template-rows: repeat(4,110px); }
  .portal-quick-dock { justify-self: stretch; justify-content: space-around; }
  .portal-bottom-nav { position: fixed; z-index: 10; left: 12px; right: 12px; bottom: 12px; width: auto; min-height: 66px; }.portal-bottom-nav button { font-size: 20px; }.portal-bottom-nav button span { display: block; margin: 2px 0 0; font-size: 9px; }.portal-bottom-nav .add { width: 50px; height: 50px; min-height: 50px; }
}

@media (max-width: 520px) {
  .portal-guest-actions { gap: 7px; }.portal-login-link, .portal-primary-link { min-height: 40px; font-size: 12px; }.portal-primary-link { min-width: 84px; }.portal-login-link { min-width: 56px; }
  .portal-member-actions { gap: 6px; }.portal-icon-button, .portal-avatar-button { width: 40px; height: 40px; }
  .portal-kicker { display: none; }.portal-hero { min-height: 560px; padding-top: 24px; }.portal-hero-actions { width: 100%; display: grid; grid-template-columns: 1fr; }.portal-cta, .portal-secondary-cta { min-height: 52px; }.portal-social-proof { align-items: flex-start; flex-direction: column; }
  .portal-self-card { grid-template-columns: minmax(0,1fr) 32%; padding-left: 20px; }.portal-self-card > img { width: 210%; transform: translateX(-28%); }
  .portal-member-actions-grid button { grid-template-columns: 50px minmax(0,1fr) 36px; padding: 12px 15px; gap: 10px; border-radius: 20px; }.portal-member-actions-grid button > span { font-size: 31px; }.portal-member-actions-grid strong { font-size: 17px; }.portal-member-actions-grid button > b { width: 34px; height: 34px; }
  .portal-quick-dock { padding: 8px 5px; }.portal-quick-dock button { width: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .portal-loader { animation-duration: 1.8s; }
  .portal-primary-link, .portal-cta, .portal-member-actions-grid button { transition: none; }
}
