.layer-panel {
  position: absolute;
  z-index: 34;
  top: 16px;
  right: 16px;
  width: min(330px, calc(100% - 32px));
  max-height: min(560px, calc(100% - 86px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(111, 122, 164, .22);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface, #fff) 94%, transparent);
  box-shadow: 0 18px 52px rgba(29, 36, 70, .18);
  backdrop-filter: blur(18px);
}

.layer-panel.hidden { display: none; }

.layer-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px;
}

.layer-panel-head > div { display: grid; gap: 2px; }
.layer-panel-head strong { font-size: 14px; color: var(--text, #20263e); }
.layer-panel-head small,
.layer-panel-hint,
.layer-meta small { color: var(--muted, #737b98); }

.layer-panel-head > button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, #5b63df, #7c55c8);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.layer-panel-head > button:disabled { opacity: .42; cursor: not-allowed; }

.layer-list {
  display: grid;
  gap: 6px;
  overflow: auto;
  padding: 4px 10px 8px;
  overscroll-behavior: contain;
}

.layer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(126, 137, 174, .07);
}

.layer-row.active {
  border-color: rgba(91, 99, 223, .48);
  background: rgba(91, 99, 223, .11);
  box-shadow: inset 3px 0 #5b63df;
}

.layer-row.hidden-layer { opacity: .62; }
.layer-row.locked .layer-thumb::after { content: ""; position: absolute; inset: 3px; border: 1px dashed #7c55c8; border-radius: 5px; }

.layer-content {
  min-width: 0;
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr);
  align-items: center;
  gap: 3px;
}

.layer-select {
  display: grid;
  place-items: center;
  padding: 7px 4px 7px 8px;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}

.layer-thumb {
  position: relative;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(92, 104, 146, .25);
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(91, 99, 223, .12) 25%, transparent 25% 75%, rgba(91, 99, 223, .12) 75%),
    linear-gradient(45deg, rgba(91, 99, 223, .12) 25%, #fff 25% 75%, rgba(91, 99, 223, .12) 75%);
  background-position: 0 0, 5px 5px;
  background-size: 10px 10px;
}

.layer-meta { min-width: 0; display: grid; gap: 2px; }
.layer-name-input {
  min-width: 0;
  width: 100%;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text, #20263e);
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
}

.layer-name-input:not([readonly]) {
  border-color: #5b63df;
  background: var(--surface, #fff);
  outline: 2px solid rgba(91, 99, 223, .12);
}

.layer-actions { display: flex; align-items: center; gap: 2px; padding-right: 7px; }
.layer-actions button {
  width: 27px;
  height: 29px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--muted, #69718e);
  background: transparent;
  cursor: pointer;
}

.layer-actions button:hover:not(:disabled) { color: #4f46c7; background: rgba(91, 99, 223, .11); }
.layer-actions button.layer-delete { font-size: 13px; }
.layer-actions button.layer-delete:hover:not(:disabled) { color: #c9344f; background: rgba(201, 52, 79, .11); }
.layer-actions button:disabled { opacity: .25; cursor: not-allowed; }

.layer-panel-hint {
  margin: 0;
  padding: 9px 14px 13px;
  border-top: 1px solid rgba(111, 122, 164, .13);
  font-size: 11px;
  line-height: 1.55;
}

[data-theme="dark"] .layer-panel { background: rgba(29, 34, 54, .94); }
[data-theme="dark"] .layer-thumb { background-color: #2e3550; }

@media (max-width: 680px) {
  .layer-panel {
    top: 8px;
    right: 8px;
    width: min(320px, calc(100% - 16px));
    max-height: calc(100% - 70px);
  }
  .layer-actions button { width: 25px; }
}
