/* Account surfaces use the same glass, corners, and instrumentation as the workspace. */
#terrantir-menu:not(.atlas-workspace-nav) {
  padding-right: 345px;
}

#terrantir-menu #terrantir-profile-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 34px;
  min-height: 36px;
  padding: 0;
  color: #e0f4fa;
  background: #152737d9;
  border: 1px solid var(--workspace-edge, #40576c);
  border-radius: 4px;
  cursor: pointer;
}

#terrantir-menu #terrantir-profile-menu svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#terrantir-menu #terrantir-profile-menu > .atlas-profile-label {
  display: none;
}

#terrantir-menu #terrantir-profile-menu:is(:hover, [aria-expanded='true']) {
  color: var(--atlas-amber, #ffc47a);
  background: var(--atlas-amber-surface, #302921);
  border-color: var(--atlas-amber-edge, #906935);
}

#terrantir-menu #terrantir-wallet-connect[data-connected='true'] {
  border-color: #5f989d;
  color: #bceff0;
  background: #153440;
}

@media (min-width: 1101px) {
  #terrantir-menu.atlas-workspace-nav .terrantir-menu__identity #terrantir-profile-menu {
    flex: 0 0 auto;
    width: auto;
    padding-inline: 9px;
    font: 600 11px/1 var(--console-mono, ui-monospace, monospace);
  }

  #terrantir-menu.atlas-workspace-nav #terrantir-profile-menu > .atlas-profile-label {
    display: inline;
  }
}

@media (max-width: 720px) {
  #terrantir-menu:not(.atlas-workspace-nav) { padding-right: 8px; }
  #terrantir-menu:not(.atlas-workspace-nav) .terrantir-menu__windows { right: 260px; }
}

@media (max-width: 480px) {
  #terrantir-menu:not(.atlas-workspace-nav) .terrantir-menu__identity .terrantir-menu__social { display: none; }
  #terrantir-menu:not(.atlas-workspace-nav) .terrantir-menu__windows { right: 170px; }
}

#terrantir-profile-panel {
  --profile-top: calc(var(--workspace-header-end, 52px) + 10px);
  --profile-inline-start: max(10px, env(safe-area-inset-left));
  --profile-inline-end: max(10px, env(safe-area-inset-right));
  --profile-bottom: max(calc(2vh + 7.6rem), env(safe-area-inset-bottom));
  --profile-edge: var(--workspace-edge, #34495e);
  --profile-amber: var(--atlas-amber, #ffc47a);
  --profile-muted: #aac0d0;
  --profile-focus: var(--workspace-focus, #b9eaff);
  --profile-mono: var(--console-mono, ui-monospace, monospace);
  --profile-well: #0a1724aa;

  position: fixed;
  z-index: 1200;
  inset: var(--profile-top) var(--profile-inline-end) auto auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(474px, calc(100vw - var(--profile-inline-start) - var(--profile-inline-end)));
  max-height: calc(100dvh - var(--profile-top) - var(--profile-bottom));
  padding: 0;
  overflow: hidden;
  color: #eaf5fb;
  color-scheme: dark;
  background:
    var(--console-brackets, linear-gradient(var(--profile-amber), var(--profile-amber)) left 3px top 3px / 14px 1px no-repeat),
    var(--console-decal, repeating-linear-gradient(128deg, #96def66b 0 1px, transparent 1px 4px) right 18px top 5px / 20px 4px no-repeat),
    var(--console-grid, none),
    var(--console-face, linear-gradient(150deg, #182c3e, #0b1a28 55%, #07131d));
  border: 1px solid var(--console-edge, #55778d);
  border-top-color: var(--profile-amber);
  border-radius: var(--console-radius, 3px 11px 3px 3px);
  box-shadow: var(--console-shadow, 0 11px 30px #0009);
  -webkit-backdrop-filter: var(--console-frost, blur(12px) saturate(130%));
  backdrop-filter: var(--console-frost, blur(12px) saturate(130%));
  font: 13px/1.5 var(--workspace-font, Inter, system-ui, sans-serif);

  & *,
  & *::before {
    box-sizing: inherit;
  }

  & [hidden] {
    display: none;
  }

  & :is(button, input, select, textarea, progress) {
    font: inherit;
  }

  & button {
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid var(--profile-edge);
    border-radius: 4px;
    background: #14283bdb;
    color: inherit;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
  }

  & button:not(:disabled):hover {
    color: #f0faff;
    border-color: #7aacbf;
    background: #234256;
  }

  & button:is([aria-current='page'], [aria-pressed='true']) {
    color: var(--profile-amber);
    border-color: var(--atlas-amber-edge, #906935);
    background: #302921e8;
  }

  & button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
  }

  & :is(button, input, select, textarea, a):focus-visible {
    outline: 2px solid var(--profile-focus);
    outline-offset: -2px;
  }

  & svg {
    display: block;
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linejoin: round;
    stroke-linecap: round;
  }

  & h3 {
    margin: 16px 0 4px;
    color: #f4f8ff;
    font-size: 15px;
    font-weight: 650;
  }

  & :is([data-profile-view], .terrantir-profile__lock) > h3:first-child {
    margin-top: 0;
  }

  & p {
    margin: 0 0 10px;
    color: var(--profile-muted);
    overflow-wrap: anywhere;
  }

  & [role='status']:empty {
    margin: 0;
  }
}

#terrantir-profile-panel[hidden],
body:is(.ui-clean-view, .recording-mode, .cockpit-mode, .scene-playback-mode) #terrantir-profile-panel {
  display: none;
}

#terrantir-profile-panel .atlas-profile-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: start;
  gap: 9px;
  padding: 9px 11px 8px 12px;
  border-bottom: 1px solid var(--profile-edge);
  background: linear-gradient(95deg, #84cafa13, transparent 75%);
}

#terrantir-profile-panel .atlas-profile-mark {
  display: block;
  width: 34px;
  height: 34px;
  flex: none;
}

#terrantir-profile-panel h2 {
  margin: 0;
  font: 650 17px/1.2 var(--profile-mono);
  letter-spacing: .055em;
  white-space: nowrap;
}

#atlas-profile-title > span {
  color: var(--profile-amber, #ffc47a);
  font-size: .84em;
  text-transform: uppercase;
}

#terrantir-profile-panel .terrantir-profile__header-actions {
  display: flex;
  gap: 5px;
  margin-inline-start: auto;
}

#terrantir-profile-panel .terrantir-profile__header-actions > button {
  display: grid;
  place-items: center;
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.atlas-profile-scroll {
  overflow: auto;
  min-height: 0;
  padding: 11px 12px 12px;
  overscroll-behavior: contain;
  scrollbar-color: #486a83 #0d1b29;
}

.atlas-profile-wallet {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 10px;
  padding: 7px 10px;
  margin-bottom: 12px;
  border: 1px solid var(--profile-edge);
  border-radius: 3px;
  background: var(--profile-well);
  font: 600 11px/1.4 var(--profile-mono);
}

.atlas-profile-wallet > span {
  color: #8ed5e3;
  text-transform: uppercase;
  letter-spacing: .08em;
}

#terrantir-profile-panel .terrantir-profile__wallet {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0 0 0 auto;
}

.terrantir-profile__wallet::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: none;
  border: 1px solid currentColor;
  border-radius: 50%;
}

#terrantir-profile-panel[data-wallet-connected='true'] .terrantir-profile__wallet {
  color: #b9f5ef;
}

#terrantir-profile-panel[data-wallet-connected='true'] .terrantir-profile__wallet::before {
  background: currentColor;
  box-shadow: 0 0 9px #87efe179;
}

#terrantir-profile-panel:not([data-wallet-connected='true']) :is(.terrantir-profile__refresh, .terrantir-profile__grid, .terrantir-profile__entitlement-card) {
  display: none;
}

#terrantir-profile-panel .terrantir-profile__layout {
  display: block;
}

#terrantir-profile-panel .terrantir-profile__nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  border: 0;
  padding: 0;
  margin-bottom: 10px;
}

#terrantir-profile-panel .terrantir-profile__nav button {
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 7px;
  width: 100%;
  padding-inline: 7px;
  border-inline-start: 2px solid #486787;
  color: #c4d9e7;
  background: var(--profile-well);
  font: 600 11px/1.25 var(--profile-mono);
  text-align: start;
}

#terrantir-profile-panel .terrantir-profile__nav button[aria-current='page'] {
  color: var(--profile-amber);
  border-inline-start-color: var(--profile-amber);
  background: linear-gradient(100deg, #4f3925, #25252a);
}

#terrantir-profile-panel .terrantir-profile__nav button > span {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  white-space: normal;
}

#terrantir-profile-panel .terrantir-profile__nav button:not([aria-current]):hover {
  color: #f0faff;
  background: #234256;
}

#terrantir-profile-panel .terrantir-profile__body {
  min-width: 0;
  min-height: 0;
  padding-top: 2px;
}

#terrantir-profile-panel .atlas-profile-subtitle {
  color: #91d1e2;
}

#terrantir-profile-panel .terrantir-profile__grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#terrantir-profile-panel .terrantir-profile__grid > div:last-child {
  grid-column: 1 / -1;
}

#terrantir-profile-panel :is(.terrantir-profile__grid > div, .terrantir-profile__entitlement-card) {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--profile-edge);
  border-radius: 4px;
  background: var(--profile-well);
}

#terrantir-profile-panel :is(.terrantir-profile__grid, .terrantir-profile__entitlement-card) small {
  display: block;
  color: var(--profile-muted);
  font: 600 10px/1.4 var(--profile-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}

#terrantir-profile-panel :is(.terrantir-profile__grid, .terrantir-profile__entitlement-card) strong {
  display: block;
  margin: 2px 0;
  color: #e8f8ff;
  font: 650 14px/1.35 var(--profile-mono);
  overflow-wrap: anywhere;
}

#terrantir-profile-panel :is(.terrantir-profile__grid, .terrantir-profile__entitlement-card) span {
  color: var(--profile-muted);
  font-size: 11px;
}

#terrantir-profile-panel .terrantir-profile__entitlement-card {
  margin-top: 8px;
}

#terrantir-profile-panel .terrantir-profile__lock-progress {
  width: 100%;
  accent-color: #83d6e5;
}

#terrantir-profile-panel .terrantir-profile__lock {
  margin: 0;
  border: 0;
}

#terrantir-profile-panel .terrantir-profile__local-note {
  margin: 12px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--profile-edge);
  color: var(--profile-muted);
  font-size: 11px;
}

#terrantir-profile-panel :is(.terrantir-profile__grid, .terrantir-profile__terms, .terrantir-profile__camera) {
  display: grid;
  gap: 6px;
}

#terrantir-profile-panel :is(.terrantir-profile__terms, .terrantir-profile__camera) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#terrantir-profile-panel .terrantir-profile__camera button:first-child {
  grid-column: auto;
}

#terrantir-profile-panel :is(.terrantir-profile__terms, .terrantir-profile__camera) button {
  padding-inline: 4px;
  font-size: 12px;
}

#terrantir-profile-panel p.terrantir-profile__until {
  margin-top: 8px;
}

#terrantir-profile-panel :is(form, form > label, .terrantir-profile__setting, .terrantir-profile__entitlement-card) {
  display: grid;
  gap: 6px;
}

#terrantir-profile-panel form {
  margin: 10px 0;
}

#terrantir-profile-panel label {
  color: #d5e6f1;
}

#terrantir-profile-panel :is(input:not([type='hidden'], [hidden]), textarea, select) {
  width: 100%;
  min-width: 0;
  padding: 8px;
  color: #eff6fc;
  background: #091826;
  border: 1px solid #55748d;
  border-radius: 4px;
}

#terrantir-profile-panel textarea {
  max-width: 100%;
  resize: vertical;
}

#terrantir-profile-panel .terrantir-profile__submit {
  width: 100%;
  margin-top: 7px;
}

#terrantir-profile-panel :is(.terrantir-profile__lock-row, .terrantir-profile__saved-row, .terrantir-profile__backup, .atlas-profile-legacy-links) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  overflow-wrap: anywhere;
}

#terrantir-profile-panel :is(.terrantir-profile__lock-row, .terrantir-profile__saved-row, .atlas-profile-legacy-links) {
  border-top: 1px solid var(--profile-edge);
  padding-top: 7px;
  margin-top: 7px;
}

#terrantir-profile-panel .terrantir-profile__saved-row button:first-child {
  flex: 1 1 0;
  min-width: 0;
  text-align: start;
}

#terrantir-profile-panel .terrantir-profile__saved-row button:last-child {
  min-width: 38px;
}

#terrantir-profile-panel :is(.terrantir-profile__more, [data-notes-export]) {
  margin-top: 8px;
}

#terrantir-profile-panel .atlas-profile-legacy-links a {
  color: #a6dfef;
}

#terrantir-profile-panel.terrantir-profile--picking {
  border-color: #83d6e5;
}

@media (max-width: 1100px) {
  #terrantir-profile-panel {
    --profile-top: calc(var(--workspace-actions-end, 87px) + 5px);
  }
}

@media (max-width: 720px) {
  #terrantir-profile-panel {
    --profile-top: calc(var(--workspace-actions-end, 136px) + 5px);
    /* Reserve the same wrapped vendor-credit corridor as the Layers rail. */
    --profile-bottom: max(calc(2vh + 10.75rem), env(safe-area-inset-bottom));
  }
}

@media (max-width: 520px) {
  #terrantir-profile-panel .atlas-profile-header {
    gap: 7px;
  }

  #terrantir-profile-panel h2 {
    font-size: 15px;
    letter-spacing: .035em;
  }

  #terrantir-profile-panel .atlas-profile-mark {
    width: 28px;
    height: 28px;
  }

  #terrantir-profile-panel .terrantir-profile__nav button {
    justify-content: center;
    padding-inline: 3px;
    text-align: center;
  }

  #terrantir-profile-panel .terrantir-profile__nav svg {
    display: none;
  }
}

@media (max-height: 460px) {
  #terrantir-profile-panel {
    --profile-top: calc(var(--workspace-header-end, 52px) + 6px);
    display: block;
    overflow: auto;
    overscroll-behavior: contain;
  }

  #terrantir-profile-panel .atlas-profile-scroll {
    overflow: visible;
  }
}

@media (max-height: 460px) and (min-width: 600px) and (max-width: 720px) {
  #terrantir-profile-panel {
    --profile-bottom: max(calc(2vh + 8.5rem), env(safe-area-inset-bottom));
  }
}

@media (pointer: coarse) {
  #terrantir-profile-panel button {
    min-height: 44px;
  }

  #terrantir-profile-panel .terrantir-profile__header-actions button {
    width: 44px;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  #terrantir-profile-panel:not([hidden]) {
    animation: atlas-profile-in 200ms var(--atlas-menu-ease, ease-out) both;
  }

  #terrantir-profile-panel [data-profile-view]:not([hidden]) {
    animation: atlas-profile-in 150ms ease-out both;
  }
}

@media (prefers-reduced-motion: reduce) {
  #terrantir-profile-panel button {
    transition: none;
  }
}

@keyframes atlas-profile-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
