.portfolio-editor {
  --pe-panel: #101421;
  --pe-field: #0a0e1a;
  --pe-stroke: #384365;
  --pe-ink: #f4f5ff;
  --pe-quiet: #b9c1d9;
  --pe-accent: #c0c9ff;
  position: fixed;
  inset: 0 0 0 auto;
  width: min(610px, 100%);
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-inline-start: 1px solid var(--pe-stroke);
  background: var(--pe-panel);
  color: var(--pe-ink);
  box-shadow: -24px 0 100px #03050b80;
  font: 400 1rem/1.45 "Segoe UI", Arial, sans-serif;
}

.portfolio-editor::backdrop { background: #05071258; }
body:has(.portfolio-editor[open]) { overflow: hidden; }
.portfolio-editor :focus-visible {
  outline: 2px solid var(--pe-accent);
  outline-offset: 3px;
}
.portfolio-editor [hidden] { display: none !important; }
.pe-form {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
}
.pe-header {
  padding: 21px 24px 17px;
  background: radial-gradient(ellipse at 75% 10%, #20284a, #13192b 82%);
}
.pe-header-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.pe-header-actions { display: flex; flex-shrink: 0; gap: 6px; }
.pe-header h2 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.16;
  letter-spacing: -.045em;
}
.pe-header p, .pe-description {
  margin: 7px 0 0;
  color: var(--pe-quiet);
  font-size: .94rem;
}
.pe-tabs {
  display: flex;
  padding-inline: 24px;
  gap: clamp(9px, 2.5vw, 20px);
  border-block: 1px solid #28324c;
  background: #11182a;
}
.pe-tab {
  min-height: 48px;
  padding: 0 3px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--pe-quiet);
  font-family: inherit;
  font-size: .94rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}
.pe-tab:hover, .pe-tab[aria-selected="true"] { color: var(--pe-ink); }
.pe-tab[aria-selected="true"] { border-bottom-color: #9faeff; }
.pe-tab:focus-visible { outline-offset: -1px; }
.pe-content {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 23px 24px 28px;
  scrollbar-color: #434f77 #101421;
  scrollbar-gutter: stable;
}
.pe-panel { display: grid; gap: 17px; }
.pe-section {
  display: grid;
  min-width: 0;
  gap: 12px;
  padding: 16px;
  border: 1px solid #2c3653;
  border-radius: 13px;
  background: #151b2e;
}
.pe-section h3 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.3;
  letter-spacing: -.02em;
}
.pe-section > .pe-description { margin-top: -7px; }
.pe-field { display: grid; min-width: 0; gap: 7px; }
.pe-label {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: #e7eaff;
  font-size: .91rem;
  font-weight: 650;
}
.pe-input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--pe-stroke);
  border-radius: 8px;
  background: var(--pe-field);
  color: var(--pe-ink);
  font: 400 1rem/1.35 "Segoe UI", Arial, sans-serif;
}
textarea.pe-input { display: block; resize: vertical; }
.pe-input::placeholder { color: #909bb9; opacity: 1; }
.pe-input:hover { border-color: #717fa8; }
.pe-input:user-invalid { border-color: #ee9fab; }
.pe-input[type="color"] {
  width: 59px;
  height: 42px;
  padding: 4px;
  cursor: pointer;
}
.pe-field-color .pe-label {
  grid-template-columns: minmax(0, max-content) auto;
  align-items: center;
  gap: 12px;
  justify-content: start;
}
select.pe-input {
  appearance: none;
  padding-right: 34px;
  background: var(--pe-field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23b9c1d9' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 11px center / 15px;
}
.pe-help, .pe-upload-status {
  margin: 0;
  color: var(--pe-quiet);
  font-size: .875rem;
  font-weight: 400;
}
.pe-upload-status:empty, .pe-status:empty { display: none; }
.pe-upload-line, .pe-project-tools, .pe-project-actions {
  display: flex;
  gap: 8px 10px;
  flex-wrap: wrap;
  align-items: center;
}
.pe-project-tools { justify-content: space-between; }
.pe-projects { display: grid; gap: 9px; }
.pe-project {
  overflow: clip;
  border: 1px solid #353f60;
  border-radius: 10px;
  background: #11172a;
}
.pe-project summary {
  min-height: 45px;
  padding: 10px 13px;
  color: #eaf0ff;
  font-weight: 700;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.pe-project summary:hover { background: #1d2745; }
.pe-project summary:focus-visible { outline-offset: -3px; }
.pe-project[open] summary { border-bottom: 1px solid #2c3653; }
.pe-project-fields { display: grid; gap: 12px; padding: 13px; }
.pe-project-actions { padding-top: 4px; }
.pe-project-actions .pe-button-danger { margin-inline-start: auto; }
.pe-check {
  display: flex;
  min-height: 42px;
  gap: 9px;
  align-items: center;
  cursor: pointer;
  color: #e7eaff;
  font-size: .92rem;
  font-weight: 650;
}
.pe-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #aab7ff;
}
.pe-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 41px;
  padding: 7px 12px;
  border: 1px solid #4a5883;
  border-radius: 9px;
  background: #1f2847;
  color: #eef0ff;
  font: 680 .9rem/1.25 "Segoe UI", Arial, sans-serif;
  text-align: center;
  cursor: pointer;
}
.pe-button:hover { background: #2b385f; border-color: #7888b9; }
.pe-button:disabled, .pe-upload-busy { opacity: .52; cursor: default; }
.pe-button-quiet { background: transparent; }
.pe-button-primary { background: #d7defe; color: #171d36; border-color: #d7defe; }
.pe-button-primary:hover { background: #eff2ff; }
.pe-button-danger { border-color: #735163; background: #412637; color: #ffdce2; }
.pe-button-danger:hover { border-color: #b87a95; background: #523046; }
.pe-upload {
  position: relative;
  min-height: 38px;
  background: transparent;
}
.pe-upload:focus-within { outline: 2px solid var(--pe-accent); outline-offset: 3px; }
.pe-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.pe-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  padding: 12px 24px max(12px, env(safe-area-inset-bottom));
  gap: 8px 12px;
  background: #13182a;
  border-top: 1px solid #323d5d;
}
.pe-footer-buttons { display: flex; gap: 8px; justify-content: end; }
.pe-status { flex: 1 1 170px; margin: 0; color: var(--pe-quiet); font-size: .875rem; }
.pe-error { color: #ffb8c6; }
.pe-preview-dock {
  position: fixed;
  z-index: 4;
  inset: auto max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  max-width: calc(100% - 32px);
  padding: 9px 11px 9px 14px;
  border: 1px solid #4a5883;
  border-radius: 12px;
  background: #151b2f;
  color: #e7eaff;
  box-shadow: 0 12px 42px #050711bf;
}
.pe-preview-dock p { margin: 0; font-size: .9rem; }
.pe-preview-dock .pe-button { flex-shrink: 0; }

@media (max-width: 520px) {
  .portfolio-editor { width: 100%; border: 0; }
  .pe-header, .pe-content, .pe-footer, .pe-tabs { padding-inline: 14px; }
  .pe-content { padding-top: 14px; }
  .pe-header { padding-block: 13px; }
  .pe-section { padding: 12px; }
  .pe-project-fields { padding: 10px; }
  .pe-project-actions .pe-button-danger { margin-inline-start: 0; }
  .pe-preview-dock { inset-inline: 10px; max-width: calc(100% - 20px); }
}
