:root {
  --profile2-page-width: min(var(--xui-v2-content-width), calc(100vw - 24px));
  --profile2-focus-ring: color-mix(in srgb, var(--xui-accent) 22%, transparent);
  --xui-v2-bottom-tab-count: 4;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

.profile2-body {
  margin: 0;
  overflow-x: hidden;
  color: var(--xui-ink);
  background: var(--xui-bg-shell);
  font-family: var(--xui-font);
  -webkit-text-size-adjust: 100%;
}

.profile2-shell {
  width: 100%;
  min-height: 100dvh;
  padding:
    max(8px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    calc(var(--xui-v2-bottom-nav-h) + 26px + env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.nav-wrap,
.profile2-panel {
  width: var(--profile2-page-width);
  max-width: 100%;
}

.profile2-shell > .nav-wrap {
  position: sticky;
  top: max(6px, env(safe-area-inset-top));
  z-index: 18;
}

.profile2-panel {
  min-width: 0;
  padding: 2px 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.profile2-panel[hidden],
.profile2-sub-panel[hidden] {
  display: none !important;
}

.profile2-section-head {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.profile2-sub-tabs {
  width: 100%;
  margin: 0 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.profile2-sub-tabs::-webkit-scrollbar {
  display: none;
}

.profile2-sub-tabs button {
  flex: 1 0 max-content;
  white-space: nowrap;
}

.profile2-group + .profile2-group {
  margin-top: 18px;
}

.profile2-group-head > div,
.profile2-card-main,
.profile2-setting-copy,
.profile2-account-copy {
  min-width: 0;
}

.profile2-group-head h3 {
  font-size: var(--xui-text-lg);
  line-height: 1.25;
  font-weight: 850;
}

.profile2-group-head a {
  white-space: nowrap;
}

.profile2-list,
.profile2-settings-stack,
.profile2-install-list {
  display: grid;
  gap: 10px;
}

.profile2-settings-stack {
  gap: 0;
}

.profile2-settings-stack > [data-settings-panel]:not([data-settings-panel="account"]) {
  margin-top: 0;
}

.profile2-list.is-featured {
  grid-template-columns: 1fr;
}

.profile2-app-launcher {
  min-height: 108px;
  padding: 0;
  overflow: hidden;
}

.profile2-app-track {
  min-width: 0;
  min-height: 108px;
  padding: 12px 10px 10px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.profile2-app-track::-webkit-scrollbar {
  display: none;
}

.profile2-app-tile {
  width: 84px;
  min-width: 84px;
  flex: 0 0 84px;
  min-height: 86px;
  padding: 7px 6px;
  border-radius: var(--xui-radius-control);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  color: var(--xui-ink);
  scroll-snap-align: start;
  text-align: center;
  transition: background-color var(--xui-speed) ease, transform var(--xui-speed) ease;
}

.profile2-app-tile:hover {
  background: var(--xui-hover-tint);
  transform: translateY(-1px);
}

.profile2-app-tile .profile2-card-thumb {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--xui-ink) 10%, transparent);
}

.profile2-app-tile strong,
.profile2-app-tile small {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile2-app-tile strong {
  font-size: var(--xui-text-sm);
  line-height: 1.2;
  font-weight: 800;
}

.profile2-app-tile small {
  color: var(--xui-ink-soft);
  font-size: var(--xui-text-xs);
  line-height: 1.15;
}

.profile2-card {
  min-width: 0;
  min-height: 76px;
  padding: 11px 12px;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  color: var(--xui-ink);
  text-decoration: none;
  transition:
    transform var(--xui-speed) ease,
    border-color var(--xui-speed) ease,
    background-color var(--xui-speed) ease,
    box-shadow var(--xui-speed) ease;
}

.profile2-card:hover {
  border-color: color-mix(in srgb, var(--xui-accent) 44%, var(--xui-line-soft));
  background: color-mix(in srgb, var(--xui-accent) 3%, var(--xui-v2-surface-raised));
  box-shadow: var(--xui-v2-shadow-2);
  transform: translateY(-1px);
}

.profile2-card.is-static:hover {
  border-color: var(--xui-line-soft);
  background: var(--xui-v2-surface-raised);
  box-shadow: var(--xui-v2-shadow-1);
  transform: none;
}

.profile2-card.has-actions {
  grid-template-columns: 50px minmax(0, 1fr) auto;
}

.profile2-card.is-static:not(.has-actions) {
  grid-template-columns: 50px minmax(0, 1fr);
}

.profile2-card-thumb {
  width: 50px;
  height: 50px;
  border: var(--xui-border) solid var(--xui-line-soft);
  border-radius: var(--xui-radius-control);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: var(--xui-surface-soft);
}

.profile2-card-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.profile2-card-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--xui-accent-strong);
  font-size: 1.05rem;
  background: var(--xui-accent-soft);
}

.profile2-card-fallback.is-logo {
  background: var(--xui-surface-soft);
}

.profile2-card-fallback.is-logo img {
  width: 60%;
  height: 60%;
  display: block;
  object-fit: contain;
  opacity: 0.2;
}

[data-xui-theme="dark"] .profile2-card-fallback.is-logo img {
  filter: invert(1);
}

.profile2-card.is-service .profile2-card-thumb {
  border-radius: 50%;
}

.profile2-card-main strong,
.profile2-setting-copy strong {
  display: block;
  overflow: hidden;
  color: var(--xui-ink);
  font-size: var(--xui-text-md);
  font-weight: 820;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile2-card-main small,
.profile2-setting-copy small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--xui-ink-soft);
  font-size: var(--xui-text-xs);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile2-card-main p,
.profile2-setting-copy p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--xui-ink-muted);
  display: -webkit-box;
  font-size: var(--xui-text-sm);
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.profile2-card-chevron {
  width: 16px;
  display: grid;
  place-items: center;
  color: var(--xui-ink-soft);
  font-size: 0.74rem;
}

.profile2-card-metrics {
  grid-column: 1 / -1;
  min-width: 0;
  margin-top: 1px;
  padding: 8px 10px;
  border-radius: 9px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 8px;
  background: var(--xui-surface-soft);
}

.profile2-metric {
  min-width: 0;
}

.profile2-metric span,
.profile2-metric strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile2-metric span {
  color: var(--xui-ink-soft);
  font-size: var(--xui-text-xs);
  line-height: 1.2;
}

.profile2-metric strong {
  margin-top: 2px;
  color: var(--xui-ink);
  font-size: var(--xui-text-sm);
  font-weight: 820;
  line-height: 1.2;
}

.profile2-card.is-order .profile2-card-main small,
.profile2-card.is-order .profile2-card-main p,
.profile2-card.is-order .profile2-metric span,
.profile2-card.is-order .profile2-metric strong {
  font-weight: 400;
}

.profile2-card.is-owned-app .profile2-metric strong {
  font-weight: 400;
}

.profile2-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.profile2-section-toggle {
  min-height: 30px;
  padding: 0 2px 0 8px;
  border: 0;
  border-radius: var(--xui-radius-small);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  background: transparent;
  color: var(--xui-ink-muted);
  font: inherit;
  font-size: var(--xui-text-xs);
  font-weight: 700;
}

.profile2-section-toggle:hover {
  background: var(--xui-hover-tint);
  color: var(--xui-accent-strong);
}

.profile2-section-toggle i {
  width: 14px;
  text-align: center;
  transition: transform var(--xui-speed) ease;
}

.profile2-section-toggle.is-expanded i {
  transform: rotate(180deg);
}

.profile2-collapsible {
  min-width: 0;
}

.profile2-empty,
.profile2-loading,
.profile2-error {
  min-height: 66px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--xui-ink-muted);
  font-size: var(--xui-text-sm);
  text-align: center;
}

.profile2-list > .profile2-empty,
.profile2-list > .profile2-loading,
.profile2-list > .profile2-error,
.profile2-app-track > .profile2-empty,
.profile2-app-track > .profile2-loading,
.profile2-app-track > .profile2-error {
  grid-column: 1 / -1;
}

.profile2-app-track > .profile2-empty,
.profile2-app-track > .profile2-loading,
.profile2-app-track > .profile2-error {
  width: 100%;
  flex: 0 0 100%;
}

.profile2-loading i {
  animation: profile2Spin 0.9s linear infinite;
}

.profile2-account-block {
  overflow: hidden;
}

.profile2-account-card {
  min-height: 74px;
  padding: 12px;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.profile2-account-avatar {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--xui-accent-strong);
  background: var(--xui-accent-soft);
  font-size: var(--xui-text-lg);
  font-weight: 850;
}

.profile2-account-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.profile2-account-copy strong,
.profile2-account-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile2-account-copy strong {
  color: var(--xui-ink);
  font-size: var(--xui-text-lg);
  font-weight: 850;
  line-height: 1.25;
}

.profile2-account-copy span {
  margin-top: 3px;
  color: var(--xui-ink-muted);
  font-size: var(--xui-text-xs);
  line-height: 1.25;
}

.profile2-form {
  padding: 12px;
  border-top: var(--xui-border) solid var(--xui-line-soft);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  background: var(--xui-surface-soft);
}

.profile2-form label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--xui-ink-muted);
  font-size: var(--xui-text-xs);
  font-weight: 750;
}

.profile2-form input,
.profile2-form select,
.profile2-token-form input {
  width: 100%;
  min-width: 0;
  min-height: var(--xui-control-h);
  padding: 0 11px;
  border: var(--xui-border) solid var(--xui-line-soft);
  border-radius: var(--xui-radius-control);
  outline: none;
  background-color: var(--xui-v2-surface-raised);
  color: var(--xui-ink);
  font: inherit;
  font-size: var(--xui-text-sm);
  box-shadow: inset 0 1px 1px color-mix(in srgb, var(--xui-ink) 3%, transparent);
}

.profile2-form input:focus,
.profile2-form select:focus,
.profile2-token-form input:focus {
  border-color: var(--xui-accent);
  box-shadow: 0 0 0 3px var(--profile2-focus-ring);
}

.profile2-form-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.profile2-token-form {
  margin: 10px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.profile2-primary-button,
.profile2-danger-button,
.profile2-action-button,
.profile2-mini-button {
  min-height: var(--xui-control-h);
  padding: 0 13px;
  border: var(--xui-border) solid transparent;
  border-radius: var(--xui-radius-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: var(--xui-text-sm);
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.profile2-primary-button {
  background: var(--xui-accent);
  color: var(--xui-accent-ink);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--xui-accent) 24%, transparent);
}

.profile2-danger-button {
  border-color: color-mix(in srgb, var(--xui-danger) 20%, var(--xui-line-soft));
  background: var(--xui-danger-soft);
  color: var(--xui-danger);
}

.profile2-action-button,
.profile2-mini-button {
  border-color: var(--xui-line-soft);
  background: var(--xui-v2-surface-raised);
  color: var(--xui-ink);
}

.profile2-mini-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: var(--xui-text-xs);
}

.profile2-mini-button.is-danger {
  color: var(--xui-danger);
}

.profile2-primary-button:disabled,
.profile2-danger-button:disabled,
.profile2-mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.profile2-preference-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.profile2-preference-card {
  min-width: 0;
  min-height: 64px;
  padding: 11px 12px;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.profile2-preference-card > p {
  margin: 0;
  color: var(--xui-ink);
  font-size: var(--xui-text-sm);
  font-weight: 800;
}

.profile2-option-segment {
  width: 100%;
  max-width: 300px;
  justify-self: end;
}

.profile2-option-segment button {
  flex: 1;
  min-width: 0;
  padding: 0 7px !important;
}

.profile2-swatch-grid {
  width: 100%;
  max-width: 340px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  justify-self: end;
}

.profile2-swatch {
  min-width: 0;
  min-height: 40px;
  border: var(--xui-border) solid var(--xui-line-soft);
  border-radius: var(--xui-radius-control);
  position: relative;
  overflow: hidden;
  background: var(--xui-surface-soft);
  color: transparent;
  font-size: 0;
}

.profile2-swatch::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 6px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.profile2-swatch.is-active {
  border-color: var(--xui-accent);
  box-shadow: 0 0 0 3px var(--profile2-focus-ring);
}

.profile2-install-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.profile2-install-card {
  width: 100%;
  min-width: 0;
  min-height: 94px;
  padding: 11px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 9px;
  appearance: none;
  color: var(--xui-ink);
  font: inherit;
  text-align: left;
  transition: transform var(--xui-speed) ease, box-shadow var(--xui-speed) ease, border-color var(--xui-speed) ease;
}

.profile2-install-card:hover {
  border-color: color-mix(in srgb, var(--xui-accent) 44%, var(--xui-line-soft));
  box-shadow: var(--xui-v2-shadow-2);
  transform: translateY(-1px);
}

.profile2-setting-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--xui-radius-control);
  display: grid;
  place-items: center;
  color: var(--xui-accent-strong);
  background: var(--xui-accent-soft);
}

.profile2-setting-action {
  color: var(--xui-ink-soft);
  font-size: var(--xui-text-sm);
}

.profile2-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--xui-v2-bottom-nav-h) + 16px + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: var(--xui-radius-control);
  background: rgba(22, 24, 29, 0.94);
  color: #ffffff;
  box-shadow: var(--xui-v2-shadow-2);
  font-size: var(--xui-text-sm);
  transform: translateX(-50%);
}

@keyframes profile2Spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 680px) {
  :root {
    --profile2-page-width: calc(100vw - 16px);
  }

  .profile2-shell {
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .profile2-install-list {
    grid-template-columns: 1fr;
  }

  .profile2-install-card {
    min-height: 74px;
  }
}

@media (min-width: 700px) {
  .profile2-list.is-featured {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile2-list.is-featured .profile2-card {
    min-height: 106px;
    grid-template-columns: 44px minmax(0, 1fr) 14px;
    align-content: center;
  }

  .profile2-list.is-featured .profile2-card-thumb {
    width: 44px;
    height: 44px;
  }

  .profile2-list.is-featured .profile2-card-main p {
    -webkit-line-clamp: 2;
  }
}

@media (max-width: 430px) {
  .profile2-card {
    grid-template-columns: 46px minmax(0, 1fr) 14px;
    padding: 10px;
  }

  .profile2-card.has-actions {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .profile2-card.is-static:not(.has-actions) {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .profile2-card-thumb {
    width: 46px;
    height: 46px;
  }

  .profile2-card.has-actions .profile2-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .profile2-account-card {
    grid-template-columns: 46px minmax(0, 1fr) auto;
  }

  .profile2-account-avatar {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }

  .profile2-action-button {
    min-width: 40px;
    width: 40px;
    padding: 0;
  }

  .profile2-action-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
}

@media (max-width: 370px) {
  .profile2-list.is-featured,
  .profile2-preference-grid,
  .profile2-form {
    grid-template-columns: 1fr;
  }

  .profile2-app-track {
    padding-inline: 4px;
  }

  .profile2-form-actions {
    grid-column: auto;
  }

  .profile2-preference-card {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
  }

  .profile2-token-form {
    grid-template-columns: 1fr;
  }
}
