:root {
  --portal-panel: #fffdf8;
  --portal-ink: #171714;
  --portal-muted: #67665f;
  --portal-line: #d9d5c9;
  --portal-violet: #a983ff;
  --portal-violet-dark: #8056de;
  --portal-acid: #dffe52;
  --portal-danger: #c34c38;
}

body.portal-body {
  min-height: 100vh;
  overflow-x: clip;
  background: #f4f1e9;
}

.portal-shell {
  width: min(1420px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
  margin-bottom: 28px;
}

.portal-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 14px;
  text-decoration: none;
}

.portal-brand img { width: 136px; }
.portal-brand span {
  padding-left: 14px;
  border-left: 1px solid var(--portal-line);
  color: var(--portal-muted);
  font: 700 11px/1 "Manrope", sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.portal-actions { display: flex; align-items: center; flex-shrink: 0; gap: 9px; }

.portal-button,
.portal-button-secondary,
.portal-tab {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font: 700 13px/1 "DM Sans", sans-serif;
  cursor: pointer;
}

.portal-button {
  background: var(--portal-ink);
  color: #fffdf8;
}

.portal-button:hover { background: var(--portal-violet-dark); }
.portal-button:disabled { cursor: wait; opacity: .55; }
/* aria-disabled keeps an unavailable or busy action focusable; it looks disabled and never acts. */
.portal-button[aria-disabled="true"],
.portal-button-secondary[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }
.portal-button[aria-disabled="true"]:hover { background: var(--portal-ink); }
.portal-button[aria-busy="true"],
.portal-button-secondary[aria-busy="true"] { cursor: wait; }

.portal-button-secondary {
  border-color: var(--portal-line);
  background: transparent;
  color: var(--portal-ink);
}

.portal-input,
.portal-select,
.portal-textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: #fff;
  color: var(--portal-ink);
  font: 500 14px/1.35 "DM Sans", sans-serif;
}

.portal-input:focus,
.portal-select:focus,
.portal-textarea:focus {
  border-color: var(--portal-violet-dark);
  outline: 2px solid var(--portal-violet-dark);
  outline-offset: 2px;
}

@media (forced-colors: active) {
  .portal-input:focus,
  .portal-select:focus,
  .portal-textarea:focus { outline-color: Highlight; }
}

.portal-label {
  display: grid;
  gap: 7px;
  color: var(--portal-muted);
  font: 700 11px/1 "Manrope", sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.portal-panel {
  overflow: hidden;
  border: 1px solid var(--portal-line);
  border-radius: 18px;
  background: var(--portal-panel);
}

/* The panel clips what overflows it, so a focus ring drawn outside a control at the panel edge
   would be cut off. Inside a panel the ring is drawn inside the control instead. */
:where(.account-main, .portal-shell) .portal-panel :is(a, button, summary, select, textarea, input, [tabindex]):focus-visible { outline-offset: -3px; }

.portal-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--portal-line);
}

.portal-panel-head h2 { font-size: 20px; }
.portal-muted { color: var(--portal-muted); }
.portal-error { color: var(--portal-danger); }
/* A live region that is empty stays rendered (display:none would drop it from the accessibility
   tree and the next message would not be announced) but takes no space. */
.portal-live:empty,
#portal-status:empty,
#portal-alert:empty,
#admin-status:empty,
#admin-alert:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  box-shadow: none;
  clip-path: inset(50%);
}
.portal-empty { padding: 32px 22px; color: var(--portal-muted); }

.portal-notice {
  margin-bottom: 16px;
  padding: 13px 16px;
  border: 1px solid #c9b3fc;
  border-radius: 10px;
  background: #eee7ff;
  font-size: 14px;
}

.portal-badge {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  background: #ebe8df;
  color: var(--portal-muted);
  font: 700 10px/1 "Manrope", sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.portal-badge[data-source="genform"] { background: #e9ddff; color: #6735bd; }
.portal-badge[data-source="makerworld"] { background: #e8f0ff; color: #315da8; }
.portal-badge[data-source="internal"] { background: #fff2d3; color: #875f0a; }

@media (max-width: 720px) {
  .portal-shell { width: min(100% - 24px, 1420px); padding-top: 12px; }
  .portal-header { align-items: center; }
  .portal-brand span { display: none; }
  .portal-brand img { width: 118px; }
  #session-email { display: none; }
  .portal-panel { border-radius: 14px; }
}
