.device-storage-ui {
  position: relative;
  flex: none;
  min-width: 0;
  color: var(--ui-text);
}

.device-storage-menu {
  position: relative;
}

.device-storage-summary {
  align-items: center;
  box-sizing: border-box;
  min-width: 44px;
  max-width: 100%;
  height: 44px;
  padding: 0 8px;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  display: inline-flex;
  justify-content: center;
  color: var(--ui-text);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
  list-style: none;
  user-select: none;
  white-space: nowrap;
}

.device-storage-summary::-webkit-details-marker { display: none; }
.device-storage-summary::marker { content: ""; }
.device-storage-summary:focus-visible,
.device-storage-help:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 2px;
}

.device-storage-mode {
  position: relative;
  display: inline-flex;
  flex: none;
}

.device-storage-mode-icon {
  width: 16px;
  height: 16px;
}

.device-storage-mode .offline-status-icon {
  position: absolute;
  right: -2px;
  bottom: -2px;
}

.device-storage-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-storage-chevron {
  flex: none;
  width: 12px;
  height: 12px;
}

.device-storage-menu[open] > summary .device-storage-chevron {
  transform: rotate(180deg);
}

.device-storage-panel {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 4px);
  right: 0;
  box-sizing: border-box;
  width: min(320px, calc(100vw - 20px));
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  padding: 12px;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  display: grid;
  gap: 12px;
  overflow-y: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
  background: var(--ui-surface, #fff);
  box-shadow: 0 8px 24px rgb(0 0 0 / 15%);
}

.device-storage-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.device-storage-ui .button,
.device-storage-ui .device-storage-switch {
  align-items: center;
  box-sizing: border-box;
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  white-space: normal;
}

.device-storage-switch { width: 100%; }

.device-storage-help {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ui-primary);
  font-size: var(--ui-font-metadata, 12px);
  text-underline-offset: 3px;
}

.device-storage-note,
.device-storage-status {
  margin: 0;
  color: var(--ui-text-soft);
  font-size: 0.8rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.device-storage-status { color: var(--ui-text); }
.device-storage-status[data-kind="error"] { font-weight: 600; }
